Beispiel #1
0
class TestKnight(unittest.TestCase):
    def setUp(self):
        self.game = Game()
        self.arthur = Knight(CoatOfArms.ARTHUR)
        self.tristan = Knight(CoatOfArms.TRISTAN)
        self.galahad = Knight(CoatOfArms.GALAHAD)
        self.game.add_knight(self.arthur)
        self.game.add_knight(self.tristan)
        self.game.add_knight(self.galahad)

    def test_lose_life_point(self):
        self.arthur.lose_life_point()
        self.assertTrue(self.arthur.alive())
        self.arthur.lose_life_point()
        self.assertTrue(self.arthur.alive())
        self.arthur.lose_life_point()
        self.assertTrue(self.arthur.alive())
        self.arthur.lose_life_point()
        self.assertFalse(self.arthur.alive())
        self.assertEqual(self.arthur._current_life, 0)
        self.arthur.lose_life_point()
        self.assertEqual(self.arthur._current_life, 0)

    def test_gain_life_point(self):
        self.arthur.gain_life_point()
        self.assertTrue(self.arthur.alive())
        self.arthur.gain_life_point()
        self.assertTrue(self.arthur.alive())
        self.arthur.gain_life_point()
        self.assertTrue(self.arthur.alive())
        self.arthur.gain_life_point()
        self.assertTrue(self.arthur.alive())
        self.assertEqual(self.arthur._current_life, 6)
