示例#1
0
 def _play_scout(self, state: GameState,
                 card: TacticGuileCard) -> Optional[GameState]:
     assert card.get_tactics() == TacticGuiles.SCOUT
     print("choose draw pattern?")
     print("[1] -- draw 3 cards from troops deck")
     print(
         "[2] -- draw 2 cards from troops deck and draw 1 card from tactics deck"
     )
     print(
         "[3] -- draw 1 card from troops deck and draw 2 cards from tactics deck"
     )
     print("[4] -- draw 3 cards from tactics deck")
     print("[0] -- return to select a card")
     user_in = await_user_num(range(5))
     if user_in == 0:
         return None
     # copy to new state
     state = state.clone()
     draw_tactics_num = user_in - 1
     peek_cards: List[Card] = []
     peek_cards.extend(state.get_tactics_deck().peek(draw_tactics_num))
     peek_cards.extend(state.get_troops_deck().peek(3 - draw_tactics_num))
     print("scouted cards: ")
     copy_hands = self.get_hands(state).copy()
     # remove the used card
     copy_hands.remove(card)
     for i, c in enumerate(peek_cards):
         print(f"[{i}]: {repr(c)}")
         copy_hands.append(c)
     # sort my hands
     copy_hands.sort()
     # add to hand
     print("choose 2 cards return to decks:")
     for i, c in enumerate(copy_hands):
         print(f"[{i + 1}]: {repr(c)}")
     input_cand = list(range(1, len(copy_hands) + 1))
     in_1 = await_user_num(input_cand)
     ret_card_1 = copy_hands[in_1 - 1]
     input_cand.remove(in_1)
     in_2 = await_user_num(input_cand)
     ret_card_2 = copy_hands[in_2 - 1]
     return self._play_tactic_guile_scout(
         state,
         card,
         (draw_tactics_num, 3 - draw_tactics_num),
         (ret_card_1, ret_card_2),
     )
示例#2
0
 def _draw_deck(self, state: GameState) -> Optional[Card]:
     troops_deck = state.get_troops_deck()
     tactics_deck = state.get_tactics_deck()
     draw_troops = troops_deck.is_remain()
     draw_tactics = tactics_deck.is_remain()
     if draw_troops and draw_tactics:
         print("draw card from?")
         print(f"[0] -- troops deck, remains {len(troops_deck)} cards")
         print(f"[1] -- tactics deck, remains {len(tactics_deck)} cards")
         if await_user_num([0, 1]) == 0:
             draw_tactics = False
         else:
             draw_troops = False
     if draw_troops:
         return troops_deck.draw()
     if draw_tactics:
         return tactics_deck.draw()
     # both decks are empty
     return None