Patch definitions under exe-patches/ and gui-patches/ move from patch.json/locate.json to patch.jsonc/locate.jsonc. Each file now holds only the data needed to apply the patch plus a short English comment stating what it changes, why the local service cannot provide it, and what happens without it. Every definition records the game versions it was verified on (verified_on, required). GUI patches keep their stock text and replacement in find.nut and replace.nut next to patch.jsonc instead of escaped JSON strings, so the script edits are readable, diffable and can carry Quirrel comments. Matching treats CRLF and LF as the same line break because stock scripts mix both; only the matched span is rewritten. Loaders on both sides (packages/build, packages/exepatch, wtotools) reject unknown keys so analysis text cannot creep back into the data. JSONC parsing moves into a shared @wto/jsonc package; the build now parses tuning/store.jsonc instead of scanning it with a regex. Verified: npm run typecheck; check-patches (10/10 ready on 2.61.0.37); check-gui (33 patches, 24 scripts compile); the TypeScript and Python appliers produce identical scripts, byte-identical to the previous definitions except one stock script with mixed line endings. The 15 battle patches are migrated mechanically and still carry the pending-review comment; they are rewritten by the LocalMP review. BREAKING CHANGE: Patch loaders require JSONC definitions. Migrate patch.json and locate.json and move embedded GUI edits to separate Quirrel files.
100 lines
4.1 KiB
Plaintext
100 lines
4.1 KiB
Plaintext
function sendWtoAircraftAndWeaponRequest(requestData, isSilent = false) {
|
|
let wtoNdb = require("nestdb")
|
|
if (!wtoNdb.ndbExists(["wto", "activeBattle"]))
|
|
return requestAircraftAndWeaponWithSpare(requestData, requestData.idInCountry,
|
|
requestData.respBaseId, requestData.spareUid)
|
|
let wtoBattle = wtoNdb.ndbTryRead(["wto", "activeBattle"])
|
|
let wtoGuiRespawn = require("guiRespawn")
|
|
let wtoChardRes = require("chardResearch")
|
|
let wtoBlkGetters = require("blkGetters")
|
|
let wtoUnitName = requestData?.name ?? ""
|
|
local wtoExtraSlot = null
|
|
foreach (slot in (wtoBattle?.extraBattleSlots ?? [])) {
|
|
if (slot?.unitName == wtoUnitName) {
|
|
wtoExtraSlot = slot
|
|
break
|
|
}
|
|
}
|
|
if ((wtoExtraSlot?.forceWeapon ?? "") != "")
|
|
requestData.weapon = wtoExtraSlot.forceWeapon
|
|
let wtoIsSpaded = wtoExtraSlot?.spaded == true
|
|
let wtoUnit = getAircraftByName(wtoUnitName) ?? this.getCurSlotUnit()
|
|
let wtoEnabledMods = []
|
|
let wtoDisabledMods = []
|
|
foreach (wtoMod in (wtoUnit?.getModifications() ?? [])) {
|
|
let wtoModName = wtoMod?.name ?? ""
|
|
if (wtoModName == "")
|
|
continue
|
|
if (wtoIsSpaded || wtoChardRes.shopIsModificationEnabled(wtoUnitName, wtoModName))
|
|
wtoEnabledMods.append(wtoModName)
|
|
else if (wtoChardRes.shopIsModificationPurchased(wtoUnitName, wtoModName))
|
|
wtoDisabledMods.append(wtoModName)
|
|
}
|
|
let wtoEdiff = this.getCurrentEdiff()
|
|
let wtoDiffRem = wtoEdiff >= 0 ? (wtoEdiff % 3) : 1
|
|
let wtoDiffSuffix = wtoDiffRem == 0 ? "Arcade" : wtoDiffRem == 1 ? "Historical" : "Simulation"
|
|
let wtoUnitCost = get_wpcost_blk()?[wtoUnitName]
|
|
let wtoWarBlk = wtoBlkGetters.get_warpoints_blk()
|
|
let wtoBlk = DataBlock()
|
|
wtoBlk.enabledMods = ";".join(wtoEnabledMods)
|
|
wtoBlk.disabledMods = ";".join(wtoDisabledMods)
|
|
wtoBlk.isSilentPreview = isSilent ? "1" : "0"
|
|
if (wtoUnitCost != null && wtoWarBlk != null) {
|
|
let wtoClassKillMul = wtoWarBlk.units[wtoUnitCost.unitClass].tofloat()
|
|
let wtoRewardMul = wtoUnitCost[$"rewardMul{wtoDiffSuffix}"].tofloat()
|
|
wtoBlk.wpPerKill = (wtoWarBlk.aKill.tofloat() * wtoClassKillMul * wtoWarBlk.wpMultiplier.tofloat() * wtoRewardMul).tofloat()
|
|
wtoBlk.expMul = wtoUnitCost.expMul.tofloat()
|
|
wtoBlk.battleTimeAward = wtoUnitCost[$"battleTimeAward{wtoDiffSuffix}"].tofloat()
|
|
wtoBlk.aiKillK = wtoWarBlk.aiKillK.tofloat()
|
|
wtoBlk.winK = wtoWarBlk.winK.tofloat()
|
|
}
|
|
if (!isSilent && (requestData?.spareUid ?? "") != "" && wtoUnitName != "") {
|
|
let prevSpares = wtoBattle?.usedSpares ?? {}
|
|
prevSpares[wtoUnitName] <- (prevSpares?[wtoUnitName] ?? 0) + 1
|
|
wtoBattle.usedSpares <- prevSpares
|
|
wtoNdb.ndbWrite(["wto", "activeBattle"], wtoBattle)
|
|
}
|
|
return wtoGuiRespawn.requestAircraftAndWeaponWithSlots(requestData, requestData.idInCountry,
|
|
requestData.respBaseId, requestData.spareUid, wtoBlk, DataBlock())
|
|
}
|
|
|
|
function requestAircraftAndWeapon(requestData) {
|
|
if (this.requestInProgress)
|
|
return
|
|
|
|
set_aircraft_accepted_cb(this, this.aircraftAcceptedCb);
|
|
let _taskId = this.sendWtoAircraftAndWeaponRequest(requestData, false)
|
|
if (_taskId < 0)
|
|
set_aircraft_accepted_cb(null, null);
|
|
else {
|
|
this.requestInProgress = true
|
|
this.showTaskProgressBox(loc("charServer/purchase0"), function() { this.requestInProgress = false })
|
|
|
|
this.lastRequestData = requestData
|
|
}
|
|
}
|
|
|
|
function requestChangeUnitSilent() {
|
|
let unit = this.getCurSlotUnit()
|
|
if (!unit?.isHuman() || !this.canChangeAircraft || this.isApplyPressed) {
|
|
this.isSilentRequestPending = false
|
|
return
|
|
}
|
|
this.isSilentRequestPending = this.requestInProgress || !canRequestAircraftNow()
|
|
if (this.isSilentRequestPending)
|
|
return
|
|
|
|
let requestData = this.getSelectedRequestData(true)
|
|
if (!requestData)
|
|
return
|
|
|
|
set_aircraft_accepted_cb(this, this.silentAircraftAcceptedCb);
|
|
let _taskId = this.sendWtoAircraftAndWeaponRequest(requestData, true)
|
|
if (_taskId < 0)
|
|
set_aircraft_accepted_cb(null, null);
|
|
else {
|
|
this.requestInProgress = true
|
|
this.lastRequestData = requestData
|
|
}
|
|
}
|