def test_equality_when_different_uids(self): """Test equality when creature uids differ.""" bg1 = BattlegroundState() bg2 = BattlegroundState() uid1 = bg1.add_creature(CreatureStateFactory()) bg1.remove_creature(uid1) creature_state = CreatureStateFactory() bg1.add_creature(creature_state) bg2.add_creature(creature_state) self.assertEqual(bg1, bg2)
def test_equality_when_different_uids(self): """Test equality when creature uids differ.""" bg1 = BattlegroundState() bg2 = BattlegroundState() uid1 = bg1.add_creature(CreatureStateFactory()) bg1.remove_creature(uid1) creature_state = CreatureStateFactory() bg1.add_creature(creature_state) bg2.add_creature(creature_state) self.assertEqual(bg1, bg2)
def test_equality_when_different_creature_order(self): """Test equality when creatures have been added in different orders.""" bg1 = BattlegroundState() bg2 = BattlegroundState() creature_state1 = CreatureStateFactory() creature_state2 = CreatureStateFactory() bg1.add_creature(creature_state1) bg1.add_creature(creature_state2) bg2.add_creature(creature_state2) bg2.add_creature(creature_state1) self.assertEqual(bg1, bg2)
def test_equality_when_different_creature_order(self): """Test equality when creatures have been added in different orders.""" bg1 = BattlegroundState() bg2 = BattlegroundState() creature_state1 = CreatureStateFactory() creature_state2 = CreatureStateFactory() bg1.add_creature(creature_state1) bg1.add_creature(creature_state2) bg2.add_creature(creature_state2) bg2.add_creature(creature_state1) self.assertEqual(bg1, bg2)
def test_normalize(self): bg = BattlegroundState() h1 = bg.normalize() uid = bg.add_creature(CreatureStateFactory()) h2 = bg.normalize() self.assertNotEqual(h1, h2) bg.remove_creature(uid) self.assertEqual(h1, bg.normalize())
def test_normalize(self): bg = BattlegroundState() h1 = bg.normalize() uid = bg.add_creature(CreatureStateFactory()) h2 = bg.normalize() self.assertNotEqual(h1, h2) bg.remove_creature(uid) self.assertEqual(h1, bg.normalize())
def test_get_combat_assignment(self): bg = BattlegroundState() cr1 = bg.add_creature(CreatureStateFactory()) cr2 = bg.add_creature(CreatureStateFactory()) cr3 = bg.add_creature(CreatureStateFactory()) cr4 = bg.add_creature(CreatureStateFactory()) bg[cr1].attack() bg[cr2].attack() bg[cr3].block(cr1) bg[cr4].block(cr1) combat_assignment = bg.get_combat_assignment() self.assertIsInstance(combat_assignment, CombatAssignment) self.assertEqual(len(combat_assignment), 2) expected_ca = CombatAssignment({cr1: [cr3, cr4], cr2: []}) self.assertTrue(combat_assignment.is_reorder_of(expected_ca)) self.assertIsInstance(combat_assignment[cr1], tuple)
def test_get_combat_assignment(self): bg = BattlegroundState() cr1 = bg.add_creature(CreatureStateFactory()) cr2 = bg.add_creature(CreatureStateFactory()) cr3 = bg.add_creature(CreatureStateFactory()) cr4 = bg.add_creature(CreatureStateFactory()) bg[cr1].attack() bg[cr2].attack() bg[cr3].block(cr1) bg[cr4].block(cr1) combat_assignment = bg.get_combat_assignment() self.assertIsInstance(combat_assignment, CombatAssignment) self.assertEqual(len(combat_assignment), 2) expected_ca = CombatAssignment({cr1: [cr3, cr4], cr2: []}) self.assertTrue(combat_assignment.is_reorder_of(expected_ca)) self.assertIsInstance(combat_assignment[cr1], tuple)