Beispiel #1
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "duel"):
         yield no_such_card(state.current_player)
     target_player = state.find_player(self.target)
     next_player: Player = target_player
     while True:
         answer = yield PlayBang(next_player)
         if isinstance(answer, SkipCommand):
             next_player.health = next_player.health - 1
             yield DamageReceivedAndEndTurn(next_player, 1)
         if isinstance(answer, BangCommand):
             if not safe_remove_card(next_player, "bang"):
                 continue
             next_player = state.current_player if next_player == target_player else target_player
Beispiel #2
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()
Beispiel #3
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()
Beispiel #4
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()
Beispiel #5
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()
Beispiel #6
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()
Beispiel #7
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()
Beispiel #8
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()
Beispiel #9
0
 def execute(self, state):
     if not safe_remove_card(state.current_player, "dodge"):
         yield no_such_card(state.current_player)
     yield NoEffect()
Beispiel #10
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()