1+ import random
12import time
23
34import scrap_engine as se
45
5- from pokete .base import loops
6- from pokete .base .input import Action , _ev , get_action
6+ from pokete .base .input import _ev
77from pokete .classes import deck
88from pokete .classes import movemap as mvp
99from pokete .classes .classes import PlayMap
1010from pokete .classes .doors import CenterDoor
11+ from pokete .classes .interactions .multi_text_choose_box import MultiTextChooseBox
1112from pokete .classes .inv import buy
1213from pokete .classes .landscape import MapInteract
1314from pokete .release import SPEED_OF_TIME
1415
16+ CUDDLE_MESSAGES = [
17+ "{name} nuzzles against you affectionately!" ,
18+ "{name} nuzzles against you lovingly!" ,
19+ "{name} nuzzles against you happily!" ,
20+ "{name} purrs contentedly in your arms!" ,
21+ "{name} looks up at you with adoring eyes!" ,
22+ "{name} snuggles closer to you!" ,
23+ ]
24+
1525
1626class CenterMap (PlayMap ):
1727 """Contains all relevant objects for centermap
@@ -87,6 +97,22 @@ def __init__(self, _he, _wi):
8797class CenterInteract (se .Object , MapInteract ):
8898 """Triggers a conversation in the Pokete center"""
8999
100+ def __init__ (self , * args , ** kwargs ):
101+ super ().__init__ (* args , ** kwargs )
102+ self .menu = MultiTextChooseBox (
103+ [
104+ "See your full deck" ,
105+ "Heal all your Poketes" ,
106+ "Cuddle with the Poketes" ,
107+ "Quit" ,
108+ ],
109+ "Select" ,
110+ )
111+
112+ def __normalize_pokes (self , ob ):
113+ while "__fallback__" in [p .identifier for p in ob .pokes ]:
114+ ob .pokes .pop ([p .identifier for p in ob .pokes ].index ("__fallback__" ))
115+
90116 def action (self , ob ):
91117 """Triggers the interaction in the Pokete center
92118 ARGS:
@@ -100,21 +126,15 @@ def action(self, ob):
100126 [
101127 "Welcome to the Pokete-Center" ,
102128 "What do you want to do?" ,
103- "1: See your full deck\n 2: Heal all your Poketes\n 3: Cuddle with the Poketes" ,
104129 ],
105- passthrough = True ,
106130 )
107- while True :
108- action , _ = get_action ()
109- if action .triggers (Action .ACT_1 ):
110- while "__fallback__" in [p .identifier for p in ob .pokes ]:
111- ob .pokes .pop (
112- [p .identifier for p in ob .pokes ].index ("__fallback__" )
113- )
131+
132+ match self .menu (self .ctx )[0 ]:
133+ case 0 :
134+ self .__normalize_pokes (ob )
114135 ob .balls_label_rechar ()
115136 deck .deck (self .ctx , len (ob .pokes ))
116- break
117- elif action .triggers (Action .ACT_2 ):
137+ case 1 :
118138 ob .heal ()
119139 time .sleep (SPEED_OF_TIME * 0.5 )
120140 mvp .movemap .text (
@@ -123,10 +143,33 @@ def action(self, ob):
123143 3 ,
124144 ["..." , "Your Poketes are now healed!" ],
125145 )
126- break
127- elif action .triggers (Action .CANCEL , Action .ACT_3 ):
128- break
129- loops .std (self .ctx )
146+ case 2 :
147+ self .__normalize_pokes (ob )
148+ if ob .pokes :
149+ selected_idx = deck .deck (
150+ self .ctx ,
151+ len (ob .pokes ),
152+ label = "Choose a Pokete to cuddle" ,
153+ in_fight = True ,
154+ )
155+ if selected_idx is not None :
156+ poke = ob .pokes [selected_idx ]
157+ message = random .choice (CUDDLE_MESSAGES ).format (
158+ name = poke .name
159+ )
160+ mvp .movemap .text (
161+ self .ctx ,
162+ mvp .movemap .bmap .inner .x - mvp .movemap .x + 8 ,
163+ 3 ,
164+ ["..." , message ],
165+ )
166+ else :
167+ mvp .movemap .text (
168+ self .ctx ,
169+ mvp .movemap .bmap .inner .x - mvp .movemap .x + 8 ,
170+ 3 ,
171+ ["You don't have any Poketes to cuddle with!" ],
172+ )
130173 mvp .movemap .full_show (init = True )
131174
132175
0 commit comments