Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
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).
- Loading branch information
Showing
with
10 additions
and
5 deletions.
-
+2
−1
fireplace/actions.py
-
+8
−4
fireplace/card.py
|
@@ -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 |
|
|
|
|
@@ -245,6 +245,7 @@ def do(self, source, player, card, target): |
|
|
card = card.parent_card |
|
|
|
|
|
card.target = target |
|
|
card._summon_index = index |
|
|
source_card.target = target |
|
|
player.game.no_aura_refresh = True |
|
|
player.game._play(card) |
|
|
|
@@ -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 keeper.play(choose=id) |
|
|
# 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)) |
|
@@ -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)) |
|
|
self.game.queue_actions(self.controller, [Play(self, target)]) |
|
|
self.game.queue_actions(self.controller, [Play(self, target, index)]) |
|
|
return self |
|
|
|
|
|
def shuffle_into_deck(self): |
|
@@ -547,6 +547,7 @@ def __init__(self, data): |
|
|
self.enrage = False |
|
|
self.poisonous = False |
|
|
self.silenced = False |
|
|
self._summon_index = None |
|
|
super().__init__(data) |
|
|
|
|
|
@property |
|
@@ -603,7 +604,10 @@ def update_scripts(self): |
|
|
|
|
|
def _set_zone(self, value): |
|
|
if value == Zone.PLAY: |
|
|
self.controller.field.append(self) |
|
|
if self._summon_index is not None: |
|
|
self.controller.field.insert(self._summon_index, self) |
|
|
else: |
|
|
self.controller.field.append(self) |
|
|
|
|
|
if self.zone == Zone.PLAY: |
|
|
self.log("%r is removed from the field", self) |
|
|
This comment has been minimized.
A
card.get_index()
helper would probably be helpful. I guess it's something likeplayer.field.index(card)
.This comment has been minimized.
I might add a
zone_position
attribute to be consistent with Hearthstone. Right now that logic is in kettle.