更新AB商城最终版

This commit is contained in:
COMPUTER\EDY
2026-09-29 18:57:56 +08:00
parent 7886bbfef5
commit 271cdb53d2
45 changed files with 43561 additions and 24952 deletions
+13
View File
@@ -412,6 +412,19 @@ export class GameConfig {
&& ["B", "2"].includes(String(assignment.group).toUpperCase());
}
static isShopB(): boolean {
const assignments = this.GM_INFO.abTestAssignments || {};
const assignment = assignments.layer_3 || Object.keys(assignments)
.map(key => assignments[key]).find(item => item && Number(item.layer) === 3);
if (assignment) return assignment.enabled !== false
&& ["B", "2"].includes(String(assignment.group).toUpperCase());
return !!this.GM_INFO.abTests && this.GM_INFO.abTests.layer_three === 2;
}
static getShopPrefabPath(): string {
return this.isShopB() ? "prefab/shop2" : "prefab/shop";
}
static getLevelConfigPath(level: number, mainline: boolean = true): string {
const folder = mainline && this.isNewPlayerB() && level >= 1 && level <= 50 ? "Json2" : "Json";
return `${folder}/level${level}`;
@@ -0,0 +1,41 @@
export interface ShopProduct {
id: string;
price: number; // 分
coin: number;
firstPurchaseKey?: string;
hammer?: number;
freeze?: number;
magic?: number;
infiniteHealth?: number; // 秒;8 元礼包没有无限体力
}
export const SHOP_A_GOLD: ShopProduct[] = [
{ id: "gold_1", price: 600, coin: 1200, firstPurchaseKey: "gold_1" },
{ id: "gold_2", price: 3600, coin: 8000, firstPurchaseKey: "gold_2" },
{ id: "gold_3", price: 6800, coin: 16000, firstPurchaseKey: "gold_3" },
{ id: "gold_4", price: 12800, coin: 32000, firstPurchaseKey: "gold_4" },
{ id: "gold_5", price: 32800, coin: 100000, firstPurchaseKey: "gold_5" },
{ id: "gold_6", price: 64800, coin: 240000, firstPurchaseKey: "gold_6" },
];
export const SHOP_B_GOLD: ShopProduct[] = [
{ id: "new_gold_1", price: 600, coin: 1200, firstPurchaseKey: "gold_1" },
{ id: "new_gold_2", price: 3000, coin: 6800, firstPurchaseKey: "gold_2" },
{ id: "new_gold_3", price: 6800, coin: 16000, firstPurchaseKey: "gold_3" },
{ id: "new_gold_4", price: 12800, coin: 32000, firstPurchaseKey: "gold_4" },
{ id: "new_gold_5", price: 32800, coin: 84000, firstPurchaseKey: "gold_5" },
{ id: "new_gold_6", price: 64800, coin: 168000, firstPurchaseKey: "gold_6" },
];
export const SHOP_B_BUNDLES: ShopProduct[] = [
{ id: "new_unlimited_health_bundle_8", price: 800, coin: 1500, hammer: 2, freeze: 2, magic: 2, infiniteHealth: 0 },
{ id: "new_unlimited_health_bundle_18", price: 1800, coin: 3000, hammer: 5, freeze: 5, magic: 5, infiniteHealth: 1800 },
{ id: "new_unlimited_health_bundle_36", price: 3600, coin: 6000, hammer: 10, freeze: 10, magic: 10, infiniteHealth: 7200 },
{ id: "new_unlimited_health_bundle_68", price: 6800, coin: 10000, hammer: 20, freeze: 20, magic: 20, infiniteHealth: 21600 },
{ id: "new_unlimited_health_bundle_98", price: 9800, coin: 20000, hammer: 25, freeze: 25, magic: 25, infiniteHealth: 43200 },
];
// 按订单商品 ID 查奖励,补单不能使用玩家当前的 AB 分组决定数值。
export function getNewShopProduct(id: string): ShopProduct {
return SHOP_B_GOLD.concat(SHOP_B_BUNDLES).find(product => product.id === id);
}
@@ -0,0 +1,10 @@
{
"ver": "1.1.0",
"uuid": "3cf4c676-9dc9-48c9-852c-2bd77c5c2039",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
+34 -1
View File
@@ -5,6 +5,7 @@ import Freeze from "../../prop/Freeze";
import SceneManager from "../../SceneManager";
import { MiniGameSdk } from "../../Sdk/MiniGameSdk";
import Utils from "../Pay/Utils";
import { getNewShopProduct } from "../Config/ShopCatalog";
import BlockAssetManager from "./BlockAssetManager";
import {
starterPackReward, applyStarterPackStatus, starterPackRemaining, starterPackNow,
@@ -999,6 +1000,10 @@ var GameTool = {
//商城购买
shopBuy(productId, compensate, orderContext: any = null) {
const newProduct = getNewShopProduct(productId);
const newOrderKey = newProduct && orderContext?.outTradeNo
? "ShopBGranted_" + cc.fx.GameConfig.GM_INFO.uid + "_" + orderContext.outTradeNo : "";
if (newOrderKey && cc.fx.StorageMessage.getStorage(newOrderKey)) return;
const rebornOrderKey = /^reborn_Gift(?:_[2-5])?$/.test(productId) && orderContext?.outTradeNo
? "RebornGiftGranted_" + cc.fx.GameConfig.GM_INFO.uid + "_" + orderContext.outTradeNo : "";
if (rebornOrderKey && cc.fx.StorageMessage.getStorage(rebornOrderKey)) return false;
@@ -1017,7 +1022,35 @@ var GameTool = {
}
//console.log(productId);
//console.log("发放奖励", productId);
switch (productId) {
if (newProduct) {
price = newProduct.price;
coin = newProduct.coin;
const doubleKey = newProduct.firstPurchaseKey;
const doubleInfo = cc.fx.GameConfig.GM_INFO.shopDouble;
if (doubleKey && doubleInfo && doubleInfo[doubleKey] === false) {
coin *= 2;
doubleInfo[doubleKey] = true;
Utils.setShopDouble(() => {}, doubleInfo);
MiniGameSdk.API.showToast("充值成功,获得双倍金币");
}
this.changeCoin(coin);
rewardData = [{ type: "coin", count: coin }];
if (newProduct.hammer) {
this.getShopProp({ hammer: newProduct.hammer, freeze: newProduct.freeze,
magic_wand: newProduct.magic, price }, compensate);
rewardData.push({ type: "hammer", count: newProduct.hammer },
{ type: "freeze", count: newProduct.freeze }, { type: "magic", count: newProduct.magic });
}
if (newProduct.infiniteHealth) {
this.setUserPowerTime(newProduct.infiniteHealth, productId, compensate);
rewardData.push({ type: "infinite_health", count: newProduct.infiniteHealth });
}
if (newOrderKey) cc.fx.StorageMessage.setStorage(newOrderKey, true);
if (shopComp) {
shopComp.initCoin();
shopComp.refreshJungleRewardDisplay();
}
} else switch (productId) {
case "gold_1":
if (cc.fx.GameConfig.GM_INFO.shopDouble.gold_1 == false) {
cc.fx.GameConfig.GM_INFO.shopDouble.gold_1 = true;