This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
World Map
Alexandru Dan edited this page Aug 30, 2017
·
9 revisions
The World Map is the central component of the simulation. The class itself consists of a grid and a set of JSON settings. The grid consists of a dictionary of type <Location, Cell>.
A cell has the following components:
- location - (x, y) pairs that can be added together, serialized, compared, etc.
- avatars - see Game Objects for more details
- pickup - see Game Objects for more details
- cell content - the cell content can either be a score cell, an obstacle or a plain floor cell
- fog of war
- actions - an array where the intended actions of different avatars are registered and, afterwards, applied
World Map has a lot of misc functionality, as multiple other objects communicate with it and need a simple API.
Cell specific functionality:
- get_cell
- all_cells
- score_cells
- pickup_cells
Map dimension functionality:
- is_on_map
- max_x
- max_y
- min_x
- min_y
- num_cols
- num_rows
- num_cells
The most important responsibility of the world map class is the self update after the intended character moves have been recored by the turn manager. The function udpate
is called by the Turn Manager.
This functionality is quite broad and could be considered for refactoring in a different class.
The update cycle is as follows:
- update avatars
- apply score: each avatar received a score
- apply pickups: each avatar grabs a pickup if present
- update map:
- expand the map so that it fits the size of the avatars if more avatars arrive
- reset score locations: new score locations are generated
- add pickups: new pickups are generated
Map expansion