-- Generated from the frozen legacy-h5 rules by migration/port-engine.cjs. -- Edit the migration source or an explicit native adapter; regenerate and run parity tests. ---@param _port table ---@param _data table ---@param _rt table return function(_port, _data, _rt) -- H5 engine.js:342 · today _port["today"] = function() do return _rt.call(_rt.call(_rt.date(), "toISOString"), "slice", 0, 10) end end -- H5 engine.js:345 · biaoqiCfg _port["biaoqiCfg"] = function() do return _rt.choose((_rt.typeof(_data["BIAOQI_POWER"]) ~= "undefined"), function() return _data["BIAOQI_POWER"] end, function() return {["maxLevel"] = 19, ["perLevel"] = 0.5, ["cap"] = 10} end) end end -- H5 engine.js:349 · regionCfg _port["regionCfg"] = function() do return _rt.choose((_rt.typeof(_data["REGION_POWER"]) ~= "undefined"), function() return _data["REGION_POWER"] end, function() return {["perRegion"] = 2, ["cap"] = 16, ["regions"] = _rt.array({"江南", "中原", "北方", "西南", "西北", "北疆", "西域", "海外"})} end) end end -- H5 engine.js:354 · chainCfg _port["chainCfg"] = function() do return _rt.choose((_rt.typeof(_data["CHAIN"]) ~= "undefined"), function() return _data["CHAIN"] end, function() return {["maxBranches"] = 10, ["costBase"] = 180, ["costGrowth"] = 4, ["synergyPer"] = 0.25, ["escortsPer"] = 2, ["prestigeBase"] = 1000, ["prestigeGrowth"] = 2.2} end) end end -- H5 engine.js:358 · monopolyCfg _port["monopolyCfg"] = function() do return _rt.choose((_rt.typeof(_data["MONOPOLY"]) ~= "undefined"), function() return _data["MONOPOLY"] end, function() return {["step"] = 25, ["maxDegree"] = 100, ["cutRate"] = 0.02, ["flowRuns"] = 20, ["costK"] = 2.5} end) end end -- H5 engine.js:362 · monopolyRoutes _port["monopolyRoutes"] = function() do return _rt.choose(_rt.andThen((_rt.typeof(_data["MONOPOLY_ROUTES"]) ~= "undefined"), function() return _rt.isArray(_data["MONOPOLY_ROUTES"]) end), function() return _data["MONOPOLY_ROUTES"] end, function() return _rt.array({}) end) end end -- H5 engine.js:366 · dayOf _port["dayOf"] = function(s) if _rt.truth((not _rt.truth(_rt.get(s, "firstDay")))) then _rt.set(s, "firstDay", _port["today"]()); end local a = _rt.date(_rt.add(_rt.get(s, "firstDay"), "T00:00:00")); local b = _rt.date(_rt.add(_port["today"](), "T00:00:00")); local real = _rt.math["max"](1, _rt.add(_rt.math["round"](((b - a) / 86400000)), 1)); do return _rt.math["max"](real, _rt.orElse(_rt.get(s, "demoDay"), function() return 1 end)) end end -- H5 engine.js:374 · rankOf _port["rankOf"] = function(prestige) local r = _rt.get(_data["RANKS"], 0); for _, x in ipairs(_data["RANKS"]) do do if _rt.truth(_rt.compare(">=", prestige, _rt.get(x, "min"))) then (function() r = x; return r end)(); end end ::_continue2:: end do return r end end _port["RANK_BONUS_CAP"] = 0.4 -- H5 engine.js:385 · rankBonus _port["rankBonus"] = function(rankIdx) local i = _rt.math["max"](0, _rt.bit("|", rankIdx, 0)); do return _rt.math["min"](_port["RANK_BONUS_CAP"], _rt.add((0.05 * _rt.math["min"](i, 6)), (0.02 * _rt.math["max"](0, (i - 6))))) end end -- H5 engine.js:390 · rankIndex _port["rankIndex"] = function(prestige) do return _rt.math["max"](0, _rt.call(_data["RANKS"], "indexOf", _port["rankOf"](prestige))) end end -- H5 engine.js:391 · rankInfo _port["rankInfo"] = function(s) local p = _port["progressionPrestige"](s); local idx = _port["rankIndex"](p); local next = _rt.orElse(_rt.get(_data["RANKS"], _rt.add(idx, 1)), function() return nil end); do return {["rank"] = _rt.get(_data["RANKS"], idx), ["idx"] = idx, ["bonus"] = _port["rankBonus"](idx), ["next"] = next, ["gap"] = _rt.choose(next, function() return _rt.math["max"](0, (_rt.get(next, "min") - p)) end, function() return 0 end)} end end -- H5 engine.js:400 · unlocked _port["unlocked"] = function(s, key) local p = _port["progressionPrestige"](s); if _rt.truth((key == "equip")) then do return _rt.compare(">=", p, 100) end end if _rt.truth((key == "fenhao")) then do return _rt.compare(">=", p, 300) end end if _rt.truth((key == "offline")) then do return _rt.compare(">=", p, 800) end end if _rt.truth((key == "biaoqi")) then do return _rt.compare(">=", p, 2000) end end if _rt.truth((key == "cross")) then do return _rt.compare(">=", p, 2000) end end do return true end end _port["QUALITY_GATES"] = _rt.array({{["d"] = 3, ["p"] = 100}, {["d"] = 5, ["p"] = 300}, {["d"] = 7, ["p"] = 800}, {["d"] = 14, ["p"] = 2000}, {["d"] = 30, ["p"] = 5000}, {["d"] = 40, ["p"] = 12000}, {["d"] = 50, ["p"] = 25000}, {["d"] = 65, ["p"] = 50000}, {["d"] = 80, ["p"] = 100000}, {["d"] = 100, ["p"] = 200000}, {["d"] = 120, ["p"] = 400000}}) -- H5 engine.js:425 · qualityGate _port["qualityGate"] = function(next) do return _rt.orElse(_rt.get(_port["QUALITY_GATES"], (next - 1)), function() return nil end) end end -- H5 engine.js:428 · maxQuality _port["maxQuality"] = function(s) local p = _port["progressionPrestige"](s); local q = 0; do local i = 0; while _rt.truth(_rt.compare("<", i, _rt.get(_port["QUALITY_GATES"], "length"))) do do local g = _rt.get(_port["QUALITY_GATES"], i); if _rt.truth(_rt.compare(">=", p, _rt.get(g, "p"))) then (function() q = _rt.add(i, 1); return q end)(); end end ::_continue3:: (function() local _before = i; i = i + (1); return _before end)() end end do return q end end -- H5 engine.js:442 · cityList _port["cityList"] = function() do return _rt.choose(_rt.andThen((_rt.typeof(_data["CITIES"]) ~= "undefined"), function() return _rt.isArray(_data["CITIES"]) end), function() return _data["CITIES"] end, function() return _rt.array({}) end) end end -- H5 engine.js:443 · cityUnlocked _port["cityUnlocked"] = function(s, c) if _rt.truth((not _rt.truth(c))) then do return false end end if _rt.truth(_rt.andThen(_rt.andThen(s, function() return _rt.get(s, "codex") end), function() return _rt.compare(">=", _rt.call(_rt.orElse(_rt.get(_rt.get(s, "codex"), "cities"), function() return _rt.array({}) end), "indexOf", _rt.get(c, "name")), 0) end)) then do return true end end do return _rt.compare(">=", _port["progressionPrestige"](s), _rt.orElse(_rt.get(c, "unlock"), function() return 0 end)) end end -- H5 engine.js:448 · citiesOpen _port["citiesOpen"] = function(s) do return _rt.call(_port["cityList"](), "filter", function(c) return _port["cityUnlocked"](s, c) end) end end -- H5 engine.js:449 · citiesForRoute _port["citiesForRoute"] = function(s, routeId) local regions = _rt.orElse(_rt.get(_port["ROUTE_REGIONS"], routeId), function() return _rt.array({"江南"}) end); do return _rt.call(_port["citiesOpen"](s), "filter", function(c) return _rt.compare(">=", _rt.call(regions, "indexOf", _rt.get(c, "region")), 0) end) end end -- H5 engine.js:453 · pickEndCity _port["pickEndCity"] = function(s, routeId) local pool = _port["citiesForRoute"](s, routeId); if _rt.truth((not _rt.truth(_rt.get(pool, "length")))) then do return nil end end do return _rt.get(pool, _rt.math["floor"]((_rt.math["random"]() * _rt.get(pool, "length")))) end end -- H5 engine.js:459 · cityLocalEvents _port["cityLocalEvents"] = function(city) if _rt.truth(_rt.orElse((not _rt.truth(city)), function() return (not _rt.truth(_rt.get(city, "locals"))) end)) then do return _rt.array({}) end end do return _rt.call(_rt.call(_rt.get(city, "locals"), "map", function(id) return _rt.call(_data["EVENTS"], "find", function(e) return (_rt.get(e, "id") == id) end) end), "filter", _rt.truth) end end end