Skip to content

Commit c5fa2eb

Browse files
committed
Implement playing minions in a specific position
Card.play() now has a new, optional `index` argument. If not provided, the minion will be appended to the end of the field (on the right).
1 parent b8942c6 commit c5fa2eb

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

fireplace/actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def _broadcast(self, entity, source, at, *args):
235235
def get_args(self, source):
236236
return (source, ) + super().get_args(source)
237237

238-
def do(self, source, player, card, target):
238+
def do(self, source, player, card, target, index):
239239
source_card = card
240240
play_action = card.action
241241

@@ -245,6 +245,7 @@ def do(self, source, player, card, target):
245245
card = card.parent_card
246246

247247
card.target = target
248+
card._summon_index = index
248249
source_card.target = target
249250
player.game.no_aura_refresh = True
250251
player.game._play(card)

fireplace/card.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,14 @@ def is_playable(self):
297297
return False
298298
return True
299299

300-
def play(self, target=None, choose=None):
300+
def play(self, target=None, index=None, choose=None):
301301
"""
302302
Queue a Play action on the card.
303303
"""
304304
if choose:
305305
# This is a helper so we can do keeper.play(choose=id)
306306
# instead of having to mess with keeper.choose_cards.filter(...)
307-
return self.choose_cards.filter(id=choose)[0].play(target=target)
307+
return self.choose_cards.filter(id=choose)[0].play(target=target, index=index)
308308
if self.has_target():
309309
if not target:
310310
raise InvalidAction("%r requires a target to play." % (self))
@@ -314,7 +314,7 @@ def play(self, target=None, choose=None):
314314
raise InvalidAction("Do not play %r! Play one of its Choose Cards instead" % (self))
315315
if not self.is_playable():
316316
raise InvalidAction("%r isn't playable." % (self))
317-
self.game.queue_actions(self.controller, [Play(self, target)])
317+
self.game.queue_actions(self.controller, [Play(self, target, index)])
318318
return self
319319

320320
def shuffle_into_deck(self):
@@ -547,6 +547,7 @@ def __init__(self, data):
547547
self.enrage = False
548548
self.poisonous = False
549549
self.silenced = False
550+
self._summon_index = None
550551
super().__init__(data)
551552

552553
@property
@@ -603,7 +604,10 @@ def update_scripts(self):
603604

604605
def _set_zone(self, value):
605606
if value == Zone.PLAY:
606-
self.controller.field.append(self)
607+
if self._summon_index is not None:
608+
self.controller.field.insert(self._summon_index, self)
609+
else:
610+
self.controller.field.append(self)
607611

608612
if self.zone == Zone.PLAY:
609613
self.log("%r is removed from the field", self)

0 commit comments

Comments
 (0)