feat: port melee combat and wounds

This commit is contained in:
goose
2026-10-03 01:03:28 -04:00
parent 159fd9f5bc
commit 454684bc87
19 changed files with 432 additions and 29 deletions
+15
View File
@@ -48,6 +48,21 @@ func test_all_current_turn_result_kinds_map_to_complete_game_events_for_one_acti
assert_eq(events[index].target_id, &"goblin" if index % 2 == 0 else &"player")
assert_eq(events[index].cell, Vector2i(index, 2))
func test_structured_combat_descriptors_are_journaled_before_legacy_compatibility_results() -> void:
var game := GameScene.instantiate() as Game
add_child_autofree(game)
await get_tree().process_frame
var descriptors: Array[Dictionary] = [
{"kind": &"attack_started", "actor_id": &"player", "target_id": &"goblin", "cell": Vector2i(2, 2), "payload": {"stance": "none"}},
{"kind": &"attack_hit", "actor_id": &"player", "target_id": &"goblin", "cell": Vector2i(2, 2), "payload": {"hit_chance": 0.75}},
{"kind": &"damage_dealt", "actor_id": &"player", "target_id": &"goblin", "cell": Vector2i(2, 2), "payload": {"damage": 3, "critical": false}},
]
game._record_events([TurnResult.new(&"player", &"melee", Vector2i(2, 2), Vector2i(3, 2), &"goblin", 3, "You strike the goblin for 3.", {"domain_events": descriptors})])
var events := game.get_run_state().recent_events(4)
assert_eq(events.map(func(event: GameEvent) -> StringName: return event.kind), [&"attack_started", &"attack_hit", &"damage_dealt", &"melee"])
assert_eq(events[2].payload, {"from_cell": Vector2i(2, 2), "to_cell": Vector2i(3, 2), "damage": 3, "critical": false})
func test_a_second_resolved_action_gets_one_new_action_turn() -> void:
var game := GameScene.instantiate() as Game
add_child_autofree(game)