Files
game-code-4/tests/unit/cases/test_economy_formulas.gd
T

60 lines
3.5 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
extends RefCounted
# 用例:核心公式(MultiplierSet / PrestigeModel / OfflineModel)
func run(a, _data) -> void:
# ---- MultiplierSet 三乘区 + 软上限 ----
var m := MultiplierSet.new(16.0, 8.0, 64.0)
m.set_click_levels(4, 0.0, 0.01)
a.near(m.click_mult(), 16.0, 1e-9, "点击区 4 级 = ×16")
m.set_click_levels(5, 0.0, 0.01)
a.near(m.click_mult(), 16.0, 1e-9, "点击区 5 级仍钳 ×16")
m.set_gen_eff("gen_01_youhun", 6)
a.near(m.gen_mult("gen_01_youhun"), 7.0, 1e-9, "班底区 6 级 = ×7")
m.set_gen_eff("gen_01_youhun", 99)
a.near(m.gen_mult("gen_01_youhun"), 8.0, 1e-9, "班底区钳 ×8")
m.set_global_add(63.0)
a.near(m.global_mult(), 64.0, 1e-9, "全局区 ×64")
m.set_global_add(100.0)
a.near(m.global_mult(), 64.0, 1e-9, "全局区钳 ×64")
m.set_click_levels(4, 8.0, 0.01)
a.near(m.click_value(1.0, 1000.0), 96.0, 1e-6, "click_value = 1×16 + 1000×8%")
# ---- PrestigeModel ----
a.eq(PrestigeModel.suihui_gain(1.5e9, 1e6, 5.0, 0.0, 0.0), 193, "宿慧 1.5B → 193")
a.eq(PrestigeModel.suihui_gain(1.25e7, 1e6, 5.0, 0.0, 0.0), 17, "宿慧 12.5M → 17")
a.eq(PrestigeModel.suihui_gain(1.5e9, 1e6, 5.0, 0.0, 0.3), 135, "宿慧 30% 削减 → 135")
a.eq(PrestigeModel.suihui_gain(1.5e9, 1e6, 5.0, 0.45, 0.0), 279, "宿慧 m03×3 → 279")
a.eq(PrestigeModel.suihui_gain(0.0, 1e6, 5.0, 0.0, 0.0), 0, "零累计 → 0 宿慧")
a.eq(PrestigeModel.wrath_layer_cost(1, 8.0, 1.8), 8, "怨煞层 1 成本 8")
a.eq(PrestigeModel.wrath_layer_cost(2, 8.0, 1.8), 28, "怨煞层 2 成本 28")
a.eq(PrestigeModel.wrath_layer_cost(22, 8.0, 1.8), 2087, "怨煞层 22 成本 2087")
a.near(PrestigeModel.wrath_penalty(10, 0.03, 0.3, 0.0), 0.3, 1e-9, "冤气削减封顶 30%")
a.near(PrestigeModel.wrath_penalty(10, 0.03, 0.3, 0.15), 0.15, 1e-9, "m07 改 15%")
a.near(PrestigeModel.wrath_penalty(5, 0.03, 0.3, 0.0), 0.15, 1e-9, "5 层 = 15%")
a.eq(PrestigeModel.skip_count(23, 5), 4, "skip 23/5 = 4")
a.eq(PrestigeModel.skip_count(23, 4), 5, "skip 23/4 = 5(m04)")
a.near(PrestigeModel.restart_target(0), 1.0, 1e-9, "重开曲线 R1")
a.near(PrestigeModel.restart_target(3), 0.3, 1e-9, "重开曲线 R4")
a.near(PrestigeModel.restart_target(4), 0.25, 1e-9, "重开曲线 R5 触底")
a.true_(PrestigeModel.enthrone_available(2, 2), "敕封:转世 2 可")
a.true_(not PrestigeModel.enthrone_available(1, 2), "敕封:转世 1 不可")
# ---- OfflineModel 分带 + 72h 封顶 + 时钟回拨 ----
var r1: Dictionary = OfflineModel.settle(3600.0, 10.0, 1.0, 2.0, 1.0, 8.0, 0.7, 24.0, 0.4, 0.1, 72.0)
a.near(r1["effective_hours"], 1.0, 1e-9, "离线 1h = 1h 等效")
a.near(r1["merit"], 36000.0, 1e-6, "离线 1h × 10/s")
var r8: Dictionary = OfflineModel.settle(8.0 * 3600.0, 10.0, 1.0, 2.0, 1.0, 8.0, 0.7, 24.0, 0.4, 0.1, 72.0)
a.near(r8["effective_hours"], 6.2, 1e-9, "离线 8h = 6.2h 等效(P-8)")
a.near(r8["merit"], 223200.0, 1e-6, "离线 8h 收益")
var r100: Dictionary = OfflineModel.settle(100.0 * 3600.0, 10.0, 1.0, 2.0, 1.0, 8.0, 0.7, 24.0, 0.4, 0.1, 72.0)
a.near(r100["effective_hours"], 17.4, 1e-9, "离线 100h → 72h 封顶 = 17.4h 等效")
var rneg: Dictionary = OfflineModel.settle(-5.0, 10.0, 1.0, 2.0, 1.0, 8.0, 0.7, 24.0, 0.4, 0.1, 72.0)
a.near(rneg["merit"], 0.0, 1e-9, "时钟回拨 → 0")
a.near(OfflineModel.ratio_8h_over_1h(2.0, 1.0, 8.0, 0.7, 24.0, 0.4, 0.1), 6.2, 1e-9,
"门 #9 比率 6.2(契约 [1.5,2.5] 预计 FAIL,P-8)")
# ---- BigNumber 红线 ----
a.true_(BigNumber.assert_within(1e13, "test"), "1e13 不过红线")
a.true_(not BigNumber.assert_within(1e15, "test"), "1e15 触红线")