Untitled
unknown
csharp
2 years ago
22 kB
2
Indexable
using _IECModules; using System.Linq; using UnityEngine; using System; using System.Collections.Generic; namespace IEC { public class ABTestController : _BaseBehaviour, IController, IEventListener, IEventAwake, IEventStart { #region COMMON public void LocateController() { Controllers.Add(this); } public bool IsActive() { return gameObject.activeSelf; } public void OnEventRaise(string gameEvent, EventParam param) { switch (gameEvent) { case EventList.NONE: break; } } public void BehaviourAwake() { } public void BehaviourStart() { var serviceAbTest = Services.ABTest(); var abTestConfigs = Services.config.abTestConfigs; var listAbTestConfig = Services.config.abTestConfigs.ToList(); var abIndex = listAbTestConfig.FindLastIndex(x => serviceAbTest.HasValue(x.KeyName)); var forceSetAb = "ForceSetAB"; var forceSetAbName = Services.DataSecure().GetString(forceSetAb, "No Force Set"); var forceSetAbIndex = listAbTestConfig.FindLastIndex(x => x.KeyName == forceSetAbName); abIndex = (forceSetAbIndex >= 0) ? forceSetAbIndex : abIndex; var abConfig = listAbTestConfig.ElementAtOrDefault(abIndex); if (abConfig == null) { Debug.LogError("No AB Test"); ResultAllAbTest(); EventController.RaiseEvent(EventList.GamePlay.APPLY_AB_TEST); return; } ModuleController.cheatCode.AddCheatCodeButtonWithDropdown("AB Test Config", cheatCodeParam => { var cheatAbIndex = cheatCodeParam.dropdownParam.value; Services.DataSecure().SetString(forceSetAb, abTestConfigs[cheatAbIndex].KeyName); ApplyAbTest(cheatAbIndex); }, abTestConfigs.Select(x => x.KeyName).ToList(), abIndex ); ApplyAbTest(abIndex); } void ApplyAbTest(int abIndex) { Pool.Set(new Game()); var serviceAbTest = Services.ABTest(); var listAbTestConfig = Services.config.abTestConfigs.ToList(); var abConfig = (abIndex >= 0) ? listAbTestConfig[abIndex] : null; if (abConfig == null) { Debug.LogError("ApplyAbTest found no AB test"); return; } var abValue = serviceAbTest.GetValue(abConfig.KeyName, 0); var abEventName = abConfig.ListEventsAB[abValue]; var listResultAb = GetListResultAction(); var listUpdateAb = GetListUpdateAbAction(); var dictOverride = GetDictOverrideResult().OrderByDescending(x => x.Key).ToDictionary(x => x.Key, x => x.Value); var listAbTestDate = listAbTestConfig.Select((x, i) => new ABTestDate() { config = x, date = int.Parse(x.KeyName.Split('_').Last()) }) .ToList(); var curTestDate = listAbTestDate[abIndex]; curTestDate.version = int.Parse(abEventName.Split('v').Last()); if (listUpdateAb.Count != listAbTestConfig.Count) { Debug.LogError("List Update AB Action Not Equal List AB Test"); return; } var isOverride = curTestDate.IsOverrideResult(dictOverride, out var overrideDate); for (int i = 0; i < listResultAb.Count; i++) { var testDate = listAbTestDate[i]; if (testDate.IsApplyResult(curTestDate, overrideDate)) { listResultAb[i].Invoke(); } } if (curTestDate.IsApplyUpdate(overrideDate)) { var updateAbAction = listUpdateAb[abIndex]; updateAbAction.Invoke(abValue); } ResultAllAbTest(); AddCheatCodeVersionAB(abConfig, abIndex, abValue); Game.abVersion = curTestDate.version; EventController.RaiseEvent(EventList.GamePlay.APPLY_AB_TEST); // Debug.Log("==>Cheat turn off WCP"); } void AddCheatCodeVersionAB(ABTestConfig abTestConfig, int abIndex, int abValue) { var cheatCodeName = "AB Test Version"; var cheatCode = ModuleController.cheatCode.GetCheatCodeParam(cheatCodeName); if (cheatCode == null) { ModuleController.cheatCode.AddCheatCodeButtonWithDropdown(cheatCodeName, null, null); cheatCode = ModuleController.cheatCode.GetCheatCodeParam(cheatCodeName); } cheatCode.action = cheatCodeParam => { abValue = cheatCodeParam.dropdownParam.value; Services.DataNormal().SetInt(abTestConfig.KeyName, abValue); ApplyAbTest(abIndex); ResultAllAbTest(); }; cheatCode.dropdownParam = new CheatCode.DropdownParam { options = abTestConfig.ListEventsAB.ToList(), value = abValue }; } #endregion void ResultAllAbTest() { ResultAbFullAds(); Game.isHaveMoveModeLevel = true; Game.hintVersionType = HintVersion.WCF; //ResultAb20210608(); //ResultAb20210615(); //ResultAb20210618(); //ResultAb20210622(); //ResultAb20210624(); //ResultAb20210628(); //ResultAb20210701(); //ResultAb20210705(); //ResultAb20210708(); //ResultAb20210714(); //ResultAb20210718(); //ResultAb20210720(); //ResultAb20210727(); //ResultAb20210803(); //ResultAb20210810(); //ResultAb20210817(); //ResultAb20210825(); //ResultAb20210902(); //ResultAb20210913(); } Dictionary<int, Func<int, int, bool>> GetDictOverrideResult() { return new Dictionary<int, Func<int, int, bool>> { //{ 20210718, (date, version) => version == 91 }, //{ 20210718, (date, version) => date == 20210714 }, { 20210718, null }, { 20210825, null }, //{ 20220106, null }, // ios { 20220618, (date, version) => Services.config.platform == "ios" }, // android //{ 20220712, (date, version) => Services.config.platform == "android" }, // ios { 20220726, null }, // android //{ 20220928, null }, // ios { 20221022, null } //android }; } List<Action> GetListResultAction() { return new List<Action>() { //ResultAbFullAds, ResultAb20221111 //ResultAb20210608, //ResultAb20210615, //ResultAb20210618, //ResultAb20210622, //ResultAb20210624, //ResultAb20210628, //ResultAb20210701, //ResultAb20210705, //ResultAb20210708, //ResultAb20210714, //ResultAb20210718, //ResultAb20210720, //ResultAb20210727, //ResultAb20210803, //ResultAb20210810, //ResultAb20210817, //ResultAb20210825, //ResultAb20210902, //ResultAb20210913, ////ResultAb20220106, //ResultAb20220618, ////ResultAb20220622, //ResultAb20220628, //ResultAb20220708, ////ResultAb20220712, //ResultAb20220715, //ResultAb20220722, //ResultAb20220726, //ResultAb20220728, //ResultAb20220806, //ResultAb20220812, //ResultAb20220828, //ResultAb20220911, //ResultAb20220918, ////ResultAb20220928, //ResultAb20221002, //ResultAb20221008 }; } List<Action<int>> GetListUpdateAbAction() { return new List<Action<int>>() { UpdateAb20221111 //UpdateAbFullAds, //UpdateAb20210608, //UpdateAb20210615, //UpdateAb20210618, //UpdateAb20210622, //UpdateAb20210624, //UpdateAb20210628, //UpdateAb20210701, //UpdateAb20210705, //UpdateAb20210708, //UpdateAb20210714, //UpdateAb20210718, //UpdateAb20210720, //UpdateAb20210727, //UpdateAb20210803, //UpdateAb20210810, //UpdateAb20210817, //UpdateAb20210825, //UpdateAb20210902, //UpdateAb20210913, ////UpdateAb20220106, //UpdateAb20220618, ////UpdateAb20220622, //UpdateAb20220628, //UpdateAb20220708, ////UpdateAb20220712, //UpdateAb20220715, //UpdateAb20220722, //UpdateAb20220726, //UpdateAb20220728, //UpdateAb20220806, //UpdateAb20220812, //UpdateAb20220828, //UpdateAb20220911, //UpdateAb20220918, ////UpdateAb20220928, //UpdateAb20221002, //UpdateAb20221008, //UpdateAb20221022 }; } void UpdateAb20221111(int abValue) { // Debug.LogError("UpdateAb20221111 " + abValue); Game.isHaveGameOverUIv2 = true; Game.isHaveHintSuggestion = true; Game.isRandomWaterColor = true; //anim start game Game.levelIntro = LevelIntroType.DropDown; Game.isHaveSound = true; //Hide btn restart-next Game.levelRotateVer = 1; //fix level rotation Game.isHaveNotification = true; Game.isUseOneBg = false; Game.isFreeMove = true; Game.levelDifficultyVer = 2; Game.isHaveHint = true; Game.waterSpeed = 2; } void ResultAb20221111() { Debug.LogError("ResultAb20221111 "); } void UpdateAb20221022(int abValue) { } void ResultAb20221008() { } void UpdateAb20221008(int abValue) { Game.reskinWCPMixColorVer = abValue == 1 ? 1 : 0; Game.popupMidGameVer = abValue == 2 ? 1 : 0; } void ResultAb20221002() { } void UpdateAb20221002(int abValue) { Game.reskinWCPVer = abValue == 0 ? 0 : abValue + 3; GameWCP.blankBlockBossVer = abValue == 2 ? 3 : 0; //GameWCP.blankBlockBossVer = 1; } void ResultAb20220928() { } void UpdateAb20220928(int abValue) { } void ResultAb20220918() { } void UpdateAb20220918(int abValue) { Game.reskinWCPVer = abValue; } void ResultAb20220911() { } void UpdateAb20220911(int abValue) { Game.dailyChallengeVer = (abValue == 2 || abValue == 3) ? 5 : Game.dailyChallengeVer; Game.WCPModeSpacingVer = (abValue == 1 || abValue == 3) ? 2 : Game.WCPModeSpacingVer; } void ResultAb20220828() { Game.isHaveGameOverUIv2 = true; } void UpdateAb20220828(int abValue) { Game.dailyChallengeVer = abValue == 1 ? 4 : Game.dailyChallengeVer; Game.isHaveGameOverUIv2 = abValue == 2; } void ResultAb20220812() { } void UpdateAb20220812(int abValue) { if (abValue > 0) { Game.dailyChallengeVer = abValue; } } void ResultAb20220806() { } void UpdateAb20220806(int abValue) { Game.balanceVersion = abValue == 1 || abValue == 2 ? abValue + 3 : 1; GameWCP.isHaveOneWayBlock = abValue == 1 || abValue == 2; GameWCP.isHaveMixColorLevel = abValue == 1 || abValue == 2; } void ResultAb20220728() { } void UpdateAb20220728(int abValue) { GameWCP.isUseWCFBackground = abValue == 1; Game.isUseHintEffectWCP = abValue == 2; } void ResultAb20220726() { } void UpdateAb20220726(int abValue) { } void ResultAb20220722() { } void UpdateAb20220722(int abValue) { Game.balanceVersion = abValue == 1 || abValue == 2 ? abValue + 1 : 1; GameWCP.isHaveOneWayBlock = abValue == 1 || abValue == 2; GameWCP.isHaveMixColorLevel = abValue == 1 || abValue == 2; } void ResultAb20220715() { } void UpdateAb20220715(int abValue) { GameWCP.isHaveOneWayBlock = abValue == 1; GameWCP.blankBlockBossVer = abValue == 2 ? 1 : 0; } void ResultAb20220712() { Game.isHaveGameOverUIv2 = true; } void UpdateAb20220712(int abValue) { } void ResultAb20220708() { Game.isHaveHintSuggestion = true; } void UpdateAb20220708(int abValue) { GameWCP.isHaveMixColorLevel = abValue == 1; Game.isHaveDynamicInter = abValue == 2; } void ResultAb20220628() { Game.isHaveLevelWCP = true; } void UpdateAb20220628(int abValue) { Game.isHaveLevelWCP = abValue == 1; } void ResultAb20220622() { Game.isHaveHintSuggestion = true; } void UpdateAb20220622(int abValue) { Game.isHaveHintSuggestion = abValue == 1; Game.isHaveBlankBlockLevel = abValue == 2; } void ResultAb20220618() { } void UpdateAb20220618(int abValue) { } void ResultAb20220106() { } void UpdateAb20220106(int abValue) { } void ResultAb20210913() { } void UpdateAb20210913(int abValue) { Game.isHave2dView = abValue == 1; Game.isHaveUnlimitedUndo = abValue == 2; Game.isHaveTopView = abValue == 3; } void ResultAb20210902() { Game.isHaveSound = Game.isHaveVibrate = true; if (!PlayerData.isSoundOnDefault) { PlayerData.SetSoundState(true); PlayerData.isSoundOnDefault = true; } Game.levelIntro = LevelIntroType.DropDown; Game.isRandomWaterColor = true; } void UpdateAb20210902(int abValue) { Game.isHaveSound = Game.isHaveVibrate = abValue == 1; if (abValue == 1) { if (!PlayerData.isSoundOnDefault) { PlayerData.SetSoundState(true); PlayerData.isSoundOnDefault = true; } } Game.levelIntro = abValue == 2 ? LevelIntroType.DropDown : LevelIntroType.None; Game.isRandomWaterColor = abValue == 3; } void ResultAb20210825() { } void UpdateAb20210825(int abValue) { } void ResultAb20210817() { } void UpdateAb20210817(int abValue) { Game.isAutoLevel = abValue == 1; Game.autoLevelVer = abValue == 1 ? 9 : 7; Game.isHaveFlyingBird = abValue == 2; Game.pipePairVer = abValue == 3 ? 1 : 0; } void ResultAb20210810() { } void UpdateAb20210810(int abValue) { Game.isAutoLevel = abValue == 1; Game.levelIntro = abValue == 2 ? LevelIntroType.DropDown : LevelIntroType.None; Game.isRandomWaterColor = abValue == 3; } void ResultAb20210803() { } void UpdateAb20210803(int abValue) { Game.oneWayPipeVer = abValue == 1 ? 2 : 1; Game.isHaveSound = Game.isHaveVibrate = abValue == 2 || abValue == 3; if (abValue == 2) { if (!PlayerData.isSoundOnDefault) { PlayerData.SetSoundState(true); PlayerData.isSoundOnDefault = true; } } if (abValue == 3) { if (!PlayerData.isVibrateOnDefault) { PlayerData.SetVibrateState(true); PlayerData.isVibrateOnDefault = true; } } } void ResultAb20210727() { Game.levelRotateVer = 2; } void UpdateAb20210727(int abValue) { Game.levelRotateVer = abValue == 1 ? 2 : 1; Game.hintVer = abValue == 2 ? 3 : 1; Game.fixedPipeVer = abValue == 3 ? 2 : 1; } void ResultAb20210720() { Game.isHaveNotification = true; } void UpdateAb20210720(int abValue) { Game.isHaveWaterFoam = Game.isHaveWaterWave = abValue == 1; Game.isHaveNotification = abValue == 2; Game.levelDifficultyVer = abValue == 3 ? 8 : 4; } void ResultAb20210718() { UpdateAb20210718(0); } void UpdateAb20210718(int abValue) { Game.levelIntro = LevelIntroType.None; Game.isHaveAnimEnding = false; Game.isUseOneBg = false; } void ResultAb20210714() { Game.reskinVer = 5; Game.isCreateBgLongPipe = true; } void UpdateAb20210714(int abValue) { Game.reskinVer = abValue + 3; Game.isCreateBgLongPipe = abValue > 0; Game.isUseOneBg = abValue == 1; } void ResultAb20210708() { Game.isHaveReskin = true; Game.reskinVer = 3; } void UpdateAb20210708(int abValue) { Game.levelIntro = (abValue == 1) ? LevelIntroType.FadeInCloud : LevelIntroType.None; Game.isHaveReskin = (abValue == 2); } void ResultAb20210705() { Game.levelDifficultyVer = 4; Game.isFreeMove = true; } void UpdateAb20210705(int abValue) { Game.levelDifficultyVer = 2; Game.isFreeMove = abValue == 0 || abValue == 1; if (abValue == 1) { Game.levelDifficultyVer = 3; } else if (abValue == 2) { Game.levelDifficultyVer = 6; } } void ResultAb20210701() { } void UpdateAb20210701(int abValue) { Game.isHaveAnimEnding = abValue == 1; Game.isHaveReskin = abValue == 2; } void ResultAb20210628() { Game.levelDifficultyVer = 2; } void UpdateAb20210628(int abValue) { Game.levelDifficultyVer = abValue + 2; Game.isFreeMove = abValue == 2; } void ResultAb20210624() { Game.levelDifficultyVer = 2; } void UpdateAb20210624(int abValue) { Game.levelDifficultyVer = abValue == 1 ? 2 : 1; } void ResultAb20210622() { Game.isHavePopupRating = true; } void UpdateAb20210622(int abValue) { Game.isHaveReskin = abValue == 1; Game.isHavePopupRating = true; } void ResultAb20210618() { Game.isHaveHint = true; } void UpdateAb20210618(int abValue) { Game.isHaveHint = abValue == 1; } void ResultAb20210615() { Game.waterSpeed = 3; } void UpdateAb20210615(int abValue) { Game.waterSpeed = abValue == 1 ? 3 : 1; } void ResultAb20210608() { } void UpdateAb20210608(int abValue) { } void ResultAbFullAds() { Game.timeDelayFullAds = 30f; } void UpdateAbFullAds(int abValue) { Game.timeDelayFullAds = (abValue == 0) ? 30f : 60f; } } }
Editor is loading...