fix: preserve mutable floor entities compatibility
This commit is contained in:
@@ -30,6 +30,9 @@ func test_floor_state_round_trip_preserves_rooms_tiles_and_floor_collections() -
|
||||
var serialized := floor.to_dict()
|
||||
var restored := FloorStateType.from_dict(serialized)
|
||||
|
||||
assert_true(serialized.has("enemies"))
|
||||
assert_true(serialized.has("npcs"))
|
||||
assert_false(serialized.has("entities"))
|
||||
assert_eq(restored.seed, 8675309)
|
||||
assert_eq(restored.floor_number, 3)
|
||||
assert_eq(restored.rooms.size(), 2)
|
||||
@@ -44,7 +47,7 @@ func test_floor_state_round_trip_preserves_rooms_tiles_and_floor_collections() -
|
||||
assert_eq(restored.enemies[&"goblin"].cell, Vector2i(5, 4))
|
||||
assert_eq(restored.npcs[&"guide"].cell, Vector2i(3, 3))
|
||||
assert_true(restored.entities.has(&"goblin"))
|
||||
assert_true(restored.entities.has(&"guide"))
|
||||
assert_false(restored.entities.has(&"guide"))
|
||||
assert_eq(restored.chests[Vector2i(3, 2)], {"opened": false, "loot": [{"id": "potion_minor", "quantity": 2}]})
|
||||
assert_eq(restored.ground_items[Vector2i(4, 2)], [{"id": "gold", "quantity": 10}])
|
||||
assert_eq(restored.events, [{"id": "entry_event", "resolved": false}])
|
||||
@@ -52,14 +55,23 @@ func test_floor_state_round_trip_preserves_rooms_tiles_and_floor_collections() -
|
||||
assert_eq(restored.explored_cells[Vector2i(2, 3)], false)
|
||||
assert_eq(restored.metadata, {"theme": "ruins", "difficulty": 2})
|
||||
|
||||
func test_floor_state_entities_remains_a_legacy_enemy_alias() -> void:
|
||||
func test_floor_state_entities_remains_a_mutable_legacy_enemy_alias() -> void:
|
||||
var floor := FloorStateType.new(GridMapStateType.new(Vector2i(2, 2)))
|
||||
var goblin := ActorStateType.new(&"goblin", Vector2i(1, 1), 6, 2)
|
||||
var orc := ActorStateType.new(&"orc", Vector2i(0, 1), 8, 3)
|
||||
|
||||
floor.entities = {&"goblin": goblin}
|
||||
floor.entities[&"orc"] = orc
|
||||
|
||||
assert_same(floor.entities[&"goblin"], floor.enemies[&"goblin"])
|
||||
assert_same(floor.entities[&"orc"], floor.enemies[&"orc"])
|
||||
assert_same(floor.enemies[&"goblin"], goblin)
|
||||
assert_same(floor.enemies[&"orc"], orc)
|
||||
|
||||
floor.entities.erase(&"goblin")
|
||||
|
||||
assert_false(floor.entities.has(&"goblin"))
|
||||
assert_false(floor.enemies.has(&"goblin"))
|
||||
assert_false(floor.npcs.has(&"goblin"))
|
||||
|
||||
func test_floor_state_deserializes_legacy_entities_and_explored_cell_arrays() -> void:
|
||||
|
||||
Reference in New Issue
Block a user