Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

commit 0d01389eaac81d1b915cb739b1687d098fb55992
parent d80a65b2f105a7de0bd783c43dd310a51f04768a
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Thu, 24 Sep 2020 20:37:24 -0500

Added teams

Diffstat:
Mdata/json/ents/testmap1.json | 3++-
Msrc/vgo.py | 10++++++----
2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/data/json/ents/testmap1.json b/data/json/ents/testmap1.json @@ -7,6 +7,7 @@ "animation" : "stand_L", "animated" : true, "passable" : false, - "tile" : [5, 4] + "tile" : [5, 4], + "team" : "Player" } } diff --git a/src/vgo.py b/src/vgo.py @@ -222,7 +222,7 @@ class Piece(Entity): sligthly modified move_motion and set_motion methods. """ - def __init__(self, name, ent_id, sheet, animation = None, animated = False, passable = False, unit = None): + def __init__(self, name, ent_id, sheet, animation = None, animated = False, passable = False, unit = None, team = None): # Parent initialization super().__init__(name, ent_id, sheet, animation, animated, passable, unit) @@ -231,7 +231,8 @@ class Piece(Entity): self.facing = "D" # TODO: This should ABSOLUTELY be an enum # Others - self.back_to_stand = False #TODO: This may not be the best way + self.team = team # TODO: team maybe should be defined in unit + self.back_to_stand = False # TODO: This may not be the best way def set_motion(self, target_pos, speed): """ @@ -317,7 +318,8 @@ class EntityManager(manager.Manager): ne = Piece(j[e]["name"], self.total_entities, self.game.sheet_manager.loaded_sheets[j[e]["sheet"]], self.game.sheet_manager.animations[j[e]["sheet"]][j[e]["animation"]], - j[e]["animated"], j[e]["passable"], unit.Unit(self, self.game.unit_manager.get_stats(j[e]["name"]))) + j[e]["animated"], j[e]["passable"], unit.Unit(self, self.game.unit_manager.get_stats(j[e]["name"])), + j[e]["team"]) ne.assign_tile(self.game.board_manager.get_tile_at_tile_pos(tuple(j[e]["tile"]))) ne.snap_to_tile() self.add_entity(ne) @@ -359,7 +361,7 @@ class EntityManager(manager.Manager): # TODO: Eventually this should return info about the team of the selected # entity so that GameInterface can make control mode decisions. e = self.get_entities_by_tile(tile_def) - if e != []: + if e != [] and e[0].team == "Player": self.selected_entity = e[0] # Select only the topmost ent on this tile self.game.board_manager.display_as_move_range(self.get_entity_legal_move_tile_pos(self.selected_entity)) return True