Exemplo n.º 1
0
 def testShoot(self):
     """Test shooting"""
     charactor = Charactor(self.event_manager)
     charactor.shoot()
     lastEvent = self.event_tester.last_event()
     self.assertTrue(isinstance(lastEvent, CharactorShootEvent))
     self.assertEqual(lastEvent.charactor, charactor)
Exemplo n.º 2
0
 def testPlace(self):
     """Test placing"""
     charactor = Charactor(self.event_manager)
     sector = Sector()
     charactor.place(sector)
     lastEvent = self.event_tester.last_event()
     self.assertTrue(isinstance(lastEvent, CharactorPlaceEvent))
     self.assertEqual(lastEvent.charactor, charactor)
Exemplo n.º 3
0
 def testTurn(self):
     """Test turning"""
     charactor = Charactor(self.event_manager)
     charactor.turn(shallowspace.constants.DIRECTION_RIGHT)
     self.assertEqual(charactor.direction, shallowspace.constants.DIRECTION_RIGHT)
     lastEvent = self.event_tester.last_event()
     self.assertTrue(isinstance(lastEvent, CharactorTurnEvent))
     self.assertEqual(lastEvent.charactor, charactor)
Exemplo n.º 4
0
 def testUnsuccesfullMove(self):
     """Test moving to a blocked direction"""
     charactor = Charactor(self.event_manager)
     sector = Sector()
     charactor.place(sector)
     event = self.event_tester.last_event()
     charactor.move(shallowspace.constants.DIRECTION_UP)
     self.assertEqual(self.event_tester.last_event(), event)
     self.assertEqual(charactor.sector, sector)
Exemplo n.º 5
0
 def testCharactorPlaceNotification(self):
     """Test charactor place notification"""
     map_state = MapState(self.event_manager)
     charactor = Charactor(self.event_manager)
     charactor.sector = Sector()
     charactor_place_event = CharactorPlaceEvent(charactor)
     self.event_manager.post(charactor_place_event)
     self.assertEqual(map_state.actors_by_sector_id[charactor.sector.sector_id], charactor)
     self.assertEqual(map_state.occupied_sectors_by_actor_id[charactor.charactor_id], charactor.sector)
Exemplo n.º 6
0
 def testSuccesfullMove(self):
     """Test moving to a non-blocked direction"""
     charactor = Charactor(self.event_manager)
     sector = Sector()
     charactor.place(sector)
     neighboring_sector = Sector()
     sector.neighbors[shallowspace.constants.DIRECTION_UP] = neighboring_sector 
     charactor.move(shallowspace.constants.DIRECTION_UP)
     self.assertTrue(isinstance(self.event_tester.last_event(), CharactorMoveEvent))
     self.assertEqual(charactor.sector, neighboring_sector)
Exemplo n.º 7
0
 def testFreeSectorActionNotification(self):
     """Test free section action notification"""
     map_state = MapState(self.event_manager)
     sector = Sector()
     
     self.actionExecuted = False #TODO: this is no good
     def function(sector_is_free):
         if sector_is_free:
             self.actionExecuted = True
     callback_function = function
     free_sector_action = FreeSectorAction(sector, callback_function)
     self.event_manager.post(free_sector_action)
     self.assertTrue(self.actionExecuted)
     
     self.actionExecuted = False
     charactor = Charactor(self.event_manager)
     charactor.sector = sector
     map_state.occupied_sectors_by_actor_id[charactor.charactor_id] = charactor.sector
     self.event_manager.post(free_sector_action)
     self.assertFalse(self.actionExecuted)