diff --git a/assets/Script/Map.ts b/assets/Script/Map.ts index 3e3610f..9202128 100644 --- a/assets/Script/Map.ts +++ b/assets/Script/Map.ts @@ -13,6 +13,7 @@ import { MiniGameSdk } from "./Sdk/MiniGameSdk"; import Animation = cc.Animation; // import Revive from "./Revive"; import Utils from "./module/Pay/Utils"; +import { getABReviveCoinCost, MAX_REVIVE_COST_STEP } from "./module/Config/ReviveCostConfig"; import Vine from "./prop/vine"; const { ccclass, property } = cc._decorator; @@ -21,7 +22,6 @@ const { ccclass, property } = cc._decorator; @ccclass export default class MapConroler extends cc.Component { private MAX_RETRY_COUNT = 6; // 最大重试次数 - private readonly reviveCoinCosts: number[] = [500, 500, 500, 500, 500, 500]; private _blocksEmptyTime: number | null = null; // 保底机制计时 static _instance: any; @property(cc.SpriteAtlas) @@ -4242,8 +4242,9 @@ export default class MapConroler extends cc.Component { } private getReviveCoinCost(): number { - const reviveCount = Math.max(0, cc.fx.GameConfig.GM_INFO.review || 0); - return this.reviveCoinCosts[Math.min(reviveCount, this.reviveCoinCosts.length - 1)]; + const assignment = cc.fx.GameConfig.GM_INFO.abTestAssignments + && cc.fx.GameConfig.GM_INFO.abTestAssignments.layer_3; + return getABReviveCoinCost(assignment, cc.fx.GameConfig.GM_INFO.review); } private updateReviveCoinDisplay(buyBtn: cc.Node) { @@ -4355,7 +4356,7 @@ export default class MapConroler extends cc.Component { this.node.parent.getChildByName("Ice").active = false; } - if (cc.fx.GameConfig.GM_INFO.review < this.reviveCoinCosts.length - 1) + if (cc.fx.GameConfig.GM_INFO.review < MAX_REVIVE_COST_STEP) cc.fx.GameConfig.GM_INFO.review += 1; this.icetimeNode[0].active = true; diff --git a/assets/Script/module/Config/ReviveCostConfig.ts b/assets/Script/module/Config/ReviveCostConfig.ts new file mode 100644 index 0000000..a339376 --- /dev/null +++ b/assets/Script/module/Config/ReviveCostConfig.ts @@ -0,0 +1,25 @@ +export const REVIVE_COST_AB_NAME = "revive_cost_ascend"; +export const MAX_REVIVE_COST_STEP = 5; + +const DEFAULT_REVIVE_COSTS = [500]; +const REVIVE_COSTS_BY_GROUP = { + B: [500, 700, 900], + C: [500, 700, 900, 1100, 1300, 1500] +}; + +export function getABReviveCoinCost(assignment: any, reviveCount: any): number { + const isTargetExperiment = assignment + && String(assignment.layer) === "3" + && assignment.name === REVIVE_COST_AB_NAME + && assignment.enabled !== false; + const group = isTargetExperiment + ? String(assignment.group || "Default").toUpperCase() + : "DEFAULT"; + const costs = group === "B" + ? REVIVE_COSTS_BY_GROUP.B + : group === "C" + ? REVIVE_COSTS_BY_GROUP.C + : DEFAULT_REVIVE_COSTS; + const step = Math.max(0, Math.floor(Number(reviveCount) || 0)); + return costs[Math.min(step, costs.length - 1)]; +} diff --git a/assets/Script/module/Config/ReviveCostConfig.ts.meta b/assets/Script/module/Config/ReviveCostConfig.ts.meta new file mode 100644 index 0000000..ef231ac --- /dev/null +++ b/assets/Script/module/Config/ReviveCostConfig.ts.meta @@ -0,0 +1,10 @@ +{ + "ver": "1.1.0", + "uuid": "763b8065-12e6-4c06-9796-051f0a1d89d8", + "importer": "typescript", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/server/laf-cloud/functions/redeem.ts b/server/laf-cloud/functions/redeem.ts index 2b3661a..169ec2d 100644 --- a/server/laf-cloud/functions/redeem.ts +++ b/server/laf-cloud/functions/redeem.ts @@ -1,12 +1,12 @@ import cloud from '@lafjs/cloud' const db = cloud.database(); import Utils from "@/Utils"; -const CDKreward={ - wucaixiaoxiaole666:{ - 1001:1000, - 2001:1, - 2002:1, - 2003:1, +const CDKreward = { + wucaixiaoxiaole666: { + 1001: 1000, + 2001: 1, + 2002: 1, + 2003: 1, } } export default async function (ctx: FunctionContext) { @@ -14,9 +14,9 @@ export default async function (ctx: FunctionContext) { if (!uid) { return { code: 0, data: null, msg: "参数错误" }; } - let cdk= ctx.body.cdk; - if(!cdk){ - return {code:0, data:null, msg:"未获取到cdk"} + let cdk = ctx.body.cdk; + if (!cdk) { + return { code: 0, data: null, msg: "未获取到cdk" } } cdk = cdk.toLowerCase(); let dbname = "users"; @@ -64,30 +64,34 @@ export default async function (ctx: FunctionContext) { }, msg: "可以购买" }; } - let info = await db.collection("idcount").where({ _id:"694e064b35004ffb5aba0dc6"}).getOne(); - let count= info.data.count; - if(count.includes(cdk)){ - let index=count.indexOf(cdk); - count.splice(index,1); + let info = await db.collection("idcount").where({ _id: "69fac04fb4d89b170da4bf64" }).getOne(); + let count = info.data.count; + if (count.includes(cdk)) { + let index = count.indexOf(cdk); + count.splice(index, 1); redeem.push(cdk); db.collection(dbname).where({ _id: uid }).update({ redeem: redeem }); - await db.collection("idcount").where({ _id: "694e064b35004ffb5aba0dc6" }).update({count:count}); - let money=600; - let num=1; - if(cdk.length==6){ - money=1500; - num=3; - }else if(cdk.length==8){ - money=600; - num=1; + await db.collection("idcount").where({ _id: "69fac04fb4d89b170da4bf64" }).update({ count: count }); + let money = 600; + let num = 1; + if (cdk.length == 6) { + money = 1500; + num = 3; + } else if (cdk.length == 8) { + money = 600; + num = 1; } - return { code: 1, data: { reward: { - 1001:money, - 2001: num, - 2002: num, - 2003: num, - } }, msg: "可以购买" }; - }else{ + return { + code: 1, data: { + reward: { + 1001: money, + 2001: num, + 2002: num, + 2003: num, + } + }, msg: "可以购买" + }; + } else { let reward = CDKreward[cdk]; if (!reward) { return { code: 0, data: null, msg: "未获取到奖励信息" }; @@ -96,5 +100,5 @@ export default async function (ctx: FunctionContext) { db.collection(dbname).where({ _id: uid }).update({ redeem: redeem }); return { code: 1, data: { reward: reward }, msg: "可以购买" }; } - + } diff --git a/server/laf-cloud/tests/ab-config-admin.test.mjs b/server/laf-cloud/tests/ab-config-admin.test.mjs index 54cdaed..7c7428f 100644 --- a/server/laf-cloud/tests/ab-config-admin.test.mjs +++ b/server/laf-cloud/tests/ab-config-admin.test.mjs @@ -165,7 +165,7 @@ test("Default is a case-insensitive reserved group name", async () => { }); test("the admin page explains edge-triggered reset behavior", async () => { - const ui = await readFile(new URL("../../xxwzUI.html", import.meta.url), "utf8"); + const ui = await readFile(new URL("../../xxwz.html", import.meta.url), "utf8"); assert.match(ui, /关闭→开启并发布/); assert.match(ui, /关闭后未登录用户不补做/); diff --git a/server/laf-cloud/tests/revive-cost-ab.test.mjs b/server/laf-cloud/tests/revive-cost-ab.test.mjs new file mode 100644 index 0000000..5506d46 --- /dev/null +++ b/server/laf-cloud/tests/revive-cost-ab.test.mjs @@ -0,0 +1,48 @@ +import test from "node:test"; +import assert from "node:assert/strict"; + +const configUrl = new URL("../../../assets/Script/module/Config/ReviveCostConfig.ts", import.meta.url); +const { getABReviveCoinCost, MAX_REVIVE_COST_STEP, REVIVE_COST_AB_NAME } = await import(configUrl); + +function assignment(group, overrides = {}) { + return { + experimentId: "exp_layer_3_003", + layer: "3", + name: REVIVE_COST_AB_NAME, + enabled: true, + group, + ...overrides, + }; +} + +test("Default and group A always cost 500", () => { + for (const group of ["Default", "A"]) { + assert.deepEqual( + Array.from({ length: 9 }, (_, count) => getABReviveCoinCost(assignment(group), count)), + Array(9).fill(500), + ); + } +}); + +test("group B ascends 500, 700, 900 and stays at 900", () => { + assert.deepEqual( + Array.from({ length: 7 }, (_, count) => getABReviveCoinCost(assignment("B"), count)), + [500, 700, 900, 900, 900, 900, 900], + ); +}); + +test("group C ascends through 1500 and stays at 1500", () => { + assert.deepEqual( + Array.from({ length: 8 }, (_, count) => getABReviveCoinCost(assignment("C"), count)), + [500, 700, 900, 1100, 1300, 1500, 1500, 1500], + ); + assert.equal(MAX_REVIVE_COST_STEP, 5); +}); + +test("disabled, missing, or unrelated assignments use the 500 fallback", () => { + assert.equal(getABReviveCoinCost(null, 5), 500); + assert.equal(getABReviveCoinCost(assignment("C", { enabled: false }), 5), 500); + assert.equal(getABReviveCoinCost(assignment("C", { layer: "2" }), 5), 500); + assert.equal(getABReviveCoinCost(assignment("C", { name: "another_experiment" }), 5), 500); + assert.equal(getABReviveCoinCost(assignment("D"), 5), 500); +}); diff --git a/server/消消王者cdk.html b/server/消消王者cdk.html new file mode 100644 index 0000000..f02c1e1 --- /dev/null +++ b/server/消消王者cdk.html @@ -0,0 +1,348 @@ + + +
+ + +1500金币 + 锤子,时间停止,魔法棒各3个道具
+ +600金币 + 锤子,时间停止,魔法棒各1个道具
+ +