Ejemplo n.º 1
0
    def test_Creation(self):
        path = self._RealPath
        print(path)
        holder = MapHolder(self._ConfigProvider)
        holder.loadMap(path)
        player1 = PlayerState(1)
        player2 = PlayerState(2)

        gamestate = GameState(player1, player2, 10)
        engine = PlayerEngine.PlayerEngine(gamestate, self._ConfigProvider,
                                           holder)
        self.assertTrue(engine.GetGameState().MyPlayer.id == 1)
        self.assertTrue(engine.GetGameState().EnemyPlayer.id == 2)
Ejemplo n.º 2
0
 def test_GetPath_Fail(self):
     path = self._RealPath
     holder = MapHolder(self._ConfigProvider)
     holder.loadMap(path)
     player1 = PlayerState(1)
     player2 = PlayerState(2)
     gamestate = GameState(player1, player2, 10)
     gamestate.MyPlayer.position = Point(1, 7)
     gamestate.EnemyPlayer.position = Point(9, 9)
     engine = PlayerEngine.PlayerEngine(gamestate, self._ConfigProvider,
                                        holder)
     path = engine.GetPathForMe(gamestate.EnemyPlayer.position)
     self.assertFalse(path.valid)
Ejemplo n.º 3
0
    def test_Movement_Success(self):
        path = self._RealPath
        holder = MapHolder(self._ConfigProvider)
        holder.loadMap(path)

        player1 = PlayerState(1)
        player2 = PlayerState(2)

        gamestate = GameState(player1, player2, 10)
        engine = PlayerEngine.PlayerEngine(gamestate, self._ConfigProvider,
                                           holder)
        PointFrom = Point(0, 0)
        PointTo = Point(1, 2)
        self.assertTrue(engine.MayIMove(PointTo))
        self.assertTrue(engine.MayMoveBetweenPoints(PointFrom, PointTo))
Ejemplo n.º 4
0
 def test_GetPath_Success_and_Draw(self):
     path = self._RealPath
     self._ConfigProvider.addValue('Game.Config', 'DrawMapHolderGraph',
                                   'True')
     holder = MapHolder(self._ConfigProvider)
     holder.loadMap(path)
     player1 = PlayerState(1)
     player2 = PlayerState(2)
     gamestate = GameState(player1, player2, 10)
     gamestate.MyPlayer.position = Point(1, 1)
     gamestate.EnemyPlayer.position = Point(1, 3)
     engine = PlayerEngine.PlayerEngine(gamestate, self._ConfigProvider,
                                        holder)
     path = engine.GetPathForMe(gamestate.EnemyPlayer.position)
     self.assertTrue(path.valid)
Ejemplo n.º 5
0
    def test_Movement_Fail(self):
        path = self._RealPath
        holder = MapHolder(self._ConfigProvider)
        holder.loadMap(path)

        player1 = PlayerState(1)
        player2 = PlayerState(2)

        gamestate = GameState(player1, player2, 10)

        self._ConfigProvider.addValue('Game.MovementDefinations',
                                      'maximumAllowedPath', '1')
        engine = PlayerEngine.PlayerEngine(gamestate, self._ConfigProvider,
                                           holder)
        PointFrom = Point(0, 0)
        PointTo = Point(3, 3)
        self.assertFalse(engine.MayIMove(PointTo))
        self.assertFalse(engine.MayMoveBetweenPoints(PointFrom, PointTo))
Ejemplo n.º 6
0
    def test_Los_Fail(self):
        path = self._RealPath
        holder = MapHolder(self._ConfigProvider)
        holder.loadMap(path)
        player1 = PlayerState(1)
        player2 = PlayerState(2)

        gamestate = GameState(player1, player2, 10)

        gamestate.MyPlayer.position = Point(1, 1)
        gamestate.EnemyPlayer.position = Point(1, 3)

        engine = PlayerEngine.PlayerEngine(gamestate, self._ConfigProvider,
                                           holder)
        self.assertFalse(engine.IsLosToEnemy())
        self.assertFalse(engine.IsLosFromMeToPoint(Point(1, 4)))
        p1 = Point(2, 1)
        p2 = Point(6, 5)
        self.assertFalse(engine.IsLosBetweenPoints(p1, p2))
Ejemplo n.º 7
0
    def test_Update_GameState(self):
        path = self._RealPath
        holder = MapHolder(self._ConfigProvider)
        holder.loadMap(path)

        player1 = PlayerState(1)
        player2 = PlayerState(2)

        gamestate = GameState(player1, player2, 10)
        engine = PlayerEngine.PlayerEngine(gamestate, self._ConfigProvider,
                                           holder)
        self.assertTrue(engine.GetGameState().MyPlayer.position.x == 0)
        self.assertTrue(engine.GetGameState().EnemyPlayer.position.x == 0)
        self.assertTrue(engine.GetGameState().playingtime == 0)
        gamestate.playingtime = 100
        gamestate.MyPlayer.position = Point(10, 10)
        gamestate.EnemyPlayer.position = Point(20, 20)
        self.assertTrue(engine.GetGameState().MyPlayer.position.x == 10)
        self.assertTrue(engine.GetGameState().EnemyPlayer.position.x == 20)
        self.assertTrue(engine.GetGameState().playingtime == 100)