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,
|
||||
}
|
||||
|
||||
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({
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user