31 lines
1.2 KiB
GDScript
31 lines
1.2 KiB
GDScript
extends Node
|
|
const RADIATION = preload("res://scripts/game/radiation_status.gd")
|
|
class Target:
|
|
extends CharacterBody2D
|
|
var total_damage := 0.0
|
|
func take_damage(amount: float, _critical: bool, _kind: int) -> void:
|
|
total_damage += amount
|
|
func take_weapon_hit(amount: float, critical: bool, kind: int) -> void:
|
|
take_damage(amount, critical, kind)
|
|
|
|
func _ready() -> void:
|
|
var target := Target.new()
|
|
add_child(target)
|
|
RADIATION.apply(target, 2.0, true)
|
|
var status := target.get_node("RadiationStatus")
|
|
status.set_physics_process(false)
|
|
assert(status.remaining == 10.0)
|
|
for index in 6:
|
|
status._physics_process(0.5)
|
|
assert(status.remaining == 7.0 and target.total_damage == 6.0)
|
|
RADIATION.apply(target, 1.0, true)
|
|
assert(status.remaining == 10.0 and status.tick_damage == 2.0)
|
|
for index in 20:
|
|
status._physics_process(0.5)
|
|
assert(status.remaining == 0.0 and target.total_damage == 26.0)
|
|
status._physics_process(1.0)
|
|
assert(target.total_damage == 26.0)
|
|
assert(preload("res://resources/items/gamma_cannon.tres").description.contains("10 s"))
|
|
print("RADIATION_DURATION_TEST: PASS 10s damage, refreshed timer, unchanged per-second damage, expiry and description")
|
|
get_tree().quit()
|