commit 29a4bbdabe334c55872725bc8927e2ce5a897f2f
parent 0afd464a03ccdca725fe4d14a8af1748a7991df5
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Wed, 23 Dec 2020 13:50:41 -0600
skel of dialog system
Diffstat:
4 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/data/json/dialog.json b/data/json/dialog.json
@@ -0,0 +1,14 @@
+{
+ "test1" : [
+ {
+ "speaker" : "Jisella",
+ "icon" : null,
+ "text" : "This is a test of the dialog subsystem."
+ },
+ {
+ "speaker" : "Jisella",
+ "icon" : null,
+ "text" : "Further test."
+ }
+ ]
+}
diff --git a/src/constants.py b/src/constants.py
@@ -42,7 +42,7 @@ SCENE_JSON_PATH = os.path.join(JSON_PATH, "scenes")
ACTORS_PATH = os.path.join(IMAGE_PATH, "actors")
# Piece constants
-CHARBASE = json.load(open(os.path.join(JSON_PATH, "pieces.json")))
+with open(os.path.join(JSON_PATH, "pieces.json")) as f: CHARBASE = json.load(f)
AFFINITIES = ("Fire", "Wind", "Life", "Miasma", "Water", "Lightning")
AFFINITY_RELATIONS = {
"Fire" : { "Opposite" : "Wind", "Weak" : "Water", "Strong" : "Life" },
@@ -87,6 +87,9 @@ BASIC_STATS = ["ATK", "DEF", "INT", "WIS", "SPD", "ACC", "LUK"]
RESERVE_STATS = ["MOVE", "INIT", "CNTR", "GARD", "PUSH", "SKLL", "PASS"]
OTHER_STATS = ["HP", "EXP", "LVL", "RNK"]
+# Dialog constants
+with open(os.path.join(JSON_PATH, "dialog.json")) as f: DIALOGS = json.load(f)
+
# Enums
STATE_MODES = enum.Enum('STATE_MODES', 'Main_Menu_Mode Battle_Mode Still_Scene_Mode')
CTRL_MODES = enum.Enum('CTRL_MODES', 'No_Control Main_Menu_Normal Turn_Normal Turn_Select_Move Turn_Select_Attack Turn_Watch_Move Turn_Watch_Attack Turn_Display_Stats Turn_Watch_Guard Still_Scene_Normal')
diff --git a/src/dialog.py b/src/dialog.py
@@ -0,0 +1,37 @@
+import pygame
+from . import manager, entity
+from .constants import *
+
+#############
+# dialog.py #
+#############
+
+# This file contains the following:
+# 1. The DialogManager class, which controls the inter-mode bottom-of-the-screen conversation events
+
+###################################
+# Section 1 - DialogManager class #
+###################################
+
+class DialogManager(manager.Manager):
+ """
+ Manager class for the dialog boxes that display
+ either during battle or while at the base.
+ """
+
+ def __init__(self, game, bus, camera, name):
+
+ # Parent initialization
+ super().__init__(game, bus, camera, name)
+
+ # Other vals
+ self.dialog_sequence = []
+
+ def load_sequence(self, seq_id):
+ """
+ Load a dialog sequence from the dialog
+ definition. Only one sequence is loaded
+ at a time.
+ """
+ self.dialog_sequence = DIALOGS[seq_id]
+
diff --git a/src/piece.py b/src/piece.py
@@ -579,7 +579,7 @@ class Piece(entity.Entity):
if raw_damage <= 0:
self.damage_to_receive = 0
else:
- self.damage_to_receive = max(0, round(((raw_damage - (self.active_stats["DEF"] * 1.4)) + random.randint(-(self.active_stats["LUK"] // 2), self.active_stats["LUK"])) * affmod * guard_factor))
+ self.damage_to_receive = max(0, round((round((raw_damage - (self.active_stats["DEF"] * 1.4)) + random.randint(-(self.active_stats["LUK"] // 2), self.active_stats["LUK"])) * affmod) * guard_factor))
self.damage_timer = 100
if hit:
self.being_damaged = True