prog
This commit is contained in:
14
battle/action/BattleItem.gd
Normal file
14
battle/action/BattleItem.gd
Normal 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")
|
||||||
1
battle/action/BattleItem.gd.uid
Normal file
1
battle/action/BattleItem.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cdx3w0ctj8f4q
|
||||||
@@ -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
|
||||||
@@ -21,9 +27,32 @@ func _init(params:Dictionary) -> void:
|
|||||||
self.accuracy = params.get("accuracy", 1.0)
|
self.accuracy = params.get("accuracy", 1.0)
|
||||||
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 perform(params:Dictionary):
|
||||||
|
super.perform(params)
|
||||||
|
|
||||||
|
var user:BattleFighter = params.get("user")
|
||||||
|
var target:BattleFighter = params.get("target")
|
||||||
|
|
||||||
func getPriority(_fighter:BattleFighter) -> float:
|
# What to do if target is dead?
|
||||||
return 1.0
|
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({
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user