Party stuff
This commit is contained in:
49
battle/BattleStats.gd
Normal file
49
battle/BattleStats.gd
Normal file
@@ -0,0 +1,49 @@
|
||||
class_name BattleStats
|
||||
|
||||
# enum Type {
|
||||
# NEUTRAL,
|
||||
# FIRE,
|
||||
# ICE,
|
||||
# }
|
||||
|
||||
enum Status {
|
||||
NORMAL,
|
||||
DEAD,
|
||||
}
|
||||
|
||||
var health:int = 100
|
||||
var maxHealth:int = 100
|
||||
var mp:int = 50
|
||||
var maxMp:int = 50
|
||||
# var type:Type = Type.NEUTRAL
|
||||
var status:Status = Status.NORMAL
|
||||
|
||||
func damage(amount:int) -> void:
|
||||
assert(amount > 0)
|
||||
if status == Status.DEAD:
|
||||
return
|
||||
health = max(health - amount, 0)
|
||||
if health == 0:
|
||||
status = Status.DEAD
|
||||
|
||||
func heal(amount:int) -> void:
|
||||
assert(amount > 0)
|
||||
if status == Status.DEAD:
|
||||
return
|
||||
health = min(health + amount, maxHealth)
|
||||
|
||||
func revive(health:int) -> void:
|
||||
assert(health > 0)
|
||||
if status != Status.DEAD:
|
||||
return
|
||||
health = min(health, maxHealth)
|
||||
status = Status.NORMAL
|
||||
self.health = health
|
||||
|
||||
func mpConsume(amount:int) -> void:
|
||||
assert(amount > 0)
|
||||
mp = max(mp - amount, 0)
|
||||
|
||||
func mpRestore(amount:int) -> void:
|
||||
assert(amount > 0)
|
||||
mp = min(mp + amount, maxMp)
|
||||
Reference in New Issue
Block a user