This commit is contained in:
2026-01-16 22:01:19 -06:00
parent 346e3f0607
commit c46afdac76
5 changed files with 48 additions and 3 deletions

View File

@@ -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")

View File

@@ -0,0 +1 @@
uid://cdx3w0ctj8f4q

View File

@@ -6,6 +6,12 @@ enum MoveType {
MAGICAL, MAGICAL,
} }
enum BattleMoveResult {
HIT,
MISS,
CRIT,
}
var name:String var name:String
var power:int var power:int
var mpCost:int var mpCost:int
@@ -22,8 +28,31 @@ func _init(params:Dictionary) -> void:
self.moveType = params.get("moveType", MoveType.PHYSICAL) self.moveType = params.get("moveType", MoveType.PHYSICAL)
self.fieldUse = params.get("fieldUse", false) self.fieldUse = params.get("fieldUse", false)
func getPriority(_fighter:BattleFighter) -> float: func perform(params:Dictionary):
return 1.0 super.perform(params)
var user:BattleFighter = params.get("user")
var target:BattleFighter = params.get("target")
# 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 # Moves
static var MOVE_PUNCH = BattleMove.new({ static var MOVE_PUNCH = BattleMove.new({

View File

@@ -65,7 +65,7 @@ func _init(params:Dictionary) -> void:
self.mp = self.maxMp self.mp = self.maxMp
func damage(amount:int, crit:bool) -> void: func damage(amount:int, crit:bool) -> void:
assert(amount > 0) assert(amount >= 0)
if status == Status.DEAD: if status == Status.DEAD:
return return
health = max(health - amount, 0) health = max(health - amount, 0)

View File

@@ -3,6 +3,7 @@ class_name BattleCutsceneAction
static func battleDecisionCallable(_params:Dictionary) -> int: static func battleDecisionCallable(_params:Dictionary) -> int:
print("Executing battle action...") print("Executing battle action...")
await UI.TEXTBOX.setTextAndWait("Performing battle decision") await UI.TEXTBOX.setTextAndWait("Performing battle decision")
var decision:BattleDecision = _params["decision"]
return Cutscene.CUTSCENE_CONTINUE return Cutscene.CUTSCENE_CONTINUE