Section 10 (class thresholds) is now parsed entirely from YAML.
This commit is contained in:
parent
e798355e80
commit
f6373dd32e
4 changed files with 45 additions and 37 deletions
|
@ -1024,18 +1024,29 @@ arbitrary_messages: !!omap
|
||||||
- GO_UNNEEDED: 'You don''t have to say "go" every time; just specify a direction or, if\nit''s nearby, name the place to which you wish to move.'
|
- GO_UNNEEDED: 'You don''t have to say "go" every time; just specify a direction or, if\nit''s nearby, name the place to which you wish to move.'
|
||||||
- CANNOT_CARRY7: !!null
|
- CANNOT_CARRY7: !!null
|
||||||
|
|
||||||
class_messages: !!omap
|
classes:
|
||||||
- CLS_0: !!null
|
- threshold: 0
|
||||||
- CLS_1: 'You are obviously a rank amateur. Better luck next time.'
|
message: !!null
|
||||||
- CLS_2: 'Your score qualifies you as a novice class adventurer.'
|
- threshold: 45
|
||||||
- CLS_3: 'You have achieved the rating: "Experienced Adventurer".'
|
message: 'You are obviously a rank amateur. Better luck next time.'
|
||||||
- CLS_4: 'You may now consider yourself a "Seasoned Adventurer".'
|
- threshold: 120
|
||||||
- CLS_5: 'You have reached "Junior Master" status.'
|
message: 'Your score qualifies you as a novice class adventurer.'
|
||||||
- CLS_6: 'Your score puts you in Master Adventurer Class C.'
|
- threshold: 170
|
||||||
- CLS_7: 'Your score puts you in Master Adventurer Class B.'
|
message: 'You have achieved the rating: "Experienced Adventurer".'
|
||||||
- CLS_8: 'Your score puts you in Master Adventurer Class A.'
|
- threshold: 250
|
||||||
- CLS_9: 'All of Adventuredom gives tribute to you, Adventurer Grandmaster!'
|
message: 'You may now consider yourself a "Seasoned Adventurer".'
|
||||||
- CLS_10: 'Adventuredom stands in awe -- you have now joined the ranks of the\n W O R L D C H A M P I O N A D V E N T U R E R S !\nIt may interest you to know that the Dungeon-Master himself has, to\nmy knowledge, never achieved this threshhold in fewer than 330 turns.'
|
- threshold: 320
|
||||||
|
message: 'You have reached "Junior Master" status.'
|
||||||
|
- threshold: 375
|
||||||
|
message: 'Your score puts you in Master Adventurer Class C.'
|
||||||
|
- threshold: 410
|
||||||
|
message: 'Your score puts you in Master Adventurer Class B.'
|
||||||
|
- threshold: 426
|
||||||
|
message: 'Your score puts you in Master Adventurer Class A.'
|
||||||
|
- threshold: 429
|
||||||
|
message: 'All of Adventuredom gives tribute to you, Adventurer Grandmaster!'
|
||||||
|
- threshold: 9999
|
||||||
|
message: 'Adventuredom stands in awe -- you have now joined the ranks of the\n W O R L D C H A M P I O N A D V E N T U R E R S !\nIt may interest you to know that the Dungeon-Master himself has, to\nmy knowledge, never achieved this threshhold in fewer than 330 turns.'
|
||||||
|
|
||||||
turn_thresholds:
|
turn_thresholds:
|
||||||
- threshold: 350
|
- threshold: 350
|
||||||
|
|
10
dungeon.c
10
dungeon.c
|
@ -30,7 +30,6 @@ static long OLDLOC;
|
||||||
// Storage for what comes out of the database
|
// Storage for what comes out of the database
|
||||||
long LINUSE;
|
long LINUSE;
|
||||||
long TRVS;
|
long TRVS;
|
||||||
long CLSSES;
|
|
||||||
long TRNVLS;
|
long TRNVLS;
|
||||||
long TABNDX;
|
long TABNDX;
|
||||||
long HNTMAX;
|
long HNTMAX;
|
||||||
|
@ -45,7 +44,6 @@ long COND[LOCSIZ + 1];
|
||||||
long KEY[LOCSIZ + 1];
|
long KEY[LOCSIZ + 1];
|
||||||
long LOCSND[LOCSIZ + 1];
|
long LOCSND[LOCSIZ + 1];
|
||||||
long LINES[LINSIZ + 1];
|
long LINES[LINSIZ + 1];
|
||||||
long CVAL[CLSMAX + 1];
|
|
||||||
long TTEXT[TRNSIZ + 1];
|
long TTEXT[TRNSIZ + 1];
|
||||||
long TRNVAL[TRNSIZ + 1];
|
long TRNVAL[TRNSIZ + 1];
|
||||||
long TRAVEL[TRVSIZ + 1];
|
long TRAVEL[TRVSIZ + 1];
|
||||||
|
@ -228,11 +226,7 @@ static void read_messages(FILE* database, long sect)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sect == 10) {
|
if (sect == 10) {
|
||||||
CLSSES = CLSSES + 1;
|
/* now parsed from YAML */
|
||||||
if (CLSSES > CLSMAX)
|
|
||||||
BUG(TOO_MANY_CLASS_OR_TURN_MESSAGES);
|
|
||||||
CTEXT[CLSSES] = LINUSE;
|
|
||||||
CVAL[CLSSES] = loc;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sect == 6) {
|
if (sect == 6) {
|
||||||
|
@ -398,7 +392,6 @@ static int read_database(FILE* database)
|
||||||
|
|
||||||
LINUSE = 1;
|
LINUSE = 1;
|
||||||
TRVS = 1;
|
TRVS = 1;
|
||||||
CLSSES = 0;
|
|
||||||
TRNVLS = 0;
|
TRNVLS = 0;
|
||||||
|
|
||||||
/* Start new data section. Sect is the section number. */
|
/* Start new data section. Sect is the section number. */
|
||||||
|
@ -529,7 +522,6 @@ static void write_file(FILE* header_file)
|
||||||
write_1d(header_file, COND, LOCSIZ + 1, "COND");
|
write_1d(header_file, COND, LOCSIZ + 1, "COND");
|
||||||
write_1d(header_file, KEY, LOCSIZ + 1, "KEY");
|
write_1d(header_file, KEY, LOCSIZ + 1, "KEY");
|
||||||
write_1d(header_file, LOCSND, LOCSIZ + 1, "LOCSND");
|
write_1d(header_file, LOCSND, LOCSIZ + 1, "LOCSND");
|
||||||
write_1d(header_file, CVAL, CLSMAX + 1, "CVAL");
|
|
||||||
write_1d(header_file, TRAVEL, TRVSIZ + 1, "TRAVEL");
|
write_1d(header_file, TRAVEL, TRVSIZ + 1, "TRAVEL");
|
||||||
write_1d(header_file, KTAB, TABSIZ + 1, "KTAB");
|
write_1d(header_file, KTAB, TABSIZ + 1, "KTAB");
|
||||||
write_1d(header_file, ATAB, TABSIZ + 1, "ATAB");
|
write_1d(header_file, ATAB, TABSIZ + 1, "ATAB");
|
||||||
|
|
|
@ -35,10 +35,15 @@ typedef struct {{
|
||||||
const char* message;
|
const char* message;
|
||||||
}} turn_threshold_t;
|
}} turn_threshold_t;
|
||||||
|
|
||||||
|
typedef struct {{
|
||||||
|
const int threshold;
|
||||||
|
const char* message;
|
||||||
|
}} class_t;
|
||||||
|
|
||||||
extern location_t locations[];
|
extern location_t locations[];
|
||||||
extern object_description_t object_descriptions[];
|
extern object_description_t object_descriptions[];
|
||||||
extern const char* arbitrary_messages[];
|
extern const char* arbitrary_messages[];
|
||||||
extern const char* class_messages[];
|
extern const class_t classes[];
|
||||||
extern turn_threshold_t turn_thresholds[];
|
extern turn_threshold_t turn_thresholds[];
|
||||||
extern obituary_t obituaries[];
|
extern obituary_t obituaries[];
|
||||||
|
|
||||||
|
@ -50,10 +55,6 @@ enum arbitrary_messages_refs {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
enum class_messages_refs {{
|
|
||||||
{}
|
|
||||||
}};
|
|
||||||
|
|
||||||
enum locations_refs {{
|
enum locations_refs {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
@ -69,7 +70,7 @@ const char* arbitrary_messages[] = {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
const char* class_messages[] = {{
|
const class_t classes[] = {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
@ -123,20 +124,25 @@ def get_arbitrary_messages(arb):
|
||||||
return arb_str
|
return arb_str
|
||||||
|
|
||||||
def get_class_messages(cls):
|
def get_class_messages(cls):
|
||||||
template = """ {},
|
template = """ {{
|
||||||
|
.threshold = {},
|
||||||
|
.message = {},
|
||||||
|
}},
|
||||||
"""
|
"""
|
||||||
cls_str = ""
|
cls_str = ""
|
||||||
for item in cls:
|
for item in cls:
|
||||||
cls_str += template.format(make_c_string(item[1]))
|
threshold = item["threshold"]
|
||||||
|
message = make_c_string(item["message"])
|
||||||
|
cls_str += template.format(threshold, message)
|
||||||
cls_str = cls_str[:-1] # trim trailing newline
|
cls_str = cls_str[:-1] # trim trailing newline
|
||||||
return cls_str
|
return cls_str
|
||||||
|
|
||||||
def get_turn_thresholds(trn):
|
def get_turn_thresholds(trn):
|
||||||
template = """ {{
|
template = """ {{
|
||||||
.threshold = {},
|
.threshold = {},
|
||||||
.point_loss = {},
|
.point_loss = {},
|
||||||
.message = {},
|
.message = {},
|
||||||
}},
|
}},
|
||||||
"""
|
"""
|
||||||
trn_str = ""
|
trn_str = ""
|
||||||
for item in trn:
|
for item in trn:
|
||||||
|
@ -204,7 +210,6 @@ with open(yaml_name, "r") as f:
|
||||||
|
|
||||||
h = h_template.format(
|
h = h_template.format(
|
||||||
get_refs(db["arbitrary_messages"]),
|
get_refs(db["arbitrary_messages"]),
|
||||||
get_refs(db["class_messages"]),
|
|
||||||
get_refs(db["locations"]),
|
get_refs(db["locations"]),
|
||||||
get_refs(db["object_descriptions"]),
|
get_refs(db["object_descriptions"]),
|
||||||
)
|
)
|
||||||
|
@ -212,12 +217,12 @@ h = h_template.format(
|
||||||
c = c_template.format(
|
c = c_template.format(
|
||||||
h_name,
|
h_name,
|
||||||
get_arbitrary_messages(db["arbitrary_messages"]),
|
get_arbitrary_messages(db["arbitrary_messages"]),
|
||||||
get_class_messages(db["class_messages"]),
|
get_class_messages(db["classes"]),
|
||||||
get_turn_thresholds(db["turn_thresholds"]),
|
get_turn_thresholds(db["turn_thresholds"]),
|
||||||
get_locations(db["locations"]),
|
get_locations(db["locations"]),
|
||||||
get_object_descriptions(db["object_descriptions"]),
|
get_object_descriptions(db["object_descriptions"]),
|
||||||
get_obituaries(db["obituaries"]),
|
get_obituaries(db["obituaries"]),
|
||||||
len(db["class_messages"]),
|
len(db["classes"]),
|
||||||
len(db["obituaries"]),
|
len(db["obituaries"]),
|
||||||
len(db["turn_thresholds"]),
|
len(db["turn_thresholds"]),
|
||||||
)
|
)
|
||||||
|
|
6
score.c
6
score.c
|
@ -120,9 +120,9 @@ void terminate(enum termination mode)
|
||||||
SETPRM(3, game.turns, game.turns);
|
SETPRM(3, game.turns, game.turns);
|
||||||
RSPEAK(TOTAL_SCORE);
|
RSPEAK(TOTAL_SCORE);
|
||||||
for (long i = 1; i <= (long)CLSSES; i++) {
|
for (long i = 1; i <= (long)CLSSES; i++) {
|
||||||
if (CVAL[i] >= points) {
|
if (classes[i].threshold >= points) {
|
||||||
speak(class_messages[i]);
|
speak(classes[i].message);
|
||||||
i = CVAL[i] + 1 - points;
|
i = classes[i].threshold + 1 - points;
|
||||||
SETPRM(1, i, i);
|
SETPRM(1, i, i);
|
||||||
RSPEAK(NEXT_HIGHER);
|
RSPEAK(NEXT_HIGHER);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue