mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-22 16:48:34 +02:00
feat(credits): client consumes served catalog; direct entry counts as a credit purchase
① assetPacks.js merges the server-authoritative catalog (from the entitlement snapshot) into RK.PACKS — operator-added packs now appear client-side and existing packs pick up server definitions, retiring the client half of the split-brain. ② A confirmed direct/single_game payment now records as 'buy 1 credit + spend it': balance nets to zero but total_credits_purchased advances (recordDirectEntryPurchase), so direct play unlocks the same tier/threshold cosmetics as buying credits, and the client gets a fresh entitlement snapshot. +2 tests. Suite 49/345 green. P1 foundation (branch feat/credits-catalog-foundation). Remaining: the buy modal reflects the unified credits model; a later pass can fully collapse single_game into the credit spend path.
This commit is contained in:
@@ -44,6 +44,30 @@
|
||||
RK.setEntitlementSnapshot = function (data) {
|
||||
data = data || {};
|
||||
var prev = RK.entitlements || {};
|
||||
|
||||
// Consume the server-authoritative catalog (migration 024). This retires the hardcoded
|
||||
// client pack list as the source of truth: operator-added packs appear, and existing packs
|
||||
// pick up server definitions (label/projection/tier). Merged (not replaced) so any client
|
||||
// fallback a render mode relies on is preserved if the operator's catalog omits it.
|
||||
if (Array.isArray(data.catalog) && data.catalog.length) {
|
||||
var merged = {};
|
||||
for (var k in RK.PACKS) merged[k] = RK.PACKS[k];
|
||||
for (var ci = 0; ci < data.catalog.length; ci++) {
|
||||
var c = data.catalog[ci];
|
||||
if (!c || !c.id) continue;
|
||||
var ex = merged[c.id] || {};
|
||||
merged[c.id] = {
|
||||
id: c.id,
|
||||
label: c.label || ex.label || c.id,
|
||||
premium: c.premium != null ? !!c.premium : !!ex.premium,
|
||||
projection: c.projection || ex.projection || null,
|
||||
tier: c.tier != null ? c.tier : ex.tier,
|
||||
unlockMinCredits: c.unlockMinCredits != null ? c.unlockMinCredits : ex.unlockMinCredits,
|
||||
unlock: ex.unlock
|
||||
};
|
||||
}
|
||||
RK.PACKS = merged;
|
||||
}
|
||||
var hasTotal = data.totalCreditsPurchased != null || data.total_credits_purchased != null;
|
||||
var hasPremium = data.premium != null;
|
||||
var hasPacks = !!data.packs;
|
||||
|
||||
Reference in New Issue
Block a user