feat(store): default free offline payment label to Direct Claim and make it tunable

Add tuning/store.jsonc freePaymentLabel (default Direct Claim in Chinese and English) and apply it consistently across the local web store, local marketplace, and the in-game payment dialog via cln_get_entitlements_price_ex top-level metadata.
This commit is contained in:
N0VAN0M4LY committed 2026-12-04 19:55:04 +08:00
1 parent 429c5eec12
commit 12a573a333
10 files changed
+154 -29

No files matched your search

+16 -3
View File
@@ -8,18 +8,24 @@
*/
import { appendParam, emptyBlock, setParam, type BlkBlock } from '@wto/blk';
import type { AccountStore } from '../../accounts/account-store.ts';
import type { LocalizedText } from '../../game-data/datasets/unit-names.ts';
import { clientProfile } from '../../profile/client-profile.ts';
import type { PlayerProfiles } from '../../profile/player-profiles.ts';
import { serverTimeNow } from '../../profile/server-time.ts';
import type { RuleOutcome } from '../../research/rule-outcome.ts';
import type { StoreCatalogue, StoreProduct } from '../../store/store-catalogue.ts';
import { buyGoldEntitlement } from '../../store/store-purchase.ts';
import { freePaymentLabelForStore } from '../../store/store-tuning.ts';
import type { CharActionHandler } from '../char-action.ts';
import { withAccount } from './account-context.ts';
import { headerOrPayloadInt, headerOrPayloadString } from './payload-params.ts';
export function entitlementsPriceEx(store: StoreCatalogue): CharActionHandler {
const table = buildEntitlementsPriceBlk(store.allProducts());
export function entitlementsPriceEx(
store: StoreCatalogue,
freePaymentLabel?: LocalizedText,
): CharActionHandler {
const label = freePaymentLabel ?? freePaymentLabelForStore(store);
const table = buildEntitlementsPriceBlk(store.allProducts(), label);
return () => ({ kind: 'data', blk: table });
}
@@ -42,8 +48,15 @@ export function buyEntitlementAction(profiles: PlayerProfiles, accounts: Account
});
}
function buildEntitlementsPriceBlk(products: readonly StoreProduct[]): BlkBlock {
function buildEntitlementsPriceBlk(
products: readonly StoreProduct[],
freePaymentLabel: LocalizedText,
): BlkBlock {
const root = emptyBlock();
// Top-level string params are ignored by stock blockCount() enumeration and read by the
// free-offline-payment-method GUI patch to localize the no-GJN payment option.
setParam(root, 'wtoFreePaymentLabelZh', { type: 'string', value: freePaymentLabel.zh });
setParam(root, 'wtoFreePaymentLabelEn', { type: 'string', value: freePaymentLabel.en });
for (const product of products) {
const block = emptyBlock(product.id);
setParam(block, 'chapter', { type: 'string', value: product.chapter });
@@ -4,8 +4,10 @@
* `extInventory` and pushing `mrpc.generic_notify` (`inventory.changed`) to active game clients.
*/
import { gjnText } from '../store/redeem-codes.ts';
import { DEFAULT_FREE_PAYMENT_LABEL } from '../store/store-tuning.ts';
import type { BlkBlock } from '@wto/blk';
import type { AccountStore } from '../accounts/account-store.ts';
import type { LocalizedText } from '../game-data/datasets/unit-names.ts';
import type { PlayerProfiles } from '../profile/player-profiles.ts';
import { balanceOf } from '../profile/profile-currency.ts';
import { externalInventoryItems } from '../profile/profile-external-inventory.ts';
@@ -36,6 +38,7 @@ export class MarketplaceService implements Service {
readonly #notifyInventoryChanged: () => void;
readonly #maxPerPurchase: number;
readonly #sellFeeRate: number;
readonly #freePaymentLabel: LocalizedText;
constructor(
accounts: AccountStore,
@@ -43,6 +46,7 @@ export class MarketplaceService implements Service {
catalogue: InventoryCatalogue,
notifyInventoryChanged: () => void,
tuning: Pick<MarketplaceTuning, 'maxPerPurchase' | 'sellFeeRate'>,
freePaymentLabel: LocalizedText = DEFAULT_FREE_PAYMENT_LABEL,
) {
this.#accounts = accounts;
this.#profiles = profiles;
@@ -50,6 +54,7 @@ export class MarketplaceService implements Service {
this.#notifyInventoryChanged = notifyInventoryChanged;
this.#maxPerPurchase = tuning.maxPerPurchase;
this.#sellFeeRate = tuning.sellFeeRate;
this.#freePaymentLabel = freePaymentLabel;
}
accepts(request: ServiceRequest): boolean {
@@ -96,6 +101,7 @@ export class MarketplaceService implements Service {
currentUserId: account?.userId ?? '',
balance,
sellFeeRate: this.#sellFeeRate,
freePaymentLabel: this.#freePaymentLabel,
listings,
}, `marketplace state (${account?.userId ?? 'no-account'})`);
}
@@ -158,7 +164,13 @@ export class MarketplaceService implements Service {
});
if (errorReason === 'NOT_ENOUGH_GJN') {
return jsonResponse({ ok: false, message: { zh: 'GJN 不够。可直接点「老福爷付过了」,或在商店的"兑换码"页用 GJN 充值码补充。', en: 'Not enough GJN. Use "老福爷付过了" or a GJN code on the Redeem tab of the store.' } }, `marketplace buy ${itemdefId}: NOMONEY`);
return jsonResponse({
ok: false,
message: {
zh: `GJN 不够。可直接点「${this.#freePaymentLabel.zh}」,或在商店的"兑换码"页用 GJN 充值码补充。`,
en: `Not enough GJN. Use "${this.#freePaymentLabel.en}" or a GJN code on the Redeem tab of the store.`,
},
}, `marketplace buy ${itemdefId}: NOMONEY`);
}
if (errorReason) {
return jsonResponse({ ok: false, message: { zh: '购买失败。', en: 'Purchase failed.' } }, `marketplace buy ${itemdefId}: ${errorReason}`);
@@ -166,15 +178,23 @@ export class MarketplaceService implements Service {
this.#notifyInventoryChanged();
const costSummary = isFree ? 'free' : `${gjnText(listing.gjnCostCents * quantity)} GJN`;
return jsonResponse({ ok: true, message: buySuccessMessage(listing, quantity, isFree) }, `marketplace buy ${itemdefId} x${quantity} (${costSummary})`);
return jsonResponse(
{ ok: true, message: buySuccessMessage(listing, quantity, isFree, this.#freePaymentLabel) },
`marketplace buy ${itemdefId} x${quantity} (${costSummary})`,
);
}
}
function buySuccessMessage(listing: MarketplaceListing, quantity: number, isFree: boolean): { zh: string; en: string } {
function buySuccessMessage(
listing: MarketplaceListing,
quantity: number,
isFree: boolean,
freePaymentLabel: LocalizedText,
): LocalizedText {
return isFree
? {
zh: `老福爷付过了!「${listing.title.zh}」兑换券 ×${quantity} 已放进游戏库存,可在机库的"道具 → 库存"里使用。`,
en: `Paid by 老福爷! ${quantity} × "${listing.title.en}" coupon is in your inventory (Items → Inventory in the hangar).`,
zh: `已通过「${freePaymentLabel.zh}」获得「${listing.title.zh}」兑换券 ×${quantity},已放进游戏库存,可在机库的"道具 → 库存"里使用。`,
en: `Claimed ${quantity} × "${listing.title.en}" coupon via "${freePaymentLabel.en}". It is in your inventory (Items → Inventory in the hangar).`,
}
: {
zh: `已购买「${listing.title.zh}」兑换券 ×${quantity},已放进游戏库存,可在机库的"道具 → 库存"里使用。`,
+8 -4
View File
@@ -9,7 +9,7 @@ const T = {
heldOnly: '只看我的库存', search: '搜索', sortPopular: '人气', sortName: '名称(从 A 到 Z)', sortPriceAsc: '价格(从低到高)', sortPriceDesc: '价格(从高到低)',
catVehicle: '载具', catSkin: '涂装', catAttachable: '装饰挂件', catDecal: '贴花', catUnlock: '头像',
allCountries: '全部国家', allClasses: '全部', rank: '{rank} 级', from: '从', held: '库存 ×{n}', owned: '已拥有',
buy: '购买', freeBuy: '老福爷付过了', sell: '出售', pickAccount: '请先在右上角选择账号', empty: '没有符合条件的物品',
buy: '购买', freeBuy: '直接获取', sell: '出售', pickAccount: '请先在右上角选择账号', empty: '没有符合条件的物品',
buyPrice: '系统售价:<b>{price}</b> GJN', sellPrice: '卖给系统:<b>{price}</b> GJN(扣 {fee}% 手续费)', youHave: '你拥有:<b>{n}</b>',
tradeUnconfirmed: '无法确认交易结果,请先查看余额和库存。',
tagType: '物品类型', tagRarity: '稀有度', tagCountry: '国家', ticker: '离线交易所:按固定价格与系统交易,价格取自官方交易所快照。',
@@ -19,7 +19,7 @@ const T = {
heldOnly: 'Only my inventory', search: 'Search', sortPopular: 'Popular', sortName: 'Name (A to Z)', sortPriceAsc: 'Price (low to high)', sortPriceDesc: 'Price (high to low)',
catVehicle: 'Vehicles', catSkin: 'Camouflages', catAttachable: 'Decorations', catDecal: 'Decals', catUnlock: 'Avatars',
allCountries: 'All countries', allClasses: 'All', rank: 'Rank {rank}', from: 'from', held: 'Owned ×{n}', owned: 'Owned',
buy: 'Buy', freeBuy: '老福爷付过了', sell: 'Sell', pickAccount: 'Pick an account at the top right', empty: 'Nothing matches the filters',
buy: 'Buy', freeBuy: 'Direct Claim', sell: 'Sell', pickAccount: 'Pick an account at the top right', empty: 'Nothing matches the filters',
buyPrice: 'System price: <b>{price}</b> GJN', sellPrice: 'Sell to system: <b>{price}</b> GJN ({fee}% fee)', youHave: 'You own: <b>{n}</b>',
tradeUnconfirmed: 'Could not confirm the trade. Check your balance and inventory.',
tagType: 'Item type', tagRarity: 'Rarity', tagCountry: 'Country', ticker: 'Offline market: fixed-price trades with the system, prices from an official market snapshot.',
@@ -33,7 +33,11 @@ const t = (key, params) => WtoUi.tr(T, key, params);
const $ = (id) => document.getElementById(id);
const wantedItem = WtoUi.query.get('n') || '';
let state = { accounts: [], currentUserId: '', balance: { gjnCents: 0, goldenEagles: 0 }, listings: [] };
let state = { accounts: [], currentUserId: '', balance: { gjnCents: 0, goldenEagles: 0 }, listings: [], freePaymentLabel: null };
function freePaymentLabel() {
return WtoUi.text(state.freePaymentLabel) || t('freeBuy');
}
const activeCats = new Set();
let openedWanted = false;
let tradeNoticeId = 0;
@@ -173,7 +177,7 @@ function fillOrderColumns(detail, listing) {
sellCol.append(sellBtn, html('totals', t('sellPrice', { price: WtoUi.gjn(listing.sellCents), fee })), html('totals', t('youHave', { n: listing.couponCount || 0 })));
const buyBtn = Object.assign(document.createElement('button'), { className: 'big buy', textContent: noAccount ? t('pickAccount') : t('buy'), disabled: noAccount });
buyBtn.onclick = () => trade('/trade.gaijin.net/api/buy', { itemdefId: listing.itemdefId, quantity: 1, payMethod: 'gjn' }, listing);
const freeBtn = Object.assign(document.createElement('button'), { className: 'big free', textContent: t('freeBuy'), disabled: noAccount });
const freeBtn = Object.assign(document.createElement('button'), { className: 'big free', textContent: freePaymentLabel(), disabled: noAccount });
freeBtn.onclick = () => trade('/trade.gaijin.net/api/buy', { itemdefId: listing.itemdefId, quantity: 1, payMethod: 'free' }, listing);
buyCol.append(buyBtn, freeBtn, html('totals', t('buyPrice', { price: WtoUi.gjn(listing.gjnCostCents) })));
}
+5 -2
View File
@@ -60,6 +60,7 @@ import { Router } from './transport/router.ts';
import { loadOrCreateCredentials } from './transport/tls/tls-certificate.ts';
import { StoreCatalogue } from './store/store-catalogue.ts';
import { StoreService } from './store/store-service.ts';
import { bindStoreFreePaymentLabel } from './store/store-tuning.ts';
import { TrainingCatalogue } from './training/training-completion.ts';
import { TrafficLog } from './traffic-log/traffic-log.ts';
import { loadTuning, type Tuning } from './tuning/tuning.ts';
@@ -235,7 +236,7 @@ export async function startServer(options: ServerOptions): Promise<RunningServer
webUi,
new RegistrationService(accounts),
new StoreService(accounts, profiles, catalogues.store, tuning.redeemCodes, options.port),
new MarketplaceService(accounts, profiles, catalogues.inventory, notifyInventoryChanged, tuning.marketplace),
new MarketplaceService(accounts, profiles, catalogues.inventory, notifyInventoryChanged, tuning.marketplace, tuning.store.freePaymentLabel),
new InventoryService(accounts, profiles, catalogues.inventory),
new LoginService(accounts),
new CharService(actionTable({
@@ -310,12 +311,14 @@ function loadDomainCatalogues(
localizedUnitNames: UnitNamesMap,
) {
const classicItemDefs = datasets.load(itemCatalogue);
const store = new StoreCatalogue(vehicles, datasets.load(storeBundles), localizedUnitNames, labels, tuning.store);
bindStoreFreePaymentLabel(store, tuning.store.freePaymentLabel);
return {
crew: new CrewSkillCatalogue(datasets.load(crewSkillData)),
decor: new DecorShop(datasets.load(decorCatalogue)),
unlocks: new UnlockShop(datasets.load(unlockPrices)),
items: new ItemCatalogue(classicItemDefs, tuning.limits.itemPiecesPerPurchase),
store: new StoreCatalogue(vehicles, datasets.load(storeBundles), localizedUnitNames, labels, tuning.store),
store,
inventory: new InventoryCatalogue(vehicles, localizedUnitNames, datasets.load(externalItemSources), classicItemDefs, tuning),
trophies: new TrophyCatalogue(vehicles, classicItemDefs, tuning.trophies),
training: new TrainingCatalogue(datasets.load(trainingMissions)),
+43
View File
@@ -39,7 +39,27 @@ export interface MultiVehiclePack extends VehiclePackContent {
readonly vehicles: readonly string[];
}
export const DEFAULT_FREE_PAYMENT_LABEL: LocalizedText = {
zh: '直接获取',
en: 'Direct Claim',
};
const MAX_FREE_PAYMENT_LABEL_LENGTH = 64;
const freePaymentLabelsByStore = new WeakMap<object, LocalizedText>();
/** Associate a configured free payment label with a StoreCatalogue instance. */
export function bindStoreFreePaymentLabel(store: object, label: LocalizedText): void {
freePaymentLabelsByStore.set(store, label);
}
/** Return the configured free payment label for a StoreCatalogue instance, falling back to the default. */
export function freePaymentLabelForStore(store: object): LocalizedText {
return freePaymentLabelsByStore.get(store) ?? DEFAULT_FREE_PAYMENT_LABEL;
}
export interface StoreTuning {
/** Localized label for the no-GJN offline payment button in the game dialog, local store, and marketplace. */
readonly freePaymentLabel: LocalizedText;
readonly goldenEaglePacks: readonly GoldenEaglePack[];
readonly silverLionPacks: readonly SilverLionPack[];
readonly premiumForGoldenEagles: readonly PremiumTier[];
@@ -53,6 +73,7 @@ export interface StoreTuning {
}
export function readStoreTuning(file: TuningReader): StoreTuning {
const freePaymentLabel = readFreePaymentLabel(file);
const packs = file.object('vehiclePacks');
const byRank = packs.list('byRank', (entry) => ({ upToRank: entry.int('upToRank', { min: 1 }), ...packContent(entry) }))
.sort((a, b) => a.upToRank - b.upToRank);
@@ -66,6 +87,7 @@ export function readStoreTuning(file: TuningReader): StoreTuning {
validateStoreUniqueness(goldenEaglePacks, silverLionPacks, premiumForGoldenEagles, premiumForGjn, multiVehiclePacks);
return {
freePaymentLabel,
goldenEaglePacks,
silverLionPacks,
premiumForGoldenEagles,
@@ -76,6 +98,27 @@ export function readStoreTuning(file: TuningReader): StoreTuning {
};
}
function readFreePaymentLabel(file: TuningReader): LocalizedText {
const labelObj = file.object('freePaymentLabel');
return {
zh: readFreePaymentLabelPart(labelObj, 'zh'),
en: readFreePaymentLabelPart(labelObj, 'en'),
};
}
function readFreePaymentLabelPart(entry: TuningReader, key: 'zh' | 'en'): string {
const trimmed = entry.string(key).trim();
if (trimmed === '') {
throw new TuningError(`tuning file store.jsonc: freePaymentLabel.${key} must not be blank`);
}
if (trimmed.length > MAX_FREE_PAYMENT_LABEL_LENGTH) {
throw new TuningError(
`tuning file store.jsonc: freePaymentLabel.${key} must be at most ${MAX_FREE_PAYMENT_LABEL_LENGTH} characters`,
);
}
return trimmed;
}
/** The pack content for a vehicle: its own entry over the first rank tier that covers its rank (the last tier above the highest). */
export function vehiclePackContent(tuning: StoreTuning, vehicle: string, rank: number): VehiclePackContent {
const tier = tuning.vehiclePacksByRank.find((entry) => rank <= entry.upToRank) ?? tuning.vehiclePacksByRank[tuning.vehiclePacksByRank.length - 1]!;
+35 -10
View File
@@ -20,6 +20,7 @@ import { describeRedeemCodes, gjnText, redeemStoreCode, type RedeemOutcome } fro
import type { RedeemTuning } from './redeem-tuning.ts';
import type { StoreCatalogue, StoreProduct } from './store-catalogue.ts';
import { buyFreeStoreProduct, buyGjnProduct, buyStoreCart, canBuyGjnProduct, type GjnPurchaseOutcome, type StoreCheckoutOutcome } from './store-purchase.ts';
import { freePaymentLabelForStore } from './store-tuning.ts';
const NO_ACCOUNT: LocalizedText = { zh: '没有找到这个账号,请先在右上角选择账号。', en: 'Account not found. Pick an account at the top right first.' };
@@ -31,12 +32,20 @@ export class StoreWebApi {
readonly #profiles: PlayerProfiles;
readonly #catalogue: StoreCatalogue;
readonly #redeemCodes: RedeemTuning;
readonly #freePaymentLabel: LocalizedText;
constructor(accounts: AccountStore, profiles: PlayerProfiles, catalogue: StoreCatalogue, redeemCodes: RedeemTuning) {
constructor(
accounts: AccountStore,
profiles: PlayerProfiles,
catalogue: StoreCatalogue,
redeemCodes: RedeemTuning,
freePaymentLabel?: LocalizedText,
) {
this.#accounts = accounts;
this.#profiles = profiles;
this.#catalogue = catalogue;
this.#redeemCodes = redeemCodes;
this.#freePaymentLabel = freePaymentLabel ?? freePaymentLabelForStore(catalogue);
}
/** The answer for /store/api/<name>, or undefined when it is not an API request. */
@@ -64,6 +73,7 @@ export class StoreWebApi {
products,
cartProductIds: profile ? storeCartIds(profile) : [],
redeemHelp: describeRedeemCodes(this.#redeemCodes),
freePaymentLabel: this.#freePaymentLabel,
}, `store web state (${account?.userId ?? 'no account'})`);
}
@@ -94,7 +104,10 @@ export class StoreWebApi {
return true;
});
const modeTag = isFree ? 'free' : 'gjn';
return jsonResponse({ ok: outcome.ok, cartProductIds, message: purchaseMessage(outcome, product, isFree) }, `store web buy ${product.id} (${modeTag}): ${outcome.ok ? 'OK' : outcome.reason}`);
return jsonResponse(
{ ok: outcome.ok, cartProductIds, message: purchaseMessage(outcome, product, isFree, this.#freePaymentLabel) },
`store web buy ${product.id} (${modeTag}): ${outcome.ok ? 'OK' : outcome.reason}`,
);
}
#cart(request: ServiceRequest): ServiceResponse {
@@ -153,7 +166,7 @@ export class StoreWebApi {
return false;
}
const outcome = buyStoreCart(profile, products, payMethod, now);
message = checkoutMessage(outcome, products, payMethod);
message = checkoutMessage(outcome, products, payMethod, this.#freePaymentLabel);
if (!outcome.ok) return false;
clearStoreCart(profile);
cartProductIds = [];
@@ -177,13 +190,18 @@ export class StoreWebApi {
}
}
function purchaseMessage(outcome: GjnPurchaseOutcome, product: StoreProduct, isFree: boolean): LocalizedText {
function purchaseMessage(
outcome: GjnPurchaseOutcome,
product: StoreProduct,
isFree: boolean,
freePaymentLabel: LocalizedText,
): LocalizedText {
const cost = gjnText(product.gjnCostCents ?? 0);
if (outcome.ok) {
return isFree
? {
zh: `老福爷付过了!已直接获得「${product.title.zh}」。关闭商店窗口后机库会自动刷新。`,
en: `Paid by 老福爷! Claimed "${product.title.en}". Close the store window to refresh the hangar.`,
zh: `已通过「${freePaymentLabel.zh}」获得「${product.title.zh}」。关闭商店窗口后机库会自动刷新。`,
en: `Claimed "${product.title.en}" via "${freePaymentLabel.en}". Close the store window to refresh the hangar.`,
}
: {
zh: `已购买「${product.title.zh}」,花费 ${cost} GJN。关闭商店窗口后机库会自动刷新。`,
@@ -191,7 +209,10 @@ function purchaseMessage(outcome: GjnPurchaseOutcome, product: StoreProduct, isF
};
}
if (outcome.reason === 'NOT_ENOUGH_GJN') {
return { zh: `GJN 不够:需要 ${cost} GJN。可直接点「老福爷付过了」,或在"兑换码"页用 GJN 充值码补充。`, en: `Not enough GJN: ${cost} GJN needed. Use "老福爷付过了" or a GJN code on the Redeem tab.` };
return {
zh: `GJN 不够:需要 ${cost} GJN。可直接点「${freePaymentLabel.zh}」,或在"兑换码"页用 GJN 充值码补充。`,
en: `Not enough GJN: ${cost} GJN needed. Use "${freePaymentLabel.en}" or a GJN code on the Redeem tab.`,
};
}
if (outcome.reason === 'ALREADY_BOUGHT') return alreadyBoughtMessage(product);
return { zh: '这个商品现在买不了。', en: 'This product cannot be bought right now.' };
@@ -208,19 +229,23 @@ function checkoutMessage(
outcome: StoreCheckoutOutcome,
products: readonly StoreProduct[],
payMethod: 'gjn' | 'free',
freePaymentLabel: LocalizedText,
): LocalizedText {
if (outcome.ok) {
const count = products.length;
const cost = gjnText(outcome.costCents);
return payMethod === 'free'
? { zh: `老福爷付过了!已领取 ${count} 件商品。关闭商城窗口后机库会自动刷新。`,
en: `Paid by 老福爷! Claimed ${count} items. Close the store to refresh the hangar.` }
? { zh: `已通过「${freePaymentLabel.zh}」领取 ${count} 件商品。关闭商城窗口后机库会自动刷新。`,
en: `Claimed ${count} items via "${freePaymentLabel.en}". Close the store to refresh the hangar.` }
: { zh: `已购买 ${count} 件商品,花费 ${cost} GJN。关闭商城窗口后机库会自动刷新。`,
en: `Bought ${count} items for ${cost} GJN. Close the store to refresh the hangar.` };
}
if (outcome.reason === 'NOT_ENOUGH_GJN') {
const cost = gjnText(outcome.costCents);
return { zh: `购物车共需 ${cost} GJN,当前余额不足。`, en: `Your cart costs ${cost} GJN. Your balance is too low.` };
return {
zh: `购物车共需 ${cost} GJN,当前余额不足。可直接点「${freePaymentLabel.zh}」。`,
en: `Your cart costs ${cost} GJN. Your balance is too low. Use "${freePaymentLabel.en}" instead.`,
};
}
const product = products.find((item) => item.id === outcome.productId);
return outcome.reason === 'ALREADY_BOUGHT' && product ? alreadyBoughtMessage(product) : NO_PRODUCT;
+9 -3
View File
@@ -9,7 +9,7 @@ const T = {
search: '搜索礼包或载具', allCountries: '所有国家', allRanks: '所有等级', rank: '{rank} 级',
sort: '商品排序', sortBest: '最畅销', sortNewest: '最新上架', sortPriceAsc: '价格从低到高', sortPriceDesc: '价格从高到低',
containsEagles: '{n} 金鹰', containsSilver: '{n} 银狮', containsPremium: '{days} 天高级账户',
buy: '购买', freeBuy: '老福爷付过了', owned: '已拥有', pickAccount: '请先选择账号',
buy: '购买', freeBuy: '直接获取', owned: '已拥有', pickAccount: '请先选择账号',
redeem: '兑换', codePlaceholder: '输入兑换码', empty: '没有符合条件的商品',
featured: '推荐礼包', bestSeller: '畅销', viewPack: '查看礼包', related: '更多推荐', packPrice: '礼包价格',
includes: '礼包内容', back: '返回目录', bonusTitle: '高级载具权益',
@@ -31,7 +31,7 @@ const T = {
search: 'Search packs or vehicles', allCountries: 'All nations', allRanks: 'All ranks', rank: 'Rank {rank}',
sort: 'Sort products', sortBest: 'Top sellers', sortNewest: 'Newest', sortPriceAsc: 'Price: low to high', sortPriceDesc: 'Price: high to low',
containsEagles: '{n} Golden Eagles', containsSilver: '{n} Silver Lions', containsPremium: '{days} days of Premium Account',
buy: 'Buy', freeBuy: '老福爷付过了', owned: 'Owned', pickAccount: 'Pick an account first',
buy: 'Buy', freeBuy: 'Direct Claim', owned: 'Owned', pickAccount: 'Pick an account first',
redeem: 'Redeem', codePlaceholder: 'Enter a code', empty: 'Nothing matches the filters',
featured: 'Featured packs', bestSeller: 'Top seller', viewPack: 'View pack', related: 'Explore other packs', packPrice: 'Pack price',
includes: 'Pack contents', back: 'Back to catalog', bonusTitle: 'Premium bonuses',
@@ -53,7 +53,7 @@ const t = (key, params) => WtoUi.tr(T, key, params);
const $ = (id) => document.getElementById(id);
let initialGuid = (WtoUi.query.get('item') || '').toUpperCase();
let state = { accounts: [], activeUserId: '', balance: { gjnCents: 0 }, products: [], cartProductIds: [], redeemHelp: [] };
let state = { accounts: [], activeUserId: '', balance: { gjnCents: 0 }, products: [], cartProductIds: [], redeemHelp: [], freePaymentLabel: null };
let currentTab = 'vehicle-pack';
let detailId = '';
let catalogScroll = 0;
@@ -61,9 +61,14 @@ let loadVersion = 0;
let loading = true;
const checkout = createStoreCheckout(loadState);
function freePaymentLabel() {
return WtoUi.text(state.freePaymentLabel) || t('freeBuy');
}
function applyStaticTexts() {
for (const el of document.querySelectorAll('[data-t]')) el.textContent = t(el.dataset.t);
for (const el of document.querySelectorAll('[data-label]')) el.setAttribute('aria-label', t(el.dataset.label));
$('payFree').textContent = freePaymentLabel();
$('searchInput').placeholder = t('search');
$('codeInput').placeholder = t('codePlaceholder');
$('marketLink').href = WtoUi.pageLink('/trade.gaijin.net/');
@@ -88,6 +93,7 @@ async function loadState(userId) {
return await loadState('');
}
state = next;
$('payFree').textContent = freePaymentLabel();
WtoUi.fillAccountSelect($('accountSelect'), state.accounts, state.activeUserId);
$('gjnVal').textContent = WtoUi.gjn(state.balance.gjnCents);
$('goldVal').textContent = WtoUi.num(state.balance.goldenEagles);
+4
View File
@@ -1,6 +1,10 @@
// Local store products and prices.
// The client receives these prices from the local server.
{
// Button label for the no-GJN offline payment method shown in the in-game payment dialog,
// local web store, and local marketplace. Players can override it in <data>/tuning/store.jsonc.
"freePaymentLabel": { "zh": "直接获取", "en": "Direct Claim" },
// GJN prices use the official USD prices at 1 GJN per USD.
// Golden Eagle packs use GJN in both the in-game payment dialog and the local web store.
@@ -3,7 +3,7 @@
// Without it: the in-game payment window offers no free offline purchase.
{
"id": "online-shop/free-offline-payment-method",
"title": "游戏内支付方式窗口增加「老福爷付过了」免 GJN 直接购买选项",
"title": "Add a no-GJN direct claim option to the in-game payment dialog",
"features": [
"G-Currencies",
"G-Premium account",
@@ -1,4 +1,11 @@
let freePayName = "老福爷付过了"
let { isChineseVersion, isChineseHarmonized } = require("%scripts/langUtils/language.nut")
let { getShopPriceBlk } = require("%scripts/onlineShop/onlineShopState.nut")
let isChinese = isChineseVersion() || isChineseHarmonized()
let priceBlk = getShopPriceBlk()
let customFreePayName = isChinese ? priceBlk?.wtoFreePaymentLabelZh : priceBlk?.wtoFreePaymentLabelEn
let freePayName = (type(customFreePayName) == "string" && customFreePayName != "")
? customFreePayName
: (isChinese ? "直接获取" : "Direct Claim")
items.append({
name = freePayName
icon = ""