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,
}
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({

View File

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