Party progress

This commit is contained in:
2026-01-10 23:00:05 -06:00
parent 6f036aac77
commit 78cc69bffe
15 changed files with 276 additions and 82 deletions

View File

@@ -1,7 +1,63 @@
class_name BattleFighter extends Node3D
class_name BattleFighter
var stats:BattleStats = null
enum Status {
NORMAL,
DEAD,
}
func setup(stats:BattleStats) -> void:
assert(stats != null)
self.stats = stats
var health:int
var maxHealth:int
var mp:int
var maxMp:int
var status:Status = Status.NORMAL
var attack:int = 10
var defense:int = 5
var speed:int = 5
var magic:int = 5
var luck:int = 1
func _init(
maxHealth:int = 100,
maxMp:int = 50,
) -> void:
self.maxHealth = maxHealth
self.health = maxHealth
self.maxMp = maxMp
self.mp = maxMp
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)
func isCrit() -> bool:
# 10% chance of a crit
var chance = 10 + min(luck * 5, 60)
var roll = randi() % 100
return roll < chance

View File

@@ -1,7 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://cf4c61ij6elir"]
[ext_resource type="Script" uid="uid://ck7wheiv8wptn" path="res://battle/fighter/BattleFighter.gd" id="1_xm54w"]
[node name="BattleFighter" type="Node3D"]
script = ExtResource("1_xm54w")
metadata/_custom_type_script = "uid://ck7wheiv8wptn"

View File

@@ -0,0 +1,15 @@
class_name BattleFighterScene extends Node3D
var fighter:BattleFighter
func _ready() -> void:
self.visible = false
if fighter:
setFighter(fighter)
func setFighter(fighter:BattleFighter) -> void:
print("Setting fighter: %s" % fighter)
# Set up the visual representation of the fighter here
self.fighter = fighter
self.visible = true
pass

View File

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

View File

@@ -0,0 +1,16 @@
[gd_scene load_steps=4 format=3 uid="uid://d1xyb0hdf1yeh"]
[ext_resource type="Script" uid="uid://bgycdhsouwhwt" path="res://battle/fighter/BattleFighterScene.gd" id="1_veb1i"]
[sub_resource type="BoxMesh" id="BoxMesh_veb1i"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_e55p4"]
shading_mode = 0
[node name="BattleFighterScene" type="Node3D"]
script = ExtResource("1_veb1i")
metadata/_custom_type_script = "uid://bgycdhsouwhwt"
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("BoxMesh_veb1i")
surface_material_override/0 = SubResource("StandardMaterial3D_e55p4")