Skip to content

Commit 2b0fade

Browse files
committed
Story logic in place mostly
1 parent 3299558 commit 2b0fade

File tree

1 file changed

+150
-22
lines changed

1 file changed

+150
-22
lines changed

main.chai

+150-22
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ class Travel_To {
1616
var requires_chains;
1717
}
1818

19+
def refusing_business(t_game) {
20+
return t_game.get_flag("christian_shared_verse")
21+
&& t_game.get_flag("have_spread_rumors")
22+
&& !t_game.get_flag("did_say_something_nice")
23+
&& !t_game.get_flag("did_not_respond");
24+
}
25+
26+
def did_make_all_responses(t_game) {
27+
return t_game.get_flag("have_talked_to_Twin2") && t_game.get_flag("have_talked_to_YoungEntrepeneur");
28+
}
29+
30+
def did_say_something_nice(t_game) {
31+
return t_game.get_flag("did_say_something_nice")
32+
}
33+
1934
def travel_to(t_loc, t_game) {
2035
var has_offroad_tires = t_game.get_flag("has_offroad_tires");
2136
var has_tire_chains = t_game.get_flag("has_tire_chains");
@@ -45,7 +60,7 @@ def sell(string t_thing, int t_price, t_game, t_game_time, t_simulation_time, t_
4560
t_game.show_message_box("You don't have any ${t_thing} to sell.");
4661
}
4762

48-
show_shop_menu(t_game, t_game_time, t_simulation_time, t_bread, t_meat, t_vegetables, t_wood);
63+
show_shop_menu(t_game, false, t_game_time, t_simulation_time, t_bread, t_meat, t_vegetables, t_wood);
4964
}
5065

5166
def do_purchase(t_game, int t_price)
@@ -76,17 +91,23 @@ def buy(string t_thing, int t_price, t_game, t_game_time, t_simulation_time, t_b
7691
}
7792
}
7893

79-
show_shop_menu(t_game, t_game_time, t_simulation_time, t_bread, t_meat, t_vegetables, t_wood);
94+
show_shop_menu(t_game, false, t_game_time, t_simulation_time, t_bread, t_meat, t_vegetables, t_wood);
8095
}
8196

