コード例 #1
0
ファイル: test_player.py プロジェクト: speque/shallowspace
 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)
コード例 #2
0
ファイル: test_player.py プロジェクト: speque/shallowspace
 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)
コード例 #3
0
ファイル: test_player.py プロジェクト: speque/shallowspace
 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)
コード例 #4
0
ファイル: test_player.py プロジェクト: speque/shallowspace
 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)
コード例 #5
0
ファイル: test_player.py プロジェクト: speque/shallowspace
 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)