fix(server): persist squadrons and align inventory wire formats
Read squadron action parameters from the request headers and persist squadron state on profile refresh. Use floating-point trophy weights to match the client probability display and assign unique log IDs when opening multiple chests. Tighten shop, marketplace, squadron, and cloud settings validation. Move PBBD and inventory encoding into the protocol modules and share CSV reading. Update the research and acceptance instructions. Type checking and all eight executable patch checks passed. In-game acceptance is pending.
This commit is contained in:
1 parent
b68f321b84
commit
29e5cf2bd8
40 files changed
+1347
-1248
No files matched your search
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* Redeem codes (implementation notes section G; implementation notes):
|
||||
* - PREMIUM-<N>D / VIP-<N>D (e.g. PREMIUM-7D, PREMIUM-30D, PREMIUM-365D): adds <N> days of
|
||||
* Premium Account (1..3650 days);
|
||||
* - WTO-GJN-<N> / GJN-<N> (e.g. WTO-GJN-100, WTO-GJN-1000): adds <N> GJN (1..100000);
|
||||
* Redeem & offline cheat codes (implementation notes section G; implementation notes;
|
||||
* local verification):
|
||||
* - PREMIUM-<N>D / WTO-PREM-<N>D / PREM-<N>D / VIP-<N>D (1..3650 days): adds <N> days of Premium Account;
|
||||
* - WTO-GJN-<N> / GJN-<N> (1..1000000): offline player cheat code adding <N> GJN;
|
||||
* - WTO-STARTER (once per save): grants 7 days of Premium Account, 1,000 Golden Eagles and 100 GJN.
|
||||
*/
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
@@ -22,28 +22,9 @@ export function redeemStoreCode(profile: BlkBlock, rawCode: string, nowFiletime:
|
||||
return { ok: false, reason: 'INVALID_CODE', message: { en: 'Enter a redeem code.', zh: '请输入兑换码。' } };
|
||||
}
|
||||
|
||||
if (code === 'WTO-STARTER') {
|
||||
if (hasEntitlement(profile, STARTER_ENTITLEMENT, nowFiletime)) {
|
||||
return {
|
||||
ok: false,
|
||||
reason: 'ALREADY_REDEEMED',
|
||||
message: { en: 'This starter code has already been redeemed on this save.', zh: '当前存档已使用过该新手礼包兑换码。' },
|
||||
};
|
||||
}
|
||||
recordEntitlementPurchase(profile, STARTER_ENTITLEMENT);
|
||||
extendPremiumAccount(profile, 7, nowFiletime);
|
||||
addGoldenEagles(profile, 1_000);
|
||||
setGjn(profile, balanceOf(profile).gjn + 100);
|
||||
return {
|
||||
ok: true,
|
||||
message: {
|
||||
en: 'Redeemed WTO-STARTER: +7d Premium Account, +1,000 Golden Eagles, +100 GJN.',
|
||||
zh: '兑换成功:高级账户 +7 天、金鹰 +1,000、GJN +100。',
|
||||
},
|
||||
};
|
||||
}
|
||||
if (code === 'WTO-STARTER') return redeemStarterCode(profile, nowFiletime);
|
||||
|
||||
const premiumMatch = /^(?:PREMIUM|PREM|VIP)-(\d{1,4})D$/.exec(code);
|
||||
const premiumMatch = /^(?:PREMIUM|WTO-PREM|PREM|VIP)-(\d{1,4})D$/.exec(code);
|
||||
if (premiumMatch) {
|
||||
const days = Number(premiumMatch[1]);
|
||||
if (days >= 1 && days <= 3_650) {
|
||||
@@ -58,10 +39,10 @@ export function redeemStoreCode(profile: BlkBlock, rawCode: string, nowFiletime:
|
||||
}
|
||||
}
|
||||
|
||||
const gjnMatch = /^(?:WTO-GJN|GJN)-(\d{1,6})$/.exec(code);
|
||||
const gjnMatch = /^(?:WTO-GJN|GJN)-(\d{1,7})$/.exec(code);
|
||||
if (gjnMatch) {
|
||||
const amount = Number(gjnMatch[1]);
|
||||
if (amount >= 1 && amount <= 100_000) {
|
||||
if (amount >= 1 && amount <= 1_000_000) {
|
||||
setGjn(profile, balanceOf(profile).gjn + amount);
|
||||
return {
|
||||
ok: true,
|
||||
@@ -77,8 +58,29 @@ export function redeemStoreCode(profile: BlkBlock, rawCode: string, nowFiletime:
|
||||
ok: false,
|
||||
reason: 'INVALID_CODE',
|
||||
message: {
|
||||
en: 'Unknown redeem code. Examples: PREMIUM-7D, PREMIUM-30D, PREMIUM-365D, WTO-GJN-100, WTO-STARTER.',
|
||||
zh: '无效的兑换码。可用示例:PREMIUM-7D、PREMIUM-30D、PREMIUM-365D、WTO-GJN-100、WTO-STARTER。',
|
||||
en: 'Unknown redeem code. Examples: PREMIUM-7D, PREMIUM-30D, WTO-PREM-90D, WTO-GJN-100, WTO-STARTER.',
|
||||
zh: '无效的兑换码。可用示例:PREMIUM-7D、PREMIUM-30D、WTO-PREM-90D、WTO-GJN-100、WTO-STARTER。',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function redeemStarterCode(profile: BlkBlock, nowFiletime: bigint): RedeemOutcome {
|
||||
if (hasEntitlement(profile, STARTER_ENTITLEMENT, nowFiletime)) {
|
||||
return {
|
||||
ok: false,
|
||||
reason: 'ALREADY_REDEEMED',
|
||||
message: { en: 'This starter code has already been redeemed on this save.', zh: '当前存档已使用过该新手礼包兑换码。' },
|
||||
};
|
||||
}
|
||||
recordEntitlementPurchase(profile, STARTER_ENTITLEMENT);
|
||||
extendPremiumAccount(profile, 7, nowFiletime);
|
||||
addGoldenEagles(profile, 1_000);
|
||||
setGjn(profile, balanceOf(profile).gjn + 100);
|
||||
return {
|
||||
ok: true,
|
||||
message: {
|
||||
en: 'Redeemed WTO-STARTER: +7d Premium Account, +1,000 Golden Eagles, +100 GJN.',
|
||||
zh: '兑换成功:高级账户 +7 天、金鹰 +1,000、GJN +100。',
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user