82-
def show_shop_menu(t_game, t_game_time, t_simulation_time, int t_bread, int t_meat, int t_vegetables, int t_wood)
97+
def show_shop_menu(t_game, t_sensitive, t_game_time, t_simulation_time, int t_bread, int t_meat, int t_vegetables, int t_wood)
8398
{
8499
var bread = t_game.get_value("bread");
85100
var meat = t_game.get_value("meat");
86101
var vegetables = t_game.get_value("vegetables");
87102
var wood = t_game.get_value("wood");
88103
var money = t_game.get_value("money");
89104

105+
106+
if (t_sensitive && refusing_business(t_game)) {
107+
t_game.show_message_box("This location is refusing to do business with you because of your rumor spreading");
108+
return;
109+
}
110+
90111
var actions =
91112
[
92113
Game_Action("Sell Bread $${t_bread} (have: ${bread})",
@@ -130,7 +151,7 @@ def show_shop_menu(t_game, t_game_time, t_simulation_time, int t_bread, int t_me
130151
} else {
131152
t_game.show_message_box("You already own tire chains.");
132153
}
133-
show_shop_menu(t_game, t_game_time, t_simulation_time, t_bread, t_meat, t_vegetables, t_wood);
154+
show_shop_menu(t_game, false, t_game_time, t_simulation_time, t_bread, t_meat, t_vegetables, t_wood);
134155
}),
135156
Game_Action("Buy off-road tires ($500)",
136157
fun[t_bread, t_meat, t_vegetables, t_wood](t_game_time, t_simulation_time, t_game){
@@ -141,7 +162,7 @@ def show_shop_menu(t_game, t_game_time, t_simulation_time, int t_bread, int t_me
141162
} else {
142163
t_game.show_message_box("You already own off-road tires.");
143164
}
144-
show_shop_menu(t_game, t_game_time, t_simulation_time, t_bread, t_meat, t_vegetables, t_wood);
165+
show_shop_menu(t_game, false, t_game_time, t_simulation_time, t_bread, t_meat, t_vegetables, t_wood);
145166
}),
146167
Game_Action("Done ($${money} avail) / (${meat+wood+vegetables+bread}/5 cargo)", fun(t_game_time, t_simulation_time, t_game) {})
147168

@@ -209,6 +230,9 @@ var game_creator = fun(game) {
209230
var glennhaven = Tile_Map(game, "resources/Maps/glennhaven.json", []);
210231
glennhaven.add_enter_action(
211232
fun(t_game) {
233+
if (refusing_business(t_game)) {
234+
t_game.show_message_box("We've decided to stop doing business with you because of your rumor spreading.");
235+
}
212236
t_game.teleport_to_tile(9, 4);
213237
}
214238
);
@@ -227,7 +251,30 @@ var game_creator = fun(game) {
227251
[Answer("YoungEntrepeneur", "Hi! Welcome to Glenn Haven.\nI've just opened up shop here.\nI think you'll like our prices on bread!")],
228252
fun(t_game_time, t_simulation_time, t_game, t_obj){ true },
229253
fun(t_game_time, t_simulation_time, t_game, t_obj){ }
254+
),
255+
Question("<spread rumors about competitor>",
256+
[Answer("YoungEntrepeneur", "That's not a very nice thing to say...")],
257+
fun(t_game_time, t_simulation_time, t_game, t_obj){
258+
t_game.get_flag("have_talked_to_christian_about_rumors") && !t_game.get_flag("have_talked_to_YoungEntrepeneur"); },
259+
fun(t_game_time, t_simulation_time, t_game, t_obj){
260+
t_game.set_flag("have_talked_to_YoungEntrepeneur", true); t_game.set_flag("have_spread_rumors", true); }
261+
),
262+
Question("<say something nice about competitor>",
263+
[Answer("YoungEntrepeneur", "That's good to hear.")],
264+
fun(t_game_time, t_simulation_time, t_game, t_obj){
265+
t_game.get_flag("have_talked_to_christian_about_rumors") && !t_game.get_flag("have_talked_to_YoungEntrepeneur"); },
266+
fun(t_game_time, t_simulation_time, t_game, t_obj){
267+
t_game.set_flag("have_talked_to_YoungEntrepeneur", true); t_game.set_flag("have_said_something_nice", true); }
268+
),
269+
Question("<say nothing about competitor>",
270+
[],
271+
fun(t_game_time, t_simulation_time, t_game, t_obj){
272+
t_game.get_flag("have_talked_to_christian_about_rumors") && !t_game.get_flag("have_talked_to_YoungEntrepeneur"); },
273+
fun(t_game_time, t_simulation_time, t_game, t_obj){
274+
t_game.set_flag("have_talked_to_YoungEntrepeneur", true); t_game.set_flag("did_not_respond", true); }
230275
)
276+
277+
231278
]);
232279

233280

@@ -248,7 +295,7 @@ var game_creator = fun(game) {
248295
),
249296
Object_Action("Shop",
250297
fun(t_game_time, t_simulation_time, t_game, t_obj){
251-
show_shop_menu(t_game, t_game_time, t_simulation_time, 80, 112, 85, 100);
298+
show_shop_menu(t_game, true, t_game_time, t_simulation_time, 80, 112, 85, 100);
252299
}
253300
)
254301
];
@@ -289,10 +336,35 @@ var game_creator = fun(game) {
289336
var Christian_conversation_tree =
290337
Conversation([
291338
Question("Hello",
292-
[Answer("Christian", "Hi! Welcome to Glenn Haven.\nI've just opened up shop here.\nI think you'll like our prices on bread!")],
339+
[Answer("Christian", "Hi! Welcome to Fairview.")],
293340
fun(t_game_time, t_simulation_time, t_game, t_obj){ true },
294341
fun(t_game_time, t_simulation_time, t_game, t_obj){ }
295-
)
342+
),
343+
Question("Rumors",
344+
[Answer("Christian", "Yes, I've heard the rumors too."),
345+
Answer("Christian", "It's an unfortunate way to do business.")],
346+
fun(t_game_time, t_simulation_time, t_game, t_obj){ t_game.get_flag("have_been_notified_of_rumors"); },
347+
fun(t_game_time, t_simulation_time, t_game, t_obj){ }
348+
),
349+
Question("What should I do?",
350+
[Answer("Christian", "Don't retaliate. Rumor mongering is not the best way to do business.")],
351+
fun(t_game_time, t_simulation_time, t_game, t_obj){ t_game.get_flag("have_been_notified_of_rumors"); },
352+
fun(t_game_time, t_simulation_time, t_game, t_obj){ t_game.set_flag("have_talked_to_christian_about_rumors", true); }
353+
),
354+
Question("What now?",
355+
[Answer("Christian", "Romans 12:19 says, 'Friends, do not avenge yourselves;\ninstead, leave room for His wrath.\nFor it is written: Vengeance belongs to Me;\nI will repay, says the Lord.'"),
356+
Answer("Christian", "I hope you didn't decide to take matters into your own hands.\nThat rarely works out well.")],
357+
fun(t_game_time, t_simulation_time, t_game, t_obj){ did_make_all_responses(t_game); },
358+
fun(t_game_time, t_simulation_time, t_game, t_obj){ t_game.set_flag("christian_shared_verse", true); }
359+
),
360+
Question("Note",
361+
[Answer("Christian", "Romans 12:19 says, 'Friends, do not avenge yourselves;\ninstead, leave room for His wrath.\nFor it is written: Vengeance belongs to Me;\nI will repay, says the Lord.'"),
362+
Answer("Christian", "This you already know."),
363+
Answer("Christian", "Romans 12:20 goes on to say 'But If your enemy is hungry,\nfeed him. If he is thirsty, give him something to drink.\nFor in so doing\nyou will be heaping fiery coals on his head.'"),
364+
Answer("Christian", "This is the lesson you've learned today.")],
365+
fun(t_game_time, t_simulation_time, t_game, t_obj){ t_game.get_flag("saw_note") },
366+
fun(t_game_time, t_simulation_time, t_game, t_obj){ t_game.set_flag("christian_shared_second_verse", true); }
367+
)
296368
]);
297369

