- CLS_9: 'All of Adventuredom gives tribute to you, Adventurer Grandmaster!'
- 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.'
-turn_threshold_messages: !!omap
-- TURN_0: !!null
-- TURN_1: 'Tsk! A wizard wouldn''t have to take 350 turns. This is going to cost\nyou a couple of points.'
-- TURN_2: 500 turns? That's another few points you've lost.
-- TURN_3: 'Are you still at it? Five points off for exceeding 1000 turns!'
-- TURN_4: 'Good grief, don''t you *EVER* give up? Do you realize you''ve spent\nover 2500 turns at this? That''s another ten points off, a total of\ntwenty points lost for taking so long.'
+turn_thresholds:
+- threshold: 350
+ point_loss: 2
+ message: 'Tsk! A wizard wouldn''t have to take 350 turns. This is going to cost\nyou a couple of points.'
+- threshold: 500
+ point_loss: 3
+ message: '500 turns? That''s another few points you''ve lost.'
+- threshold: 1000
+ point_loss: 5
+ message: 'Are you still at it? Five points off for exceeding 1000 turns!'
+- threshold: 2500
+ point_loss: 10
+ message: 'Good grief, don''t you *EVER* give up? Do you realize you''ve spent\nover 2500 turns at this? That''s another ten points off, a total of\ntwenty points lost for taking so long.'
object_descriptions: !!omap
- OBJ_0:
L2607:
game.foobar = (game.foobar > 0 ? -game.foobar : 0);
++game.turns;
- if (game.turns == game.thresh) {
- speak(turn_threshold_messages[game.trndex]);
- game.trnluz = game.trnluz + TRNVAL[game.trndex] / 100000;
- ++game.trndex;
- game.thresh = -1;
- if (game.trndex <= TRNVLS)
- game.thresh = MOD(TRNVAL[game.trndex], 100000) + 1;
- }
+
+ /* If a turn threshold has been met, apply penalties and tell
+ * the player about it. */
+ for (int i = turn_threshold_count; i >= 0; --i)
+ {
+ if (game.turns == turn_thresholds[i].threshold)
+ {
+ game.trnluz += turn_thresholds[i].point_loss;
+ speak(turn_thresholds[i].message);
+ }
+ }
+ /* if (game.turns == game.thresh) { */
+ /* speak(turn_threshold_messages[game.trndex]); */
+ /* game.trnluz = game.trnluz + TRNVAL[game.trndex] / 100000; */
+ /* ++game.trndex; */
+ /* game.thresh = -1; */
+ /* if (game.trndex <= TRNVLS) */
+ /* game.thresh = MOD(TRNVAL[game.trndex], 100000) + 1; */
+ /* } */
if (command.verb == SAY && WD2 > 0)
command.verb = 0;
if (command.verb == SAY) {
const char* yes_response;
}} obituary_t;
+typedef struct {{
+ const int threshold;
+ const int point_loss;
+ const char* message;
+}} turn_threshold_t;
+
extern location_t locations[];
extern object_description_t object_descriptions[];
extern const char* arbitrary_messages[];
extern const char* class_messages[];
-extern const char* turn_threshold_messages[];
+extern turn_threshold_t turn_thresholds[];
extern obituary_t obituaries[];
extern size_t CLSSES;
extern int maximum_deaths;
+extern int turn_threshold_count;
enum arbitrary_messages_refs {{
{}
{}
}};
-enum turn_threshold_messages_refs {{
-{}
-}};
-
enum locations_refs {{
{}
}};
{}
}};
-const char* turn_threshold_messages[] = {{
+turn_threshold_t turn_thresholds[] = {{
{}
}};
size_t CLSSES = {};
int maximum_deaths = {};
+int turn_threshold_count = {};
"""
def make_c_string(string):
cls_str = cls_str[:-1] # trim trailing newline
return cls_str
-def get_turn_threshold_messages(trn):
- template = """ {},
+def get_turn_thresholds(trn):
+ template = """ {{
+ .threshold = {},
+ .point_loss = {},
+ .message = {},
+}},
"""
trn_str = ""
for item in trn:
- trn_str += template.format(make_c_string(item[1]))
+ threshold = item["threshold"]
+ point_loss = item["point_loss"]
+ message = make_c_string(item["message"])
+ trn_str += template.format(threshold, point_loss, message)
trn_str = trn_str[:-1] # trim trailing newline
return trn_str
h = h_template.format(
get_refs(db["arbitrary_messages"]),
get_refs(db["class_messages"]),
- get_refs(db["turn_threshold_messages"]),
get_refs(db["locations"]),
get_refs(db["object_descriptions"]),
)
h_name,
get_arbitrary_messages(db["arbitrary_messages"]),
get_class_messages(db["class_messages"]),
- get_turn_threshold_messages(db["turn_threshold_messages"]),
+ get_turn_thresholds(db["turn_thresholds"]),
get_locations(db["locations"]),
get_object_descriptions(db["object_descriptions"]),
get_obituaries(db["obituaries"]),
len(db["class_messages"]),
len(db["obituaries"]),
+ len(db["turn_thresholds"]),
)
with open(h_name, "w") as hf: