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(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 __init__(self, worker_manager_class, game_state_generator, django_api_url, port): super(GameRunner, self).__init__() self.worker_manager = worker_manager_class(port=port) self.game_state = game_state_generator(AvatarManager()) self.communicator = DjangoCommunicator(django_api_url=django_api_url, completion_url=django_api_url + 'complete/') self.simulation_runner = ConcurrentSimulationRunner( communicator=self.communicator, game_state=self.game_state) self._end_turn_callback = lambda: None
def game_runner(): async def mock_callback(): pass game_state = GameState(InfiniteMap(), AvatarManager()) game_runner = GameRunner( game_state_generator=lambda avatar_manager: game_state, port="0000", communicator=MockCommunicator(), worker_manager_class=MockWorkerManager, ) game_runner.set_end_turn_callback(mock_callback) return game_runner
def game_runner(): async def mock_callback(): pass game_state = GameState(InfiniteMap(), AvatarManager()) game_runner = GameRunner( worker_manager_class=ConcreteWorkerManager, game_state_generator=lambda avatar_manager: game_state, port='0000', django_api_url='http://test') game_runner.communicator = MockCommunicator() game_runner.set_end_turn_callback(mock_callback) return game_runner
def run_game(port): global worker_manager print("Running game...") settings = pickle.loads(os.environ['settings']) api_url = os.environ.get('GAME_API_URL', 'http://localhost:8000/players/api/games/') generator = getattr(map_generator, settings['GENERATOR'])(settings) player_manager = AvatarManager() game_state = generator.get_game_state(player_manager) turn_manager = ConcurrentTurnManager(game_state=game_state, end_turn_callback=send_world_update, completion_url=api_url+'complete/') WorkerManagerClass = WORKER_MANAGERS[os.environ.get('WORKER_MANAGER', 'local')] worker_manager = WorkerManagerClass(game_state=game_state, users_url=api_url, port=port) worker_manager.start() turn_manager.start()
def __init__( self, game_state_generator, communicator: DjangoCommunicator, port, worker_manager_class=WorkerManager, ): super(GameRunner, self).__init__() self.worker_manager = worker_manager_class(port=port) self.game_state = game_state_generator(AvatarManager()) self.communicator = communicator self.simulation_runner = ConcurrentSimulationRunner( communicator=self.communicator, game_state=self.game_state) self._end_turn_callback = lambda: None
def __init__( self, game_state_generator, communicator: DjangoCommunicator, port, turn_collector: "TurnCollector", ): super(GameRunner, self).__init__() self.game_state: "GameState" = game_state_generator(AvatarManager()) self.communicator = communicator self.simulation_runner = ConcurrentSimulationRunner( communicator=self.communicator, game_state=self.game_state) self.turn_collector = turn_collector self.turn_collector.new_turn(self.game_state.turn_count) self._end_turn_callback = lambda: None
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 = ConcurrentTurnManager(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 setUp(self): self.avatar = MoveDummy(1, ORIGIN, EAST) self.other_avatar = MoveDummy(2, EAST_OF_ORIGIN, EAST) self.avatar_manager = AvatarManager()
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 setUp(self): self.game_state = GameState(InfiniteMap(), AvatarManager()) self.worker_manager = ConcreteWorkerManager(self.game_state, 'http://test')
def setUp(self): self.avatar = DummyAvatarRunner(ORIGIN, player_id=1) self.other_avatar = DummyAvatarRunner(EAST_OF_ORIGIN, player_id=2) self.avatar_manager = AvatarManager([self.avatar, self.other_avatar])