Map builder & Exporter - UQcsse3200/2024-studio-1 GitHub Wiki

The MapGenerator class is responsible for dynamically creating and managing game maps. It provides functionality to generate rooms, connect them, and manipulate the map structure, and store item and animal information.

the RandomNumberGenerator is a utility class, that acts for the intent of creating repeatable seeds in actions.

  • MapGenerator Class: the Map generation class handler the creation of room to room connections and some difficulty system via these the a amount of rooms and connections. for this, the class takes a map size argument that when generating the rooms is used as a variable in a log function, this log function is to prevent linear and exponential behaviour with rooms. Thus allowing for difficulty to be artificially create by adding more rooms. To generate the rooms, it uses the RandomNumberGenerator child class, that is used with the second argument seed which is used to allow for repeatable behaviours between different maps based off the room. The Map generator would then be able to either export to be imported by mapFactory to allow for easy importation and saves later on, or would use the getter function to programmatically get the map and connection data.

  • RandomNumberGenerator Class: the RandomNumberGenerator was built with the intent to image

 public MapGenerator Map = MapGenerator(int mapSize, String seed)
 public RandomNumberGenerator rng = RandomNumberGenerator("testseed")

MapGenerator Testing and RandomNumberGenerator testing

both classes have automated testing for all code that can be tested automatically

for the export mechanism it has to be tested manually

Usage

Using the MapGenerator class is straightforward and pure. After creating the class, create the map with MapGenerator.create_map(), this will then generate all the map connections, animalIndexes, and ItemIndexes access room connections, player start location, and other map-specific data.

    MapFactory.getRoomConnections("0_0");

to get data from this class you can use getPositions to get a Hashmap<List>

    MapFactory.getPostion()
    MapFactory.getRoomDetails()

This would return the list of rooms or data(animal_index and item_index) that the input room (e.g "0_0") is

Inside the code

Why JSON Configuration?

Using JSON files for map configuration allows for greater flexibility and ease of use when creating maps, it also allows for most of the code for future features like "save" to be done with relative ease. It also has the interaction of allows the user to look at the map in the json if needed, because having a full map showing feature would be too difficult to implement.

Extensibility and Flexibility

The RandomNumberGenerator function was built with the intent of being reusable and flexible for different situations in mind

the MapGenerator class was built with the flexibility to allow the consumer to both export a json, or take information using the getters, however for this class, its primary reason for existing is to be as pure as possible, allow for as little changes as possible to be as repeatable as possible this class being flexible is against its intent

References

https://blog.hubspot.com/website/json-files#:~:text=A%20JSON%20file%20stores%20data,the%20values%20containing%20related%20data.

⚠️ **GitHub.com Fallback** ⚠️