Replace magic MINTRS/MAXTRS with a treasure attribute in YAML.
This commit is contained in:
parent
25077d0b4e
commit
c3a2816821
7 changed files with 43 additions and 107 deletions
|
@ -899,7 +899,7 @@ static int throw (FILE *cmdin, struct command_t *command)
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
if (command->obj >= MINTRS && command->obj <= MAXTRS && AT(TROLL)) {
|
if (object_descriptions[command->obj].is_treasure && AT(TROLL)) {
|
||||||
spk = TROLL_SATISFIED;
|
spk = TROLL_SATISFIED;
|
||||||
/* Snarf a treasure for the troll. */
|
/* Snarf a treasure for the troll. */
|
||||||
DROP(command->obj, 0);
|
DROP(command->obj, 0);
|
||||||
|
|
2
advent.h
2
advent.h
|
@ -9,8 +9,6 @@
|
||||||
#define NDWARVES 6 /* number of dwarves */
|
#define NDWARVES 6 /* number of dwarves */
|
||||||
#define PIRATE NDWARVES /* must be NDWARVES-1 when zero-origin */
|
#define PIRATE NDWARVES /* must be NDWARVES-1 when zero-origin */
|
||||||
#define DALTLC LOC_NUGGET /* alternate dwarf location */
|
#define DALTLC LOC_NUGGET /* alternate dwarf location */
|
||||||
#define MINTRS 50 /* index of lowest reasure */
|
|
||||||
#define MAXTRS 79 /* index of highest reasure */
|
|
||||||
#define MAXPARMS 25 /* Max parameters for speak() */
|
#define MAXPARMS 25 /* Max parameters for speak() */
|
||||||
#define INVLIMIT 7 /* inverntory limit (# of objects) */
|
#define INVLIMIT 7 /* inverntory limit (# of objects) */
|
||||||
#define INTRANSITIVE -1 /* illegal object number */
|
#define INTRANSITIVE -1 /* illegal object number */
|
||||||
|
|
114
adventure.yaml
114
adventure.yaml
|
@ -64,6 +64,7 @@
|
||||||
#
|
#
|
||||||
# objects: Each item contains a description for use in the inventory command
|
# objects: Each item contains a description for use in the inventory command
|
||||||
# and one or more messages describing the object in different states.
|
# and one or more messages describing the object in different states.
|
||||||
|
# There is also a boolean "treasure" attribute, deaykting to false.
|
||||||
# If a state message is a tuple then the first element is made the name
|
# If a state message is a tuple then the first element is made the name
|
||||||
# of a #define viible to the code for the associayed state, numbered
|
# of a #define viible to the code for the associayed state, numbered
|
||||||
# from zero upwards. If the inventory desription begins with "*" the
|
# from zero upwards. If the inventory desription begins with "*" the
|
||||||
|
@ -1749,40 +1750,49 @@ object_descriptions: !!omap
|
||||||
- '"Treasure Vault. Keys in main office."'
|
- '"Treasure Vault. Keys in main office."'
|
||||||
- OBJ_50:
|
- OBJ_50:
|
||||||
inventory: 'Large gold nugget'
|
inventory: 'Large gold nugget'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is a large sparkling nugget of gold here!'
|
- 'There is a large sparkling nugget of gold here!'
|
||||||
- OBJ_51:
|
- OBJ_51:
|
||||||
inventory: 'Several diamonds'
|
inventory: 'Several diamonds'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There are diamonds here!'
|
- 'There are diamonds here!'
|
||||||
- OBJ_52:
|
- OBJ_52:
|
||||||
inventory: 'Bars of silver'
|
inventory: 'Bars of silver'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There are bars of silver here!'
|
- 'There are bars of silver here!'
|
||||||
- OBJ_53:
|
- OBJ_53:
|
||||||
inventory: 'Precious jewelry'
|
inventory: 'Precious jewelry'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is precious jewelry here!'
|
- 'There is precious jewelry here!'
|
||||||
- OBJ_54:
|
- OBJ_54:
|
||||||
inventory: 'Rare coins'
|
inventory: 'Rare coins'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There are many coins here!'
|
- 'There are many coins here!'
|
||||||
- OBJ_55:
|
- OBJ_55:
|
||||||
inventory: 'Treasure chest'
|
inventory: 'Treasure chest'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'The pirate''s treasure chest is here!'
|
- 'The pirate''s treasure chest is here!'
|
||||||
- OBJ_56:
|
- OBJ_56:
|
||||||
inventory: 'Golden eggs'
|
inventory: 'Golden eggs'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is a large nest here, full of golden eggs!'
|
- 'There is a large nest here, full of golden eggs!'
|
||||||
- 'The nest of golden eggs has vanished!'
|
- 'The nest of golden eggs has vanished!'
|
||||||
- 'Done!'
|
- 'Done!'
|
||||||
- OBJ_57:
|
- OBJ_57:
|
||||||
inventory: 'Jeweled trident'
|
inventory: 'Jeweled trident'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is a jewel-encrusted trident here!'
|
- 'There is a jewel-encrusted trident here!'
|
||||||
- OBJ_58:
|
- OBJ_58:
|
||||||
inventory: 'Ming vase'
|
inventory: 'Ming vase'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- [VASE_WHOLE, 'There is a delicate, precious, ming vase here!']
|
- [VASE_WHOLE, 'There is a delicate, precious, ming vase here!']
|
||||||
- [VASE_RESTING, 'The vase is now resting, delicately, on a velvet pillow.']
|
- [VASE_RESTING, 'The vase is now resting, delicately, on a velvet pillow.']
|
||||||
|
@ -1790,149 +1800,67 @@ object_descriptions: !!omap
|
||||||
- [VASE_DROPS, 'The ming vase drops with a delicate crash.']
|
- [VASE_DROPS, 'The ming vase drops with a delicate crash.']
|
||||||
- OBJ_59:
|
- OBJ_59:
|
||||||
inventory: 'Egg-sized emerald'
|
inventory: 'Egg-sized emerald'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is an emerald here the size of a plover''s egg!'
|
- 'There is an emerald here the size of a plover''s egg!'
|
||||||
- 'There is an emerald resting in a small cavity in the rock!'
|
- 'There is an emerald resting in a small cavity in the rock!'
|
||||||
- OBJ_60:
|
- OBJ_60:
|
||||||
inventory: 'Platinum pyramid'
|
inventory: 'Platinum pyramid'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is a platinum pyramid here, 8 inches on a side!'
|
- 'There is a platinum pyramid here, 8 inches on a side!'
|
||||||
- OBJ_61:
|
- OBJ_61:
|
||||||
inventory: 'Glistening pearl'
|
inventory: 'Glistening pearl'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'Off to one side lies a glistening pearl!'
|
- 'Off to one side lies a glistening pearl!'
|
||||||
- OBJ_62:
|
- OBJ_62:
|
||||||
inventory: 'Persian rug'
|
inventory: 'Persian rug'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is a persian rug spread out on the floor!'
|
- 'There is a persian rug spread out on the floor!'
|
||||||
- 'The dragon is sprawled out on a persian rug!!'
|
- 'The dragon is sprawled out on a persian rug!!'
|
||||||
- 'There is a persian rug here, hovering in mid-air!'
|
- 'There is a persian rug here, hovering in mid-air!'
|
||||||
- OBJ_63:
|
- OBJ_63:
|
||||||
inventory: 'Rare spices'
|
inventory: 'Rare spices'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There are rare spices here!'
|
- 'There are rare spices here!'
|
||||||
- OBJ_64:
|
- OBJ_64:
|
||||||
inventory: 'Golden chain'
|
inventory: 'Golden chain'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is a golden chain lying in a heap on the floor!'
|
- 'There is a golden chain lying in a heap on the floor!'
|
||||||
- 'The bear is locked to the wall with a golden chain!'
|
- 'The bear is locked to the wall with a golden chain!'
|
||||||
- 'There is a golden chain locked to the wall!'
|
- 'There is a golden chain locked to the wall!'
|
||||||
- OBJ_65:
|
- OBJ_65:
|
||||||
inventory: 'Giant ruby'
|
inventory: 'Giant ruby'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is an enormous ruby here!'
|
- 'There is an enormous ruby here!'
|
||||||
- 'There is a ruby resting in a small cavity in the rock!'
|
- 'There is a ruby resting in a small cavity in the rock!'
|
||||||
- OBJ_66:
|
- OBJ_66:
|
||||||
inventory: 'Jade necklace'
|
inventory: 'Jade necklace'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'A precious jade necklace has been dropped here!'
|
- 'A precious jade necklace has been dropped here!'
|
||||||
- OBJ_67:
|
- OBJ_67:
|
||||||
inventory: 'Amber gemstone'
|
inventory: 'Amber gemstone'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is a rare amber gemstone here!'
|
- 'There is a rare amber gemstone here!'
|
||||||
- 'There is an amber gemstone resting in a small cavity in the rock!'
|
- 'There is an amber gemstone resting in a small cavity in the rock!'
|
||||||
- OBJ_68:
|
- OBJ_68:
|
||||||
inventory: 'Star sapphire'
|
inventory: 'Star sapphire'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'A brilliant blue star sapphire is here!'
|
- 'A brilliant blue star sapphire is here!'
|
||||||
- 'There is a star sapphire resting in a small cavity in the rock!'
|
- 'There is a star sapphire resting in a small cavity in the rock!'
|
||||||
- OBJ_69:
|
- OBJ_69:
|
||||||
inventory: 'Ebony statuette'
|
inventory: 'Ebony statuette'
|
||||||
|
treasure: true
|
||||||
longs:
|
longs:
|
||||||
- 'There is a richly-carved ebony statuette here!'
|
- 'There is a richly-carved ebony statuette here!'
|
||||||
- OBJ_70:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_71:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_72:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_73:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_74:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_75:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_76:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_77:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_78:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_79:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_80:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_81:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_82:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_83:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_84:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_85:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_86:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_87:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_88:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_89:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_90:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_91:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_92:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_93:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_94:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_95:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_96:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_97:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_98:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_99:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
- OBJ_100:
|
|
||||||
inventory: !!null
|
|
||||||
longs: !!null
|
|
||||||
|
|
||||||
obituaries:
|
obituaries:
|
||||||
- query: 'Oh dear, you seem to have gotten yourself killed. I might be able to\nhelp you out, but I''ve never really done this before. Do you want me\nto try to reincarnate you?'
|
- query: 'Oh dear, you seem to have gotten yourself killed. I might be able to\nhelp you out, but I''ve never really done this before. Do you want me\nto try to reincarnate you?'
|
||||||
|
|
15
init.c
15
init.c
|
@ -199,15 +199,16 @@ void initialise(void)
|
||||||
DROP(k, PLAC[k]);
|
DROP(k, PLAC[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Treasures, as noted earlier, are objects MINTRS through MAXTRS
|
/* Treasure props are initially -1, and are set to 0 the first time
|
||||||
* Their props are initially -1, and are set to 0 the first time
|
|
||||||
* they are described. game.tally keeps track of how many are
|
* they are described. game.tally keeps track of how many are
|
||||||
* not yet found, so we know when to close the cave. */
|
* not yet found, so we know when to close the cave. */
|
||||||
game.tally = 0;
|
game.tally = 0;
|
||||||
for (int treasure = MINTRS; treasure <= MAXTRS; treasure++) {
|
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
|
||||||
if (object_descriptions[treasure].inventory != 0)
|
if (object_descriptions[treasure].is_treasure) {
|
||||||
game.prop[treasure] = -1;
|
if (object_descriptions[treasure].inventory != 0)
|
||||||
game.tally = game.tally - game.prop[treasure];
|
game.prop[treasure] = -1;
|
||||||
|
game.tally = game.tally - game.prop[treasure];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the hint stuff. game.hintlc[i] is how long he's been at LOC
|
/* Clear the hint stuff. game.hintlc[i] is how long he's been at LOC
|
||||||
|
@ -260,7 +261,7 @@ void initialise(void)
|
||||||
VOLCANO = VOCWRD(WORD_VOLCANO, 1);
|
VOLCANO = VOCWRD(WORD_VOLCANO, 1);
|
||||||
WATER = VOCWRD(WORD_WATER, 1);
|
WATER = VOCWRD(WORD_WATER, 1);
|
||||||
|
|
||||||
/* Objects from MINTRS through MAXTRS are treasures. Here are a few. */
|
/* Vocabulary for treasures */
|
||||||
AMBER = VOCWRD(WORD_AMBER, 1);
|
AMBER = VOCWRD(WORD_AMBER, 1);
|
||||||
CHAIN = VOCWRD(WORD_CHAIN, 1);
|
CHAIN = VOCWRD(WORD_CHAIN, 1);
|
||||||
CHEST = VOCWRD(WORD_CHEST, 1);
|
CHEST = VOCWRD(WORD_CHEST, 1);
|
||||||
|
|
8
main.c
8
main.c
|
@ -289,7 +289,9 @@ static bool spotted_by_pirate(int i)
|
||||||
return true;
|
return true;
|
||||||
int snarfed = 0;
|
int snarfed = 0;
|
||||||
bool movechest = false, robplayer = false;
|
bool movechest = false, robplayer = false;
|
||||||
for (int treasure = MINTRS; treasure <= MAXTRS; treasure++) {
|
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
|
||||||
|
if (!object_descriptions[treasure].is_treasure)
|
||||||
|
continue;
|
||||||
/* Pirate won't take pyramid from plover room or dark
|
/* Pirate won't take pyramid from plover room or dark
|
||||||
* room (too easy!). */
|
* room (too easy!). */
|
||||||
if (treasure == PYRAMID && (game.loc == PLAC[PYRAMID] || game.loc == PLAC[EMERALD])) {
|
if (treasure == PYRAMID && (game.loc == PLAC[PYRAMID] || game.loc == PLAC[EMERALD])) {
|
||||||
|
@ -323,7 +325,9 @@ static bool spotted_by_pirate(int i)
|
||||||
}
|
}
|
||||||
if (robplayer) {
|
if (robplayer) {
|
||||||
rspeak(PIRATE_POUNCES);
|
rspeak(PIRATE_POUNCES);
|
||||||
for (int treasure = MINTRS; treasure <= MAXTRS; treasure++) {
|
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
|
||||||
|
if (!object_descriptions[treasure].is_treasure)
|
||||||
|
continue;
|
||||||
if (!(treasure == PYRAMID && (game.loc == PLAC[PYRAMID] || game.loc == PLAC[EMERALD]))) {
|
if (!(treasure == PYRAMID && (game.loc == PLAC[PYRAMID] || game.loc == PLAC[EMERALD]))) {
|
||||||
if (AT(treasure) && game.fixed[treasure] == 0)
|
if (AT(treasure) && game.fixed[treasure] == 0)
|
||||||
CARRY(treasure, game.loc);
|
CARRY(treasure, game.loc);
|
||||||
|
|
|
@ -21,6 +21,7 @@ h_template = """/* Generated from adventure.yaml - do not hand-hack! */
|
||||||
|
|
||||||
typedef struct {{
|
typedef struct {{
|
||||||
const char* inventory;
|
const char* inventory;
|
||||||
|
bool is_treasure;
|
||||||
const char** longs;
|
const char** longs;
|
||||||
const char** sounds;
|
const char** sounds;
|
||||||
const char** texts;
|
const char** texts;
|
||||||
|
@ -216,6 +217,7 @@ def get_locations(loc):
|
||||||
def get_object_descriptions(obj):
|
def get_object_descriptions(obj):
|
||||||
template = """ {{
|
template = """ {{
|
||||||
.inventory = {},
|
.inventory = {},
|
||||||
|
.is_treasure = {},
|
||||||
.longs = (const char* []) {{
|
.longs = (const char* []) {{
|
||||||
{}
|
{}
|
||||||
}},
|
}},
|
||||||
|
@ -263,7 +265,8 @@ def get_object_descriptions(obj):
|
||||||
for l_msg in item[1]["texts"]:
|
for l_msg in item[1]["texts"]:
|
||||||
texts_str += " " * 12 + make_c_string(l_msg) + ",\n"
|
texts_str += " " * 12 + make_c_string(l_msg) + ",\n"
|
||||||
texts_str = texts_str[:-1] # trim trailing newline
|
texts_str = texts_str[:-1] # trim trailing newline
|
||||||
obj_str += template.format(i_msg, longs_str, sounds_str, texts_str)
|
treasure = "true" if item[1].get("treasure") else "false"
|
||||||
|
obj_str += template.format(i_msg, treasure, longs_str, sounds_str, texts_str)
|
||||||
obj_str = obj_str[:-1] # trim trailing newline
|
obj_str = obj_str[:-1] # trim trailing newline
|
||||||
return obj_str
|
return obj_str
|
||||||
|
|
||||||
|
|
4
score.c
4
score.c
|
@ -37,7 +37,9 @@ long score(enum termination mode)
|
||||||
/* First tally up the treasures. Must be in building and not broken.
|
/* First tally up the treasures. Must be in building and not broken.
|
||||||
* Give the poor guy 2 points just for finding each treasure. */
|
* Give the poor guy 2 points just for finding each treasure. */
|
||||||
mxscor = 0;
|
mxscor = 0;
|
||||||
for (long i = MINTRS; i <= MAXTRS; i++) {
|
for (int i = 1; i <= NOBJECTS; i++) {
|
||||||
|
if (!object_descriptions[i].is_treasure)
|
||||||
|
continue;
|
||||||
if (object_descriptions[i].inventory != 0) {
|
if (object_descriptions[i].inventory != 0) {
|
||||||
long k = 12;
|
long k = 12;
|
||||||
if (i == CHEST)k = 14;
|
if (i == CHEST)k = 14;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue