예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
파일: models.py 프로젝트: jishi9/aimmo
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()
예제 #4
0
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()
예제 #5
0
파일: service.py 프로젝트: yongjizhou/aimmo
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()
예제 #6
0
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()
예제 #7
0
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()
예제 #8
0
 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)
예제 #9
0
 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)