Refactor how turn threshold penalties are accounted for.
This commit is contained in:
parent
89de4e4602
commit
d029b08ad1
3 changed files with 54 additions and 25 deletions
|
@ -1037,12 +1037,19 @@ class_messages: !!omap
|
||||||
- CLS_9: 'All of Adventuredom gives tribute to you, Adventurer Grandmaster!'
|
- 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.'
|
- 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_thresholds:
|
||||||
- TURN_0: !!null
|
- threshold: 350
|
||||||
- TURN_1: 'Tsk! A wizard wouldn''t have to take 350 turns. This is going to cost\nyou a couple of points.'
|
point_loss: 2
|
||||||
- TURN_2: 500 turns? That's another few points you've lost.
|
message: 'Tsk! A wizard wouldn''t have to take 350 turns. This is going to cost\nyou a couple of points.'
|
||||||
- TURN_3: 'Are you still at it? Five points off for exceeding 1000 turns!'
|
- threshold: 500
|
||||||
- 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.'
|
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
|
object_descriptions: !!omap
|
||||||
- OBJ_0:
|
- OBJ_0:
|
||||||
|
|
27
main.c
27
main.c
|
@ -1024,14 +1024,25 @@ L2600:
|
||||||
L2607:
|
L2607:
|
||||||
game.foobar = (game.foobar > 0 ? -game.foobar : 0);
|
game.foobar = (game.foobar > 0 ? -game.foobar : 0);
|
||||||
++game.turns;
|
++game.turns;
|
||||||
if (game.turns == game.thresh) {
|
|
||||||
speak(turn_threshold_messages[game.trndex]);
|
/* If a turn threshold has been met, apply penalties and tell
|
||||||
game.trnluz = game.trnluz + TRNVAL[game.trndex] / 100000;
|
* the player about it. */
|
||||||
++game.trndex;
|
for (int i = turn_threshold_count; i >= 0; --i)
|
||||||
game.thresh = -1;
|
{
|
||||||
if (game.trndex <= TRNVLS)
|
if (game.turns == turn_thresholds[i].threshold)
|
||||||
game.thresh = MOD(TRNVAL[game.trndex], 100000) + 1;
|
{
|
||||||
}
|
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)
|
if (command.verb == SAY && WD2 > 0)
|
||||||
command.verb = 0;
|
command.verb = 0;
|
||||||
if (command.verb == SAY) {
|
if (command.verb == SAY) {
|
||||||
|
|
|
@ -29,15 +29,22 @@ typedef struct {{
|
||||||
const char* yes_response;
|
const char* yes_response;
|
||||||
}} obituary_t;
|
}} obituary_t;
|
||||||
|
|
||||||
|
typedef struct {{
|
||||||
|
const int threshold;
|
||||||
|
const int point_loss;
|
||||||
|
const char* message;
|
||||||
|
}} turn_threshold_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 char* class_messages[];
|
||||||
extern const char* turn_threshold_messages[];
|
extern turn_threshold_t turn_thresholds[];
|
||||||
extern obituary_t obituaries[];
|
extern obituary_t obituaries[];
|
||||||
|
|
||||||
extern size_t CLSSES;
|
extern size_t CLSSES;
|
||||||
extern int maximum_deaths;
|
extern int maximum_deaths;
|
||||||
|
extern int turn_threshold_count;
|
||||||
|
|
||||||
enum arbitrary_messages_refs {{
|
enum arbitrary_messages_refs {{
|
||||||
{}
|
{}
|
||||||
|
@ -47,10 +54,6 @@ enum class_messages_refs {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
enum turn_threshold_messages_refs {{
|
|
||||||
{}
|
|
||||||
}};
|
|
||||||
|
|
||||||
enum locations_refs {{
|
enum locations_refs {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
@ -70,7 +73,7 @@ const char* class_messages[] = {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
const char* turn_threshold_messages[] = {{
|
turn_threshold_t turn_thresholds[] = {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
@ -88,6 +91,7 @@ obituary_t obituaries[] = {{
|
||||||
|
|
||||||
size_t CLSSES = {};
|
size_t CLSSES = {};
|
||||||
int maximum_deaths = {};
|
int maximum_deaths = {};
|
||||||
|
int turn_threshold_count = {};
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def make_c_string(string):
|
def make_c_string(string):
|
||||||
|
@ -127,12 +131,19 @@ def get_class_messages(cls):
|
||||||
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_threshold_messages(trn):
|
def get_turn_thresholds(trn):
|
||||||
template = """ {},
|
template = """ {{
|
||||||
|
.threshold = {},
|
||||||
|
.point_loss = {},
|
||||||
|
.message = {},
|
||||||
|
}},
|
||||||
"""
|
"""
|
||||||
trn_str = ""
|
trn_str = ""
|
||||||
for item in trn:
|
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
|
trn_str = trn_str[:-1] # trim trailing newline
|
||||||
return trn_str
|
return trn_str
|
||||||
|
|
||||||
|
@ -194,7 +205,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["class_messages"]),
|
||||||
get_refs(db["turn_threshold_messages"]),
|
|
||||||
get_refs(db["locations"]),
|
get_refs(db["locations"]),
|
||||||
get_refs(db["object_descriptions"]),
|
get_refs(db["object_descriptions"]),
|
||||||
)
|
)
|
||||||
|
@ -203,12 +213,13 @@ 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["class_messages"]),
|
||||||
get_turn_threshold_messages(db["turn_threshold_messages"]),
|
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["class_messages"]),
|
||||||
len(db["obituaries"]),
|
len(db["obituaries"]),
|
||||||
|
len(db["turn_thresholds"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(h_name, "w") as hf:
|
with open(h_name, "w") as hf:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue