def takeAction(urlParam, parent): actionResult = ActionResult() userId = str(parent.Current.UserId) user = PersonalCacheStruct.Get[GameUser](userId) gameRoom = GameRoom.Current dailyFreeNum = ConfigEnvSet.GetInt("User.DailyFreeNum", 3) useNum = 0 userRestrain = GameDataCacheSet[UserDailyRestrain]().FindKey(userId) if userRestrain != None: gameRoom.RefreshRestrain(userRestrain) if userRestrain.RestrainProperty != None: useNum = userRestrain.RestrainProperty.DialFreeNum if dailyFreeNum > useNum: actionResult.FreeNum = MathUtils.Subtraction(dailyFreeNum, useNum) else: actionResult.IsFree = 1 actionResult.DailList = ConfigCacheSet[DialInfo]().FindAll() actionResult.UserCoin = user.GameCoin gameHall = GameHall(user) actionResult.UserGold = gameHall.UserGold #需要实现 return actionResult
def takeAction(urlParam, parent): def compareToCrystal(x, y): if x == None and y == None: return 0 if x != None and y == None: return 1 if x == None: return -1 return x.CreateDate.CompareTo(y.CreateDate) actionResult = ActionResult() userId = parent.Current.User.PersonalId urlParam.userID = parent.Current.User.PersonalId contextUser = parent.Current.User if contextUser.VipLv < 5: parent.ErrorCode = LanguageManager.GetLang().ErrorCode parent.ErrorInfo = LanguageManager.GetLang().St_VipNotEnough actionResult.Result = False return actionResult UserHelper.GetUserLightOpen(userId) if CrystalHelper.CheckAllowCrystall(contextUser) == False: parent.ErrorCode = LanguageManager.GetLang().ErrorCode parent.ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull actionResult.Result = False return actionResult saleNum = CrystalHelper.SellGrayCrystal(contextUser, None) actionResult.prompt = CrystalHelper.AkeyHuntingLife(contextUser) dailyRestrainSet = ShareCacheStruct[DailyRestrainSet]().FindKey( RestrainType.MianFeiLieMing) userRestrain = GameDataCacheSet[UserDailyRestrain]().FindKey(userId) if dailyRestrainSet is not None and userRestrain is not None: if MathUtils.Now.Date == userRestrain.RefreshDate.Date: actionResult.freeNum = VipHelper.GetVipUseNum( contextUser.VipLv, RestrainType.MianFeiLieMing) actionResult.freeNum = MathUtils.Subtraction( actionResult.freeNum, userRestrain.Funtion2, 0) else: actionResult.freeNum = VipHelper.GetVipUseNum( contextUser.VipLv, RestrainType.MianFeiLieMing) actionResult.userLightArray = GameDataCacheSet[UserLight]().FindAll( contextUser.UserID) allowSale = False allowTake = False list = CrystalHelper.GetNotSaleCrystalNum(contextUser) if list.Count > 0: actionResult.grayCrystalArray = list[0] MathUtils.QuickSort[GrayCrystal](actionResult.grayCrystalArray, lambda x, y: compareToCrystal(x, y)) if list.Count > 1: allowSale = list[1] if list.Count > 2: allowTake = list[2] if allowSale is True: actionResult.isSale = 1 else: actionResult.isSale = 2 if allowTake is True: actionResult.issTelegrams = 1 else: actionResult.issTelegrams = 2 actionResult.goldNum = contextUser.GoldNum actionResult.gameCoin = contextUser.GameCoin #需要实现 return actionResult
def takeAction(urlParam, parent): actionResult = ActionResult() userId = parent.Current.User.PersonalId user = parent.Current.User gameRoom = GameRoom.Current dailyFreeNum = ConfigEnvSet.GetInt("User.DailyFreeNum", 3) useNum = 0 useGold = 0 userRestrain = GameDataCacheSet[UserDailyRestrain]().FindKey(userId) if userRestrain == None: parent.ErrorCode = Lang.getLang("ErrorCode") parent.ErrorInfo = Lang.getLang("LoadError") actionResult.Result = False return actionResult gameRoom.RefreshRestrain(userRestrain) gameHall = GameHall(user) if userRestrain.RestrainProperty != None: useNum = userRestrain.RestrainProperty.DialFreeNum if useNum > dailyFreeNum: useGold = MathUtils.Subtraction(useNum, dailyFreeNum) * 2 useGold = MathUtils.Addition(useGold, 2) if useNum == dailyFreeNum: useGold = 2 if useGold > 20: useGold = 20 if urlParam.Ops == 1 and useNum >= dailyFreeNum: parent.ErrorCode = Lang.getLang("ErrorCode") parent.ErrorInfo = Lang.getLang("St12002_FreeNotEnough") actionResult.Result = False return actionResult #useNum = userRestrain.RestrainProperty.DialFreeNum if urlParam.Ops == 1: userRestrain.RestrainProperty.DialFreeNum = MathUtils.Addition( userRestrain.RestrainProperty.DialFreeNum, 1) if urlParam.Ops == 2: if useNum < dailyFreeNum: parent.ErrorCode = Lang.getLang("ErrorCode") parent.ErrorInfo = Lang.getLang("St12002_FreeEnough") actionResult.Result = False return actionResult parent.ErrorCode = urlParam.Ops parent.ErrorInfo = Lang.getLang("St12002_UseGoldTurntable") % useGold actionResult.Result = False return actionResult if urlParam.Ops == 3: if gameHall.UserGold < useGold: parent.ErrorCode = 4 parent.ErrorInfo = Lang.getLang("St_2909_StGoldNumNullEnough") actionResult.Result = False return actionResult user.UseGold = MathUtils.Addition(user.UseGold, useGold) userRestrain.RestrainProperty.DialFreeNum = MathUtils.Addition( userRestrain.RestrainProperty.DialFreeNum, 1) postion = gameHall.DialPrizePostion() dialList = ConfigCacheSet[DialInfo]().FindAll() if dialList.Count > postion: dialInfo = dialList[postion] user.GameCoin = MathUtils.Addition(user.GameCoin, dialInfo.GameCoin) actionResult.Postion = MathUtils.Addition(postion, 1) actionResult.RewardContent = Lang.getLang( "St12002_GoldenBeanAwards") % dialInfo.GameCoin #需要实现 parent.ErrorCode = urlParam.Ops if dailyFreeNum > userRestrain.RestrainProperty.DialFreeNum: actionResult.FreeNum = MathUtils.Subtraction( dailyFreeNum, userRestrain.RestrainProperty.DialFreeNum) actionResult.UserCoin = user.GameCoin actionResult.UserGold = gameHall.UserGold GameTable.Current.NotifyUserChange(user.UserId) return actionResult