feat(store): open store pages in-game and centralize economy tuning
Use the native embedded browser and pass the game language through auto_local. Share web assets and extract vehicle icons, flags, and localized names from the installed client. Load and validate per-domain JSONC tuning and merge local overrides by field. Use official store USD prices for GJN products, keep GJN balances in integer cents, and split the native and web store handlers by protocol. Multi-vehicle packs are still listed as single vehicles at this point. Type checking, patch checks, and configuration loading passed. In-game acceptance is pending.
This commit is contained in:
1 parent
8d9cca9d05
commit
9cf7df5299
74 files changed
+2904
-1455
No files matched your search
@@ -13,8 +13,11 @@ export const ITEM_TYPES = ['rateBooster', 'personalDiscounts', 'wager', 'mission
|
||||
|
||||
export class ItemCatalogue {
|
||||
readonly #items: ReadonlyMap<string, ItemDefinition>;
|
||||
/** The most pieces one cln_buy_item may ask for (tuning/limits.jsonc). */
|
||||
readonly maxPiecesPerPurchase: number;
|
||||
|
||||
constructor(definitions: readonly ItemDefinition[]) {
|
||||
constructor(definitions: readonly ItemDefinition[], maxPiecesPerPurchase: number) {
|
||||
this.maxPiecesPerPurchase = maxPiecesPerPurchase;
|
||||
const known = new Set<string>(ITEM_TYPES);
|
||||
this.#items = new Map(definitions.filter((item) => known.has(item.type)).map((item) => [item.name, item]));
|
||||
}
|
||||
|
||||
@@ -13,11 +13,9 @@ import { ACCEPTED, refused, type RuleOutcome } from '../research/rule-outcome.ts
|
||||
import { isForSale, type ItemCatalogue } from './item-catalogue.ts';
|
||||
import { grantItem } from './item-grants.ts';
|
||||
|
||||
const MAX_PIECES = 1000;
|
||||
|
||||
export function buyItem(profile: BlkBlock, catalogue: ItemCatalogue, name: string, pieces: number, offered: Price, now: ServerTime): RuleOutcome {
|
||||
const item = catalogue.item(name);
|
||||
if (!item || pieces < 1 || pieces > MAX_PIECES) return refused('BAD_PARAMS');
|
||||
if (!item || pieces < 1 || pieces > catalogue.maxPiecesPerPurchase) return refused('BAD_PARAMS');
|
||||
if (!isForSale(item)) return refused('NOT_AVAILABLE');
|
||||
const price: Price = { silverLions: item.silverLions * pieces, goldenEagles: item.goldenEagles * pieces };
|
||||
if (price.silverLions !== offered.silverLions || price.goldenEagles !== offered.goldenEagles) return refused('PRICE_CHANGED');
|
||||
|
||||
Reference in new issue
Block a user