Return to repo list

heart-of-gold

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

commit e08614854f3dc849215ca674049c84d94cc316ec
parent 4abf9b566c2e633d7c553418c1bfe8412563c533
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Mon, 23 Nov 2020 13:14:05 -0600

Filling out more of stat screen

Diffstat:
Mdata/img/action_buttons_1.png | 0
Mdata/json/items.json | 4++--
Mdata/json/pieces.json | 2+-
Msrc/constants.py | 2+-
Msrc/piece.py | 11++++++++---
Msrc/status.py | 61++++++++++++++++++++++++++++++++++++++++++++++++++++---------
6 files changed, 64 insertions(+), 16 deletions(-)

diff --git a/data/img/action_buttons_1.png b/data/img/action_buttons_1.png Binary files differ. diff --git a/data/json/items.json b/data/json/items.json @@ -21,7 +21,7 @@ "GARD" : 0, "PUSH" : 0, "MOVE" : 0, - "SKIL" : 0, + "SKLL" : 0, "PASS" : 0 }, "effects" : [] @@ -48,7 +48,7 @@ "GARD" : 0, "PUSH" : 0, "MOVE" : 0, - "SKIL" : 0, + "SKLL" : 0, "PASS" : 0 }, "effects" : [] diff --git a/data/json/pieces.json b/data/json/pieces.json @@ -20,7 +20,7 @@ "GARD" : 1, "PUSH" : 2, "MOVE" : 6, - "SKIL" : 3, + "SKLL" : 3, "PASS" : 4 }, "growth" : { diff --git a/src/constants.py b/src/constants.py @@ -75,7 +75,7 @@ WEAPON_TYPE_BONUSES = { # Stat constants BASIC_STATS = ["ATK", "DEF", "INT", "WIS", "SPD", "ACC", "LUK"] -RESERVE_STATS = ["MOVE", "INIT", "CNTR", "GARD", "PUSH", "SKIL", "PASS"] +RESERVE_STATS = ["MOVE", "INIT", "CNTR", "GARD", "PUSH", "SKLL", "PASS"] OTHER_STATS = ["HP", "EXP", "LVL", "RNK"] # Enums diff --git a/src/piece.py b/src/piece.py @@ -61,6 +61,7 @@ class PieceManager(manager.Manager): n_sheet = self.bus.fetch("sheet_manager", "sheets")[work["sheet"]] n_anim = self.bus.fetch("sheet_manager", "animations")[work["sheet"]][work["animation"]] n_name = work["name"] + n_class = work["class"] n_pic = work["pictures"] n_lvl = work["level"] n_exp = work["exp"] @@ -73,7 +74,7 @@ class PieceManager(manager.Manager): n_team = work["team"] n_equip = work["equipment"] n_growth = work["growth"] - np = Piece(n_sheet, (0, 0), n_anim, True, self, n_name, n_pic, n_lvl, n_exp, n_rank, n_aff, n_tise, False, n_nstats, n_mod, n_dist, + np = Piece(n_sheet, (0, 0), n_anim, True, self, n_name, n_class, n_pic, n_lvl, n_exp, n_rank, n_aff, n_tise, False, n_nstats, n_mod, n_dist, n_team, n_equip, n_growth) np.assign_tile(tuple(work["tile"]), self.bus.fetch("board_manager", "board_tile_layer")[tuple(work["tile"])]) np.snap_to_tile() @@ -110,6 +111,7 @@ class PieceManager(manager.Manager): "animated" : True, "passable" : False, "pictures" : jsondef[p]["replace"]["pictures"] if "pictures" in jsondef[p]["replace"].keys() else temp["pictures"], + "class" : temp["class"], "level" : jsondef[p]["level"], "exp" : jsondef[p]["exp"], "rank" : jsondef[p]["rank"], @@ -248,8 +250,9 @@ class Piece(entity.Entity): """ def __init__(self, sheet, sprite = (0, 0), animation = None, animated = False, - manager = None, name = None, pictures = None, level = None, exp = None, rank = None, affinity = None, expertise = None, - passable = False, normal_stats = None, stat_mod = None, stat_dist = None, team = None, equipment = None, growth = None): + manager = None, name = None, classname = None, pictures = None, level = None, exp = None, rank = None, affinity = None, + expertise = None, passable = False, normal_stats = None, stat_mod = None, stat_dist = None, team = None, equipment = None, + growth = None): # Parent initialization super().__init__(sheet, sprite, animation, animated) @@ -260,6 +263,7 @@ class Piece(entity.Entity): # Others self.manager = manager self.name = name + self.classname = classname self.level = 1 self.rank = rank self.exp = exp @@ -475,6 +479,7 @@ class Piece(entity.Entity): if self.active_stats != None and self.normal_stats != None: return { "name" : self.name, + "class" : self.classname, "level" : self.level, "exp" : self.exp, "rank" : self.rank, diff --git a/src/status.py b/src/status.py @@ -34,6 +34,8 @@ class StatusDisplay(entity.Entity): self.affinity_icon = None self.name_surface = None self.name_surface_rect = None + self.class_surface = None + self.class_surface_rect = None self.stat_surfaces = { i: None for i in self.stat_def["normal_stats"].keys() } self.stat_surface_rects = { i: None for i in self.stat_def["normal_stats"].keys() } self.equipment_surfaces = { i: None for i in self.stat_def["equipment"].keys() } @@ -42,9 +44,10 @@ class StatusDisplay(entity.Entity): # Surface base positions # TODO: hardcoded self.affinity_icon_position = (504, 84) - self.name_surface_position = (94, 96) + self.name_surface_position = (94, 95) + self.class_surface_position = (94, 152) self.stat_surfaces_position = (140, 216) - self.equipment_surface_position = (300, 216) + self.equipment_surfaces_position = (510, 224) # Load up self.load_subs() @@ -71,27 +74,63 @@ class StatusDisplay(entity.Entity): self.name_surface = self.font.render(self.stat_def["name"], False, (0, 0, 0)).convert() self.name_surface_rect = self.name_surface.get_rect() self.name_surface_rect.topleft = self.name_surface_position + self.class_surface = self.font.render(self.stat_def["class"], False, (0, 0, 0)).convert() + self.class_surface_rect = self.class_surface.get_rect() + self.class_surface_rect.topleft = self.class_surface_position self.stat_surfaces["ATK"] = self.font.render(str(self.stat_def["active_stats"]["ATK"]), False, (0, 0, 0)).convert() self.stat_surface_rects["ATK"] = self.stat_surfaces["ATK"].get_rect() - self.stat_surface_rects["ATK"].topleft = (self.stat_surfaces_position[0] + (0), self.stat_surfaces_position[1]) + self.stat_surface_rects["ATK"].topleft = self.stat_surfaces_position self.stat_surfaces["INT"] = self.font.render(str(self.stat_def["active_stats"]["INT"]), False, (0, 0, 0)).convert() self.stat_surface_rects["INT"] = self.stat_surfaces["INT"].get_rect() - self.stat_surface_rects["INT"].topleft = (self.stat_surfaces_position[0] + (150), self.stat_surfaces_position[1]) + self.stat_surface_rects["INT"].topleft = (self.stat_surfaces_position[0] + 150, self.stat_surfaces_position[1]) self.stat_surfaces["DEF"] = self.font.render(str(self.stat_def["active_stats"]["DEF"]), False, (0, 0, 0)).convert() self.stat_surface_rects["DEF"] = self.stat_surfaces["DEF"].get_rect() - self.stat_surface_rects["DEF"].topleft = (self.stat_surfaces_position[0] + (0), self.stat_surfaces_position[1] + 22) + self.stat_surface_rects["DEF"].topleft = (self.stat_surfaces_position[0], self.stat_surfaces_position[1] + 22) self.stat_surfaces["WIS"] = self.font.render(str(self.stat_def["active_stats"]["WIS"]), False, (0, 0, 0)).convert() self.stat_surface_rects["WIS"] = self.stat_surfaces["WIS"].get_rect() - self.stat_surface_rects["WIS"].topleft = (self.stat_surfaces_position[0] + (150), self.stat_surfaces_position[1] + 22) + self.stat_surface_rects["WIS"].topleft = (self.stat_surfaces_position[0] + 150, self.stat_surfaces_position[1] + 22) self.stat_surfaces["ACC"] = self.font.render(str(self.stat_def["active_stats"]["ACC"]), False, (0, 0, 0)).convert() self.stat_surface_rects["ACC"] = self.stat_surfaces["ACC"].get_rect() - self.stat_surface_rects["ACC"].topleft = (self.stat_surfaces_position[0] + (0), self.stat_surfaces_position[1] + 45) + self.stat_surface_rects["ACC"].topleft = (self.stat_surfaces_position[0], self.stat_surfaces_position[1] + 45) self.stat_surfaces["SPD"] = self.font.render(str(self.stat_def["active_stats"]["SPD"]), False, (0, 0, 0)).convert() self.stat_surface_rects["SPD"] = self.stat_surfaces["SPD"].get_rect() - self.stat_surface_rects["SPD"].topleft = (self.stat_surfaces_position[0] + (150), self.stat_surfaces_position[1] + 45) + self.stat_surface_rects["SPD"].topleft = (self.stat_surfaces_position[0] + 150, self.stat_surfaces_position[1] + 45) self.stat_surfaces["LUK"] = self.font.render(str(self.stat_def["active_stats"]["LUK"]), False, (0, 0, 0)).convert() self.stat_surface_rects["LUK"] = self.stat_surfaces["LUK"].get_rect() - self.stat_surface_rects["LUK"].topleft = (self.stat_surfaces_position[0] + (0), self.stat_surfaces_position[1] + 69) + self.stat_surface_rects["LUK"].topleft = (self.stat_surfaces_position[0], self.stat_surfaces_position[1] + 69) + self.stat_surfaces["MOVE"] = self.font.render(str(self.stat_def["active_stats"]["MOVE"]), False, (0, 0, 0)).convert() + self.stat_surface_rects["MOVE"] = self.stat_surfaces["MOVE"].get_rect() + self.stat_surface_rects["MOVE"].topleft = (self.stat_surfaces_position[0] + 18, self.stat_surfaces_position[1] + 89) + self.stat_surfaces["INIT"] = self.font.render(str(self.stat_def["active_stats"]["INIT"]), False, (0, 0, 0)).convert() + self.stat_surface_rects["INIT"] = self.stat_surfaces["INIT"].get_rect() + self.stat_surface_rects["INIT"].topleft = (self.stat_surfaces_position[0] + 158, self.stat_surfaces_position[1] + 89) + self.stat_surfaces["GARD"] = self.font.render(str(self.stat_def["active_stats"]["GARD"]), False, (0, 0, 0)).convert() + self.stat_surface_rects["GARD"] = self.stat_surfaces["GARD"].get_rect() + self.stat_surface_rects["GARD"].topleft = (self.stat_surfaces_position[0] + 18, self.stat_surfaces_position[1] + 111) + self.stat_surfaces["PASS"] = self.font.render(str(self.stat_def["active_stats"]["PASS"]), False, (0, 0, 0)).convert() + self.stat_surface_rects["PASS"] = self.stat_surfaces["PASS"].get_rect() + self.stat_surface_rects["PASS"].topleft = (self.stat_surfaces_position[0] + 158, self.stat_surfaces_position[1] + 111) + self.stat_surfaces["PUSH"] = self.font.render(str(self.stat_def["active_stats"]["PUSH"]), False, (0, 0, 0)).convert() + self.stat_surface_rects["PUSH"] = self.stat_surfaces["PUSH"].get_rect() + self.stat_surface_rects["PUSH"].topleft = (self.stat_surfaces_position[0] + 18, self.stat_surfaces_position[1] + 132) + self.stat_surfaces["SKLL"] = self.font.render(str(self.stat_def["active_stats"]["SKLL"]), False, (0, 0, 0)).convert() + self.stat_surface_rects["SKLL"] = self.stat_surfaces["SKLL"].get_rect() + self.stat_surface_rects["SKLL"].topleft = (self.stat_surfaces_position[0] + 158, self.stat_surfaces_position[1] + 132) + self.stat_surfaces["CNTR"] = self.font.render(str(self.stat_def["active_stats"]["CNTR"]), False, (0, 0, 0)).convert() + self.stat_surface_rects["CNTR"] = self.stat_surfaces["CNTR"].get_rect() + self.stat_surface_rects["CNTR"].topleft = (self.stat_surfaces_position[0] + 18, self.stat_surfaces_position[1] + 154) + + for e in self.equipment_surfaces: + if self.stat_def["equipment"][e] != None: + self.equipment_surfaces[e] = self.font.render(ITEMBASE[self.stat_def["equipment"][e]]["name"], False, (0, 0, 0)).convert() + else: + self.equipment_surfaces[e] = self.font.render("-----", False, (0, 0, 0)).convert() + self.equipment_surface_rects[e] = self.equipment_surfaces[e].get_rect() + self.equipment_surface_rects["weapon"].topleft = self.equipment_surfaces_position + self.equipment_surface_rects["armor"].topleft = (self.equipment_surfaces_position[0], self.equipment_surfaces_position[1] + 28) + self.equipment_surface_rects["acc1"].topleft = (self.equipment_surfaces_position[0], self.equipment_surfaces_position[1] + 56) + self.equipment_surface_rects["acc2"].topleft = (self.equipment_surfaces_position[0], self.equipment_surfaces_position[1] + 84) + self.equipment_surface_rects["acc3"].topleft = (self.equipment_surfaces_position[0], self.equipment_surfaces_position[1] + 112) def update(self, surface = None): """ @@ -101,6 +140,10 @@ class StatusDisplay(entity.Entity): self.affinity_icon.update(surface) super().update(surface) surface.blit(self.name_surface, self.name_surface_rect) + surface.blit(self.class_surface, self.class_surface_rect) for s in self.stat_surfaces: if self.stat_surfaces[s] != None: surface.blit(self.stat_surfaces[s], self.stat_surface_rects[s]) + for e in self.equipment_surfaces: + if self.equipment_surfaces[e] != None: + surface.blit(self.equipment_surfaces[e], self.equipment_surface_rects[e])