コード例 #1
0
ファイル: test_battle.py プロジェクト: mjoniak/magisterka
    def test_prob(self):
        a = Territory()
        a.reinforce(3)
        a.owner = TestPlayer((1, 4, 5))

        d = Territory()
        d.owner = TestPlayer((2, ))
        d.connect(a)

        b = Battle(a, d)
        b.resolve()

        self.assertIs(a.owner, d.owner)
コード例 #2
0
    def test_player_reinforces(self):
        player = GeneticPlayer()
        territory = Territory()
        territory.owner = player

        player.reinforce()
        self.assertEqual(4, territory.armies)
コード例 #3
0
ファイル: test_battle.py プロジェクト: mjoniak/magisterka
def failed_attack():
    defending = Territory()
    defending.reinforce(1)
    defender = TestPlayer((1, 4))
    defending.owner = defender

    attacking = Territory()
    attacking.reinforce(2)
    attacker = TestPlayer((4, 2))
    attacking.owner = attacker

    attacking.connect(defending)

    battle = Battle(attacking, defending)
    battle.resolve()
    return attacking, defending
コード例 #4
0
ファイル: test_battle.py プロジェクト: mjoniak/magisterka
def successful_attack():
    defending = Territory()
    defending.reinforce(1)
    losing_player = TestPlayer((1, 1))
    defending.owner = losing_player

    attacking = Territory()
    attacking.reinforce(2)
    winning_player = TestPlayer((6, 6, 6))
    attacking.owner = winning_player

    attacking.connect(defending)

    battle = Battle(attacking, defending)
    battle.resolve()
    return attacking, defending
コード例 #5
0
ファイル: test_player.py プロジェクト: mjoniak/magisterka
    def test_player_has_reinforcement_for_every_continent(self):
        player = Player()
        t = Territory()
        Continent([t], bonus_value=10)
        t.owner = player

        armies = player.count_reinforcements()
        self.assertEqual(10, armies)
コード例 #6
0
ファイル: test_player.py プロジェクト: mjoniak/magisterka
    def test_player_has_reinforcement_for_every_three_territories(self):
        player = Player()
        for _ in range(13):
            t = Territory()
            t.owner = player

        armies = player.count_reinforcements()
        self.assertEqual(4, armies)
コード例 #7
0
ファイル: test_territory.py プロジェクト: mjoniak/magisterka
    def test_bordering_enemies(self):
        first_player = Player()
        second_player = Player()

        t1 = Territory()
        t2 = Territory()
        t3 = Territory()

        t1.owner = first_player
        t2.owner = first_player
        t3.owner = second_player

        t2.reinforce(1)
        t3.reinforce(2)

        t1.connect(t2)
        t1.connect(t3)

        self.assertEqual(3, t1.bordering_enemies())