commit 4abf9b566c2e633d7c553418c1bfe8412563c533
parent 71f7f900a6c3fc30cf6435465d4a38db84da8aa0
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Sun, 22 Nov 2020 22:56:24 -0600
Displaying affinities in stats
Diffstat:
8 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/data/board/testmap1/testmap1.json b/data/board/testmap1/testmap1.json
@@ -43,7 +43,7 @@
},
"stat_mod" : { },
"stat_dist" : { },
- "replace" : { "sheet" : "jisella_2", "pictures" : "jisella_pictures_2" }
+ "replace" : { "sheet" : "jisella_2", "pictures" : "jisella_pictures_2", "affinity" : "Miasma" }
},
"testent3" : {
"name" : "Faker2",
@@ -66,7 +66,7 @@
},
"stat_mod" : { },
"stat_dist" : { },
- "replace" : { "sheet" : "jisella_3", "pictures" : "jisella_pictures_3" }
+ "replace" : { "sheet" : "jisella_3", "pictures" : "jisella_pictures_3", "affinity" : "Wind" }
},
"testent4" : {
"name" : "SomeName",
@@ -89,6 +89,6 @@
},
"stat_mod" : { },
"stat_dist" : { },
- "replace" : { "sheet" : "jisella_4", "pictures" : "jisella_pictures_4" }
+ "replace" : { "sheet" : "jisella_4", "pictures" : "jisella_pictures_4", "affinity" : "Water" }
}
}
diff --git a/data/img/affinity_icons_1.png b/data/img/affinity_icons_1.png
Binary files differ.
diff --git a/data/img/affinity_icons_named_1.png b/data/img/affinity_icons_named_1.png
Binary files differ.
diff --git a/data/json/sheets.json b/data/json/sheets.json
@@ -126,7 +126,12 @@
},
"affinity_icons_1" : {
"filename" : "affinity_icons_1.png",
- "dimensions" : [64, 64],
+ "dimensions" : [142, 100],
+ "total_sprites" : 6
+ },
+ "affinity_icons_named_1" : {
+ "filename" : "affinity_icons_named_1.png",
+ "dimensions" : [142, 100],
"total_sprites" : 6
}
}
diff --git a/src/constants.py b/src/constants.py
@@ -42,7 +42,7 @@ SCENE_JSON_PATH = os.path.join(JSON_PATH, "scenes")
# Piece constants
CHARBASE = json.load(open(os.path.join(JSON_PATH, "pieces.json")))
-AFFINITIES = ("Fire", "Miasma", "Water", "Wind", "Life", "Lightning")
+AFFINITIES = ("Fire", "Wind", "Life", "Miasma", "Water", "Lightning")
# Item constants
ITEMBASE = json.load(open(os.path.join(JSON_PATH, "items.json")))
diff --git a/src/piece.py b/src/piece.py
@@ -475,6 +475,11 @@ class Piece(entity.Entity):
if self.active_stats != None and self.normal_stats != None:
return {
"name" : self.name,
+ "level" : self.level,
+ "exp" : self.exp,
+ "rank" : self.rank,
+ "affinity" : self.affinity,
+ "expertise" : self.expertise,
"normal_stats" : self.normal_stats,
"active_stats" : self.active_stats,
"equipment" : self.equipment
diff --git a/src/status.py b/src/status.py
@@ -23,13 +23,15 @@ class StatusDisplay(entity.Entity):
"""
def __init__(self, sheet, sprite = (0, 0), animation = None, animated = None,
- stat_def = None):
+ manager = None, stat_def = None):
# Parent initialiazation
super().__init__(sheet, sprite, animation, animated)
# Other important values
+ self.manager = manager
self.stat_def = stat_def # Consists of a piece's active stats and normal stats, in a dict
self.font = pygame.font.Font(os.path.join(FONT_PATH, UI_FONT), SCREEN_HEIGHT // 34)
+ self.affinity_icon = None
self.name_surface = None
self.name_surface_rect = None
self.stat_surfaces = { i: None for i in self.stat_def["normal_stats"].keys() }
@@ -39,13 +41,28 @@ class StatusDisplay(entity.Entity):
# Surface base positions
# TODO: hardcoded
+ self.affinity_icon_position = (504, 84)
self.name_surface_position = (94, 96)
self.stat_surfaces_position = (140, 216)
self.equipment_surface_position = (300, 216)
# Load up
+ self.load_subs()
self.load_text()
+ def load_subs(self):
+ """
+ Load a sequence of subentities that are used in
+ a status display.
+ """
+ sh = self.manager.bus.fetch("sheet_manager", "sheets")
+ x = 0
+ y = 0
+ af = { i : j for i, j in zip(AFFINITIES, [(0, 0), (1, 0), (0, 1), (1, 1), (0, 2), (1, 2)]) }
+
+ self.affinity_icon = entity.Entity(sh["affinity_icons_named_1"], af[self.stat_def["affinity"]], None, False)
+ self.affinity_icon.set_position(self.affinity_icon_position)
+
def load_text(self):
"""
Load all the various text fields and
@@ -80,6 +97,8 @@ class StatusDisplay(entity.Entity):
"""
Update overwrite to handle drawing subsurfaces.
"""
+ if self.affinity_icon != None:
+ self.affinity_icon.update(surface)
super().update(surface)
surface.blit(self.name_surface, self.name_surface_rect)
for s in self.stat_surfaces:
diff --git a/src/turn.py b/src/turn.py
@@ -177,7 +177,7 @@ class TurnManager(manager.Manager):
"""
if piece != None:
sh = self.bus.fetch("sheet_manager", "sheets")["stat_screen_1"]
- self.stat_screen = status.StatusDisplay(sh, (0, 0), None, False, piece.get_full_stat_def())
+ self.stat_screen = status.StatusDisplay(sh, (0, 0), None, False, self, piece.get_full_stat_def())
else:
self.stat_screen = None