298370
var Christian_actions = fun[Christian_conversation_tree](t_game_time, t_simulation_time, t_game, t_obj){
@@ -311,7 +383,7 @@ var game_creator = fun(game) {
311383
),
312384
Object_Action("Shop",
313385
fun(t_game_time, t_simulation_time, t_game, t_obj){
314-
show_shop_menu(t_game, t_game_time, t_simulation_time, 95, 100, 85, 93);
386+
show_shop_menu(t_game, false, t_game_time, t_simulation_time, 95, 100, 85, 93);
315387
}
316388
)
317389
];
@@ -336,26 +408,57 @@ var game_creator = fun(game) {
336408
);
337409

338410
var mineralville = Tile_Map(game, "resources/Maps/mineralville.json", []);
411+
412+
var OldMan_conversation_tree =
413+
Conversation([
414+
Question("Rumors",
415+
[Answer("OldMan", "You must be the new trader in town.\nYour competitor has been saying unflattering things about you."),
416+
Answer("OldMan", "But you seem like a nice person... I'm not sure I believe them.")],
417+
fun(t_game_time, t_simulation_time, t_game, t_obj){ true },
418+
fun(t_game_time, t_simulation_time, t_game, t_obj){ t_game.set_flag("have_been_notified_of_rumors", true); }
419+
),
420+
Question("What should I do?",
421+
[Answer("OldMan", "Well, if it were me, I'd start spreading rumors of my own about them!\nYou have to fight for what you get.")],
422+
fun(t_game_time, t_simulation_time, t_game, t_obj){ true },
423+
fun(t_game_time, t_simulation_time, t_game, t_obj){ }
424+
),
425+
Question("Note?",
426+
[Answer("OldMan", "There's a note here from your competitor."),
427+
Answer("OldMan", "It says he's sorry for starting those rumors about you, and promises to set things right")],
428+
fun(t_game_time, t_simulation_time, t_game, t_obj) { !t_game.get_flag("saw_note") && did_make_all_responses(t_game) && did_say_something_nice(t_game) },
429+
fun(t_game_time, t_simulation_time, t_game, t_obj) { t_game.set_flag("saw_note", true); }
430+
),
431+
Question("Share bible verses you've learned.",
432+
[Answer("OldMan", "Well that is interesting...")],
433+
fun(t_game_time, t_simulation_time, t_game, t_obj) { t_game.get_flag("christian_shared_second_verse") },
434+
fun(t_game_time, t_simulation_time, t_game, t_obj) { }
435+
)
436+
]);
437+
339438
mineralville.add_enter_action(
340-
fun(t_game) {
341-
t_game.teleport_to_tile(9, 4);
439+
fun[OldMan_conversation_tree](t_game) {
440+
t_game.teleport_to_tile(2, 5);
441+
442+
if (!t_game.get_flag("have_been_notified_of_rumors")) {
443+
t_game.show_message_box("You see an old man who has the look of someone who has\nspent many years living in a remote\nmountain town.");
444+
t_game.show_message_box("OldMan: There's the person I've been hearing so much about!");
445+
}
446+
447+
if (!t_game.get_flag("saw_note") && did_make_all_responses(t_game) && did_say_something_nice(t_game))
448+
{
449+
t_game.show_message_box("There's a note over here for you");
450+
}
342451
}
343452
);
453+
344454
mineralville.set_collision_action("ExitSquare",
345455
fun(t_game_time, t_simulation_time, t_game, t_obj, t_sprite) {
346456
t_game.enter_map("world");
347457
t_game.teleport_to_tile(14,5);
348458
}
349459
);
350460

351-
var OldMan_conversation_tree =
352-
Conversation([
353-
Question("Hello",
354-
[Answer("OldMan", "Hi! Welcome to Glenn Haven.\nI've just opened up shop here.\nI think you'll like our prices on bread!")],
355-
fun(t_game_time, t_simulation_time, t_game, t_obj){ true },
356-
fun(t_game_time, t_simulation_time, t_game, t_obj){ }
357-
)
358-
]);
461+
359462

360463
var OldMan_actions = fun[OldMan_conversation_tree](t_game_time, t_simulation_time, t_game, t_obj){
361464
return [
@@ -373,7 +476,7 @@ var game_creator = fun(game) {
373476
),
374477
Object_Action("Shop",
375478
fun(t_game_time, t_simulation_time, t_game, t_obj){
376-
show_shop_menu(t_game, t_game_time, t_simulation_time, 100, 125, 95, 70);
479+
show_shop_menu(t_game, false, t_game_time, t_simulation_time, 100, 125, 95, 70);
377480
}
378481
)
379482
];
@@ -399,6 +502,9 @@ var game_creator = fun(game) {
399502
var camp = Tile_Map(game, "resources/Maps/camp.json", []);
400503
camp.add_enter_action(
401504
fun(t_game) {
505+
if (refusing_business(t_game)) {
506+
t_game.show_message_box("We've decided to stop doing business with you because of your rumor spreading.");
507+
}
402508
t_game.teleport_to_tile(9, 4);
403509
}
404510
);
@@ -415,12 +521,34 @@ var game_creator = fun(game) {
415521
[Answer("Twin1", "Hi! Welcome to Glenn Haven.\nI've just opened up shop here.\nI think you'll like our prices on bread!")],
416522
fun(t_game_time, t_simulation_time, t_game, t_obj){ true },
417523
fun(t_game_time, t_simulation_time, t_game, t_obj){ }
524+
),
525+
Question("<spread rumors about competitor>",
526+
[Answer("Twin2", "That's not a very nice thing to say...")],
527+
fun(t_game_time, t_simulation_time, t_game, t_obj){
528+
t_game.get_flag("have_talked_to_christian_about_rumors") && !t_game.get_flag("have_talked_to_Twin2"); },
529+
fun(t_game_time, t_simulation_time, t_game, t_obj){
530+
t_game.set_flag("have_talked_to_Twin2", true); t_game.set_flag("have_spread_rumors", true); }
531+
),
532+
Question("<say something nice about competitor>",
533+
[Answer("Twin2", "That's good to hear.")],
534+
fun(t_game_time, t_simulation_time, t_game, t_obj){
535+
t_game.get_flag("have_talked_to_christian_about_rumors") && !t_game.get_flag("have_talked_to_Twin2"); },
536+
fun(t_game_time, t_simulation_time, t_game, t_obj){
537+
t_game.set_flag("have_talked_to_Twin2", true); t_game.set_flag("have_said_something_nice", true); }
538+
),
539+
Question("<say nothing about competitor>",
540+
[],
541+
fun(t_game_time, t_simulation_time, t_game, t_obj){
542+
t_game.get_flag("have_talked_to_christian_about_rumors") && !t_game.get_flag("have_talked_to_Twin2"); },
543+
fun(t_game_time, t_simulation_time, t_game, t_obj){
544+
t_game.set_flag("have_talked_to_Twin2", true); t_game.set_flag("did_not_respond", true); }
418545
)
546+
419547
]);
420548

421549

422550
def camp_shop(t_game_time, t_simulation_time, t_game, t_obj) {
423-
show_shop_menu(t_game, t_game_time, t_simulation_time, 115, 147, 104, 84);
551+
show_shop_menu(t_game, true, t_game_time, t_simulation_time, 115, 147, 104, 84);
424552
}
425553

426554
var Twin1_actions = fun[Twin_conversation_tree](t_game_time, t_simulation_time, t_game, t_obj){
@@ -483,7 +611,7 @@ var game_creator = fun(game) {
483611

484612
game.add_start_action(
485613
fun(t_game) {
486-
t_game.set_value("money", 500);
614+
t_game.set_value("money", 1000);
487615
var money = t_game.get_value("money");
488616
t_game.show_message_box("Welcome to the game!\nYou have ${money} to start with.\nUse it wisely.");
489617
t_game.add_queued_action(

0 commit comments

Comments
 (0)