def test_fortify(self): t = Territory() from_t = Territory() from_t.reinforce(20) t.fortify(from_t, 20) self.assertEqual(21, t.armies) self.assertEqual(1, from_t.armies)
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 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_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())
def test_reinforce(self): t = Territory() t.reinforce(20) self.assertEqual(21, t.armies)