Ejemplo n.º 1
0
	def test_player_reset(self):
		#Ensure that the player can be reset
		#Note that this class should only be instantiated by the GameStarter and so has less validity check on its inputs
		pl = GamePlayer(1.0, 2.0, 0.5)
		pl.pushed = True
		pl.timeStep(5.0)
		pl.reset()
		self.assertEquals(0.0, pl.level)
		self.assertEquals("OUT", pl.state)
		self.assertEquals(False, pl.pushed)
Ejemplo n.º 2
0
	def test_player_timing(self):
		#Ensure that the player can be instantiated and does sensible things
		#Note that this class should only be instantiated by the GameStarter and so has less validity check on its inputs
		pl = GamePlayer(1.0, 2.0, 0.5)
		pl.timeStep(0.5)
		self.assertEquals("OUT", pl.state)
		self.assertEquals(False, pl.pushed)
		self.assertEquals(0.0, pl.level)

		pl.pushed = True
		self.assertEquals(True, pl.pushed)

		pl.timeStep(0.51)
		self.assertEquals("WAIT", pl.state)
		level = pl.level
		self.assertTrue((0.509<level) and (level < 0.511))

		pl.timeStep(0.5)
		self.assertEquals("ACTIVE", pl.state)
		level = pl.level
		self.assertTrue((1.009<level) and (level < 1.011))

		pl.timeStep(1.0)
		self.assertEquals("START", pl.state)
		level = pl.level
		self.assertTrue((1.99<level) and (level < 2.01))