Skip to content


Browse files Browse the repository at this point in the history
Implement playing minions in a specific position now has a new, optional `index` argument. If not provided,
the minion will be appended to the end of the field (on the right).
  • Loading branch information
jleclanche committed Oct 7, 2015
1 parent b8942c6 commit c5fa2eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion fireplace/
Expand Up @@ -235,7 +235,7 @@ def _broadcast(self, entity, source, at, *args):
def get_args(self, source):
return (source, ) + super().get_args(source)

def do(self, source, player, card, target):
def do(self, source, player, card, target, index):
source_card = card
play_action = card.action

Expand All @@ -245,6 +245,7 @@ def do(self, source, player, card, target):
card = card.parent_card = target
card._summon_index = index = target = True
Expand Down
12 changes: 8 additions & 4 deletions fireplace/
Expand Up @@ -297,14 +297,14 @@ def is_playable(self):
return False
return True

def play(self, target=None, choose=None):
def play(self, target=None, index=None, choose=None):
Queue a Play action on the card.
if choose:
# This is a helper so we can do
# instead of having to mess with keeper.choose_cards.filter(...)
return self.choose_cards.filter(id=choose)[0].play(target=target)
return self.choose_cards.filter(id=choose)[0].play(target=target, index=index)
if self.has_target():
if not target:
raise InvalidAction("%r requires a target to play." % (self))
Expand All @@ -314,7 +314,7 @@ def play(self, target=None, choose=None):
raise InvalidAction("Do not play %r! Play one of its Choose Cards instead" % (self))
if not self.is_playable():
raise InvalidAction("%r isn't playable." % (self)), [Play(self, target)]), [Play(self, target, index)])
return self

def shuffle_into_deck(self):
Expand Down Expand Up @@ -547,6 +547,7 @@ def __init__(self, data):
self.enrage = False
self.poisonous = False
self.silenced = False
self._summon_index = None

Expand Down Expand Up @@ -603,7 +604,10 @@ def update_scripts(self):

def _set_zone(self, value):
if value == Zone.PLAY:
if self._summon_index is not None:
self.controller.field.insert(self._summon_index, self)

if == Zone.PLAY:
self.log("%r is removed from the field", self)
Expand Down

2 comments on commit c5fa2eb

Copy link

@beheh beheh commented on c5fa2eb Oct 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A card.get_index() helper would probably be helpful. I guess it's something like player.field.index(card).

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might add a zone_position attribute to be consistent with Hearthstone. Right now that logic is in kettle.

Please sign in to comment.