diff --git a/assets/Script/GameManager.ts b/assets/Script/GameManager.ts index 0375649..3d9f462 100644 --- a/assets/Script/GameManager.ts +++ b/assets/Script/GameManager.ts @@ -439,7 +439,13 @@ export default class GameManager extends cc.Component { this.checkDailyQuests(); // console.log("服务器强制刷新状态__________", data.data.forcedUpdate); //如果有连胜记录,就赋值 - if (data.data.winStreak !== undefined && data.data.winStreak !== null) { + if (cc.fx.GameConfig.forceRainbowWinStreakB) { + cc.fx.GameConfig.GM_INFO.winStreak = 10; + cc.fx.GameConfig.GM_INFO.winState = true; + cc.fx.StorageMessage.setStorage("winStreak", 10); + cc.fx.StorageMessage.setStorage("winState", true); + } + else if (data.data.winStreak !== undefined && data.data.winStreak !== null) { // console.log("从服务器得到连胜", data.data.winStreak); cc.fx.GameConfig.GM_INFO.winStreak = parseInt(data.data.winStreak); let winState = cc.fx.StorageMessage.getStorage("winState"); diff --git a/assets/Script/Map.ts b/assets/Script/Map.ts index 61dcf67..b56f3a0 100644 --- a/assets/Script/Map.ts +++ b/assets/Script/Map.ts @@ -1036,7 +1036,7 @@ export default class MapConroler extends cc.Component { "win_streak": cc.fx.GameConfig.GM_INFO.winStreak, } if (cc.fx.GameConfig.GM_INFO.winStreak >= 10 && cc.fx.GameConfig.GM_INFO.otherLevel == 0) { - cc.fx.GameConfig.GM_INFO.winState = false; + cc.fx.GameConfig.GM_INFO.winState = cc.fx.GameConfig.forceRainbowWinStreakB; cc.fx.StorageMessage.setStorage("winState", cc.fx.GameConfig.GM_INFO.winState); } cc.fx.GameTool.shushu_Track("enter_stage", data); diff --git a/assets/Script/RainbowRules.ts b/assets/Script/RainbowRules.ts index b1089ce..d8a2de7 100644 --- a/assets/Script/RainbowRules.ts +++ b/assets/Script/RainbowRules.ts @@ -2,7 +2,7 @@ export const RAINBOW_COLOR = 100; export const RAINBOW_CAPACITY = 30; export const RAINBOW_CELL_ENERGY = 3; // 临时放慢飞行以便测试;飞行结束后才裁切方块,正式时长为 0.3 秒。 -export const RAINBOW_CAST_SECONDS = 1.5; +export const RAINBOW_CAST_SECONDS = 1; export interface RainbowCell { x: number; y: number; } export interface RainbowCut { diff --git a/assets/Script/module/Config/GameConfig.ts b/assets/Script/module/Config/GameConfig.ts index b616ca3..d62ae50 100644 --- a/assets/Script/module/Config/GameConfig.ts +++ b/assets/Script/module/Config/GameConfig.ts @@ -431,7 +431,7 @@ export class GameConfig { return levels[feature]; } - // 临时测试彩虹十连胜 B 方案;改为 false 后恢复真实 AB 分组。 + // 临时测试:强制彩虹 B 方案,输赢、退出均保持十连胜;false 恢复真实 AB 和正常连胜规则。 static forceRainbowWinStreakB = true; static isRainbowWinStreak(): boolean { diff --git a/assets/Script/module/Tool/GameTool.ts b/assets/Script/module/Tool/GameTool.ts index f755524..44487c5 100644 --- a/assets/Script/module/Tool/GameTool.ts +++ b/assets/Script/module/Tool/GameTool.ts @@ -1986,6 +1986,13 @@ var GameTool = { }, setWinStreak(type) { + if (cc.fx.GameConfig.forceRainbowWinStreakB) { + cc.fx.GameConfig.GM_INFO.winStreak = 10; + cc.fx.GameConfig.GM_INFO.winState = true; + cc.fx.StorageMessage.setStorage("winStreak", 10); + cc.fx.StorageMessage.setStorage("winState", true); + return; + } if (type == "sucess") { if (cc.fx.GameConfig.GM_INFO.winStreak <= 10) { cc.fx.GameConfig.GM_INFO.winStreak += 1; diff --git a/tools/test-rainbow-streak.cjs b/tools/test-rainbow-streak.cjs index 42a3eeb..dd26a31 100644 --- a/tools/test-rainbow-streak.cjs +++ b/tools/test-rainbow-streak.cjs @@ -500,3 +500,30 @@ test('home restores test streak before rendering, even when login or a previous assert.equal(config.GM_INFO.winState, enabled); } }); + +test('test switch keeps ten wins through wins and losses; disabling restores normal settlement', () => { + const source = ts.createSourceFile('GameTool.ts', read('assets/Script/module/Tool/GameTool.ts'), ts.ScriptTarget.Latest, true); + const declaration = source.statements.filter(ts.isVariableStatement) + .flatMap(node => [...node.declarationList.declarations]).find(node => node.name.getText(source) === 'GameTool'); + const member = declaration.initializer.properties.find(node => node.name.getText(source) === 'setWinStreak'); + const config = { forceRainbowWinStreakB: true, GM_INFO: { winStreak: 0, winState: false } }; + const saved = {}; let uploads = 0; + const settle = vm.runInNewContext('({' + member.getText(source) + '}).setWinStreak', { + cc: { fx: { GameConfig: config, StorageMessage: { setStorage: (key, value) => saved[key] = value } } }, + Utils: { setWinStreak() { uploads++; } } + }); + for (const result of ['fail', 'sucess', 'fail', 'fail', 'sucess']) { + settle(result); + assert.equal(config.GM_INFO.winStreak, 10); assert.equal(config.GM_INFO.winState, true); + assert.deepEqual(saved, { winStreak: 10, winState: true }); + } + assert.equal(uploads, 0); + config.forceRainbowWinStreakB = false; + settle('fail'); + assert.equal(config.GM_INFO.winStreak, 0); assert.equal(config.GM_INFO.winState, false); + assert.deepEqual(saved, { winStreak: 0, winState: false }); + config.GM_INFO.winStreak = 9; + settle('sucess'); + assert.equal(config.GM_INFO.winStreak, 10); assert.equal(config.GM_INFO.winStreakFirst, true); + assert.equal(uploads, 2); +});