def test_scenario_2(): """ Same as scenario 1 but doubling the highest count """ generate_cards() t1 = Table() t1.plt1.place_card(_all_cards[4]) t1.plt1.place_card(_all_cards[8]) t1.plt1.place_card(_all_cards[13]) t1.plt1.place_card(_all_cards[10]) t1.plt1.place_card(_all_cards[0]) t1.plt1.place_card(_all_cards[16]) print(t1.plt1) assert t1.plt1.max_point_win == 0 assert t1.plt1.vp == 0 assert t1.plt1.win_ties is False t1.plt1.eval_non_vps() assert t1.plt1.win_ties is True t1.plt1.eval_vps() t1.plt1.eval_highest() assert t1.plt1.vp == (9 + 13 + 5 + 3) * 2 assert t1.plt1.max_point_win == 26 t1.plt1.remove_cards() assert t1.plt1.win_ties is False assert t1.plt1.max_point_win == 0
def test_scenario_3(): """ Win majority check: Normal winning """ generate_cards() t1 = Table() t1.plt1.place_card(_all_cards[1]) t1.plt1.place_card(_all_cards[10]) t1.plt2.place_card(_all_cards[3]) print(t1.plt1) print(t1.plt2) assert t1.plt1.max_point_win == 0 assert t1.plt1.vp == 0 assert t1.plt1.win_ties is False t1.plt1.eval_non_vps() t1.plt2.eval_non_vps() assert t1.plt1.win_ties is False t1.plt1.eval_vps() t1.plt2.eval_vps() t1.plt1.eval_highest() t1.plt2.eval_highest() assert t1.plt1.vp == 7 + 3 assert t1.plt1.max_point_win == 7 t1.plt1.remove_cards() assert t1.plt1.win_ties is False assert t1.plt1.max_point_win == 0
def test_scenario_8(): """ Win Highest with tie """ generate_cards() t1 = Table() t1.plt1.place_card(_all_cards[1]) t1.plt1.place_card(_all_cards[0]) t1.plt1.place_card(_all_cards[11]) t1.plt1.place_card(_all_cards[17]) t1.plt2.place_card(_all_cards[12]) t1.plt2.place_card(_all_cards[3]) print(t1.plt1) print(t1.plt2) assert t1.plt1.max_point_win == 0 assert t1.plt1.vp == 0 assert t1.plt1.win_ties is False t1.plt1.eval_non_vps() t1.plt2.eval_non_vps() assert t1.plt1.win_ties is True t1.plt1.eval_vps() t1.plt2.eval_vps() t1.plt1.eval_highest() t1.plt2.eval_highest() assert t1.plt1.vp == 7 + 8 assert t1.plt1.max_point_win == 7 t1.plt1.remove_cards() assert t1.plt1.win_ties is False assert t1.plt1.max_point_win == 0
def test_scenario_1(): """ Check win for each set cards, and win tie setting. Card removal resets win ties and max point win. """ generate_cards() t1 = Table() t1.plt1.place_card(_all_cards[4]) t1.plt1.place_card(_all_cards[8]) t1.plt1.place_card(_all_cards[13]) t1.plt1.place_card(_all_cards[10]) t1.plt1.place_card(_all_cards[0]) print(t1.plt1) assert t1.plt1.max_point_win == 0 assert t1.plt1.vp == 0 assert t1.plt1.win_ties is False t1.plt1.eval_non_vps() assert t1.plt1.win_ties is True t1.plt1.eval_vps() t1.plt1.eval_highest() assert t1.plt1.vp == 9 + 13 + 5 + 3 assert t1.plt1.max_point_win == 13 t1.plt1.remove_cards() assert t1.plt1.win_ties is False assert t1.plt1.max_point_win == 0
def test_scenario_7_1(): """ Win More Single suit normally """ generate_cards() t1 = Table() t1.plt1.place_card(_all_cards[1]) t1.plt1.place_card(_all_cards[0]) t1.plt1.place_card(_all_cards[11]) t1.plt1.place_card(_all_cards[15]) t1.plt2.place_card(_all_cards[10]) print(t1.plt1) print(t1.plt2) assert t1.plt1.max_point_win == 0 assert t1.plt1.vp == 0 assert t1.plt1.win_ties is False t1.plt1.eval_non_vps() t1.plt2.eval_non_vps() assert t1.plt1.win_ties is True t1.plt1.eval_vps() t1.plt2.eval_vps() t1.plt1.eval_highest() t1.plt2.eval_highest() assert t1.plt1.vp == 7 + 8 assert t1.plt1.max_point_win == 8 t1.plt1.remove_cards() assert t1.plt1.win_ties is False assert t1.plt1.max_point_win == 0
def test_all_cards(): generate_cards() assert len(_all_cards) == 18 assert _all_cards[3].suit == Suit.Library and _all_cards[3].cid == 4 tmp_suit = ['Palace', 'Library', 'Garden', 'Stronghold', 'Temple', 'NonSuit'] for i, crd in enumerate(_all_cards): assert crd.cid == i+1 assert crd.suit == Suit[tmp_suit[i//3]]
def test_scenario_0(): """ Check win for each single cards. """ generate_cards() t1 = Table() t1.plt1.place_card(_all_cards[2]) t1.plt1.place_card(_all_cards[5]) t1.plt1.place_card(_all_cards[7]) t1.plt1.place_card(_all_cards[10]) t1.plt1.place_card(_all_cards[14]) print(t1.plt1) assert t1.plt1.max_point_win == 0 assert t1.plt1.vp == 0 t1.plt1.eval_vps() t1.plt1.eval_highest() assert t1.plt1.vp == 5 * 3 assert t1.plt1.max_point_win == 3
def rand_game(): del_cards() generate_cards() print_all_cards() print("\n") t1 = Table() d = Deck() d.shuffle() # print("Size of Deck: {}".format(len(d.deck))) plt1 = t1.plt1 plt2 = t1.plt2 h1 = Hand() h2 = Hand() for i in range(5): h1.pull_card(d.pop()) h2.pull_card(d.pop()) for i in range(5): # print("\n-------------------------------------") # print("{}'th round:".format(i)) # print("Hand1: ") # print(h1) # print("Hand2: ") # print(h2) plt1.place_card(h1.place_rand()) plt2.place_card(h2.place_rand()) # print(plt1) # print(plt2) h1, h2 = h2, h1 print("First turn:") # print(t1) t1.evaluate_table() plt1.discard_card(plt1.choose_random()) plt2.discard_card(plt2.choose_random()) plt1.freeze_card(plt1.choose_random()) plt2.freeze_card(plt2.choose_random()) # print("After freezing and discarding") # print(t1) # print("After collecting the cards from the table") h1.cards = plt1.remove_cards() h2.cards = plt2.remove_cards() # print(plt1) # print(plt2) # print("Hand1: ") # print(h1) # print("Hand2: ") # print(h2) for i in range(2): h1.pull_card(d.pop()) h2.pull_card(d.pop()) for i in range(5): # print("\n-------------------------------------") # print("{}'th round:".format(i)) # print("Hand1: ") # print(h1) # print("Hand2: ") # print(h2) plt1.place_card(h1.place_rand()) plt2.place_card(h2.place_rand()) # print(plt1) # print(plt2) h1, h2 = h2, h1 print("Second turn:") # print(t1) t1.evaluate_table() cid = plt1.choose_random() while plt1.cards[cid].frozen is True: cid = plt1.choose_random() plt1.discard_card(cid) cid = plt2.choose_random() while plt2.cards[cid].frozen is True: cid = plt2.choose_random() plt2.discard_card(cid) plt1.freeze_card(plt1.choose_random()) plt2.freeze_card(plt2.choose_random()) # print("After freezing and discarding") # print(plt1) # print(plt2) # print("After collecting the cards from the table") h1.cards = plt1.remove_cards() h2.cards = plt2.remove_cards() # print(plt1) # print(plt2) # print("Hand1: ") # print(h1) # print("Hand2: ") # print(h2) for i in range(2): h1.pull_card(d.pop()) h2.pull_card(d.pop()) for i in range(5): # print("\n-------------------------------------") # print("{}'th round:".format(i)) # print("Hand1: ") # print(h1) # print("Hand2: ") # print(h2) plt1.place_card(h1.place_rand()) plt2.place_card(h2.place_rand()) # print(plt1) # print(plt2) h1, h2 = h2, h1 print("Third turn:") # print(t1) t1.evaluate_table() if len(d.deck) == 0: # print("test pass") return True return False
def simple_game(): generate_cards() t1 = Table() d = Deck() # print("Size of Deck: {}".format(len(d.deck))) plt1 = t1.plt1 plt2 = t1.plt2 h1 = Hand() h2 = Hand() # Pull card from deck iteratively for i in range(5): h1.pull_card(d.pop()) h2.pull_card(d.pop()) for i in range(5): # print("\n-------------------------------------") # print("{}'th round:".format(i)) # print("Hand1: ") # print(h1) # print("Hand2: ") # print(h2) # Choose a card an place it to the table simultaneously plt1.place_card(h1.place_smallest()) plt2.place_card(h2.place_smallest()) # print(plt1) # print(plt2) # swap hands h1, h2 = h2, h1 print("First turn:") # print(t1) t1.evaluate_table() # choose a card to discard plt1.discard_card(plt1.choose_largest()) plt2.discard_card(plt2.choose_largest()) # choose a card to freeze plt1.freeze_card(plt1.choose_smallest()) plt2.freeze_card(plt2.choose_smallest()) # print("After freezing and discarding") # print(plt1) # print(plt2) # print("After collecting the cards from the table") # Pick up the remaining unfrozen cards h1.cards = plt1.remove_cards() h2.cards = plt2.remove_cards() # print(plt1) # print(plt2) # print("Hand1: ") # print(h1) # print("Hand2: ") # print(h2) # pull 2 cards iteratively, to fill up to 5 cards in hand for i in range(2): h1.pull_card(d.pop()) h2.pull_card(d.pop()) # place 5 cards for i in range(5): # print("\n-------------------------------------") # print("{}'th round:".format(i)) # print("Hand1: ") # print(h1) # print("Hand2: ") # print(h2) plt1.place_card(h1.place_smallest()) plt2.place_card(h2.place_smallest()) # print(plt1) # print(plt2) h1, h2 = h2, h1 print("Second turn:") # print(t1) t1.evaluate_table() # choose a card to discard plt1.discard_card(plt1.choose_largest()) plt2.discard_card(plt2.choose_largest()) # choose a card to freeze plt1.freeze_card(nsmallest(2, list(plt1.cards.keys()))[-1]) plt2.freeze_card(nsmallest(2, list(plt2.cards.keys()))[-1]) # print("After freezing and discarding") # print(plt1) # print(plt2) # print("After collecting the cards from the table") # pick up the remaining unfrozen cards h1.cards = plt1.remove_cards() h2.cards = plt2.remove_cards() # print(plt1) # print(plt2) # print("Hand1: ") # print(h1) # print("Hand2: ") # print(h2) # draw 2 cards to top up to 5 for i in range(2): h1.pull_card(d.pop()) h2.pull_card(d.pop()) # place 5 cards iteratively and swap hands between them for i in range(5): # print("\n-------------------------------------") # print("{}'th round:".format(i)) # print("Hand1: ") # print(h1) # print("Hand2: ") # print(h2) plt1.place_card(h1.place_smallest()) plt2.place_card(h2.place_smallest()) # print(plt1) # print(plt2) h1, h2 = h2, h1 print("Third turn:") # print(t1) t1.evaluate_table() if len(d.deck) == 0: print("test pass") return True return False