-- 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) _port["CITY_TRIAL"] = _rt.cityTrial _port["SAVE_KEY"] = _rt.choose(_port["CITY_TRIAL"], function() return "biaoxing_city_trial_v1" end, function() return "biaoxing_demo_v1" end) _port["DEMO_SPEED"] = 20 _port["WARN_AT"] = 33 _port["LEAVE_BASE"] = 0.1 _port["LEAVE_STEP"] = 0.02 _port["GIFT_COST"] = 20 _port["GIFT_GAIN"] = 20 _port["INSIGHT_BONUS"] = 5 _port["SILVER_PER_INSIGHT"] = 0.002 _port["LEG_ROUTES"] = {["cross"] = 3} _port["LEG_P_SHARE"] = _rt.array({0.35, 0.35}) _port["LEG_S_SHARE"] = _rt.array({0.3, 0.3}) _port["LEG_STOPS"] = {["cross"] = _rt.array({"渡口驿", "关隘驿"})} _port["ROUTE_REGIONS"] = {["near"] = _rt.array({"江南"}), ["city"] = _rt.array({"江南", "中原"}), ["far"] = _rt.array({"中原", "北方", "西南"}), ["cross"] = _rt.array({"北方", "西南", "西北", "北疆", "西域", "海外"})} _port["CITY_CONTRACTS"] = _rt.array({{["id"] = "hangzhou", ["name"] = "杭州", ["cargo"] = "湖绸", ["ability"] = "丝绸押运", ["mul"] = 1.8, ["time"] = 1.5, ["pitch"] = "多花一点时间,接一笔更大的生意", ["benefit"] = "基础镖银 +80% · 用时 +50%"}, {["id"] = "suzhou", ["name"] = "苏州", ["cargo"] = "苏州急件", ["ability"] = "水路急递", ["mul"] = 1.15, ["time"] = 0.65, ["pitch"] = "走通水路,让镖队更快回来", ["benefit"] = "用时 −35% · 基础镖银 +15%"}}) -- H5 engine.js:40 · cityRunName _port["cityRunName"] = function(run) local city = _rt.call(_port["CITY_CONTRACTS"], "find", function(c) return (_rt.get(c, "id") == _rt.get(run, "cityGoalId")) end); if _rt.truth((not _rt.truth(city))) then do return _rt.orElse(_rt.get(run, "bizName"), function() return "" end) end end do return _rt.choose((_rt.get(run, "cityKind") == "prepare"), function() return _rt.add(_rt.get(city, "name"), "沿途 · 短途押运") end, function() return _rt.choose((_rt.get(run, "cityKind") == "open"), function() return _rt.add(_rt.get(city, "name"), " · 首批货物") end, function() return _rt.get(city, "ability") end) end) end end -- H5 engine.js:45 · journeyState _port["journeyState"] = function(s) if _rt.truth((not _rt.truth(_rt.get(s, "cityJourney")))) then _rt.set(s, "cityJourney", {["target"] = nil, ["cities"] = {}}); end if _rt.truth((not _rt.truth(_rt.get(_rt.get(s, "cityJourney"), "cities")))) then _rt.set(_rt.get(s, "cityJourney"), "cities", {}); end do return _rt.get(s, "cityJourney") end end -- H5 engine.js:50 · cityGoal _port["cityGoal"] = function(s, id) local j = _port["journeyState"](s); local c = _rt.call(_port["CITY_CONTRACTS"], "find", function(c) return (_rt.get(c, "id") == _rt.orElse(id, function() return _rt.get(j, "target") end)) end); if _rt.truth((not _rt.truth(c))) then do return nil end end local progress = _rt.orElse(_rt.get(_rt.get(j, "cities"), _rt.get(c, "id")), function() return {["deliveries"] = 0, ["drilled"] = false, ["opened"] = false, ["contracts"] = 0} end); do return _rt.assign({}, c, progress, {["ready"] = _rt.andThen(_rt.compare(">=", _rt.get(progress, "deliveries"), 2), function() return _rt.get(progress, "drilled") end)}) end end -- H5 engine.js:56 · selectCityGoal _port["selectCityGoal"] = function(s, id) if _rt.truth(_rt.get(_rt.get(s, "runs"), "length")) then do return {["ok"] = false, ["msg"] = "请先结算本趟押运,再更换目的地"} end end if _rt.truth((not _rt.truth(_rt.call(_port["CITY_CONTRACTS"], "some", function(c) return (_rt.get(c, "id") == id) end)))) then do return {["ok"] = false, ["msg"] = "这条商路尚未开放"} end end local j = _port["journeyState"](s); _rt.set(j, "target", id); if _rt.truth((not _rt.truth(_rt.get(_rt.get(j, "cities"), id)))) then _rt.set(_rt.get(j, "cities"), id, {["deliveries"] = 0, ["drilled"] = false, ["opened"] = false, ["contracts"] = 0}); end _port["track"](s, "city_goal_selected", id); do return {["ok"] = true, ["msg"] = _rt.add("目标已定:", _rt.get(_port["cityGoal"](s), "name"))} end end -- H5 engine.js:65 · drillCityTeam _port["drillCityTeam"] = function(s) local g = _port["cityGoal"](s); if _rt.truth(_rt.orElse((not _rt.truth(g)), function() return _rt.get(g, "drilled") end)) then do return {["ok"] = false, ["msg"] = "本城所需的集体训练已完成,或尚未选择目的地"} end end if _rt.truth(_rt.get(_rt.get(s, "runs"), "length")) then do return {["ok"] = false, ["msg"] = "请等镖队归来并结算后,再安排集体训练"} end end if _rt.truth(_rt.compare("<", _rt.get(g, "deliveries"), 1)) then do return {["ok"] = false, ["msg"] = "请先完成一趟短途押运"} end end if _rt.truth(_rt.compare("<", _rt.get(s, "silver"), 80)) then do return {["ok"] = false, ["msg"] = "集体训练需 80 两银子,可先接短途镖赚取镖银"} end end local ids = _rt.call(_rt.get(s, "escorts"), "map", function(e) return _rt.get(e, "id") end); local before = _port["teamPower"](s, ids); _rt.update(s, "silver", "-", 80); _rt.call(_rt.get(s, "escorts"), "forEach", function(e) _rt.set(_rt.get(e, "train"), "force", _rt.math["max"](_rt.orElse(_rt.get(_rt.get(e, "train"), "force"), function() return 0 end), _rt.math["min"](_port["trainCap"](s), _rt.add(_rt.orElse(_rt.get(_rt.get(e, "train"), "force"), function() return 0 end), 5)))); end); _rt.set(_rt.get(_rt.get(_port["journeyState"](s), "cities"), _rt.get(g, "id")), "drilled", true); local after = _port["teamPower"](s, ids); _port["track"](s, "city_goal_drill", (after - before)); do return {["ok"] = true, ["msg"] = _rt.add(_rt.add(_rt.add("集体训练完成 · 全队战力 ", before), " → "), after), ["before"] = before, ["after"] = after} end end -- H5 engine.js:79 · startCityRun _port["startCityRun"] = function(s, kind, escortIds) local g = _port["cityGoal"](s); if _rt.truth(_rt.orElse((not _rt.truth(g)), function() return (not _rt.truth(_rt.call(_rt.array({"prepare", "open", "contract"}), "includes", kind))) end)) then do return {["ok"] = false, ["msg"] = "先选定目标城"} end end if _rt.truth(_rt.andThen((kind == "open"), function() return _rt.orElse(_rt.get(g, "opened"), function() return (not _rt.truth(_rt.get(g, "ready"))) end) end)) then do return {["ok"] = false, ["msg"] = "请先完成两趟短途押运和一次集体训练"} end end if _rt.truth(_rt.andThen((kind == "contract"), function() return (not _rt.truth(_rt.get(g, "opened"))) end)) then do return {["ok"] = false, ["msg"] = "首次送达并结算后,才能承接商会委托"} end end if _rt.truth(_rt.get(_rt.get(s, "runs"), "length")) then do return {["ok"] = false, ["msg"] = "请先结算本趟押运"} end end local ids = _rt.call(_rt.concat(_rt.setOf(escortIds)), "filter", function(id) return _rt.call(_rt.get(s, "escorts"), "some", function(e) return (_rt.get(e, "id") == id) end) end); local need = _rt.choose((kind == "prepare"), function() return 50 end, function() return 70 end); if _rt.truth(_rt.compare("<", _port["teamPower"](s, ids), need)) then do return {["ok"] = false, ["msg"] = _rt.add(_rt.add("需战力 ", need), ",可训练镖师或增加随行人数")} end end local previousGoods = _rt.concat(_rt.get(_rt.get(s, "codex"), "goods")); local result = _port["startRun"](s, "civil", ids); if _rt.truth((not _rt.truth(_rt.get(result, "ok")))) then do return result end end local run = _rt.get(_rt.get(s, "runs"), (_rt.get(_rt.get(s, "runs"), "length") - 1)); _rt.set(run, "cityGoalId", _rt.get(g, "id")); _rt.set(run, "cityKind", kind); _rt.set(run, "endCity", _rt.choose((kind == "prepare"), function() return nil end, function() return _rt.get(g, "name") end)); _rt.set(run, "need", need); _rt.set(run, "duration", _rt.choose((kind == "open"), function() return 18 end, function() return _rt.choose((kind == "contract"), function() return (12 * _rt.get(g, "time")) end, function() return 12 end) end)); _rt.set(run, "eventAt", _rt.array({(_rt.get(run, "duration") * 0.25), (_rt.get(run, "duration") * 0.65)})); _rt.set(run, "goods", _rt.choose((kind == "contract"), function() return _rt.get(g, "cargo") end, function() return _rt.choose((kind == "open"), function() return "商会首批货" end, function() return "沿途补给" end) end)); _rt.set(_rt.get(s, "codex"), "goods", previousGoods); if _rt.truth((not _rt.truth(_rt.call(_rt.get(_rt.get(s, "codex"), "goods"), "includes", _rt.get(run, "goods"))))) then _rt.call(_rt.get(_rt.get(s, "codex"), "goods"), "push", _rt.get(run, "goods")); end _rt.set(run, "contractMul", _rt.choose((kind == "contract"), function() return _rt.get(g, "mul") end, function() return 1 end)); _rt.set(run, "value", _rt.math["round"]((_rt.get(run, "value") * _rt.get(run, "contractMul")))); _rt.set(run, "bizName", _port["cityRunName"](run)); _port["initCityDecisions"](s, run); _port["track"](s, _rt.add(_rt.add("city_", kind), "_start"), _rt.get(g, "id")); do return {["ok"] = true, ["msg"] = _rt.add(_rt.get(run, "bizName"), "已出发")} end end _port["CITY_ROAD_CONDITIONS"] = _rt.array({{["id"] = "river", ["name"] = "雨后涨水", ["title"] = "河水漫过旧渡口", ["danger"] = 22, ["wait"] = 0.3, ["rush"] = (-0.12), ["forecast"] = "水势难料。抢渡可能伤货,等水退更稳妥,也可能久等。", ["safe"] = "等水退,稳稳过河", ["fast"] = "冒险抢渡河道", ["guide"] = "走向导找到的浅滩", ["text"] = "河水正在上涨。抢渡有机会缩短行程,但水势难料,货物可能受损。"}, {["id"] = "ridge", ["name"] = "晴日山路", ["title"] = "山口有条碎石近道", ["danger"] = 10, ["wait"] = 0.25, ["rush"] = (-0.18), ["forecast"] = "近道或许能省时。货多车重、人马疲乏时,货物更容易磕坏。", ["safe"] = "沿官道绕行", ["fast"] = "穿过碎石近道", ["guide"] = "走向导熟悉的平整小径", ["text"] = "官道绕山,近道却铺满碎石。轻车容易通过,满载的货箱经不起颠簸。"}, {["id"] = "fog", ["name"] = "山间浓雾", ["title"] = "浓雾遮住了栈道", ["danger"] = 16, ["wait"] = 0.35, ["rush"] = (-0.15), ["forecast"] = "等雾散最稳妥,赶路容易磕碰货箱。", ["safe"] = "停下等雾散", ["fast"] = "摸索栈道,继续赶路", ["guide"] = "跟向导走熟路", ["text"] = "雾气遮住了栈道边缘。停下来等雾散,可能更好走;直接赶路则要小心货箱磕碰。"}}) -- H5 engine.js:119 · cityRoadBrief _port["cityRoadBrief"] = function(s, kind) local g = _port["cityGoal"](s); local promise = _rt.choose((kind == "contract"), function() return _rt.choose((_rt.get(g, "id") == "hangzhou"), function() return "intact" end, function() return "timely" end) end, function() return _rt.choose((_rt.get(_rt.get(s, "stats"), "runs") % 2), function() return "timely" end, function() return "intact" end) end); local duration = _rt.choose((kind == "open"), function() return 18 end, function() return _rt.choose((kind == "contract"), function() return (12 * _rt.get(g, "time")) end, function() return 12 end) end); do return {["condition"] = _rt.get(_port["CITY_ROAD_CONDITIONS"], (_rt.get(_rt.get(s, "stats"), "runs") % _rt.get(_port["CITY_ROAD_CONDITIONS"], "length"))), ["promise"] = promise, ["deadline"] = duration} end end -- H5 engine.js:125 · initCityDecisions _port["initCityDecisions"] = function(s, run) local base = _port["settle"](s, run); local brief = _port["cityRoadBrief"](s, _rt.get(run, "cityKind")); local seed = _rt.choose(_rt.andThen((_rt.typeof(nil) ~= "undefined"), function() return _rt.get(nil, "getRandomValues") end), function() return _rt.get(_rt.call(nil, "getRandomValues", _rt.array({0})), 0) end, function() return _rt.math["floor"]((_rt.math["random"]() * 4294967296)) end); local crew = _rt.call(_rt.call(_rt.get(run, "escortIds"), "map", function(id) return _rt.call(_rt.get(s, "escorts"), "find", function(e) return (_rt.get(e, "id") == id) end) end), "filter", _rt.truth); local skill = (_rt.call(crew, "reduce", function(sum, e) return _rt.add(_rt.add(sum, (_rt.call(_rt.array({"force", "agility", "insight", "courage"}), "reduce", function(n, k) return _rt.add(n, _port["effAttr"](e, k)) end, 0) / 600)), (_rt.get(e, "level") * 0.002)) end, 0) / _rt.math["max"](1, _rt.get(crew, "length"))); _rt.set(run, "journeyDecision", {["version"] = 2, ["randomState"] = _rt.bit(">>>", seed, 0), ["crewSkill"] = _rt.math["min"](0.18, skill), ["fatigue"] = 0, ["guideQuality"] = nil, ["baseSilver"] = _rt.get(base, "silver"), ["basePrestige"] = _rt.get(base, "prestige"), ["condition"] = _rt.get(_rt.get(brief, "condition"), "id"), ["promise"] = _rt.get(brief, "promise"), ["deadline"] = _rt.get(run, "duration"), ["baseDuration"] = _rt.get(run, "duration"), ["path"] = nil, ["cargo"] = 100, ["extra"] = 0, ["fee"] = 0, ["timeDelta"] = 0, ["log"] = _rt.array({})}); end -- H5 engine.js:136 · cityDecisionReport _port["cityDecisionReport"] = function(run) local j = _rt.get(run, "journeyDecision"); if _rt.truth((not _rt.truth(j))) then do return nil end end local base = _rt.get(j, "baseSilver"); local extra = _rt.math["round"]((base * _rt.get(j, "extra"))); local fee = _rt.math["round"]((base * _rt.get(j, "fee"))); local loss = _rt.math["round"](((_rt.add(base, extra) * (100 - _rt.get(j, "cargo"))) / 100)); local duration = (_rt.get(j, "baseDuration") * _rt.add(1, _rt.get(j, "timeDelta"))); local fulfilled = _rt.choose((_rt.get(j, "promise") == "intact"), function() return _rt.compare(">=", _rt.get(j, "cargo"), 90) end, function() return _rt.compare("<=", duration, _rt.add(_rt.get(j, "deadline"), 1e-7)) end); local offeredBonus = _rt.math["round"]((base * 0.3)); local bonus = _rt.choose(fulfilled, function() return offeredBonus end, function() return 0 end); local silver = _rt.math["max"](1, _rt.add(((_rt.add(base, extra) - loss) - fee), bonus)); do return {["base"] = base, ["extra"] = extra, ["fee"] = fee, ["loss"] = loss, ["bonus"] = bonus, ["offeredBonus"] = offeredBonus, ["fulfilled"] = fulfilled, ["silver"] = silver, ["subtotal"] = ((_rt.add(base, extra) - loss) - fee), ["confirmed"] = _rt.compare(">=", _rt.get(_rt.get(j, "log"), "length"), 2), ["delta"] = (silver - base), ["duration"] = duration, ["cargo"] = _rt.get(j, "cargo"), ["promise"] = _rt.get(j, "promise"), ["deadline"] = _rt.get(j, "deadline"), ["condition"] = _rt.call(_port["CITY_ROAD_CONDITIONS"], "find", function(c) return (_rt.get(c, "id") == _rt.get(j, "condition")) end), ["log"] = _rt.get(j, "log")} end end -- H5 engine.js:149 · cityDecisionSpecs _port["cityDecisionSpecs"] = function(run) local j = _rt.get(run, "journeyDecision"); local c = _rt.call(_port["CITY_ROAD_CONDITIONS"], "find", function(c) return (_rt.get(c, "id") == _rt.get(j, "condition")) end); if _rt.truth((_rt.get(_rt.get(j, "log"), "length") == 0)) then do return _rt.array({{["key"] = "guide", ["t"] = "雇向导带路", ["hint"] = "付基础镖银的 15%;下一段解锁安全近路。", ["reason"] = "向导同行,险段可以走安全近路。", ["fee"] = 0.15, ["path"] = "guide"}, {["key"] = "load", ["t"] = "接下顺路货", ["hint"] = "加赚基础镖银的 40%,行程 +15%;抢行时额外货损 12%。", ["reason"] = "多带了一箱货,险段抢行时更容易损坏。", ["extra"] = 0.4, ["time"] = 0.15, ["path"] = "load"}, {["key"] = "light", ["t"] = "趁早赶路", ["hint"] = "行程 −20%;队伍疲劳,下一段抢行时额外货损 8%。", ["reason"] = "抢出了时间,但连续赶路会加重货损。", ["time"] = (-0.2), ["path"] = "light"}}) end end if _rt.truth((_rt.get(_rt.get(j, "log"), "length") ~= 1)) then do return _rt.array({}) end end local damage = _rt.add(_rt.get(c, "danger"), _rt.choose((_rt.get(j, "path") == "load"), function() return 12 end, function() return _rt.choose((_rt.get(j, "path") == "light"), function() return 8 end, function() return 0 end) end)); do return _rt.array({{["key"] = "safe", ["t"] = _rt.get(c, "safe"), ["hint"] = _rt.add(_rt.add("货物不受损;行程 +", _rt.math["round"]((_rt.get(c, "wait") * 100))), "%。"), ["reason"] = "选择稳妥通过,保住全部货物,付出了时间。", ["time"] = _rt.get(c, "wait")}, {["key"] = "rush", ["t"] = _rt.get(c, "fast"), ["hint"] = _rt.add(_rt.add(_rt.add(_rt.add("行程 −", _rt.math["round"](((-_rt.get(c, "rush")) * 100))), "%;确定损失 "), damage), "% 货物。"), ["reason"] = _rt.add(_rt.add(_rt.add(_rt.choose((_rt.get(j, "path") == "load"), function() return "满载增加了颠簸损失;" end, function() return _rt.choose((_rt.get(j, "path") == "light"), function() return "连续赶路加重了磕碰;" end, function() return "" end) end), "抢行省下时间,但货物实际损失 "), damage), "%。"), ["time"] = _rt.get(c, "rush"), ["damage"] = damage}, _rt.choose((_rt.get(j, "path") == "guide"), function() return {["key"] = "guided", ["t"] = _rt.get(c, "guide"), ["hint"] = "前面雇的向导派上用场:行程 −10%,零货损,不再收费。", ["reason"] = "先前雇的向导找到了安全近路,省时且没有货损。", ["time"] = (-0.1)} end, function() return {["key"] = "porters", ["t"] = "请当地脚夫转运", ["hint"] = "付基础镖银的 22%;行程 +5%,货物不受损。", ["reason"] = "付费转运避开了险段,保住货物并减少等待。", ["fee"] = 0.22, ["time"] = 0.05} end)}) end end -- H5 engine.js:166 · applyDecisionEffect _port["applyDecisionEffect"] = function(j, spec) _rt.update(j, "extra", "+", _rt.orElse(_rt.get(spec, "extra"), function() return 0 end)); _rt.update(j, "fee", "+", _rt.orElse(_rt.get(spec, "fee"), function() return 0 end)); _rt.update(j, "timeDelta", "+", _rt.orElse(_rt.get(spec, "time"), function() return 0 end)); _rt.set(j, "cargo", _rt.math["max"](0, (_rt.get(j, "cargo") - _rt.orElse(_rt.get(spec, "damage"), function() return 0 end)))); if _rt.truth(_rt.get(spec, "path")) then _rt.set(j, "path", _rt.get(spec, "path")); end end -- H5 engine.js:171 · previewCityDecision _port["previewCityDecision"] = function(run, key) if _rt.truth(_rt.compare(">=", _rt.get(_rt.get(run, "journeyDecision"), "version"), 2)) then do return nil end end local spec = _rt.call(_port["cityDecisionSpecs"](run), "find", function(o) return (_rt.get(o, "key") == key) end); if _rt.truth((not _rt.truth(spec))) then do return nil end end local copy = _rt.assign({}, run, {["journeyDecision"] = _rt.assign({}, _rt.get(run, "journeyDecision"), {["log"] = _rt.concat(_rt.get(_rt.get(run, "journeyDecision"), "log"))})}); _port["applyDecisionEffect"](_rt.get(copy, "journeyDecision"), spec); do return _port["cityDecisionReport"](copy) end end -- H5 engine.js:179 · cityDecisionHint _port["cityDecisionHint"] = function(run, o) local hints = {["guide"] = "花些银两请人带路。熟路能少走弯路,但向导也未必事事料准。", ["load"] = "掌柜说这批货有赚头。多带一箱,装卸和过山涉水时都得更小心。", ["light"] = "趁天色尚早赶一程。有望提早抵达,也可能把队伍累着。", ["safe"] = "宁可慢些,尽量护住货物。等待和绕路也可能遇上新的麻烦。", ["rush"] = "抓住眼前的机会闯过去。可能顺利抢出时间,也可能失足伤货。", ["guided"] = "让之前雇的向导领路。熟路更稳妥,临时的水势和路况仍难预料。", ["porters"] = "花钱请熟悉当地的人接手。省些力气,交货也得看他们是否顺利。"}; do return _rt.orElse(_rt.get(hints, _rt.get(o, "key")), function() return "路上变数不少,由你定夺。" end) end end -- H5 engine.js:191 · cityDecisionOptions _port["cityDecisionOptions"] = function(run) do return _rt.call(_port["cityDecisionSpecs"](run), "map", function(o) return {["t"] = _rt.get(o, "t"), ["e"] = {}, ["decisionKey"] = _rt.get(o, "key"), ["hint"] = _rt.choose(_rt.compare(">=", _rt.get(_rt.get(run, "journeyDecision"), "version"), 2), function() return _port["cityDecisionHint"](run, o) end, function() return _rt.get(o, "hint") end), ["cost"] = _rt.choose(_rt.get(o, "fee"), function() return _rt.math["round"]((_rt.get(_rt.get(run, "journeyDecision"), "baseSilver") * _rt.get(o, "fee"))) end, function() return 0 end), ["preview"] = _port["cityDecisionPreview"](run, o)} end) end end -- H5 engine.js:196 · cityDecisionPreview _port["cityDecisionPreview"] = function(run, spec) local before = _port["cityDecisionReport"](run); local j = _rt.get(run, "journeyDecision"); local outcomes = _rt.choose(_rt.compare(">=", _rt.get(j, "version"), 2), function() return _port["cityDecisionOutcomes"](run, spec) end, function() return _rt.array({spec}) end); local values = _rt.call(outcomes, "map", function(result) local copy = _rt.assign({}, run, {["journeyDecision"] = _rt.assign({}, j, {["log"] = _rt.concat(_rt.get(j, "log"))})}); _port["applyDecisionEffect"](_rt.get(copy, "journeyDecision"), result); if _rt.truth(_rt.compare(">=", _rt.get(j, "version"), 2)) then _rt.set(_rt.get(copy, "journeyDecision"), "timeDelta", _rt.math["max"](_rt.get(_rt.get(copy, "journeyDecision"), "timeDelta"), (_rt.add((_rt.get(run, "elapsed") / _rt.get(j, "baseDuration")), 0.08) - 1))); end local after = _port["cityDecisionReport"](copy); do return {["silver"] = (_rt.get(after, "subtotal") - _rt.get(before, "subtotal")), ["time"] = (_rt.get(after, "duration") - _rt.get(before, "duration")), ["damage"] = (_rt.get(before, "cargo") - _rt.get(after, "cargo"))} end end); do return {["silverMin"] = _rt.math["min"](table.unpack(_rt.concat(_rt.call(values, "map", function(v) return _rt.get(v, "silver") end)))), ["silverMax"] = _rt.math["max"](table.unpack(_rt.concat(_rt.call(values, "map", function(v) return _rt.get(v, "silver") end)))), ["timeMin"] = _rt.math["min"](table.unpack(_rt.concat(_rt.call(values, "map", function(v) return _rt.get(v, "time") end)))), ["timeMax"] = _rt.math["max"](table.unpack(_rt.concat(_rt.call(values, "map", function(v) return _rt.get(v, "time") end)))), ["damageMin"] = _rt.math["min"](table.unpack(_rt.concat(_rt.call(values, "map", function(v) return _rt.get(v, "damage") end)))), ["damageMax"] = _rt.math["max"](table.unpack(_rt.concat(_rt.call(values, "map", function(v) return _rt.get(v, "damage") end))))} end end -- H5 engine.js:210 · decisionRandom _port["decisionRandom"] = function(j) local t = _rt.set(j, "randomState", _rt.bit(">>>", _rt.add(_rt.get(j, "randomState"), 1831565813), 0)); (function() t = _rt.math["imul"](_rt.bit("^", t, _rt.bit(">>>", t, 15)), _rt.bit("|", t, 1)); return t end)(); (function() t = _rt.bit("^", t, _rt.add(t, _rt.math["imul"](_rt.bit("^", t, _rt.bit(">>>", t, 7)), _rt.bit("|", t, 61)))); return t end)(); do return (_rt.bit(">>>", _rt.bit("^", t, _rt.bit(">>>", t, 14)), 0) / 4294967296) end end -- H5 engine.js:215 · cityDecisionOutcomes _port["cityDecisionOutcomes"] = function(run, spec) local j = _rt.get(run, "journeyDecision"); local c = _rt.call(_port["CITY_ROAD_CONDITIONS"], "find", function(c) return (_rt.get(c, "id") == _rt.get(j, "condition")) end); local skill = _rt.orElse(_rt.get(j, "crewSkill"), function() return 0 end); local clamp = function(x, min, max) return _rt.math["max"](min, _rt.math["min"](max, x)) end; local outcomes; local entry = function(weight, outcome, reason, effect) return _rt.assign({}, {["weight"] = weight, ["outcome"] = outcome, ["reason"] = reason}, effect) end; if _rt.truth((_rt.get(spec, "key") == "guide")) then (function() outcomes = _rt.array({entry(_rt.add(0.6, skill), "遇到识途老客", "向导常年往来此路,刚上路便替队伍省下了一段绕行。", {["guideQuality"] = "expert", ["time"] = (-0.04)}), entry((0.32 - skill), "向导先去探路", "向导认真查看路况,稍费了些工夫,记下了可走的岔路。", {["guideQuality"] = "steady", ["time"] = 0.04}), entry(0.08, "旧路发生塌方", "向导认得的旧路有了塌方,带队退回路口,耽搁了一阵。", {["guideQuality"] = "uncertain", ["time"] = 0.12})}); return outcomes end)(); else if _rt.truth((_rt.get(spec, "key") == "load")) then (function() outcomes = _rt.array({entry(_rt.add(0.55, skill), "接到一笔好生意", "货主急着出货,答应了更高的镖银,装车也很顺利。", {["extra"] = 0.55, ["time"] = 0.08}), entry((0.32 - skill), "货物顺利装车", "按约接下货箱,装卸占了些时间,多带货也多了一份报酬。", {["extra"] = 0.35, ["time"] = 0.16}), entry(0.13, "装卸时出了岔子", "货主临时压了价,重箱装车时又碰破了几件货,镖银比说好的少,装车也耽搁了时间。", {["extra"] = 0.18, ["time"] = 0.28, ["damage"] = 4})}); return outcomes end)(); else if _rt.truth((_rt.get(spec, "key") == "light")) then (function() outcomes = _rt.array({entry(_rt.add(0.52, skill), "赶路很顺利", "路面比预想平整,队伍趁势赶出一段路,仍留有余力。", {["time"] = (-0.24), ["fatigue"] = 0}), entry((0.35 - skill), "赶路后人马疲乏", "队伍抢出了一些时间,但人马已经疲惫,后面再催着赶路更容易失手。", {["time"] = (-0.14), ["fatigue"] = 1}), entry(0.13, "急行反而陷了车", "车轮陷进路边软土,搬车费了力气,货箱也有轻微磕碰。", {["time"] = 0.06, ["fatigue"] = 2, ["damage"] = 3})}); return outcomes end)(); else if _rt.truth((_rt.get(spec, "key") == "rush")) then local risk = clamp(((_rt.add(_rt.add(_rt.add(0.38, (_rt.get(c, "danger") * 0.012)), _rt.choose((_rt.get(j, "path") == "load"), function() return 0.12 end, function() return 0 end)), (_rt.orElse(_rt.get(j, "fatigue"), function() return 0 end) * 0.06)) - skill) - _rt.choose((_rt.get(j, "guideQuality") == "expert"), function() return 0.04 end, function() return 0 end)), 0.15, 0.88); local pressure = _rt.add(_rt.choose((_rt.get(j, "path") == "load"), function() return 8 end, function() return 0 end), (_rt.orElse(_rt.get(j, "fatigue"), function() return 0 end) * 4)); (function() outcomes = _rt.array({entry((1 - risk), "平安通过险路", "队伍抓住了路况转好的短暂空隙,顺利通过,货物没有受损。", {["time"] = (-0.23)}), entry((risk * 0.65), "赶路时磕坏了货物", _rt.add(_rt.add("前面的道路比想象中难走。", _rt.choose((_rt.get(j, "path") == "load"), function() return "满载让车身更难控制," end, function() return _rt.choose(_rt.get(j, "fatigue"), function() return "疲劳让镖师慢了半拍," end, function() return "" end) end)), "虽抢出时间,仍有一部分货受损。"), {["time"] = (-0.1), ["damage"] = _rt.math["round"](_rt.add(_rt.add(8, (_rt.get(c, "danger") * 0.5)), pressure))}), entry((risk * 0.35), "车马失足,停车抢救", _rt.add("队伍在险处失手,赶紧停下抢救货物。", _rt.choose((_rt.get(j, "path") == "load"), function() return "多装的货箱加重了损失。" end, function() return _rt.choose(_rt.get(j, "fatigue"), function() return "疲劳让收拾残局更加吃力。" end, function() return "耽搁了脚程,也损失了部分货物。" end) end)), {["time"] = 0.16, ["damage"] = _rt.math["min"](55, _rt.math["round"](_rt.add(_rt.add(20, (_rt.get(c, "danger") * 0.7)), pressure)))})}); return outcomes end)(); else if _rt.truth((_rt.get(spec, "key") == "safe")) then local descriptions = _rt.get({["river"] = _rt.array({_rt.array({"水势渐缓,平安渡河", "等了片刻,水势便缓了下来,镖队顺利渡河。"}), _rt.array({"等水退后再渡河", "耐心等到水势减弱,镖队把货物完好地送到了对岸。"}), _rt.array({"挪车避水时磕坏了货", "水迟迟不退,挪车避水时又磕坏了少量货物。"})}), ["ridge"] = _rt.array({_rt.array({"官道畅通,平安绕行", "官道比预想好走,镖队绕开碎石路,货物没有受损。"}), _rt.array({"绕过碎石路,货物完好", "沿官道多绕了一段,镖队把货物完好地送过了山口。"}), _rt.array({"绕行途中仍有磕碰", "官道比预想更远,路面也有坑洼,几件货物被磕坏了。"})}), ["fog"] = _rt.array({_rt.array({"雾气渐散,继续赶路", "等了片刻,雾气便散去不少,镖队稳稳走过了栈道。"}), _rt.array({"等雾散后走过栈道", "耐心等到雾散,镖队把货物完好地送过了栈道。"}), _rt.array({"等雾时挪车磕坏了货", "雾迟迟不散,挪车避让时又磕坏了少量货物。"})})}, _rt.get(c, "id")); local risk = clamp((_rt.add(0.1, (_rt.get(c, "danger") * 0.003)) - (skill * 0.3)), 0.04, 0.2); (function() outcomes = _rt.array({entry(table.unpack(_rt.concat(_rt.array({_rt.add(0.42, skill)}), _rt.get(descriptions, 0), _rt.array({{["time"] = 0.12}})))), entry(table.unpack(_rt.concat(_rt.array({(((1 - risk) - 0.42) - skill)}), _rt.get(descriptions, 1), _rt.array({{["time"] = _rt.get(c, "wait")}})))), entry(table.unpack(_rt.concat(_rt.array({risk}), _rt.get(descriptions, 2), _rt.array({{["time"] = _rt.add(_rt.get(c, "wait"), 0.18), ["damage"] = 4}}))))}); return outcomes end)(); else local guided = (_rt.get(spec, "key") == "guided"); local risk = _rt.choose(guided, function() return clamp((_rt.add(_rt.add(0.1, (_rt.get(c, "danger") * 0.004)), _rt.choose((_rt.get(j, "guideQuality") == "uncertain"), function() return 0.12 end, function() return _rt.choose((_rt.get(j, "guideQuality") == "expert"), function() return (-0.06) end, function() return 0 end) end)) - (skill * 0.5)), 0.03, 0.35) end, function() return clamp((_rt.add(0.14, (_rt.get(c, "danger") * 0.002)) - (skill * 0.4)), 0.06, 0.24) end); (function() outcomes = _rt.choose(guided, function() return _rt.array({entry((0.8 - risk), "向导领队安然通过", "先前雇的向导找到了可走的小路,队伍绕开险处,省下了时间。", {["time"] = (-0.1)}), entry(0.2, "向导带队谨慎探行", "向导发现路况有变,带队查看前方道路,虽慢些却保住了货。", {["time"] = 0.06}), entry(risk, "熟路也有意外", "熟悉的小路临时受损,向导带队退避时仍碰坏了少量货物。", {["time"] = 0.18, ["damage"] = 7})}) end, function() return _rt.array({entry((0.8 - risk), "脚夫顺利转运", "当地脚夫熟悉落脚处,顺利把货物转运到了另一头。", {["time"] = 0.02}), entry(0.2, "脚夫分批搬运", "脚夫为了稳妥分批搬货,多费了些工夫,货物保持完好。", {["time"] = 0.12}), entry(risk, "转运时滑落一箱", "转运途中一箱货滑落,脚夫赶忙收拾,仍有少量损失。", {["time"] = 0.28, ["damage"] = 9})}) end); return outcomes end)(); end end end end end do return _rt.call(outcomes, "map", function(o) return _rt.assign({}, o, {["key"] = _rt.get(spec, "key"), ["path"] = _rt.get(spec, "path"), ["fee"] = _rt.orElse(_rt.get(spec, "fee"), function() return 0 end)}) end) end end -- H5 engine.js:263 · randomDecisionResult _port["randomDecisionResult"] = function(run, spec) local j = _rt.get(run, "journeyDecision"); local outcomes = _port["cityDecisionOutcomes"](run, spec); local roll = _port["decisionRandom"](j); local chosen = _rt.get(outcomes, (_rt.get(outcomes, "length") - 1)); for _, candidate in ipairs(outcomes) do do (function() roll = (roll - _rt.get(candidate, "weight")); return roll end)(); if _rt.truth(_rt.compare("<", roll, 0)) then (function() chosen = candidate; return chosen end)(); break end end ::_continue1:: end do return _rt.assign({}, chosen, {["key"] = _rt.get(spec, "key"), ["path"] = _rt.get(spec, "path"), ["fee"] = _rt.orElse(_rt.get(spec, "fee"), function() return 0 end)}) end end -- H5 engine.js:269 · acknowledgeCityDecision _port["acknowledgeCityDecision"] = function(s, runId) local run = _rt.call(_rt.get(s, "runs"), "find", function(r) return (_rt.get(r, "id") == runId) end); if _rt.truth((not _rt.truth(_rt.get(run, "decisionNotice")))) then do return false end end _rt.set(run, "decisionNotice", nil); _rt.set(run, "paused", false); do return true end end -- H5 engine.js:274 · cityDecisionEvent _port["cityDecisionEvent"] = function(run) local j = _rt.get(run, "journeyDecision"); local c = _rt.call(_port["CITY_ROAD_CONDITIONS"], "find", function(c) return (_rt.get(c, "id") == _rt.get(j, "condition")) end); local first = (_rt.get(_rt.get(j, "log"), "length") == 0); local setup = _rt.choose((_rt.get(j, "path") == "load"), function() return "你已接下额外货物,满载时冒险更容易伤货。" end, function() return _rt.choose((_rt.get(j, "path") == "light"), function() return "队伍已赶过一程,接下来得留意人马的状态。" end, function() return "你之前雇的向导认得另一条路。" end) end); do return {["id"] = _rt.add("decision-", _rt.get(_rt.get(j, "log"), "length")), ["journeyStage"] = _rt.get(_rt.get(j, "log"), "length"), ["cat"] = "商路抉择", ["title"] = _rt.choose(first, function() return "途中歇脚" end, function() return _rt.get(c, "title") end), ["text"] = _rt.choose(first, function() return _rt.add(_rt.add(_rt.add(_rt.get(c, "name"), "。"), _rt.get(c, "forecast")), " 驿站有人招揽带路,也有商人托你捎货。") end, function() return _rt.add(_rt.add(_rt.get(c, "text"), " "), setup) end), ["opts"] = _port["cityDecisionOptions"](run)} end end -- H5 engine.js:283 · applyCityDecision _port["applyCityDecision"] = function(s, run, opt) local j = _rt.get(run, "journeyDecision"); local ev = _rt.get(run, "pendingEvent"); if _rt.truth(_rt.orElse(_rt.orElse(_rt.orElse(_rt.orElse(_rt.get(run, "done"), function() return (not _rt.truth(_rt.get(run, "paused"))) end), function() return (not _rt.truth(ev)) end), function() return (_rt.get(ev, "journeyStage") ~= _rt.get(_rt.get(j, "log"), "length")) end), function() return (not _rt.truth(_rt.call(_rt.get(ev, "opts"), "some", function(o) return (_rt.get(o, "decisionKey") == _rt.get(opt, "decisionKey")) end))) end)) then do return {["failed"] = false, ["ignored"] = true} end end local spec = _rt.call(_port["cityDecisionSpecs"](run), "find", function(o) return (_rt.get(o, "key") == _rt.get(opt, "decisionKey")) end); if _rt.truth((not _rt.truth(spec))) then do return {["failed"] = false, ["ignored"] = true} end end local before = _port["cityDecisionReport"](run); local result = _rt.choose(_rt.compare(">=", _rt.get(j, "version"), 2), function() return _port["randomDecisionResult"](run, spec) end, function() return spec end); _port["applyDecisionEffect"](j, result); if _rt.truth(_rt.get(result, "guideQuality")) then _rt.set(j, "guideQuality", _rt.get(result, "guideQuality")); end if _rt.truth((_rt.get(result, "fatigue") ~= nil)) then _rt.set(j, "fatigue", _rt.get(result, "fatigue")); end if _rt.truth(_rt.compare(">=", _rt.get(j, "version"), 2)) then _rt.set(j, "timeDelta", _rt.math["max"](_rt.get(j, "timeDelta"), (_rt.add((_rt.get(run, "elapsed") / _rt.get(j, "baseDuration")), 0.08) - 1))); end local after = _port["cityDecisionReport"](run); local entry = {["title"] = _rt.get(ev, "title"), ["choice"] = _rt.get(spec, "t"), ["key"] = _rt.get(spec, "key"), ["reason"] = _rt.get(result, "reason"), ["outcome"] = _rt.get(result, "outcome"), ["extraDelta"] = (_rt.get(after, "extra") - _rt.get(before, "extra")), ["feeDelta"] = (_rt.get(after, "fee") - _rt.get(before, "fee")), ["lossDelta"] = (_rt.get(after, "loss") - _rt.get(before, "loss")), ["silverDelta"] = _rt.choose(_rt.compare(">=", _rt.get(j, "version"), 2), function() return (_rt.get(after, "subtotal") - _rt.get(before, "subtotal")) end, function() return (_rt.get(after, "silver") - _rt.get(before, "silver")) end), ["timeDelta"] = (_rt.get(after, "duration") - _rt.get(before, "duration")), ["cargoDelta"] = (_rt.get(after, "cargo") - _rt.get(before, "cargo")), ["afterSilver"] = _rt.get(after, "silver"), ["afterCargo"] = _rt.get(after, "cargo"), ["afterDuration"] = _rt.get(after, "duration")}; _rt.call(_rt.get(j, "log"), "push", entry); _rt.set(_rt.get(run, "effects"), "time", _rt.add(1, _rt.get(j, "timeDelta"))); if _rt.truth((_rt.get(_rt.get(j, "log"), "length") == 1)) then _rt.set(_rt.get(run, "eventAt"), 1, _rt.math["max"](_rt.add(_rt.get(run, "elapsed"), 0.5), (_rt.get(after, "duration") * 0.65))); end _rt.set(run, "pendingEvent", nil); _rt.set(run, "paused", _rt.compare(">=", _rt.get(j, "version"), 2)); if _rt.truth(_rt.compare(">=", _rt.get(j, "version"), 2)) then _rt.set(run, "decisionNotice", entry); end _port["track"](s, "city_decision", _rt.get(spec, "key")); do return {["failed"] = false, ["decision"] = entry} end end -- H5 engine.js:310 · cityRunOutcome _port["cityRunOutcome"] = function(s, run) local g = _port["cityGoal"](s, _rt.get(run, "cityGoalId")); if _rt.truth((not _rt.truth(g))) then do return "" end end if _rt.truth(_rt.get(run, "battleFailed")) then do return "本趟遇挫,此前完成的商路进度保留,请训练镖师后再试" end end if _rt.truth(_rt.andThen((_rt.get(run, "cityKind") == "prepare"), function() return _rt.get(g, "opened") end)) then do return _rt.add("短途押运完成 · 结算后可继续承接", _rt.get(g, "ability")) end end if _rt.truth((_rt.get(run, "cityKind") == "prepare")) then do return _rt.add(_rt.add(_rt.add("短途押运 ", _rt.math["min"](2, _rt.add(_rt.get(g, "deliveries"), 1))), "/2 趟 · "), _rt.choose((not _rt.truth(_rt.get(g, "drilled"))), function() return "结算后可花 80 两银子集体训练" end, function() return _rt.choose(_rt.compare(">=", _rt.get(g, "deliveries"), 1), function() return _rt.add(_rt.add("结算后可向", _rt.get(g, "name")), "送货") end, function() return "还需完成一趟短途押运" end) end)) end end if _rt.truth((_rt.get(run, "cityKind") == "open")) then do return _rt.add(_rt.add(_rt.add("首次送达", _rt.get(g, "name")), " · 结算后可承接"), _rt.get(g, "ability")) end end if _rt.truth((_rt.get(run, "cityKind") == "contract")) then do return _rt.add(_rt.get(g, "ability"), "已完成") end end do return "" end end -- H5 engine.js:320 · creditCityRun _port["creditCityRun"] = function(s, run) local g = _port["cityGoal"](s, _rt.get(run, "cityGoalId")); if _rt.truth(_rt.orElse((not _rt.truth(g)), function() return _rt.get(run, "battleFailed") end)) then do return nil end end local p = _rt.get(_rt.get(_port["journeyState"](s), "cities"), _rt.get(g, "id")); if _rt.truth((_rt.get(run, "cityKind") == "prepare")) then _rt.set(p, "deliveries", _rt.math["min"](2, _rt.add(_rt.get(p, "deliveries"), 1))); end if _rt.truth((_rt.get(run, "cityKind") == "contract")) then _rt.increment(p, "contracts", 1, false); end if _rt.truth(_rt.andThen((_rt.get(run, "cityKind") == "open"), function() return (not _rt.truth(_rt.get(p, "opened"))) end)) then _rt.set(p, "opened", true); _port["track"](s, "city_first_open", _rt.get(g, "id")); do return g end end do return nil end end _port["RIVALS"] = _rt.array({{["name"] = "铁掌帮 · 赵四", ["base"] = 120}, {["name"] = "顺风镖局 · 沈掌柜", ["base"] = 980}, {["name"] = "独行刀客 · 叶九", ["base"] = 2400}, {["name"] = "江南首富 · 范蠡", ["base"] = 6200}, {["name"] = "北地镖王 · 呼延烈", ["base"] = 11800}, {["name"] = "无声客栈 · 柳娘", ["base"] = 3400}, {["name"] = "西域商首 · 阿史那", ["base"] = 18500}, {["name"] = "江湖散人 · 无名氏", ["base"] = 520}}) end