Skip to content

Commit 022c10b

Browse files
committed
fix: Reordering in Cuddle
1 parent 6c6922f commit 022c10b

2 files changed

Lines changed: 10 additions & 15 deletions

File tree

src/pokete/classes/fight/providers.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ def heal(self):
4646
if poke.player:
4747
self.balls_label_rechar()
4848

49-
@property
50-
def valid_pokes(self) -> list[Poke]:
51-
"""Returns all non-fallback Poketes"""
52-
return [p for p in self.pokes if p.identifier != "__fallback__"]
53-
5449
@property
5550
def curr(self) -> Poke:
5651
"""Returns the currently used Pokete"""

src/pokete/classes/map_additions/center.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ def __init__(self, *args, **kwargs):
109109
"Select",
110110
)
111111

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+
112116
def action(self, ob):
113117
"""Triggers the interaction in the Pokete center
114118
ARGS:
@@ -124,14 +128,10 @@ def action(self, ob):
124128
"What do you want to do?",
125129
],
126130
)
127-
selected = self.menu(self.ctx)[0]
128131

129-
match selected:
132+
match self.menu(self.ctx)[0]:
130133
case 0:
131-
while "__fallback__" in [p.identifier for p in ob.pokes]:
132-
ob.pokes.pop(
133-
[p.identifier for p in ob.pokes].index("__fallback__")
134-
)
134+
self.__normalize_pokes(ob)
135135
ob.balls_label_rechar()
136136
deck.deck(self.ctx, len(ob.pokes))
137137
case 1:
@@ -144,16 +144,16 @@ def action(self, ob):
144144
["...", "Your Poketes are now healed!"],
145145
)
146146
case 2:
147-
valid_pokes = ob.valid_pokes
148-
if valid_pokes:
147+
self.__normalize_pokes(ob)
148+
if ob.pokes:
149149
selected_idx = deck.deck(
150150
self.ctx,
151-
len(valid_pokes),
151+
len(ob.pokes),
152152
label="Choose a Pokete to cuddle",
153153
in_fight=True,
154154
)
155155
if selected_idx is not None:
156-
poke = valid_pokes[selected_idx]
156+
poke = ob.pokes[selected_idx]
157157
message = random.choice(CUDDLE_MESSAGES).format(
158158
name=poke.name
159159
)

0 commit comments

Comments
 (0)