Party stuff

This commit is contained in:
2026-01-10 17:23:29 -06:00
parent db15eeb672
commit 6f036aac77
12 changed files with 106 additions and 3 deletions

View File

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

View File

@@ -1 +1,23 @@
class_name BattleScene extends Node3D class_name BattleScene extends Node3D
enum BattlePosition {
LEFT_TOP_BACK,
LEFT_TOP_FRONT,
LEFT_MIDDLE_BACK,
LEFT_MIDDLE_FRONT,
LEFT_BOTTOM_BACK,
LEFT_BOTTOM_FRONT,
RIGHT_TOP_BACK,
RIGHT_TOP_FRONT,
RIGHT_MIDDLE_BACK,
RIGHT_MIDDLE_FRONT,
RIGHT_BOTTOM_BACK,
RIGHT_BOTTOM_FRONT,
# Should have pinned positions for enemies as well?
}
# @export var fighters:Node3D = null
# func start(

View File

@@ -1,4 +1,6 @@
[gd_scene format=3 uid="uid://dy54m7dvjgqta"] [gd_scene load_steps=2 format=3 uid="uid://dy54m7dvjgqta"]
[ext_resource type="PackedScene" uid="uid://cf4c61ij6elir" path="res://battle/fighter/BattleFighter.tscn" id="1_abr1f"]
[node name="BattleScene" type="Node3D"] [node name="BattleScene" type="Node3D"]
@@ -13,3 +15,7 @@ layout_mode = 0
offset_right = 40.0 offset_right = 40.0
offset_bottom = 12.0 offset_bottom = 12.0
text = "Battle" text = "Battle"
[node name="Fighters" type="Node" parent="."]
[node name="BattleFighter" parent="Fighters" instance=ExtResource("1_abr1f")]

49
battle/BattleStats.gd Normal file
View 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)

View File

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

View File

@@ -0,0 +1,7 @@
class_name BattleFighter extends Node3D
var stats:BattleStats = null
func setup(stats:BattleStats) -> void:
assert(stats != null)
self.stats = stats

View File

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

View File

@@ -0,0 +1,7 @@
[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

@@ -1 +1,3 @@
class_name PartySingleton extends Node class_name PartySingleton extends Node
static var PARTY_JOHN = PartyMember.new()

6
party/PartyMember.gd Normal file
View File

@@ -0,0 +1,6 @@
class_name PartyMember
var stats:BattleStats
func _init() -> void:
stats = BattleStats.new()

1
party/PartyMember.gd.uid Normal file
View File

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

View File

@@ -55,4 +55,4 @@ func onSceneChange(newScene:SceneSingleton.SceneType) -> void:
removeAndHide(initial) removeAndHide(initial)
removeAndHide(overworld) removeAndHide(overworld)
removeAndHide(battle) removeAndHide(battle)
removeAndHide(cooking) removeAndHide(cooking)