class TestTurnManager(unittest.TestCase): def construct_default_avatar_appearance(self): return AvatarAppearance("#000", "#ddd", "#777", "#fff") def construct_turn_manager(self, *avatars): self.avatar_manager = AvatarManager(avatars) self.game_state = GameState(InfiniteMap(), self.avatar_manager) self.turn_manager = TurnManager(self.game_state) def test_run_turn(self): avatar = DummyAvatarRunner(ORIGIN, player_id=1) self.construct_turn_manager(avatar) self.turn_manager.run_turn() self.assertEqual(avatar.location, RIGHT_OF_ORIGIN) def test_run_several_turns(self): avatar = DummyAvatarRunner(ORIGIN, player_id=1) self.construct_turn_manager(avatar) [self.turn_manager.run_turn() for _ in xrange(5)] self.assertEqual(avatar.location, FIVE_RIGHT_OF_ORIGIN) def test_run_several_turns_and_avatars(self): avatar1 = DummyAvatarRunner(ORIGIN, player_id=1) avatar2 = DummyAvatarRunner(ABOVE_ORIGIN, player_id=2) self.construct_turn_manager(avatar1, avatar2) [self.turn_manager.run_turn() for _ in xrange(5)] self.assertEqual(avatar1.location, FIVE_RIGHT_OF_ORIGIN) self.assertEqual(avatar2.location, FIVE_RIGHT_OF_ORIGIN_AND_ONE_ABOVE)
def run_game(): print("Running game...") my_map = map_generator.generate_map(15, 15, 0.1) player_manager = AvatarManager([]) game_state = GameState(my_map, player_manager) turn_manager = TurnManager(game_state) turn_manager.run_game()
def run_game(): print("Running game...") my_map = map_generator.generate_map(15, 15, 0.1) player_manager = AvatarManager() game_state = GameState(my_map, player_manager) turn_manager = TurnManager(game_state=game_state, end_turn_callback=send_world_update) worker_manager = LocalWorkerManager(game_state=game_state, users_url='http://localhost:8000/players/api/games/') worker_manager.start() turn_manager.start()
def run_game(): print("Running game...") my_map = map_generator.generate_map(10, 10, 0.1) player_manager = AvatarManager() game_state = GameState(my_map, player_manager) turn_manager = TurnManager(game_state=game_state, end_turn_callback=send_world_update) worker_manager = LocalWorkerManager(game_state=game_state, users_url='http://localhost:8000/players/api/games/') worker_manager.start() turn_manager.start()
def run_game(): global worker_manager print("Running game...") my_map = map_generator.generate_map(10, 10, 0.1) player_manager = AvatarManager() game_state = GameState(my_map, player_manager) turn_manager = TurnManager(game_state=game_state, end_turn_callback=send_world_update) WorkerManagerClass = WORKER_MANAGERS[os.environ.get('WORKER_MANAGER', 'local')] worker_manager = WorkerManagerClass(game_state=game_state, users_url=os.environ.get('GAME_API_URL', 'http://localhost:8000/players/api/games/')) worker_manager.start() turn_manager.start()
def construct_turn_manager(self, *avatars): self.avatar_manager = AvatarManager(avatars) self.game_state = GameState(InfiniteMap(), self.avatar_manager) self.turn_manager = TurnManager(self.game_state)