@@ -20,8 +20,8 @@ class GameBoard(GameObject):
2020
2121 Map Size:
2222 ---------
23- map_size is a Vector object, allowing you to specify the size of the (x, y) plane of the game board.
24- For example, a Vector object with an 'x' of 5 and a 'y' of 7 will create a board 5 tiles wide and
23+ ` map_size` is a Vector object, allowing you to specify the size of the (x, y) plane of the game board.
24+ For example, a Vector object with an 'x' of 5 and a 'y' of 7 will set a boarder of 5 tiles wide and
2525 7 tiles long.
2626
2727 Example:
@@ -39,70 +39,21 @@ class GameBoard(GameObject):
3939
4040 Locations:
4141 ----------
42- This is the bulkiest part of the generation.
43-
44- The locations field is a dictionary with a key of a tuple of Vectors, and the value being a list of
45- GameObjects (the key **must** be a tuple instead of a list because Python requires dictionary keys to be
46- immutable).
47-
48- This is used to assign the given GameObjects the given coordinates via the Vectors. This is done in two ways:
49-
50- Statically:
51- If you want a GameObject to be at a specific coordinate, ensure that the key-value pair is
52- *ONE* Vector and *ONE* GameObject.
53- An example of this would be the following:
54- ::
55- locations = { (vector_2_4) : [station_0] }
56-
57- In this example, vector_2_4 contains the coordinates (2, 4). (Note that this naming convention
58- isn't necessary, but was used to help with the concept). Furthermore, station_0 is the
59- GameObject that will be at coordinates (2, 4).
60-
61- Dynamically:
62- If you want to assign multiple GameObjects to different coordinates, use a key-value
63- pair of any length.
64-
65- **NOTE**: The length of the tuple and list *MUST* be equal, otherwise it will not
66- work. In this case, the assignments will be random. An example of this would be the following:
67- ::
68- locations =
69- {
70- (vector_0_0, vector_1_1, vector_2_2) : [station_0, station_1, station_2]
71- }
72-
73- (Note that the tuple and list both have a length of 3).
74-
75- When this is passed in, the three different vectors containing coordinates (0, 0), (1, 1), or
76- (2, 2) will be randomly assigned station_0, station_1, or station_2.
77-
78- If station_0 is randomly assigned at (1, 1), station_1 could be at (2, 2), then station_2 will be at (0, 0).
79- This is just one case of what could happen.
80-
81- Lastly, another example will be shown to explain that you can combine both static and
82- dynamic assignments in the same dictionary:
83- ::
84- locations =
85- {
86- (vector_0_0) : [station_0],
87- (vector_0_1) : [station_1],
88- (vector_1_1, vector_1_2, vector_1_3) : [station_2, station_3, station_4]
89- }
90-
91- In this example, station_0 will be at vector_0_0 without interference. The same applies to
92- station_1 and vector_0_1. However, for vector_1_1, vector_1_2, and vector_1_3, they will randomly
93- be assigned station_2, station_3, and station_4.
42+ The locations field is a dictionary with a key of a vector with a value of GameObjectContainer.
43+ Every object in a GameObjectContainer will be store at the specified location.
44+ Each container will function like a stack, where you can only place a new object at the top of the stack.
9445
9546 -----
9647
9748 Walled:
9849 -------
9950 This is simply a bool value that will create a wall barrier on the boundary of the game_board. If
100- walled is True, the wall will be created for you .
51+ walled is True, the wall will be generated .
10152
102- For example, let the dimensions of the map be (5, 7). There will be wall Objects horizontally across
103- x = 0 and x = 4. There will also be wall Objects vertically at y = 0 and y = 6
53+ For example, let the dimensions of the map be (5, 7). There will be Wall objects horizontally across
54+ x = 0 and x = 4. There will also be Wall objects vertically at y = 0 and y = 6
10455
105- Below is a visual example of this, with 'x' being where the wall Objects are.
56+ Below is a visual example of this, with 'x' being where the Wall objects are.
10657
10758 Example:
10859 ::
@@ -206,10 +157,10 @@ def walled(self, walled: bool) -> None:
206157 self .__walled = walled
207158
208159 def generate_map (self ) -> None :
209- # Dictionary Init
210- self . game_map = self .__map_init ()
211-
212- def __map_init ( self ) -> dict [ Vector , GameObjectContainer ]:
160+ """
161+ Populates the game map based off self.locations.
162+ :return: None
163+ """
213164 output : dict [Vector , GameObjectContainer ] = dict ()
214165
215166 # Update all Avatar positions if they are to be placed on the map
@@ -229,7 +180,7 @@ def __map_init(self) -> dict[Vector, GameObjectContainer]:
229180
230181 # convert locations dict to go_container
231182 output .update ({vec : GameObjectContainer (objs ) for vec , objs in self .locations .items ()})
232- return output
183+ self . game_map = output
233184
234185 def get (self , coords : Vector ) -> GameObjectContainer | None :
235186 """
@@ -322,7 +273,7 @@ def is_occupiable(self, coords: Vector) -> bool:
322273 isinstance (self .get (coords ).get_top (), Occupiable ))
323274
324275 # Returns the Vector and a list of GameObject for whatever objects you are trying to get
325- # CHANGE RETURN TYPE TO BE A DICT NOT A LIST OF TUPLES
276+ # TODO: CHANGE RETURN TYPE TO BE A DICT NOT A LIST OF TUPLES
326277 def get_objects (self , look_for : ObjectType ) -> list [tuple [Vector , list [GameObject ]]]:
327278 """
328279 Zips together the game map's keys and values. A nested for loop then iterates through the zipped lists, and
0 commit comments