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)
def test_player_reinforces(self): player = GeneticPlayer() territory = Territory() territory.owner = player player.reinforce() self.assertEqual(4, territory.armies)
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
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
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)
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)
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())