def test_battle_orders_flee(self): self.my_unit = WorldUnit.objects.create( owner_character_id=7, world_id=2, location_id=1003, origin_id=1003, name="Commonwealth lord unit", recruitment_type=WorldUnit.CONSCRIPTION, type=WorldUnit.INFANTRY, status=WorldUnit.FOLLOWING, mobilization_status_since=0, current_status_since=0, generation_size=30, default_battle_orders=Order.objects.create(what=Order.CHARGE) ) self.barbarian_unit = WorldUnit.objects.create( owner_character=None, world_id=2, location_id=1003, origin_id=1003, name="Barbarian unit", recruitment_type=WorldUnit.CONSCRIPTION, type=WorldUnit.INFANTRY, status=WorldUnit.FOLLOWING, mobilization_status_since=0, current_status_since=0, generation_size=5, default_battle_orders=Order.objects.create(what=Order.MOVE) ) initialize_unit(self.my_unit) initialize_unit(self.barbarian_unit) self.tile = Tile.objects.get(id=105) trigger_battles_in_tile(self.tile) self.battle = Battle.objects.get(id=1) self.assertTrue( WorldUnit.objects.filter(owner_character__isnull=True).exists()) start_battle(self.battle) battle_unit = BattleUnit.objects.get(owner=None) self.assertEqual( battle_unit.get_order().what, Order.FLEE) battle_tick(self.battle) battle_unit = BattleUnit.objects.get(owner=None) self.assertEqual( battle_unit.get_order().what, Order.FLEE)
def test_conflict_creation_on_region_without_able_soldiers(self): tile = Tile.objects.get(id=108) trigger_battles_in_tile(tile) self.assertFalse(Battle.objects.exists())
def test_battle_initialization(self): self.my_unit = WorldUnit.objects.create( owner_character_id=7, world_id=2, location_id=1003, origin_id=1003, name="Commonwealth lord unit", recruitment_type=WorldUnit.CONSCRIPTION, type=WorldUnit.INFANTRY, status=WorldUnit.FOLLOWING, mobilization_status_since=0, current_status_since=0, generation_size=5, default_battle_orders=Order.objects.create(what=Order.CHARGE)) self.barbarian_unit = WorldUnit.objects.create( owner_character=None, world_id=2, location_id=1003, origin_id=1003, name="Barbarian unit", recruitment_type=WorldUnit.CONSCRIPTION, type=WorldUnit.INFANTRY, status=WorldUnit.FOLLOWING, mobilization_status_since=0, current_status_since=0, generation_size=30, default_battle_orders=Order.objects.create(what=Order.MOVE)) initialize_unit(self.my_unit) initialize_unit(self.barbarian_unit) self.tile = Tile.objects.get(id=105) trigger_battles_in_tile(self.tile) self.battle = Battle.objects.get(id=1) self.assertTrue( WorldUnit.objects.filter(owner_character__isnull=True).exists()) start_battle(self.battle) self.assertTrue( BattleOrganization.objects.filter(organization=World.objects.get( id=2).get_barbaric_state()).exists()) self.assertTrue( BattleOrganization.objects.filter(organization_id=105).exists()) self.assertEqual(BattleCharacter.objects.count(), 1) self.assertEqual(BattleUnit.objects.count(), 2) self.assertEqual( BattleUnit.objects.filter(battle_side__battle=self.battle).count(), 2) self.assertEqual( BattleSoldier.objects.filter( battle_contubernium__battle_unit__battle_side__battle=self. battle).count(), 35) self.assertEqual( BattleSoldierInTurn.objects.filter( battle_turn__battle=self.battle).count(), 35)