Beispiel #2
0
class TestPictQuest(unittest.TestCase):
    def setUp(self):
        self.game = Game()
        self.quest = self.game._pict_quest
        self.arthur = Knight(CoatOfArms.ARTHUR)
        self.game.add_knight(self.arthur)
        self.game.add_knight_to_pict(self.arthur)

    def test_lose(self):
        self.quest.lose()
        self.assertTrue(self.quest.active)

    def test_win(self):
        self.quest.win()
        self.assertTrue(self.quest.active)
        self.assertEqual(self.game._num_siege_engines, 0)
        self.assertEqual(self.game._num_white_swords, 1)

    def test_can_add_knight(self):
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertFalse(self.quest.can_add_knight())

    def test_add_knight(self):
        self.assertEqual(len(self.quest._present_knights), 1)

    def test_quest_lost(self):
        self.quest.add_pict()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_pict()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_pict()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_pict()
        self.assertTrue(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.assertTrue(self.quest.active)
        self.assertEqual(self.game._num_black_swords, 1)
        self.assertEqual(self.game._num_siege_engines, 2)
        self.assertEqual(self.arthur._current_life, 3)

    def test_reset(self):
        self.quest.reset()
        self.assertTrue(self.quest.active)
Beispiel #3
0
class TestBlackKnightQuest(unittest.TestCase):
    def setUp(self):
        self.game = Game()
        self.quest = self.game._black_knight_quest
        self.arthur = Knight(CoatOfArms.ARTHUR)
        self.game.add_knight(self.arthur)
        self.game.add_knight_to_black_knight(self.arthur)

    def test_can_add_pair_a(self):
        self.assertTrue(self.quest._can_add_pair_a(1))
        self.assertTrue(self.quest._can_add_pair_a(2))
        self.assertTrue(self.quest._can_add_pair_a(3))
        self.assertTrue(self.quest._can_add_pair_a(4))
        self.assertTrue(self.quest._can_add_pair_a(5))
class TestProgressEvil(unittest.TestCase):
    def setUp(self):
        self.game = Game()
        self.arthur = Knight(CoatOfArms.ARTHUR)
        self.tristan = Knight(CoatOfArms.TRISTAN)
        self.galahad = Knight(CoatOfArms.GALAHAD)
        self.game.add_knight(self.arthur)
        self.game.add_knight(self.tristan)
        self.game.add_knight(self.galahad)
        self.knight = self.game.get_current_player()

    def test_lose_life_point(self):
        self.assertIsNone(
            self.game.progress_evil(ProgressEvilChoice.TAKE_LIFE_POINT))
        self.assertEqual(self.arthur._current_life, 3)
        self.assertIsNone(
            self.game.progress_evil(ProgressEvilChoice.TAKE_LIFE_POINT))
        self.assertEqual(self.arthur._current_life, 2)
        self.assertIsNone(
            self.game.progress_evil(ProgressEvilChoice.TAKE_LIFE_POINT))
        self.assertEqual(self.arthur._current_life, 1)
        self.assertIsNone(
            self.game.progress_evil(ProgressEvilChoice.TAKE_LIFE_POINT))
        self.assertEqual(self.arthur._current_life, 0)
        self.assertFalse(self.game.get_current_player().alive())

    def test_siege_engine(self):
        self.assertIsNone(
            self.game.progress_evil(ProgressEvilChoice.ADD_SIEGE_ENGINE))
        self.assertEqual(self.game._num_siege_engines, 1)
        self.assertIsNone(
            self.game.progress_evil(ProgressEvilChoice.ADD_SIEGE_ENGINE))
        self.assertEqual(self.game._num_siege_engines, 2)
        self.assertIsNone(
            self.game.progress_evil(ProgressEvilChoice.ADD_SIEGE_ENGINE))
        self.assertEqual(self.game._num_siege_engines, 3)

    def test_draw_card(self):
        self.assertIsNotNone(
            self.game.progress_evil(ProgressEvilChoice.DRAW_BLACK_CARD))
Beispiel #5
0
class TestGame(unittest.TestCase):
    def setUp(self):
        self.game = Game()
        self.arthur = Knight(CoatOfArms.ARTHUR)
        self.tristan = Knight(CoatOfArms.TRISTAN)
        self.galahad = Knight(CoatOfArms.GALAHAD)
        self.game.add_knight(self.arthur)
        self.game.add_knight(self.tristan)
        self.game.add_knight(self.galahad)

    def test_black_swords(self):
        for i in range(6):
            self.game.add_black_sword()
            self.assertFalse(self.game.game_lost())
        self.game.add_black_sword()
        self.assertTrue(self.game.game_lost())

    def test_white_swords(self):
        for i in range(11):
            self.game.add_white_sword()
            self.assertFalse(self.game.game_won())
            self.assertFalse(self.game.game_lost())
        self.game.add_white_sword()
        self.assertTrue(self.game.game_won())
        self.assertFalse(self.game.game_lost())

    def test_swords_equal_white(self):
        for i in range(6):
            self.game.add_white_sword()
        for i in range(6):
            self.game.add_black_sword()
        self.assertFalse(self.game.game_won())
        self.assertTrue(self.game.game_lost())

    def test_swords_equal_black(self):
        for i in range(6):
            self.game.add_black_sword()
        for i in range(6):
            self.game.add_white_sword()
        self.assertFalse(self.game.game_won())
        self.assertTrue(self.game.game_lost())

    def test_swords_won(self):
        for i in range(7):
            self.game.add_white_sword()
            self.assertFalse(self.game.game_lost())
            self.assertFalse(self.game.game_won())
        for i in range(6):
            self.game.add_black_sword()
            self.assertFalse(self.game.game_lost())
        self.assertTrue(self.game.game_won())
        self.assertFalse(self.game.game_lost())

    def test_swords_lost(self):
        for i in range(6):
            self.game.add_white_sword()
            self.assertFalse(self.game.game_lost())
            self.assertFalse(self.game.game_won())
        for i in range(7):
            self.game.add_black_sword()
        self.assertTrue(self.game.game_lost())
        self.assertFalse(self.game.game_won())

    def test_game_won_lost(self):
        for i in range(3):
            self.game.knight_lose_life_point(self.arthur)
            self.game.knight_lose_life_point(self.galahad)
            self.game.knight_lose_life_point(self.tristan)
            self.assertEqual(self.game.game_won(), self.game.game_lost())
        self.game.knight_lose_life_point(self.arthur)
        self.game.knight_lose_life_point(self.galahad)
        self.game.knight_lose_life_point(self.tristan)
        self.assertNotEqual(self.game.game_won(), self.game.game_lost())
        self.assertTrue(self.game.game_lost())

    def test_dead_knight(self):
        self.game.knight_lose_life_point(self.arthur)
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.knight_lose_life_point(self.arthur)
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.knight_lose_life_point(self.arthur)
        self.assertFalse(self.game.game_won())
        self.assertFalse(self.game.game_lost())
        self.game.knight_lose_life_point(self.arthur)
        self.game.knight_lose_life_point(self.tristan, 4)
        self.game.knight_lose_life_point(self.galahad, 4)
        self.assertFalse(self.game.game_won())
        self.assertTrue(self.game.game_lost())

    def test_dead_knights(self):
        self.game.knight_lose_life_point(self.arthur)
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.knight_lose_life_point(self.arthur)
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.knight_lose_life_point(self.arthur)
        self.assertFalse(self.game.game_won())
        self.assertFalse(self.game.game_lost())
        self.game.knight_lose_life_point(self.arthur)
        self.assertFalse(self.game.game_won())
        self.assertFalse(self.game.game_lost())
        self.game.knight_lose_life_point(self.tristan)
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.knight_lose_life_point(self.tristan)
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.knight_lose_life_point(self.tristan)
        self.assertFalse(self.game.game_won())
        self.assertFalse(self.game.game_lost())
        self.game.knight_lose_life_point(self.tristan)
        self.game.knight_lose_life_point(self.galahad, 4)
        self.assertFalse(self.game.game_won())
        self.assertTrue(self.game.game_lost())

    def test_num_seige_engines(self):
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertFalse(self.game.game_lost())
        self.assertFalse(self.game.game_won())
        self.game.add_siege_engine()
        self.assertTrue(self.game.game_lost())
        self.assertFalse(self.game.game_won())

    def test_turn_order(self):
        self.assertEqual(self.game.get_current_player(), self.arthur)
        self.game.set_next_player()
        self.assertEqual(self.game.get_current_player(), self.tristan)
        self.game.set_next_player()
        self.assertEqual(self.game.get_current_player(), self.galahad)
        self.game.set_next_player()
        self.assertEqual(self.game.get_current_player(), self.arthur)

    def test_turn_order_died(self):
        self.assertEqual(self.game.get_current_player(), self.arthur)
        self.game.set_next_player()
        self.assertEqual(self.game.get_current_player(), self.tristan)
        self.game.set_next_player()
        self.game.knight_lose_life_point(self.galahad)
        self.game.knight_lose_life_point(self.galahad)
        self.game.knight_lose_life_point(self.galahad)
        self.game.knight_lose_life_point(self.galahad)
        self.assertFalse(self.game.get_current_player().alive())
        self.assertFalse(self.galahad.alive())
        self.assertEqual(self.game.get_current_player(), self.galahad)
        self.game.set_next_player()
        self.assertEqual(self.game.get_current_player(), self.arthur)
        self.game.set_next_player()
        self.assertEqual(self.game.get_current_player(), self.tristan)
        self.game.set_next_player()
        self.assertEqual(self.game.get_current_player(), self.arthur)
Beispiel #6
0
class TestBlackCards(unittest.TestCase):
    def setUp(self):
        self.game = Game()
        self.cards = BlackCardsDeck(self.game)
        self.arthur = Knight(CoatOfArms.ARTHUR)
        self.tristan = Knight(CoatOfArms.TRISTAN)
        self.galahad = Knight(CoatOfArms.GALAHAD)
        self.game.add_knight(self.arthur)
        self.game.add_knight(self.tristan)
        self.game.add_knight(self.galahad)

    def test_vivien(self):
        card = self.cards.get_card_by_name("Vivien")
        self.game.play_black_card(card)
        self.assertFalse(self.game._merlins_allowed)
        self.game._pict_quest.win()
        self.assertTrue(self.game._merlins_allowed)

    def test_mists_of_avalon(self):
        card = self.cards.get_card_by_name("MistsOfAvalon")
        self.game.play_black_card(card)
        self.game._excalibur_quest.lose()
        self.assertEqual(self.game._num_black_swords, 3)

    def test_pict(self):
        card = self.cards.get_card_by_name("Pict")
        self.game.play_black_card(card)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.game.play_black_card(card)
        self.assertTrue(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.assertEqual(self.game._num_black_swords, 1)

    def test_saxon(self):
        card = self.cards.get_card_by_name("Saxon")
        self.game.play_black_card(card)
        self.assertFalse(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.game.play_black_card(card)
        self.assertTrue(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.assertEqual(self.game._num_black_swords, 1)

    def test_mercenaries(self):
        card = self.cards.get_card_by_name("Mercenaries")
        self.game.play_black_card(card)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.game.play_black_card(card)
        self.assertTrue(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.assertEqual(self.game._num_black_swords, 1)

    def test_mercenaries2(self):
        card = self.cards.get_card_by_name("Mercenaries")
        self.game.play_black_card(card, False)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.assertFalse(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.game.play_black_card(card, False)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.assertFalse(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.game.play_black_card(card, False)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.assertFalse(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.assertFalse(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.assertFalse(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.assertFalse(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.game.play_black_card(card)
        self.assertTrue(self.game._pict_quest.quest_lost())
        self.assertFalse(self.game._pict_quest.quest_won())
        self.assertFalse(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.assertEqual(self.game._num_black_swords, 1)
        self.game.play_black_card(card, False)
        self.assertFalse(self.game._pict_quest.quest_won())
        self.assertTrue(self.game._saxon_quest.quest_lost())
        self.assertFalse(self.game._saxon_quest.quest_won())
        self.assertEqual(self.game._num_black_swords, 2)

    def test_morgan_4(self):
        card = self.cards.get_card_by_name("Morgan_4")
        self.game.play_black_card(card)
        self.assertEqual(self.game._num_siege_engines, 2)
        self.game.discard_black_card(card)

    def test_excalibur(self):
        card = self.cards.get_card_by_name("Excalibur")
        self.game.play_black_card(card)
        self.assertFalse(self.game._excalibur_quest.quest_lost())
        self.game.play_black_card(card)
        self.assertFalse(self.game._excalibur_quest.quest_lost())
        self.game.play_black_card(card)
        self.assertFalse(self.game._excalibur_quest.quest_lost())
        self.game.play_black_card(card)
        self.assertFalse(self.game._excalibur_quest.quest_lost())
        self.game.play_black_card(card)
        self.assertTrue(self.game._excalibur_quest.quest_lost())
        self.assertEqual(self.game._num_black_swords, 2)

    def test_despair(self):
        card = self.cards.get_card_by_name("Despair")
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertTrue(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())

    def test_desolation(self):
        card = self.cards.get_card_by_name("Desolation")
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(card)
        self.assertTrue(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())

    def test_grail_despair_desolation(self):
        deso = self.cards.get_card_by_name("Desolation")
        self.game.play_black_card(deso)
        desp = self.cards.get_card_by_name("Despair")
        self.game.play_black_card(desp)
        # 2 d, 0g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game._holy_grail_quest.add_grail()
        # 2 d, 1 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game._holy_grail_quest.add_grail()
        # 2 d, 2 g
        self.game._holy_grail_quest.add_grail()
        # 2 d, 3 g
        self.game._holy_grail_quest.add_grail()
        # 2 d, 4 g
        self.game._holy_grail_quest.add_grail()
        # 2 d, 5 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game._holy_grail_quest.add_grail()
        # 1 d, 5 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game._holy_grail_quest.add_grail()
        # 1 d, 6 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(deso)
        # 2 d, 5 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game._holy_grail_quest.add_grail()
        # 1 d, 5 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game._holy_grail_quest.add_grail()
        # 1 d, 6 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game.play_black_card(desp)
        # 1 d, 5 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game._holy_grail_quest.add_grail()
        # 1 d, 6 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game._holy_grail_quest.add_grail()
        # 0 d, 6 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertFalse(self.game._holy_grail_quest.quest_won())
        self.game._holy_grail_quest.add_grail()
        # 0 d, 7 g
        self.assertFalse(self.game._holy_grail_quest.quest_lost())
        self.assertTrue(self.game._holy_grail_quest.quest_won())
Beispiel #7
0
class TestExcaliburQuest(unittest.TestCase):
    def setUp(self):
        self.game = Game()
        self.quest = self.game._excalibur_quest
        self.arthur = Knight(CoatOfArms.ARTHUR)
        self.game.add_knight(self.arthur)
        self.game.add_knight_to_excalibur(self.arthur)

    def test_lose(self):
        self.quest.lose()
        self.assertFalse(self.quest.active)

    def test_win(self):
        self.quest.win()
        self.assertFalse(self.quest.active)

    def test_can_add_knight(self):
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertFalse(self.quest.can_add_knight())

    def test_add_knight(self):
        self.assertEqual(len(self.quest._present_knights), 1)

    def test_quest_lost(self):
        self.quest.move_toward_defeat()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.move_toward_defeat()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.move_toward_defeat()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.move_toward_defeat()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.move_toward_defeat()
        self.assertTrue(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.assertFalse(self.quest.active)
        self.assertEqual(self.game._num_black_swords, 2)
        self.assertEqual(self.arthur._current_life, 3)

    def test_quest_won(self):
        self.quest.move_toward_win()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.move_toward_win()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.move_toward_win()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.move_toward_win()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.move_toward_win()
        self.assertFalse(self.quest.quest_lost())
        self.assertTrue(self.quest.quest_won())
        self.assertFalse(self.quest.active)
        self.assertEqual(self.game._num_white_swords, 2)
        self.assertEqual(self.arthur._current_life, 5)

    def test_won_multi(self):
        self.quest.move_toward_win(5)
        self.assertFalse(self.quest.quest_lost())
        self.assertTrue(self.quest.quest_won())
        self.assertFalse(self.quest.active)
Beispiel #8
0
class TestHolyGrailQuest(unittest.TestCase):
    def setUp(self):
        self.game = Game()
        self.quest = self.game._holy_grail_quest
        self.arthur = Knight(CoatOfArms.ARTHUR)
        self.game.add_knight(self.arthur)
        self.game.add_knight_to_holy_grail(self.arthur)

    def test_lose(self):
        self.quest.lose()
        self.assertFalse(self.quest.active)

    def test_win(self):
        self.quest.win()
        self.assertFalse(self.quest.active)

    def test_can_add_knight(self):
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertTrue(self.quest.can_add_knight())
        self.quest.add_knight(self.arthur)
        self.assertFalse(self.quest.can_add_knight())

    def test_number_despair(self):
        self.quest.add_despair()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.assertEqual(self.quest._grail_cards, 0)
        self.assertEqual(self.quest._despair_cards, 1)

    def test_number_desolation(self):
        self.quest.add_desolation()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.assertEqual(self.quest._grail_cards, 0)
        self.assertEqual(self.quest._despair_cards, 1)
        self.quest.add_grail()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.assertEqual(self.quest._grail_cards, 1)
        self.assertEqual(self.quest._despair_cards, 1)
        self.quest.add_desolation()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.assertEqual(self.quest._grail_cards, 0)
        self.assertEqual(self.quest._despair_cards, 2)

    def test_mixed_crossover(self):
        self.quest.add_desolation()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.assertEqual(self.quest._grail_cards, 0)
        self.assertEqual(self.quest._despair_cards, 1)
        self.quest.add_grail()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.assertEqual(self.quest._grail_cards, 1)
        self.assertEqual(self.quest._despair_cards, 1)

    def test_number_grail(self):
        self.quest.add_grail()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.assertEqual(self.quest._grail_cards, 1)
        self.assertEqual(self.quest._despair_cards, 0)

    def test_lost(self):
        self.quest.add_despair()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_despair()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_despair()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_despair()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_despair()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_despair()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_despair()
        self.assertTrue(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.assertFalse(self.quest.active)
        self.assertEqual(self.game._num_black_swords, 3)
        self.assertEqual(self.arthur._current_life, 3)

    def test_won(self):
        self.quest.add_grail()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_grail()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_grail()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_grail()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_grail()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_grail()
        self.assertFalse(self.quest.quest_lost())
        self.assertFalse(self.quest.quest_won())
        self.quest.add_grail()
        self.assertFalse(self.quest.quest_lost())
        self.assertTrue(self.quest.quest_won())
        self.assertFalse(self.quest.active)
        self.assertEqual(self.game._num_white_swords, 3)
        self.assertEqual(self.arthur._current_life, 5)