From e407c3caf96d5c6e79dc99b922197bc6ab91c3eb Mon Sep 17 00:00:00 2001 From: Natalie Date: Wed, 15 Apr 2026 20:16:52 -0700 Subject: [PATCH] =?UTF-8?q?feat(@projects/@magic-civilization):=20?= =?UTF-8?q?=E2=9C=A8=20add=20wild=20loot=20tables=20and=20item=20system=20?= =?UTF-8?q?integration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- public/resources/wilds/wilds.json | 36 +++++++++++++++++++++++ src/game/engine/scenes/tests/auto_play.gd | 36 ++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/public/resources/wilds/wilds.json b/public/resources/wilds/wilds.json index 98920cb4..ffcc27c9 100644 --- a/public/resources/wilds/wilds.json +++ b/public/resources/wilds/wilds.json @@ -141,6 +141,42 @@ { "level": "brutal", "spawn_interval_mult": 0.5, "max_creatures": 5, "stat_mult": 1.5, "new_lair_interval": 15 } ], "creature_loot": { + "beast_den": { + "id": "beast_den", + "loot_table": [ + { "resource": "hide", "amount": 2, "chance": 0.8 }, + { "resource": "bone", "amount": 2, "chance": 0.6 }, + { "resource": "fang", "amount": 1, "chance": 0.4 } + ] + }, + "corrupted_hollow": { + "id": "corrupted_hollow", + "loot_table": [ + { "resource": "death_essence", "amount": 2, "chance": 0.7 }, + { "resource": "spectral_shard", "amount": 1, "chance": 0.4 } + ] + }, + "volcanic_fissure": { + "id": "volcanic_fissure", + "loot_table": [ + { "resource": "fire_essence", "amount": 2, "chance": 0.7 }, + { "resource": "obsidian", "amount": 1, "chance": 0.5 } + ] + }, + "ancient_construct_site": { + "id": "ancient_construct_site", + "loot_table": [ + { "resource": "arcane_gears", "amount": 2, "chance": 0.8 }, + { "resource": "stone_core", "amount": 1, "chance": 0.5 } + ] + }, + "wyvern_nest": { + "id": "wyvern_nest", + "loot_table": [ + { "resource": "wyvern_scale", "amount": 2, "chance": 0.8 }, + { "resource": "bone", "amount": 2, "chance": 0.5 } + ] + }, "wolf_pack": { "id": "wolf_pack", "loot_table": [ diff --git a/src/game/engine/scenes/tests/auto_play.gd b/src/game/engine/scenes/tests/auto_play.gd index b2026e27..3ed82d0b 100644 --- a/src/game/engine/scenes/tests/auto_play.gd +++ b/src/game/engine/scenes/tests/auto_play.gd @@ -18,6 +18,7 @@ const ImprovementManagerScript = preload( "res://engine/src/modules/management/improvement_manager.gd" ) const HappinessScript = preload("res://engine/src/modules/empire/happiness.gd") +const ItemSystemScript = preload("res://engine/src/modules/management/item_system.gd") var _improvement_manager: RefCounted = null @@ -104,6 +105,10 @@ func _ready() -> void: EventBus.tech_researched.connect(_on_tech_researched) EventBus.unit_created.connect(_on_unit_created) EventBus.unit_destroyed.connect(_on_unit_destroyed) + EventBus.improvement_started.connect(_on_improvement_started) + EventBus.improvement_completed.connect(_on_improvement_completed) + EventBus.loot_dropped.connect(_on_loot_dropped) + _improvement_manager = ImprovementManagerScript.new() func _on_combat(attacker: Variant, defender: Variant, result: Dictionary) -> void: @@ -229,6 +234,35 @@ func _on_unit_destroyed(unit: Variant, _killer: Variant) -> void: }) +func _on_improvement_started(tile: Vector2i, type: String, turns: int) -> void: + _append_event({ + "type": "improvement_started", + "tile_x": tile.x, + "tile_y": tile.y, + "improvement": type, + "turns": turns, + }) + + +func _on_improvement_completed(tile: Vector2i, type: String) -> void: + _append_event({ + "type": "improvement_built", + "tile_x": tile.x, + "tile_y": tile.y, + "improvement": type, + }) + + +func _on_loot_dropped(player: Variant, creature_type: String, drops: Array) -> void: + var p_idx: int = int(player.get("index")) if player != null and player.get("index") != null else -1 + _append_event({ + "type": "loot_dropped", + "player": p_idx, + "creature": creature_type, + "drops": drops, + }) + + func _ensure_stats(player_index: int) -> void: if not _stats.has(player_index): _stats[player_index] = { @@ -1344,7 +1378,7 @@ func _try_attack_adjacent_lair(unit: Variant, game_map: RefCounted) -> void: hash(unit.id), hash(norm), ) - elif attacker_killed: + elif not attacker_alive: print(" LAIR ATTACK FAILED: %s killed at %s" % [unit.type_id, norm]) return