def test_attacking_options(self): for i in range(100): self.deck = Deck(36) self.player = Player('Aleksei') self.player.draw_cards(self.deck) self.player.remove_card(self.player.cards[0]) self.assertEqual(len(self.player.attacking_options()), 5)
def test_remove_card_ability(self): for i in range(100): self.deck = Deck(36) self.player = Player('Aleksei') self.player.draw_cards(self.deck) self.player.remove_card(self.player.cards[0]) self.assertEqual(len(self.player.cards), 5)
def test_defending_options(self): for i in range(100): self.deck = Deck(36) self.player = Player('Aleksei') self.player.draw_cards(self.deck) self.table = Table() for i in self.player.cards: self.table.update_table(i) self.assertIsNotNone(self.player.defending_options(self.table))
def test_grab_table(self): for i in range(100): self.deck = Deck(36) self.player = Player('Aleksei') self.player.draw_cards(self.deck) self.table = Table() for i in self.player.cards: self.table.update_table(i) self.player.grab_table(self.table) self.assertEqual(len(self.player.cards), 12)
def test_attack_defend_addcard(self): for i in range(100): self.deck = Deck(36) self.player1 = AIPlayerDumb('Aleksei') self.player2 = AIPlayerDumb('Loh') self.player1.draw_cards(self.deck) self.player2.draw_cards(self.deck) self.table = Table() self.player1.attack(self.table) self.assertEqual(len(self.table.show()), 1) self.player2.defend(self.table) self.assertIn(len(self.table.show()), [0, 1, 2]) if len(self.table.show()) == 2: self.player1.adding_card(self.table) self.assertIn(len(self.table.show()), [2, 3])
import time import os from player import AIPlayerDumb from game_mechanics import GameProcess from game_mechanics import Deck if os.path.isfile('game.log'): os.remove('game.log') logger = logging.getLogger('logging_games') logger.setLevel(logging.INFO) fh = logging.FileHandler('game.log') P1 = AIPlayerDumb('VALL E') P2 = AIPlayerDumb('EVA') players_list = [P1, P2] i = 0 t = time.time() logger.addHandler(fh) logger.info({'Game': 0}) deck = Deck(36) while i != 200: GameProcess(players_list, deck, logger) print(P1.cards) print(P2.cards) i += 1 logger.info({"Game": i}) print(i) print(time.time() - t)
def test_draw_card_ability(self): for i in range(100): self.deck = Deck(52) self.player = Player('Aleksei') self.player.draw_cards(self.deck) self.assertEqual(len(self.player.cards), 6)