コード例 #1
0
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    userId = str(parent.Current.UserId)
    user = PersonalCacheStruct.Get[GameUser](userId)

    shopinfo = ConfigCacheSet[ShopInfo]().FindKey(urlParam.ItemID)
    if shopinfo == None:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St_7002_ShopOffTheShelf")
        actionResult.Result = False
        return actionResult
    gameHall = GameHall(user)
    useGold = shopinfo.Price
    if user.VipLv > 0:
        userGold = shopinfo.VipPrice
    if gameHall.UserGold < useGold:
        parent.ErrorCode = 1
        parent.ErrorInfo = Lang.getLang("St_2909_StGoldNumNullEnough")
        actionResult.Result = False
        return actionResult
    if shopinfo.ShopType == ShopType.HeadID:
        if gameHall.CheckUserItem(urlParam.ItemID):
            parent.ErrorCode = Lang.getLang("ErrorCode")
            parent.ErrorInfo = Lang.getLang("St_7002_PurchasedHeadID")
            actionResult.Result = False
            return actionResult
        gameHall.AddUserItem(urlParam.ItemID, shopinfo.ShopType)
        ClientNotifier.NotifyAction(ActionIDDefine.Cst_Action1013, user, None)
    if shopinfo.ShopType == ShopType.Beans:
        user.GameCoin = MathUtils.Addition(user.GameCoin, shopinfo.GameCoin)
    user.UseGold = MathUtils.Addition(user.UseGold, useGold)
    GameTable.Current.NotifyUserChange(user.UserId)

    mallItemLog = MallItemLog()
    mallItemLog.ItemID = urlParam.ItemID
    mallItemLog.Uid = user.UserId
    mallItemLog.Num = 1
    mallItemLog.CurrencyType = MathUtils.ToInt(shopinfo.ShopType)
    mallItemLog.Amount = useGold
    mallItemLog.CreateDate = MathUtils.Now
    mallItemLog.RetailID = user.RetailId
    mallItemLog.MobileType = user.MobileType
    mallItemLog.Pid = user.Pid
    mallItemLog.ItemName = shopinfo.ShopName
    sender = DataSyncManager.GetDataSender()
    sender.Send(mallItemLog)

    #需要实现
    return actionResult
コード例 #2
0
    def UpdateArcheologyRestrain(self,user, npcinfoID):  

        """通关考古副本活动,更新通关次数与奖励"""
        def IsArcheologyPlot(self,plotID,npcInfoID):  
            """是否当前考古副本的npc"""    
            npcinfoList = ConfigCacheSet[PlotNPCInfo]().FindAll(match = lambda s:s.PlotID == plotID and s.NpcSeqNo>0);
            for npcInfo in npcinfoList:
                if npcInfoID == npcInfo.PlotNpcID:
                    return True;
            return False
        festivalInfosList = ShareCacheStruct[FestivalInfo]().FindAll(match = lambda m:m.FestivalType == FestivalType.Archeology);
        for info in festivalInfosList:
            if not NoviceHelper.IsFestivalOpen(info.FestivalID) or info.FestivalExtend == None or info.FestivalExtend.PlotID == 0:
                continue;
            if not IsArcheologyPlot(self,info.FestivalExtend.PlotID,npcinfoID):
                continue
            cacheSet = GameDataCacheSet[FestivalRestrain]();
            restrain = cacheSet.FindKey(user.UserID,info.FestivalID);
            if restrain != None and restrain.IsReceive:
                continue;
            if restrain == None :
                restrain = FestivalRestrain();
                restrain.FestivalID = info.FestivalID;
                restrain.UserID = user.UserID;
                restrain.RestrainNum = 0;
                restrain.RefreashDate = DateTime.Now;
                restrain.IsReceive = False;
                cacheSet.Add(restrain);
            userExtend = restrain.UserExtend.Find(lambda s:s.ID == npcinfoID);
            if userExtend:
                userExtend.Num = MathUtils.Addition(userExtend.Num, 1);
            else :
                userExtend = RestrainExtend();
                userExtend.ID = npcinfoID;
                userExtend.Num = 1;
                restrain.UserExtend.Add(userExtend);
            isGo = True;
            if restrain ==None or restrain.UserExtend.Count == 0 or info.FestivalExtend == None or info.FestivalExtend.PlotID == 0:
                isGo = False;
            npcinfoList = ConfigCacheSet[PlotNPCInfo]().FindAll(match = lambda s:s.PlotID == info.FestivalExtend.PlotID and s.NpcSeqNo>0);
            for npcInfo in npcinfoList:
                userExtend = restrain.UserExtend.Find(lambda s:s.ID == npcInfo.PlotNpcID)
                if userExtend and userExtend.Num >= info.RestrainNum:
                    continue;
                isGo = False;  
                break;         

            if isGo:
                restrain.IsReceive = True;
                content = PrizeHelper.GetPrizeUserTake(user, info.Reward.ToList());
                if content and info.FestivalExtend.Desc :
                    content = content.Replace(",","")
                    TjxChatService().SystemSendWhisper(user, info.FestivalExtend.Desc %content)   
コード例 #3
0
def buildPacket(writer, urlParam, actionResult):
    postion = 0
    writer.PushShortIntoStack(actionResult.IsFree)
    writer.PushIntoStack(actionResult.FreeNum)
    writer.PushIntoStack(len(actionResult.DailList))
    for info in actionResult.DailList:
        postion = MathUtils.Addition(postion, 1)
        Probability = PythonHelper.TransformString(info.Probability)
        dsItem = DataStruct()
        dsItem.PushIntoStack(postion)
        dsItem.PushIntoStack(MathUtils.ToNotNullString(info.HeadID))
        dsItem.PushIntoStack(MathUtils.ToNotNullString(Probability))
        dsItem.PushIntoStack(MathUtils.ToNotNullString(info.ItemDesc))
        dsItem.PushIntoStack(info.GameCoin)
        writer.PushIntoStack(dsItem)
    writer.PushIntoStack(actionResult.UserCoin)
    writer.PushIntoStack(actionResult.UserGold)
    return True
コード例 #4
0
ファイル: Action3004.py プロジェクト: zhukaixy/Scut
def takeAction(urlParam, parent):
    actionResult = ActionResult()
    user = parent.Current.User
    userId = parent.Current.User.PersonalId
    AchieveTask.RefreashUserTask(userId)
    usertaskInfo = AchieveTask.GetUserTaskInfo(userId, urlParam.TaskID)
    if not usertaskInfo or usertaskInfo.TaskStatus == TaskStatus.Unfinished:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St3004_CurrentTaskIsNotCompleted")
        actionResult.Result = False
        return actionResult
    if usertaskInfo.TaskStatus == TaskStatus.Receive:
        parent.ErrorCode = Lang.getLang("ErrorCode")
        parent.ErrorInfo = Lang.getLang("St3004_CurrentTaskrewardHasReceived")
        actionResult.Result = False
        return actionResult

    taskInfo = ConfigCacheSet[TaskInfo]().FindKey(urlParam.TaskID)
    if taskInfo:
        user.GameCoin = MathUtils.Addition(user.GameCoin, taskInfo.GameCoin)
        usertaskInfo.TaskStatus = TaskStatus.Receive
        GameTable.Current.NotifyUserChange(user.UserId)
    #需要实现
    return actionResult
コード例 #5
0
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