예제 #1
0
def test_collect_logs():
    avatar_manager = MockAvatarManager()

    log_collector = LogCollector(avatar_manager)

    avatar = AvatarWrapper(None, None, None)

    avatar_manager.avatars_by_id[1] = avatar

    assert log_collector.collect_logs(1) == ""

    avatar.logs = ["Avatar test log"]

    assert log_collector.collect_logs(1) == "Avatar test log"
def test_worksheet1_avatar_state():
    worksheet1 = worksheets[1]
    avatar_wrapper = AvatarWrapper(1, Location(0, 0), MagicMock())
    serialized_avatar_state = worksheet1.avatar_state_serializer(avatar_wrapper)
    assert serialized_avatar_state == {
        "id": 1,
        "orientation": "north",
        "location": {"x": 0, "y": 0},
    }
예제 #3
0
def test_collect_logs():
    worker_manager = MockWorkerManager()
    avatar_manager = MockAvatarManager()

    log_collector = LogCollector(worker_manager, avatar_manager)
    worker = MockWorker(None, None)
    worker.logs = ["Worker test log"]

    worker_manager.player_id_to_worker[1] = worker

    avatar = AvatarWrapper(None, None, None)

    avatar_manager.avatars_by_id[1] = avatar

    assert log_collector.collect_logs(1) == "Worker test log"

    avatar.logs = ["Avatar test log"]

    assert log_collector.collect_logs(1) == "Worker test log\nAvatar test log"
def test_worksheet2_avatar_state():
    worksheet2 = worksheets[2]
    avatar_wrapper = AvatarWrapper(23, Location(14, -2), MagicMock())
    serialized_avatar_state = worksheet2.avatar_state_serializer(avatar_wrapper)
    assert serialized_avatar_state == {
        "id": 23,
        "location": {"x": 14, "y": -2},
        "orientation": "north",
        "backpack": [],
    }
def test_worksheet3_avatar_state():
    worksheet3 = worksheets[3]
    avatar_wrapper = AvatarWrapper(12, Location(-5, 7), MagicMock())
    serialized_avatar_state = worksheet3.avatar_state_serializer(
        avatar_wrapper)
    assert serialized_avatar_state == {
        "id": 12,
        "location": {
            "x": -5,
            "y": 7
        },
        "orientation": "north",
        "backpack": [],
    }
예제 #6
0
 def add_avatar(self, player_id, location):
     avatar = AvatarWrapper(
         player_id, location, AvatarAppearance("#000", "#ddd", "#777", "#fff")
     )
     self.avatars_by_id[player_id] = avatar
     return avatar
예제 #7
0
 def add_avatar(self, player_id, location=None):
     avatar = AvatarWrapper(player_id, None, None)
     self.avatars_by_id[player_id] = avatar
     return avatar
예제 #8
0
 def add_avatar(self, player_id, worker_url, location):
     avatar = AvatarWrapper(
         location, player_id, worker_url,
         AvatarAppearance("#000", "#ddd", "#777", "#fff"))
     self.avatarsById[player_id] = avatar
     return avatar