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:
1 parent
429c5eec12
commit
12a573a333
10 files changed
+154
-29
No files matched your search
@@ -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 });
|
||||
|
||||
Reference in new issue
Block a user