コード例 #1
0
ファイル: unit_test.py プロジェクト: kyphelps/porter
    def testTankDoesNotEqualModifiedTank(self):
        modified = types.new_unit('Tank', consts.RED)
        modified.health -= 1
        self.assertNotEqual(modified, types.new_unit('Tank', consts.RED))

        modified = types.new_unit('Tank', consts.RED)
        modified.armor[0] = 1000.0
        self.assertNotEqual(modified, types.new_unit('Tank', consts.RED))
コード例 #2
0
ファイル: control_test.py プロジェクト: kyphelps/porter
    def oneVsOther(self, AttackUnit, DefendUnit, delta, start_damage=0):
        attack_unit = types.new_unit(AttackUnit, consts.RED)
        attack_unit.health -= start_damage
        expected_attack_unit = types.new_unit(AttackUnit, consts.RED)
        expected_attack_unit.health -= start_damage
        defend_unit = types.new_unit(DefendUnit, consts.BLUE)
        expected_defend_unit = types.new_unit(DefendUnit, consts.BLUE)
        expected_defend_unit.health -= delta

        control.DoDamage(attack_unit, defend_unit)

        self.assertEqual(attack_unit, expected_attack_unit)
        self.assertEqual(defend_unit, expected_defend_unit)
コード例 #3
0
ファイル: player_test.py プロジェクト: kyphelps/porter
 def testPlayerGetUnit(self):
     player_ = player.Player(1)
     tank = types.new_unit('Tank', consts.RED)
     player_.add_unit(tank, 1)
     returned_tank = player_.get_unit(1)
     self.assertEqual(returned_tank, tank)
     self.assertRaises(Exception, player_.get_unit, 2)
コード例 #4
0
ファイル: unit_test.py プロジェクト: kyphelps/porter
 def testRecon(self):
     recon = types.new_unit('Recon', consts.RED)
     self.assertEqual(recon.health, 10)
     self.assertEqual(recon.attacks, [types.new_attack('DoubleMachineGun')])
     self.assertEqual(recon.armor, types.new_armor('WeakMetal'))
     self.assertEqual(recon.movement, types.new_movement('Tires'))
     self.assertEqual(recon.distance, 9)
コード例 #5
0
ファイル: unit_test.py プロジェクト: kyphelps/porter
 def testInfantry(self):
     inf = types.new_unit('Infantry', consts.RED)
     self.assertEqual(inf.health, 10)
     self.assertEqual(inf.attacks, [types.new_attack('MachineGun')])
     self.assertEqual(inf.armor, types.new_armor('BodyArmor'))
     self.assertEqual(inf.movement, types.new_movement('Feet'))
     self.assertEqual(inf.distance, 3)
コード例 #6
0
ファイル: world_test.py プロジェクト: kyphelps/porter
 def testWorldMove(self):
     world_ = world.World([13, 26])
     world_.add_unit(13, types.new_unit('Tank', consts.RED))
     self.assertEqual(world_.move_unit(13, 0, [(1, 1)]), True)
     self.assertEqual(world_.move_unit(13, 0, [(1, 1), (2, 2)]), False)
     self.assertEqual(
         world_.move_unit(13, 0, [(1, 1), (1, 2), (2, 2)]),
         True)
コード例 #7
0
ファイル: unit_test.py プロジェクト: kyphelps/porter
 def testTank(self):
     tank = types.new_unit('Tank', consts.RED)
     self.assertEqual(tank.health, 10)
     self.assertEqual(
         tank.attacks, [types.new_attack('RegularCannon'), types.new_attack('MachineGun')])
     self.assertEqual(tank.armor, types.new_armor('HeavyMetal'))
     self.assertEqual(tank.movement, types.new_movement('Treads'))
     self.assertEqual(tank.distance, 7)
コード例 #8
0
ファイル: player_test.py プロジェクト: kyphelps/porter
 def testPlayerAddUnit(self):
     player_ = player.Player(1)
     tank = types.new_unit('Tank', consts.RED)
     player_.add_unit(tank, 1)
     self.assertEqual(player_.units, {1: tank})
コード例 #9
0
ファイル: world_test.py プロジェクト: kyphelps/porter
 def testWorldAddUnit(self):
     world_ = world.World([13, 26])
     tank = types.new_unit('Tank', consts.RED)
     world_.add_unit(26, tank)
     self.assertEqual(world_.get_player(26).units[0], tank)
コード例 #10
0
ファイル: unit_test.py プロジェクト: kyphelps/porter
 def testSerializeTank(self):
     tank = types.new_unit('Tank', consts.RED)
     self.assertEqual(tank.serialize(True), {'name': 'Tank', 'health': 10})
コード例 #11
0
ファイル: unit_test.py プロジェクト: kyphelps/porter
 def testTankDoesNotEqualRecon(self):
     self.assertNotEqual(
         types.new_unit('Tank', consts.RED),
         types.new_unit('Recon', consts.RED))
コード例 #12
0
ファイル: unit_test.py プロジェクト: kyphelps/porter
 def testTankEqualsTank(self):
     self.assertEqual(types.new_unit('Tank', consts.RED), types.new_unit('Tank', consts.RED))