Esempio n. 1
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "panic"):
         yield no_such_card(state.current_player)
     target = state.find_player(self.target)
     stolen_card = target.get_and_remove_card_on_index(self.card_index - 1)
     state.current_player.add_cards([stolen_card])
     yield NoEffect()
Esempio n. 2
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "kate"):
         yield no_such_card(state.current_player)
     target_player = state.find_player(self.target)
     while True:
         answer = yield DropCards(target_player)
         if isinstance(answer, DropCardsCommand):
             if len(answer.cards_to_remove) != 1:
                 continue
             target_player.drop_cards(answer.cards_to_remove)
             yield NoEffect()
Esempio n. 3
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "indians"):
         yield no_such_card(state.current_player)
     for target in (p for p in state.players if p != state.current_player):
         while True:
             answer = yield PlayBang(target)
             if isinstance(answer, SkipCommand):
                 target.health = target.health - 1
                 yield DamageReceived(target, 1)
                 break
             elif isinstance(answer, BangCommand):
                 if not safe_remove_card(state.current_player, "bang"):
                     continue
                 break
     yield NoEffect()
Esempio n. 4
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "shop"):
         yield no_such_card(state.current_player)
     current_player_index = state.players.index(state.current_player)
     ordered_players = state.players[
         current_player_index:] + state.players[:current_player_index]
     cards_in_shop = state.pop_cards(len(state.players))
     for target in ordered_players:
         while True:
             answer = yield PickCard(target, cards_in_shop)
             if isinstance(answer, PickCardCommand):
                 if answer.index_to_pick > len(cards_in_shop):
                     continue
                 target.add_cards([cards_in_shop[answer.index_to_pick - 1]])
                 cards_in_shop.pop(answer.index_to_pick - 1)
                 break
     yield NoEffect()
Esempio n. 5
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "gatling"):
         yield no_such_card(state.current_player)
     for target in (p for p in state.players if p != state.current_player):
         while True:
             answer = yield PlayBeerOrDodge(target)
             if isinstance(answer, SkipCommand):
                 target.health = target.health - 1
                 yield DamageReceived(target, 1)
                 break
             elif isinstance(answer, DodgeCommand):
                 if not safe_remove_card(state.current_player, "dodge"):
                     continue
                 break
             elif isinstance(answer, BeerCommand) and target.health == 1:
                 if not safe_remove_card(state.current_player, "beer"):
                     continue
                 break
     yield NoEffect()
Esempio n. 6
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "stagecoach"):
         yield no_such_card(state.current_player)
     state.give_cards_to(state.current_player, 2)
     yield NoEffect()
Esempio n. 7
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "beer"):
         yield no_such_card(state.current_player)
     state.current_player.heal_for(1)
     yield NoEffect()
Esempio n. 8
0
 def execute(self, state):
     yield NoEffect()
Esempio n. 9
0
 def execute(self, state):
     state.current_player.drop_cards(self.cards_to_remove)
     yield NoEffect()
Esempio n. 10
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "dodge"):
         yield no_such_card(state.current_player)
     yield NoEffect()
Esempio n. 11
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "wells_fargo"):
         yield no_such_card(state.current_player)
     state.give_cards_to(state.current_player, 3)
     yield NoEffect()