From be1fecbc11c1086a5f8b69ba0b6c958e357ec9a3 Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Mon, 3 Apr 2023 01:30:15 +0100 Subject: [PATCH] Refactor variables - Part 3 --- game/characters/twins/vars.rpy | 11 ++++++ game/scripts/characters/hermione/summon.rpy | 2 +- game/scripts/characters/snape/vars.rpy | 3 ++ game/scripts/events/DayNight.rpy | 4 +-- game/scripts/events/quests.rpy | 6 ++-- game/scripts/interface/letter.rpy | 2 +- .../minigames/cardgame/__card_game_init__.rpy | 18 ---------- .../minigames/cardgame/_deck_builder_.rpy | 2 +- .../cardgame/_hermione_card_game_.rpy | 6 ++-- .../minigames/cardgame/_snape_card_game_.rpy | 35 ++++++++++--------- .../minigames/cardgame/_twins_card_game_.rpy | 28 +++++++-------- game/scripts/shops/item/room.rpy | 22 ++++++------ 12 files changed, 68 insertions(+), 71 deletions(-) create mode 100644 game/characters/twins/vars.rpy diff --git a/game/characters/twins/vars.rpy b/game/characters/twins/vars.rpy new file mode 100644 index 00000000..45daa285 --- /dev/null +++ b/game/characters/twins/vars.rpy @@ -0,0 +1,11 @@ + +# Event flags + +default states.twi.ev.cardgame.known = False +default states.twi.ev.cardgame.stage = 0 +default states.twi.ev.cardgame.first_random = True +default states.twi.ev.cardgame.delay = 7 +default states.twi.ev.cardgame.stocked = False +default states.twi.ev.cardgame.stock_talk = False +default states.twi.ev.cardgame.interest = False +default states.twi.ev.cardgame.profit = 1.0 diff --git a/game/scripts/characters/hermione/summon.rpy b/game/scripts/characters/hermione/summon.rpy index b9e63e33..39caff16 100644 --- a/game/scripts/characters/hermione/summon.rpy +++ b/game/scripts/characters/hermione/summon.rpy @@ -85,7 +85,7 @@ label summon_hermione: call wardrobe jump hermione_requests - "-Let's Duel-" (icon="interface/icons/small/cards.webp") if snape_second_win: + "-Let's Duel-" (icon="interface/icons/small/cards.webp") if states.sna.ev.cardgame.stage > 2: jump hermione_cardgame_menu "-Give Item-" (icon="interface/icons/small/gift.webp") if states.her.favors_unlocked: diff --git a/game/scripts/characters/snape/vars.rpy b/game/scripts/characters/snape/vars.rpy index 6a3319ec..3c599b73 100644 --- a/game/scripts/characters/snape/vars.rpy +++ b/game/scripts/characters/snape/vars.rpy @@ -32,3 +32,6 @@ default states.sna.ev.hangouts.tonks_e2 = False default states.sna.ev.hangouts.tonks_e3 = False default states.sna.ev.hangouts.cho_e1 = False default states.sna.ev.hangouts.cho_e2 = False +default states.sna.ev.cardgame.stage = 0 +default states.sna.ev.cardgame.wagers = False +default states.sna.ev.cardgame.known = False diff --git a/game/scripts/events/DayNight.rpy b/game/scripts/events/DayNight.rpy index 2474f6d6..9fe565bb 100644 --- a/game/scripts/events/DayNight.rpy +++ b/game/scripts/events/DayNight.rpy @@ -93,8 +93,8 @@ label day_start: if game.day % 7 == 0: if states.paperwork_reports >= 1: letter_work_report.send() - if not first_random_twins: - twins_interest = True + if not states.twi.ev.cardgame.first_random: + states.twi.ev.cardgame.interest = True # Pass time mailbox.tick() diff --git a/game/scripts/events/quests.rpy b/game/scripts/events/quests.rpy index 455c0f1a..0a78c6c2 100644 --- a/game/scripts/events/quests.rpy +++ b/game/scripts/events/quests.rpy @@ -120,12 +120,12 @@ label quests: # CARDGAME - EVENTS # - if game.day >= twins_cards_delay: - if states.cardgame.unlocked and twins_first_win and not twins_cards_stocked: + if game.day >= states.twi.ev.cardgame.delay: + if states.cardgame.unlocked and states.twi.ev.cardgame.stage >= 1 and not states.twi.ev.cardgame.stocked: if not game.daytime: $ letter_cards_store.send() - if geniecard_level < 2 and snape_third_win and states.her.ev.cardgame.stage >= 3 and twins_second_win: + if geniecard_level < 2 and states.sna.ev.cardgame.stage >= 3 and states.her.ev.cardgame.stage >= 3 and states.twi.ev.cardgame.stage >= 2: if not game.daytime: $ letter_cards_tier2.send() diff --git a/game/scripts/interface/letter.rpy b/game/scripts/interface/letter.rpy index 1f1227cd..10dffef2 100644 --- a/game/scripts/interface/letter.rpy +++ b/game/scripts/interface/letter.rpy @@ -116,7 +116,7 @@ default letter_cards_store = Letter( ) label letter_cards_store: - $ twins_cards_stocked = True + $ states.twi.ev.cardgame.stocked = True $ poker_outfit_ITEM.unlocked = True $ lootbox_ITEM.unlocked = True gen "Great, let's see how they're doing." ("base", xpos="far_left", ypos="head") diff --git a/game/scripts/minigames/cardgame/__card_game_init__.rpy b/game/scripts/minigames/cardgame/__card_game_init__.rpy index 20b0b43e..6d859b81 100644 --- a/game/scripts/minigames/cardgame/__card_game_init__.rpy +++ b/game/scripts/minigames/cardgame/__card_game_init__.rpy @@ -431,24 +431,6 @@ default card_item_wine = Card( imagepath="images/cardgame/t1/other/wine_v1.webp" default enemy_deck = [] -default snape_know_cards = False -default snape_first_win = False -default snape_second_win = False -default snape_third_win = False -default snape_wager_talk = False -default random_snape_win = False - -default twins_know_cards = False -default twins_first_win = False -default twins_second_win = False -default twins_cards_delay = 7 -default twins_cards_stocked = False -default twins_cards_stocked_talk = False -default twins_interest = False -default first_random_twins = True -default twins_random_win = True -default twins_profit = 1.0 - default card_rand_realm = renpy.random.choice([card_iris, card_jasmine, card_azalea]) default card_rand_girl = renpy.random.choice([card_her_schoolgirl, card_sus_schoolgirl, card_cho_schoolgirl, card_lun_schoolgirl]) default card_rand_item1 = renpy.random.choice([card_item_desk, card_item_bird]) diff --git a/game/scripts/minigames/cardgame/_deck_builder_.rpy b/game/scripts/minigames/cardgame/_deck_builder_.rpy index cf2acca5..79110b0f 100644 --- a/game/scripts/minigames/cardgame/_deck_builder_.rpy +++ b/game/scripts/minigames/cardgame/_deck_builder_.rpy @@ -248,7 +248,7 @@ label deck_builder_guide: $ deck_guide_page = 5 nar "The player with the most cards of their colour by the end wins the game." - if not snape_know_cards: + if not states.sna.ev.cardgame.known: gen "(Seems simple enough....)" ("base", xpos="far_left", ypos="head") gen "(Wait... who the fuck do I play against?)" ("angry", xpos="far_left", ypos="head") gen "(Maybe I should ask my good ole pal Snape if he has any cards...)" ("grin", xpos="far_left", ypos="head") diff --git a/game/scripts/minigames/cardgame/_hermione_card_game_.rpy b/game/scripts/minigames/cardgame/_hermione_card_game_.rpy index 6e77874a..7310e383 100644 --- a/game/scripts/minigames/cardgame/_hermione_card_game_.rpy +++ b/game/scripts/minigames/cardgame/_hermione_card_game_.rpy @@ -34,15 +34,15 @@ label hermione_cardgame_menu: $ states.her.ev.cardgame.known = True jump hermione_requests - elif states.her.ev.cardgame.known and twins_know_cards == False: + elif states.her.ev.cardgame.known and states.twi.ev.cardgame.known == False: gen "(I should talk to Fred and George about wizard cards first.)" ("base", xpos="far_left", ypos="head") jump hermione_requests - elif states.her.ev.cardgame.known and twins_know_cards and not twins_cards_stocked: + elif states.her.ev.cardgame.known and states.twi.ev.cardgame.known and not states.twi.ev.cardgame.stocked: gen "(I have to convince Fred and George to start stocking up cards in their shop first.)" ("base", xpos="far_left", ypos="head") jump hermione_requests - elif twins_cards_stocked_talk and not states.her.ev.cardgame.has_cards: + elif states.twi.ev.cardgame.stock_talk and not states.her.ev.cardgame.has_cards: gen "Hello again [name_hermione_genie]." ("base", xpos="far_left", ypos="head") her "Hello [name_genie_hermione]." ("base","base") gen "I wanted to thank you for mentioning the Weasley shop." ("base", xpos="far_left", ypos="head") diff --git a/game/scripts/minigames/cardgame/_snape_card_game_.rpy b/game/scripts/minigames/cardgame/_snape_card_game_.rpy index 697bdf0c..83c41b79 100644 --- a/game/scripts/minigames/cardgame/_snape_card_game_.rpy +++ b/game/scripts/minigames/cardgame/_snape_card_game_.rpy @@ -4,7 +4,7 @@ label snape_duel_menu: if geniecard_level == 1: - if not snape_know_cards: + if not states.sna.ev.cardgame.known: gen "Ever heard of Wizard Cards?" ("base", xpos="far_left", ypos="head") sna "What about them?" ("snape_05") gen "Do you have any?" ("grin", xpos="far_left", ypos="head") @@ -26,25 +26,25 @@ label snape_duel_menu: sna "Fine, I'm confident enough to beat a beginner." ("snape_06") sna "But first a bit of practice..." ("snape_02") gen "Let's play." ("grin", xpos="far_left", ypos="head") - $ snape_know_cards = True + $ states.sna.ev.cardgame.known = True menu: "-First Duel-": jump snape_first_duel - "-Second Duel-" if snape_first_win: + "-Second Duel-" if states.sna.ev.cardgame.stage >= 1: jump snape_second_duel - "-You need to beat the first duel-" (style="disabled") if not snape_first_win: + "-You need to beat the first duel-" (style="disabled") if states.sna.ev.cardgame.stage < 1: jump snape_duel_menu - "-Challenge-" if snape_second_win: + "-Challenge-" if states.sna.ev.cardgame.stage >= 2: jump snape_third_duel - "-You need to beat the second duel-" (style="disabled") if not snape_second_win: + "-You need to beat the second duel-" (style="disabled") if states.sna.ev.cardgame.stage < 2: jump snape_duel_menu "-Never mind-": jump snape_ready else: gen "Up for another game?" ("base", xpos="far_left", ypos="head") - if not snape_wager_talk: + if not states.sna.ev.cardgame.wagers: sna "With you?" sna "..." @@ -84,7 +84,7 @@ label snape_duel_menu: gen "(Must be something good if he's not going to tell me...)" ("base", xpos="far_left", ypos="head") gen "I'm in." ("grin", xpos="far_left", ypos="head") - $ snape_wager_talk = True + $ states.sna.ev.cardgame.wagers = True if wine_ITEM.owned < 1: sna "Show me the bottle." gen "What?" ("base", xpos="far_left", ypos="head") @@ -184,7 +184,9 @@ label snape_first_duel: $ states.sna.busy = True $ achievements.unlock("Cardwin") - $ snape_first_win = True + + if states.sna.ev.cardgame.stage < 1: + $ states.sna.ev.cardgame.stage = 1 $ tokens += 1 jump main_room_menu @@ -224,19 +226,18 @@ label snape_second_duel: $ states.sna.busy = True - $ snape_second_win = True + if states.sna.ev.cardgame.stage < 2: + $ states.sna.ev.cardgame.stage = 2 $ tokens += 1 jump main_room_menu - - label snape_third_duel: if not states.her.ev.cardgame.known: gen "(I should probably see if Hermione is interested and practise some more before challenging Snape.)" ("base", xpos="far_left", ypos="head") jump snape_duel_menu - if not twins_cards_stocked_talk: + if not states.twi.ev.cardgame.stock_talk: gen "(I should wait for an owl from Fred and George and train with Hermione first.)" ("base", xpos="far_left", ypos="head") jump snape_duel_menu @@ -283,13 +284,13 @@ label snape_third_duel: stop music fadeout 1 hide screen blkfade - if snape_third_win == False: + if states.sna.ev.cardgame.stage < 3: sna "Impossible... There must be something wrong with my cards!" ("snape_05") gen "They're old, that's what." ("base", xpos="far_left", ypos="head") gen "Now to the prize..." ("base", xpos="far_left", ypos="head") sna "Fine... Here's your tokens and one of my precious cards." ("snape_05") sna "(You were a good card my boy. But it's time to grow up.)" ("snape_05") - $ snape_third_win = True + $ states.sna.ev.cardgame.stage = 3 $ unlocked_cards += [card_snape] call give_reward("You have received a special card!", "images/cardgame/t1/special/snape_v1.webp") $ tokens += 3 @@ -330,8 +331,8 @@ label snape_random_duel: ingredients = [x for x in inventory.get_instances_of_type("ingredient") if x.price > 0] item = renpy.random.choice(ingredients) - if not random_snape_win: - $ random_snape_win = True + if states.sna.ev.cardgame.stage < 4: + $ states.sna.ev.cardgame.stage = 4 gen "Yes!" ("base", xpos="far_left", ypos="head") gen "No wine for you.." ("grin", xpos="far_left", ypos="head") diff --git a/game/scripts/minigames/cardgame/_twins_card_game_.rpy b/game/scripts/minigames/cardgame/_twins_card_game_.rpy index a579ba21..e186afc1 100644 --- a/game/scripts/minigames/cardgame/_twins_card_game_.rpy +++ b/game/scripts/minigames/cardgame/_twins_card_game_.rpy @@ -11,7 +11,7 @@ label twins_first_duel: hide screen blkfade stop music fadeout 1 - if not twins_first_win: + if states.twi.ev.cardgame.stage < 1: twi "No way!" ger "You must've been cheating." gen "It's all in the cards boys." ("base", xpos="far_left", ypos="head") @@ -28,8 +28,8 @@ label twins_first_duel: fre "So you better get ready for a rematch!" twi "Because we'll win next time!" gen "We'll see about that... I can't have students going around showing up to their headmaster can I?" ("base", xpos="far_left", ypos="head") - $ twins_first_win = True - $ twins_cards_delay = twins_cards_delay+game.day + $ states.twi.ev.cardgame.stage = 1 + $ states.twi.ev.cardgame.delay = states.twi.ev.cardgame.delay+game.day pass else: twi "Not again.." @@ -43,7 +43,7 @@ label twins_first_duel: jump main_room label twins_second_duel: - if twins_cards_stocked == False: + if states.twi.ev.cardgame.stocked == False: gen "(I need to wait for an owl from them before we can duel again)" ("base", xpos="far_left", ypos="head") jump twins_duel_menu @@ -75,7 +75,7 @@ label twins_second_duel: hide screen blkfade stop music fadeout 1 - if not twins_second_win: + if states.twi.ev.cardgame.stage < 2: fre "I feel like we should have foreseen this." ger "I blame Trelawney on this, she said that luck would be on our side today..." fre "Well... A promise is a promise." @@ -85,7 +85,7 @@ label twins_second_duel: $ card_rand_twins = renpy.random.choice([[card_fred, "fred"], [card_george, "george"]]) $ unlocked_cards += [card_rand_twins[0]] call give_reward("You have received a special card!", "images/cardgame/t1/special/%s_v1.webp" % str(card_rand_twins[1])) - $ twins_second_win = True + $ states.twi.ev.cardgame.stage = 2 $ tokens += 3 else: twi "Not again.." @@ -96,8 +96,8 @@ label twins_second_duel: jump main_room label twins_random_duel: - if first_random_twins: - $ first_random_twins = False + if states.twi.ev.cardgame.first_random: + $ states.twi.ev.cardgame.first_random = False gen "How about another game?" ("base", xpos="far_left", ypos="head") twi "Sure, why not?" fre "But let's make it a bit interesting." @@ -134,7 +134,7 @@ label twins_random_duel: gen "Obviously..." ("base", xpos="far_left", ypos="head") fre "Just making sure that we have all grounds covered." gen "Let's begin then..." ("base", xpos="far_left", ypos="head") - elif twins_profit == 0.2: + elif states.twi.ev.cardgame.profit == 0.2: gen "Ready for another wager?" ("base", xpos="far_left", ypos="head") ger "No, I think we've had quite enough of a dent in our profit margin..." fre "We're almost half way to where we were before we introduced the card game." @@ -185,7 +185,7 @@ label twins_random_duel: hide screen blkfade stop music fadeout 1 - if twins_random_win: + if states.twi.ev.cardgame.stage < 3: twi "Impossible!" ger "How did you even do that? we weighed these packs for a reason..." gen "You did what, sorry?" ("base", xpos="far_left", ypos="head") @@ -213,10 +213,10 @@ label twins_random_duel: ger "We'll think about it..." call give_reward("You have received 5%% of the twins profits!", "interface/icons/cards.webp") - $ twins_profit += 0.05 - $ twins_random_win = False + $ states.twi.ev.cardgame.profit += 0.05 + $ states.twi.ev.cardgame.stage = 3 $ tokens += 3 - elif twins_profit >= 1.2: + elif states.twi.ev.cardgame.profit >= 1.2: fre "Nice job but you've reached the cap I'm afraid." ger "Yeah, don't want to go minus do we?" $ tokens += 1 @@ -225,7 +225,7 @@ label twins_random_duel: gen "Time to pay up, boys." ("base", xpos="far_left", ypos="head") ger "Fine... We'll up your profits by 1%%..." $ tokens += 1 - $ twins_profit += 0.01 + $ states.twi.ev.cardgame.profit += 0.01 "You return to your office." jump main_room diff --git a/game/scripts/shops/item/room.rpy b/game/scripts/shops/item/room.rpy index bddd22ea..18a85a56 100644 --- a/game/scripts/shops/item/room.rpy +++ b/game/scripts/shops/item/room.rpy @@ -40,8 +40,8 @@ label item_store: gen "What sort of items are you \"not selling\"?" ("base", xpos="far_left", ypos="head") ger "We have books, treats, and knick-knacks for sale." fre "Take a look." - elif twins_interest: - $ twins_interest = False + elif states.twi.ev.cardgame.interest: + $ states.twi.ev.cardgame.interest = False twi "Greetings Dumbledore, sir!" gen "Hello boys." ("base", xpos="far_left", ypos="head") @@ -56,9 +56,9 @@ label item_store: $ shop_profit = renpy.random.randint(50+her_help, 300) ger "Here, your weekly cut." - call give_reward("You've received "+str(int(shop_profit*twins_profit))+" gold.", "interface/icons/gold.webp") + call give_reward("You've received "+str(int(shop_profit*states.twi.ev.cardgame.profit))+" gold.", "interface/icons/gold.webp") - $ game.gold += int(shop_profit*twins_profit) + $ game.gold += int(shop_profit*states.twi.ev.cardgame.profit) ger "..." twi "Did you need anything else?" else: @@ -127,7 +127,7 @@ label item_store: gen "Right..." ("base", xpos="far_left", ypos="head") ger "We've put the book in \"Quest Items\" section, can't miss it." - elif states.cardgame.unlocked and states.her.ev.cardgame.known and not twins_know_cards: + elif states.cardgame.unlocked and states.her.ev.cardgame.known and not states.twi.ev.cardgame.known: gen "Let's see..." ("base", xpos="far_left", ypos="head") twi "Looking for something in particular, sir?" gen "I'm looking to acquire some Wizard cards." ("base", xpos="far_left", ypos="head") @@ -145,10 +145,10 @@ label item_store: gen "So..." ("base", xpos="far_left", ypos="head") ger "If you beat us we'll do a trial run and stock some cards for the students." twi "(There's no way this\nold man would ever beat us.)" - $ twins_know_cards = True + $ states.twi.ev.cardgame.known = True jump twins_duel_menu - elif twins_cards_stocked and not twins_second_win and not twins_cards_stocked_talk: + elif states.twi.ev.cardgame.stocked and states.twi.ev.cardgame.stage < 2 and not states.twi.ev.cardgame.stock_talk: gen "Well, well... Looking good as always boys!" ("base", xpos="far_left", ypos="head") twi "..." gen "In a professional sense that is... Don't you worry." ("base", xpos="far_left", ypos="head") @@ -180,7 +180,7 @@ label item_store: gen "That's it? Sounds a bit out of character for you guys to make it this easy." ("base", xpos="far_left", ypos="head") fre "Let's call it an insurance so that we can continue our business." ger "There's no way you'll beat us again anyway." - $ twins_cards_stocked_talk = True + $ states.twi.ev.cardgame.stock_talk = True jump twins_duel_menu elif states.lun.unlocked and not states.lun.ev.spectrespecs.e1_complete: @@ -191,7 +191,7 @@ label item_store: jump main_room elif states.lun.ev.quibbler.stocked and not states.lun.ev.spectrespecs.e2_complete: call spectrespecs_E2 - elif twins_know_cards: + elif states.twi.ev.cardgame.known: twi "Perhaps a game of cards?" label twins_menu: menu: @@ -203,9 +203,9 @@ label item_store: menu: "-First Duel-": jump twins_first_duel - "-Challenge-" if twins_first_win: + "-Challenge-" if states.twi.ev.cardgame.stage > 1: jump twins_second_duel - "-You need to beat the first duel-" (style="disabled") if not twins_first_win: + "-You need to beat the first duel-" (style="disabled") if states.twi.ev.cardgame.stage < 1: jump twins_duel_menu "-Never mind-": twi "Your loss professor."