Esempio n. 1
0
    def setUp(self):
        """
        Sets up the JSON of the world state generated by the service file for testing.
        """
        self.avatar_manager = self.DummyAvatarManager()

        CELLS = [
            [
                {
                    "interactable": MockPickup("b"),
                    "avatar": self.avatar_manager.avatars[0],
                },
                {},
                {},
            ],
            [{}, {
                "habitable": False
            }, {
                "interactable": MockPickup("a")
            }],
        ]

        grid = {
            Location(x, y - 1): MockCell(Location(x, y - 1), **CELLS[x][y])
            for y in range(3) for x in range(2)
        }
        grid[Location(0, 1)].interactable = ScoreLocation(grid[Location(0, 1)])
        test_game_state = GameState(WorldMap(grid, {}), self.avatar_manager)
        self.world_state_json = test_game_state.serialize()
Esempio n. 2
0
def world_state_json(avatar_manager):
    CELLS = [
        [
            {
                "interactable": MockPickup("b"),
                "avatar": avatar_manager.avatars[0],
            },
            {},
            {},
        ],
        [{}, {"habitable": False}, {"interactable": MockPickup("a")}],
    ]

    grid = {
        Location(x, y - 1): MockCell(Location(x, y - 1), **CELLS[x][y])
        for y in range(3)
        for x in range(2)
    }
    grid[Location(0, 1)].interactable = ScoreLocation(grid[Location(0, 1)])
    test_game_state = GameState(WorldMap(grid, {}), avatar_manager)
    return test_game_state.serialize()