Ejemplo n.º 1
0
 def testNotifyCharactorMoveToRequest(self):
     """Test notifying the player abot a CharactorMoveToRequest"""
     player = Player(self.event_manager, self.id_manager)
     request = CharactorMoveToRequest(None)
     self.event_tester.clear()
     player.notify(request)
     self.assertTrue(isinstance(self.event_tester.last_event(), CalculatePathRequest))
     self.assertEqual(None, self.event_tester.last_event().pos)
Ejemplo n.º 2
0
 def testNotifyActiveCharactorChangeRequest(self):
     """Test notifying the player abot a ActiveCharactorChangeRequest"""
     player = Player(self.event_manager, self.id_manager)
     request = ActiveCharactorChangeRequest(None)
     self.event_tester.clear()
     player.notify(request)
     self.assertTrue(isinstance(self.event_tester.last_event(), OccupiedSectorAction))
     self.assertEqual(None, self.event_tester.last_event().pos)
     self.assertTrue(type(self.event_tester.last_event().function) is FunctionType)
Ejemplo n.º 3
0
 def testNotifyGameStartedEvent(self):
     """Test notifying the player abot a GameStartedEvent"""
     player = Player(self.event_manager, self.id_manager)
     game_started_event = GameStartedEvent()
     self.event_tester.clear()
     player.notify(game_started_event)
     for index, charactor in enumerate(player.charactors):
         self.assertTrue(isinstance(self.event_tester.events[index], CharactorPlaceRequest))
         self.assertEqual(charactor, self.event_tester.events[index].charactor)
Ejemplo n.º 4
0
 def testNotifyCharatorMoveRequest(self):
     """Test notifying the player about a CharactorMoveRequest"""
     player = Player(self.event_manager, self.id_manager)
     request = CharactorMoveRequest(DIRECTION_DOWN)
     player.active_charactor.direction = DIRECTION_UP
     def register_turn_call(direction):
         register_turn_call.called = True
     player.active_charactor.turn = register_turn_call
     self.event_tester.clear()
     
     #charactor is facing up, request is to move down -> active charactor should turn 
     player.notify(request)
     self.assertTrue(player.active_charactor.turn.called)
     self.assertIsNone(self.event_tester.last_event())
     
     request = CharactorMoveRequest(DIRECTION_UP)
     player.active_charactor.turn.called = False
     player.notify(request)
     # the active charactor does not have a sector yet
     self.assertIsNone(self.event_tester.last_event())
     self.assertFalse(player.active_charactor.turn.called)
     
     request = CharactorMoveRequest(DIRECTION_UP, True)
     player.active_charactor.turn.called = False
     player.notify(request)
     # the active charactor does not have a sector yet
     self.assertIsNone(self.event_tester.last_event())
     self.assertFalse(player.active_charactor.turn.called)
     
     player.active_charactor.sector = Sector()
     player.notify(request)
     self.assertTrue(isinstance(self.event_tester.last_event(), FreeSectorAction))
     self.assertIsNone(self.event_tester.last_event().sector)
Ejemplo n.º 5
0
 def testCharactorShootRequest(self):
     """Test notifying the player about a CharactorChoorReuquest"""
     player = Player(self.event_manager, self.id_manager)
     request = CharactorShootRequest()
     self.event_tester.clear()
     def register_shoot_call():
         register_shoot_call.called = True
     self.shoot_called = False
     player.active_charactor.shoot = register_shoot_call
     player.notify(request)
     self.assertTrue(player.active_charactor.shoot.called)