Grimmys / rpg_tactical_fantasy_game

A tactical turn-based game project in pygame, open to support
GNU General Public License v3.0
392 stars 85 forks source link

save game : TypeError: 'LevelEntityCollections' object is not subscriptable #55

Closed arek121281 closed 1 year ago

arek121281 commented 1 year ago

In my opnion in file save_state_manager.py shold be: self.save_collection("foes", "foe", self.level.entities.foes) not self.save_collection("foes", "foe", self.level.entities["foes"]) ######################################################################################## TypeError: 'LevelEntityCollections' object is not subscriptable

pygame 2.0.3 (SDL 2.0.16, Python 3.9.7) Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "/home/arek/helena/rpg_tactical_fantasy_game/main.py", line 95, in main_loop(scene_manager, main_screen, pygame.time.Clock()) File "/home/arek/helena/rpg_tactical_fantasy_game/main.py", line 33, in main_loop quit_game = game_controller.process_game_iteration() File "/home/arek/helena/rpg_tactical_fantasy_game/src/services/scene_manager.py", line 48, in process_game_iteration quit_game = self.active_scene.click(event.button, event.pos) File "/home/arek/helena/rpg_tactical_fantasy_game/src/scenes/level_scene.py", line 2162, in click self.left_click(position) File "/home/arek/helena/rpg_tactical_fantasy_game/src/scenes/level_scene.py", line 1982, in left_click self.menu_manager.click(1, position) File "/home/arek/helena/rpg_tactical_fantasy_game/virtual/lib/python3.9/site-packages/pygamepopup/menu_manager.py", line 156, in click self.active_menu.click(position)() File "/home/arek/helena/rpg_tactical_fantasy_game/src/services/menu_creator_manager.py", line 1380, in callback=lambda slot_id=i: save_game_function(slot_id), File "/home/arek/helena/rpg_tactical_fantasy_game/src/scenes/level_scene.py", line 374, in save_game save_state_manager.save_game(slot_id) File "/home/arek/helena/rpg_tactical_fantasy_game/src/services/save_state_manager.py", line 20, in save_game level = self.save_level() File "/home/arek/helena/rpg_tactical_fantasy_game/src/services/save_state_manager.py", line 49, in save_level entities = self.save_entities() File "/home/arek/helena/rpg_tactical_fantasy_game/src/services/save_state_manager.py", line 65, in save_entities self.save_collection("foes", "foe", self.level.entities["foes"]) TypeError: 'LevelEntityCollections' object is not subscriptable

Grimmys commented 1 year ago

Hi,

You are definitely correct. I can't understand why I didn't see this error earlier, I refactored entities that was previously a dict with keys instead of a class with attributes and guess I forgot to replace some references.

Thanks for your report! I'm going to fix it (or you can open a PR)

Grimmys commented 1 year ago

Fixed in #ac745c6eaf479d6c094259cd3d761f968e11e974