@@ -4,6 +4,24 @@ extends Node2D
44@onready var hero : Combatant = $ "../Hero"
55@onready var foe : Combatant = $ "../Enemy"
66
7+ func clear_status (u : Combatant ) -> void :
8+ for k in StatusEffects .KEYS .keys ():
9+ u .set_status_flag (k , false )
10+
11+ func demo_phys (label : String ) -> void :
12+ var hp0 := foe .base_stats .hp
13+ var r := FF4DamageEngine .physical_damage (hero , foe )
14+ FF4DamageEngine .apply_result (foe , r )
15+ print (label , " -> " , r .pretty_str (), " (Enemy HP " , hp0 , " -> " , foe .base_stats .hp , ")" )
16+ foe .base_stats .hp = hp0
17+
18+ func demo_mag (label : String , power : int , elem : Element .Type ) -> void :
19+ var hp0 := foe .base_stats .hp
20+ var r := FF4DamageEngine .magical_damage (hero , foe , power , elem )
21+ r .apply_to (foe )
22+ print (label , " -> " , r .pretty_str (), " (Enemy HP " , hp0 , " -> " , foe .base_stats .hp , ")" )
23+ foe .base_stats .hp = hp0
24+
725func _ready ():
826 randomize ()
927 # Example enemy resistances
@@ -14,11 +32,44 @@ func _ready():
1432 Element .Type .DARK : "absorb"
1533 }
1634
17- # Physical attack
18- var r1 : FF4DamageEngine .CombatResult = FF4DamageEngine .physical_damage (hero , foe )
19- FF4DamageEngine .apply_result (foe , r1 )
20- print ("Phys -> " , r1 .pretty_str ())
35+ # Baseline (no statuses)
36+ clear_status (hero )
37+ clear_status (foe )
38+ demo_phys ("Phys baseline" )
39+ demo_mag ("Fire baseline" , 30 , Element .Type .FIRE )
40+
41+ # Defender has Protect (physical incoming halved)
42+ clear_status (hero )
43+ clear_status (foe )
44+ foe .set_status_flag (StatusEffects .Status .PROTECT , true )
45+ demo_phys ("Phys vs PROTECT" )
46+
47+ # Defender is Defending (halves incoming physical)
48+ clear_status (hero )
49+ clear_status (foe )
50+ foe .set_status_flag (StatusEffects .Status .DEFENDING , true )
51+ demo_phys ("Phys vs DEFENDING" )
52+
53+ # Attacker is Berserk (physical output up)
54+ clear_status (hero )
55+ clear_status (foe )
56+ hero .set_status_flag (StatusEffects .Status .BERSERK , true )
57+ demo_phys ("Phys with BERSERK" )
58+
59+ # Attacker is Blind (physical output down and lower hit chance; may miss)
60+ clear_status (hero )
61+ clear_status (foe )
62+ hero .set_status_flag (StatusEffects .Status .BLIND , true )
63+ for i in 3 :
64+ demo_phys ("Phys with BLIND (try %d )" % (i + 1 ))
65+
66+ # Defender has Shell (magical incoming halved)
67+ clear_status (hero )
68+ clear_status (foe )
69+ foe .set_status_flag (StatusEffects .Status .SHELL , true )
70+ demo_mag ("Fire vs SHELL" , 30 , Element .Type .FIRE )
2171
22- var r2 : FF4DamageEngine .CombatResult = FF4DamageEngine .magical_damage (hero , foe , 30 , Element .Type .FIRE )
23- r2 .apply_to (foe ) # instance method also available
24- print ("Fire -> " , r2 .pretty_str ())
72+ # Magical absorb example (Dark is absorbed per resist table above)
73+ clear_status (hero )
74+ clear_status (foe )
75+ demo_mag ("Dark absorb" , 30 , Element .Type .DARK )
0 commit comments