Enhance item visibility logic and update initial energy parameter; add tests for life icon functionality
This commit is contained in:
+4
-4
@@ -128,9 +128,7 @@ func _unlock_items():
|
||||
break
|
||||
|
||||
if _flag_to_unlock:
|
||||
var item_id: String = owniverse.entities[_item_id].count_as
|
||||
if item_id == "":
|
||||
item_id = _item_id
|
||||
for item_id in [_item_id, owniverse.entities[_item_id].count_as]:
|
||||
if owniverse_items.has(item_id):
|
||||
owniverse_items[item_id].set_visible(true)
|
||||
else:
|
||||
@@ -229,7 +227,9 @@ func item_activated(item: OwniverseItem) -> void:
|
||||
_set_item_description(item)
|
||||
|
||||
if item.item_id == "S" or item.item_id == "H":
|
||||
var _value = owniverse.produce_hs(item.item_id, 100_000_000_000_000)
|
||||
var _value = owniverse.state.amount[item.item_id]
|
||||
_value = 10 * _value if _value > 0 else 1
|
||||
owniverse.produce_hs(item.item_id, _value)
|
||||
|
||||
|
||||
func _check_counters(delta: float) -> Array:
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# Проверки поэтапного переноса из Owniverse.U
|
||||
|
||||
## Иконки стадий жизни
|
||||
|
||||
`godot --headless --path Owniverse.GI --script res://tests/test_life_icons.gd`
|
||||
|
||||
Проверяются одновременная разблокировка подробных и общих иконок EON/LP и C0.0/C0, количества свободных и связанных планет без двойного учёта, переключение подпанелей и очистка счётчика при исчезновении стадии. Сохранение игрока не используется.
|
||||
|
||||
## Параметры мира и индикаторы
|
||||
|
||||
```sh
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
extends SceneTree
|
||||
|
||||
var checks: int = 0
|
||||
var failures: int = 0
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("run")
|
||||
|
||||
func check(value: bool, message: String) -> void:
|
||||
checks += 1
|
||||
if not value:
|
||||
failures += 1
|
||||
push_error(message)
|
||||
|
||||
func run() -> void:
|
||||
var scene = load("res://world/world.tscn").instantiate()
|
||||
var stage = scene.get_node("Stage")
|
||||
stage.owniverse.free()
|
||||
stage.set_script(load("res://tests/fixtures/ui_stage.gd"))
|
||||
root.add_child(scene)
|
||||
await process_frame
|
||||
await process_frame
|
||||
var world = stage.owniverse
|
||||
world.state.binds.RD = {"EON1": 10.0, "EON2": 4.0, "C0.0": 3.0}
|
||||
world.state.amount.EON1 = 2.0
|
||||
world.state.stats.total_amount.EON1 = 12.0
|
||||
world.state.stats.total_amount.EON2 = 4.0
|
||||
world.state.stats.total_amount["C0.0"] = 3.0
|
||||
var before: Dictionary = world.state.duplicate(true)
|
||||
stage._refresh_universe_ui()
|
||||
var counts: Dictionary = world.get_item_amounts()
|
||||
check(counts.EON1 == 12.0 and counts.EON2 == 4.0 and counts.LP == 16.0, "Individual eons and their total include bound planets")
|
||||
check(counts["C0.0"] == 3.0 and counts.C0 == 3.0 and counts.Planet == 19.0, "Civilization detail does not double the planetary total")
|
||||
check(world.get_item_amounts(true).EON1 == 12.0 and world.get_item_amounts(true).LP == 16.0, "Historical counts retain individual and aggregate values")
|
||||
check(world.state == before, "Presentation does not modify simulation state")
|
||||
for id in ["EON1", "EON2", "LP", "C0.0", "C0"]:
|
||||
check(stage.owniverse_items[id].visible, "Unlock both levels: " + id)
|
||||
check(stage.owniverse_items[id].description.text != "", "Populate the icon counter: " + id)
|
||||
check(not stage.owniverse_items.EON3.visible, "Unreached eon remains locked")
|
||||
stage.item_activated(stage.owniverse_items.LP)
|
||||
check(stage.owniverse_items.EON1.is_visible_in_tree(), "Selecting LP shows its unlocked eons")
|
||||
stage.item_activated(stage.owniverse_items.C0)
|
||||
check(stage.owniverse_items["C0.0"].is_visible_in_tree() and not stage.owniverse_items.EON1.is_visible_in_tree(), "Selecting C0 switches the detail panel")
|
||||
world.state.binds.RD.EON2 = 0.0
|
||||
stage._refresh_universe_ui()
|
||||
check(stage.owniverse_items.EON2.visible and stage.owniverse_items.EON2.description.text == "", "Previously reached stage stays unlocked after extinction with no stale count")
|
||||
for entity in world.entities.values(): entity.free()
|
||||
world.free()
|
||||
scene.free()
|
||||
print("Life icons: %d checks, %d failures" % [checks, failures])
|
||||
quit(0 if failures == 0 else 1)
|
||||
@@ -0,0 +1 @@
|
||||
uid://c4p1ad0ij32xo
|
||||
@@ -145,6 +145,10 @@ func get_item_amounts(total_produced: bool = false) -> Dictionary[String, float]
|
||||
var item_id: String = id
|
||||
if entities.has(id) and entities[id].count_as != "":
|
||||
item_id = entities[id].count_as
|
||||
# Detailed icons need their own count as well as the summary alias.
|
||||
# Aggregate only from source, never from these presentation entries.
|
||||
if item_id != id:
|
||||
result[id] = result.get(id, 0.0) + float(source[id])
|
||||
result[item_id] = result.get(item_id, 0.0) + float(source[id])
|
||||
for id in source:
|
||||
if _is_group(id):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extends RefCounted
|
||||
|
||||
const INITIAL_ENERGY = 1.0e14
|
||||
const INITIAL_ENERGY = 1.0e27
|
||||
const TRENDS = ["Antitheism", "Integration", "Xenocide", "Reconstruction", "Spirituality"]
|
||||
const WEIGHTS = {
|
||||
"m": [0, 2, 2, 0, 6], "l": [6, 1, 1, 2, 0],
|
||||
|
||||
Reference in New Issue
Block a user