diff --git a/battle/action/BattleItem.gd b/battle/action/BattleItem.gd new file mode 100644 index 0000000..28e3311 --- /dev/null +++ b/battle/action/BattleItem.gd @@ -0,0 +1,14 @@ +class_name BattleItem extends BattleAction + +var stack:ItemStack + +func _init(params:Dictionary) -> void: + super(params) + assert(params.has("stack")) + self.stack = params.get("stack") + +func perform(params:Dictionary) -> void: + super.perform(params) + + var user:BattleFighter = params.get("user") + var target:BattleFighter = params.get("target") \ No newline at end of file diff --git a/battle/action/BattleItem.gd.uid b/battle/action/BattleItem.gd.uid new file mode 100644 index 0000000..e098da4 --- /dev/null +++ b/battle/action/BattleItem.gd.uid @@ -0,0 +1 @@ +uid://cdx3w0ctj8f4q diff --git a/battle/action/BattleMove.gd b/battle/action/BattleMove.gd index c31fc25..6e3141a 100644 --- a/battle/action/BattleMove.gd +++ b/battle/action/BattleMove.gd @@ -6,6 +6,12 @@ enum MoveType { MAGICAL, } +enum BattleMoveResult { + HIT, + MISS, + CRIT, +} + var name:String var power:int var mpCost:int @@ -21,9 +27,32 @@ func _init(params:Dictionary) -> void: self.accuracy = params.get("accuracy", 1.0) self.moveType = params.get("moveType", MoveType.PHYSICAL) self.fieldUse = params.get("fieldUse", false) + +func perform(params:Dictionary): + super.perform(params) + + var user:BattleFighter = params.get("user") + var target:BattleFighter = params.get("target") -func getPriority(_fighter:BattleFighter) -> float: - return 1.0 + # What to do if target is dead? + if target.status == BattleFighter.Status.DEAD: + print("Target is already dead. Move has no effect.") + assert(false) + + # TODO: Determine damage + var damage:int = 0 + var isCrit:bool = false + var isMiss:bool = false + user.mpConsume(self.mpCost) + + if isMiss: + print("ATTACK MISS") + assert(false) + + if isCrit: + print("CRITICAL HIT!") + target.damage(damage, isCrit) + print("DAMAGE DONE") # Moves static var MOVE_PUNCH = BattleMove.new({ diff --git a/battle/fighter/BattleFighter.gd b/battle/fighter/BattleFighter.gd index ade093c..c53c83e 100644 --- a/battle/fighter/BattleFighter.gd +++ b/battle/fighter/BattleFighter.gd @@ -65,7 +65,7 @@ func _init(params:Dictionary) -> void: self.mp = self.maxMp func damage(amount:int, crit:bool) -> void: - assert(amount > 0) + assert(amount >= 0) if status == Status.DEAD: return health = max(health - amount, 0) diff --git a/cutscene/battle/BattleCutsceneAction.gd b/cutscene/battle/BattleCutsceneAction.gd index a4c5b1f..e7c0c52 100644 --- a/cutscene/battle/BattleCutsceneAction.gd +++ b/cutscene/battle/BattleCutsceneAction.gd @@ -3,6 +3,7 @@ class_name BattleCutsceneAction static func battleDecisionCallable(_params:Dictionary) -> int: print("Executing battle action...") await UI.TEXTBOX.setTextAndWait("Performing battle decision") + var decision:BattleDecision = _params["decision"] return Cutscene.CUTSCENE_CONTINUE