Example #1
0
 def testAllLevelsComplete(self):
     game = Game([ [(10, 20), [(5, 4, 1, 1)]] ])
     game.getWorld().getExplosion().blow()
     self.manyUpdates(game.getWorld())
     self.assertEquals(GameState_Continue, game.getState())
     game.nextWorld()
     self.assertEquals(GameState_AllLevelsCompleted, game.getState())
Example #2
0
 def testNextWorld(self):
     game = Game([ [(10, 20), [(5, 4, 1, 1)]], [(15, 25), [(5, 5, 1, 1)]] ])
     game.getWorld().getExplosion().blow()
     self.manyUpdates(game.getWorld())
     
     game.nextWorld()
     
     self.assertSize((15, 25), game.getWorld())
Example #3
0
class GameControllerTest(unittest.TestCase):
    def setUp(self):
        self.game = Game([[(8, 9), []]])
        self.controller = GameController(self.game)

    def testMoveCarAfterBlow(self):
        x = self.game.getWorld().getCar().getX()
        self.controller.blow()
        self.controller.moveCar(-1.0)
        self.controller.moveCar(5.0)
        dx = self.game.getWorld().getCar().getX() - x
        self.assertEquals(0, dx)

    def testMoveExplosionAfterBlow(self):
        x = self.game.getWorld().getExplosion().getX()
        self.controller.blow()
        self.controller.moveExplosion(-2.0)
        self.controller.moveExplosion(8.0)
        dx = self.game.getWorld().getExplosion().getX() - x
        self.assertEquals(0, dx)

    def testChangeExplosionVolumeAfterBlow(self):
        volume = self.game.getWorld().getExplosion().getVolume()
        self.controller.blow()
        self.controller.nextExplosionVolume()
        self.assertEquals(volume, self.game.getWorld().getExplosion().getVolume())
        self.controller.prevExplosionVolume()
        self.assertEquals(volume, self.game.getWorld().getExplosion().getVolume())

    def testTwiceBlow(self):
        self.controller.blow()
        self.controller.blow()
        # no exception and errors !

    def testNextWorldOnNonCompletedWorld(self):
        self.game = Game([[(8, 9), [(1, 1, 1, 1)]]])
        self.controller = GameController(self.game)
        self.controller.nextWorld()
Example #4
0
 def testGetFirstWorld(self):
     worlds = [[(15, 25), [(1, 2, 3, 4)]]]
     game = Game(worlds)
     self.assertEquals(GameState_Continue, game.getState())
     self.assertSize((15, 25), game.getWorld())
Example #5
0
 def testNextWorldNonComplete(self):
     game = Game([ [(100, 20), [(1, 10, 1, 1)]] ])
     game.getWorld().getExplosion().blow()
     self.manyUpdates(game.getWorld())
     self.assertRaises(GameError, lambda: game.nextWorld())
Example #6
0
 def testResetWorld(self):
     game = Game([ [(10, 25), [(1, 10, 3, 4)]] ])
     game.getWorld().getCar().move(-100)
     game.getWorld().getExplosion().move(100)
     game.getWorld().getExplosion().setVolume(ExplosionVolume_Hight)
     game.getWorld().getExplosion().blow()
     self.manyUpdates(game.getWorld())
     
     game.resetWorld()
     
     self.assertSize((10, 25), game.getWorld())
     self.assertPosition((4, 0), game.getWorld().getCar())
     self.assertPosition((5, 0), game.getWorld().getExplosion())
     self.assertEquals(ExplosionVolume_Normal, game.getWorld().getExplosion().getVolume())
     self.assertEquals(1, game.getWorld().getEnemiesCount())
     self.assertPosition((1, 10), game.getWorld().getEnemies()[0])
     self.assertSize((3, 4), game.getWorld().getEnemies()[0])
Example #7
0
 def setUp(self):
     self.game = Game([[(8, 9), []]])
     self.controller = GameController(self.game)
Example #8
0
 def testNextWorldOnNonCompletedWorld(self):
     self.game = Game([[(8, 9), [(1, 1, 1, 1)]]])
     self.controller = GameController(self.game)
     self.controller.nextWorld()