From b56aec8d5b6fad48119cb7154dea6b834ec442cf Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期一, 24 六月 2019 14:04:59 +0800 Subject: [PATCH] 6603 【后端】【2.0】增加新版的sp和被动技能 - 4532修改逻辑 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py | 235 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 185 insertions(+), 50 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py index 3c2f580..dbb2d4d 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py @@ -28,14 +28,14 @@ import IpyGameDataPY import PyGameData import GameFuncComm - +import EventShell +import PlayerPet #关联类型 ( -RelatedType_1, # 1关联日常活动表 -RelatedType_2, # 2关联副本总表 +RelatedType_1, # 1关联日常活动表 +RelatedType_2, # 2关联副本总表 ) = range(1, 3) - def OnWeek(curPlayer, onWeekType): @@ -49,7 +49,7 @@ # 重置类型不同的不处理 if ipyData.GetWeekResetType() != onWeekType: continue - key = ChConfig.Def_PDict_DailyActionWeekTimes%ipyData.GetDailyID() + key = ChConfig.Def_PDict_DailyActionWeekTimes % ipyData.GetDailyID() __SetPDictValue(curPlayer, key, 0) actionIDInfo.append(ipyData.GetDailyID()) @@ -72,7 +72,7 @@ ipyData = ipyDataMgr.GetDailyQuestByIndex(i) key = ChConfig.Def_PDict_Activity_FinishCnt % ipyData.GetID() - curPBCnt = __GetPDictValue(curPlayer, key) #单次进度值 + curPBCnt = __GetPDictValue(curPlayer, key) #单次进度值 if curPBCnt: __SetPDictValue(curPlayer, key, 0) #总活跃度重置 @@ -98,42 +98,47 @@ actionIDInfo = [] for i in xrange(ipyDataMgr.GetDailyActionCount()): ipyData = ipyDataMgr.GetDailyActionByIndex(i) - dayTimesLimit = GetMaxDayTimes(ipyData)#ipyData.GetDayTimes() + dayTimesLimit = GetMaxDayTimes(ipyData) #ipyData.GetDayTimes() if not dayTimesLimit: continue # 重置类型不同的不处理 if ipyData.GetDayResetType() != onEventType: continue - key = ChConfig.Def_PDict_DailyActionDayTimes%ipyData.GetDailyID() - __SetPDictValue(curPlayer, key, 0) + dailyID = ipyData.GetDailyID() + __SetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayTimes % dailyID, 0) + __SetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayBuyTimes % dailyID, 0) + __SetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayItemTimes % dailyID, 0) + actionIDInfo.append(ipyData.GetDailyID()) if actionIDInfo: SyncDailyActionInfo(curPlayer, actionIDInfo) return + def SendDayActionMail(curPlayer): ##发送每日活动邮件 - if curPlayer.GetLV()>= IpyGameDataPY.GetFuncCfg('DailyQuestMailLvLimit'): + if curPlayer.GetLV() >= IpyGameDataPY.GetFuncCfg('DailyQuestMailLvLimit'): PlayerControl.SendMailByKey('TodayDailyTask', [curPlayer.GetID()], []) return #重新计算奖励阶段 def __CalcAwardStage(curPlayer): - realmLV= curPlayer.GetOfficialRank() + realmLV = curPlayer.GetOfficialRank() ipyData = IpyGameDataPY.IPY_Data().GetDailyLivenessRewardByIndex(0) if not ipyData: return stageLVList = ipyData.GetStageLV() curStage = 0 for i, lv in enumerate(stageLVList): - if realmLV <lv: + if realmLV < lv: break if realmLV >= lv: curStage = i __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_AwardStage, curStage) - GameWorld.DebugLog(' 重新计算活跃奖励阶段 curStage=%s,realmLV=%s'%(curStage, realmLV)) + GameWorld.DebugLog(' 重新计算活跃奖励阶段 curStage=%s,realmLV=%s' % (curStage, realmLV)) return + ## OnLogin # @param curPlayer 玩家实例 @@ -153,6 +158,7 @@ # @return def __GetPDictValue(curPlayer, key, defaultValue=0): return curPlayer.NomalDictGetProperty(key, defaultValue) + ## 设置活跃度玩家数据库字典信息值 # @param curPlayer 玩家实例 @@ -180,7 +186,6 @@ return - ## 摸NPC获得活跃度 # @param atkObj # @param curNPC @@ -201,6 +206,7 @@ return + ## 增加完成活跃度次数 # @param curPlayer 玩家实例 # @param activityNum 活跃度编号 @@ -218,39 +224,76 @@ onceActivityTime = dailyQuestData.GetOnceActivityTime() if not onceActivity: return - if maxActiveValue and finishCnt > maxActiveValue/onceActivity*onceActivityTime: + if maxActiveValue and finishCnt > maxActiveValue / onceActivity * onceActivityTime: #GameWorld.DebugLog("活跃度可完成次数已达到上限,activityNum=%s" % (activityNum)) return key = ChConfig.Def_PDict_Activity_FinishCnt % activityNum - curPBCnt = __GetPDictValue(curPlayer, key) #单次进度值 + curPBCnt = __GetPDictValue(curPlayer, key) #单次进度值 - addValue = (addCnt+curPBCnt)/onceActivityTime * onceActivity #增加的活跃度 - addPbCnt = (addCnt+curPBCnt) % onceActivityTime + addValue = (addCnt + curPBCnt) / onceActivityTime * onceActivity #增加的活跃度 + addPbCnt = (addCnt + curPBCnt) % onceActivityTime __SetPDictValue(curPlayer, key, addPbCnt) # + DoAddActivity(curPlayer, addValue, True) + return + +def DoAddActivityByLV(curPlayer, befLV, aftLV): + ##升级增加活跃点 + perLVAddPoint = IpyGameDataPY.GetFuncCfg('ImmortalDomainActivePoint', 3) + skillTypeID, perAddLV, addPoint, maxPoint = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomainActivePoint', 4) + learnSkillList, passiveSkillList = PlayerPet.GetPetLearnSkill(curPlayer) + addValue = (aftLV-befLV)*perLVAddPoint + if skillTypeID in passiveSkillList: + for lv in xrange(befLV+1, aftLV+1): + addValue += min(((lv-1)/perAddLV+1) * addPoint, maxPoint) + DoAddActivity(curPlayer, addValue, False, True) + return + +def AddActivityByLVOnLearnSkill(curPlayer, skillID): + ## 获得技能时,处理增加升级获得活跃点效果 + skillTypeID, perAddLV, addPoint, maxPoint = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomainActivePoint', 4) + if skillID != skillTypeID: + return + curLV = curPlayer.GetLV() + addValue = 0 + for lv in xrange(2, curLV+1): + addValue += min(((lv-1)/perAddLV+1) * addPoint, maxPoint) + DoAddActivity(curPlayer, addValue, False, True) + return + +def DoAddActivity(curPlayer, addValue, isMultiple=False, isLVUp=False): + if not addValue: + return multiple = 1 - if addValue: + addExtraPoint = 0 + if isMultiple: multiple, extraPointLimit = __GetActionAddPer(curPlayer) curExtraPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_ExtraRealmPoint) - addExtraPoint = max(0, min(addValue*(multiple-1),extraPointLimit-curExtraPoint)) if extraPointLimit else addValue*(multiple-1) - __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_ExtraRealmPoint, curExtraPoint+addExtraPoint) + addExtraPoint = max(0, min(addValue * (multiple - 1), + extraPointLimit - curExtraPoint)) if extraPointLimit else addValue * (multiple - 1) + __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_ExtraRealmPoint, curExtraPoint + addExtraPoint) addValue = addValue + addExtraPoint - curTotalPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint) - __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint, curTotalPoint+addValue) - #realmPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint) - #__SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint, realmPoint+addValue) - SyncDailyActivityInfo(curPlayer) - - GameWorld.DebugLog("增加活跃度任务次数,activityNum=%s,addPbCnt=%s,addValue=%s, multiple=%s, addExtraPoint=%s,curExtraPoint=%s" - % (activityNum, addPbCnt, addValue, multiple, addExtraPoint, curExtraPoint), curPlayer.GetPlayerID()) + curTotalPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint) + __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint, curTotalPoint + addValue) + AddCanCostActivityPoint(curPlayer, addValue, isLVUp) + historyPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityHistoryPoint) + __SetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityHistoryPoint, + min(ChConfig.Def_UpperLimit_DWord, historyPoint + addValue)) + + SyncDailyActivityInfo(curPlayer) + EventShell.EventRespons_AddActivityValue(curPlayer) + GameWorld.DebugLog( + "增加活跃度,addValue=%s, multiple=%s, addExtraPoint=%s" + % (addValue, multiple, addExtraPoint), curPlayer.GetPlayerID()) + return def __GetActionAddPer(curPlayer): - multiple, extraPointLimit = 1, 0 #倍数、额外可获得修行点上限 - actRealmPointInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_RealmPoint, {})# 多倍修行点活动 + multiple, extraPointLimit = 1, 0 #倍数、额外可获得修行点上限 + actRealmPointInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_RealmPoint, {}) # 多倍修行点活动 if not actRealmPointInfo: return multiple, extraPointLimit if not actRealmPointInfo.get(ShareDefine.ActKey_State): @@ -262,6 +305,27 @@ return multiple, extraPointLimit return actRealmPointIpyData.GetMultiple(), actRealmPointIpyData.GetPointLimit() +def AddCanCostActivityPoint(curPlayer, addValue, isLVUp): + # 增加可消耗的活跃点 + curPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint) + if isLVUp: + updPoint = min(ChConfig.Def_UpperLimit_DWord, curPoint + addValue) + else: + updPoint = min(IpyGameDataPY.GetFuncCfg('ImmortalDomainActivePoint'), curPoint + addValue) + __SetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint, updPoint) + return + +def CostActivityPoint(curPlayer, costPoint, isOnlyCheck=False): + # 消耗活跃点 + curPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint) + if curPoint < costPoint: + return + if not isOnlyCheck: + __SetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint, + curPoint - costPoint) + SyncDailyActivityInfo(curPlayer) + return True + ## 同步活跃度信息 # @param curPlayer # @param syncNum 默认-1时全部同步 @@ -272,11 +336,10 @@ sendPack.CurValue = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint) sendPack.StageIndex = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_AwardStage) sendPack.AwardRecord = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityAwardRecord) - sendPack.RealmPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint) + sendPack.RealmPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint) sendPack.ExtraPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_ExtraRealmPoint) NetPackCommon.SendFakePack(curPlayer, sendPack) return - ## 领取活跃度奖励 @@ -312,7 +375,7 @@ itemIDList = ipyData.GetItemID() itemCntList = ipyData.GetItemCount() itemIsBindList = ipyData.GetItemBind() - if awardStage >=len(itemIDList) or awardStage >= len(itemCntList) or awardStage >= len(itemIsBindList): + if awardStage >= len(itemIDList) or awardStage >= len(itemCntList) or awardStage >= len(itemIsBindList): return itemID = itemIDList[awardStage] @@ -333,10 +396,9 @@ SyncDailyActivityInfo(curPlayer) GameWorld.DebugLog("领取活跃度奖励OK!awardStage=%s, index=%s,needActivity=%s,totalActivity=%s,awardRecord=%s" % (awardStage, awardIndex, needActivity, totalActivity, updAwardRecord)) - - - + EventShell.EventRespons_ActivityAward(curPlayer, awardIndex) return + def GetRealmPointAward(curPlayer): #领取活跃修行点 @@ -350,14 +412,16 @@ SyncDailyActivityInfo(curPlayer) return + def GetActivityNum(relatedType, relatedID): ## 获取日常任务ID(活跃ID) - ipyData = IpyGameDataPY.GetIpyGameDataByCondition('DailyQuest', {"RelatedID":relatedID,"RelatedType":relatedType}, False, False) + ipyData = IpyGameDataPY.GetIpyGameDataByCondition('DailyQuest', {"RelatedID":relatedID, "RelatedType":relatedType}, False, False) if not ipyData: return 0 return ipyData.GetID() #########################################日常活动########################################### + def AddDailyActionFinishCnt(curPlayer, dailyID, addCnt=1): ##增加日常活动完成次数 @@ -375,7 +439,7 @@ GameWorld.DebugLog("日常活动未开启!dailyID=%s" % dailyID) return - dayTimesLimit = GetMaxDayTimes(ipyData)#ipyData.GetDayTimes() + dayTimesLimit = GetMaxDayTimes(ipyData) #ipyData.GetDayTimes() weekTimesLimit = ipyData.GetWeekTimes() if not dayTimesLimit and not weekTimesLimit: return @@ -389,24 +453,26 @@ updDayTimes = 0 if dayTimesLimit: - key = ChConfig.Def_PDict_DailyActionDayTimes%dailyID + key = ChConfig.Def_PDict_DailyActionDayTimes % dailyID curDayTimes = curPlayer.NomalDictGetProperty(key) - if not unLimitCnt and curDayTimes >= dayTimesLimit: + curDayBuyTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayBuyTimes % dailyID) + curDayItemTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayItemTimes % dailyID) + if not unLimitCnt and curDayTimes >= dayTimesLimit + curDayBuyTimes + curDayItemTimes: return - updDayTimes = curDayTimes+addCnt if unLimitCnt else min(dayTimesLimit, curDayTimes+addCnt) + updDayTimes = curDayTimes + addCnt if unLimitCnt else min(dayTimesLimit + curDayBuyTimes + curDayItemTimes, curDayTimes + addCnt) addCnt = updDayTimes - curDayTimes PlayerControl.NomalDictSetProperty(curPlayer, key, updDayTimes) - GameWorld.DebugLog('增加日常活动完成次数 dailyID=%s, curDayTimes=%s, updDayTimes=%s'%(dailyID, curDayTimes, updDayTimes)) + GameWorld.DebugLog('增加日常活动完成次数 dailyID=%s, curDayTimes=%s, updDayTimes=%s' % (dailyID, curDayTimes, updDayTimes)) updWeekTimes = 0 if weekTimesLimit: - key = ChConfig.Def_PDict_DailyActionWeekTimes%dailyID + key = ChConfig.Def_PDict_DailyActionWeekTimes % dailyID curWeekTimes = curPlayer.NomalDictGetProperty(key) if not unLimitCnt and curWeekTimes >= weekTimesLimit: return - updWeekTimes = curWeekTimes+addCnt if unLimitCnt else min(weekTimesLimit, curWeekTimes+addCnt) + updWeekTimes = curWeekTimes + addCnt if unLimitCnt else min(weekTimesLimit, curWeekTimes + addCnt) addCnt = updWeekTimes - curWeekTimes PlayerControl.NomalDictSetProperty(curPlayer, key, updWeekTimes) - GameWorld.DebugLog('增加日常活动完成次数 dailyID=%s, curWeekTimes=%s, updWeekTimes=%s'%(dailyID, curWeekTimes, updWeekTimes)) + GameWorld.DebugLog('增加日常活动完成次数 dailyID=%s, curWeekTimes=%s, updWeekTimes=%s' % (dailyID, curWeekTimes, updWeekTimes)) SyncDailyActionInfo(curPlayer, [dailyID]) @@ -416,14 +482,24 @@ AddActivityFinishCnt(curPlayer, activityNum, updTimes, addCnt) return True + def GetDailyActionFinishCnt(curPlayer, dailyID): - key = ChConfig.Def_PDict_DailyActionDayTimes%dailyID + key = ChConfig.Def_PDict_DailyActionDayTimes % dailyID curDayTimes = __GetPDictValue(curPlayer, key) ipyData = IpyGameDataPY.GetIpyGameData('DailyAction', dailyID) if not ipyData: return 0, 0 - dayTimesLimit = GetMaxDayTimes(ipyData)#ipyData.GetDayTimes() + dayTimesLimit = GetMaxDayTimes(ipyData) #ipyData.GetDayTimes() return curDayTimes, dayTimesLimit + +def GetDailyActionrRemainCnt(curPlayer, dailyID): + ##获取活动剩余次数 + curDayTimes = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayTimes % dailyID) + curDayBuyTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayBuyTimes % dailyID) + curDayItemTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayItemTimes % dailyID) + ipyData = IpyGameDataPY.GetIpyGameData('DailyAction', dailyID) + dayTimesLimit = GetMaxDayTimes(ipyData) + return max(0, dayTimesLimit+curDayBuyTimes+curDayItemTimes-curDayTimes) def GetMaxDayTimes(ipyData): dayTimesLimit = ipyData.GetDayTimes() @@ -431,11 +507,67 @@ dayTimesLimit += IpyGameDataPY.GetFuncCfg('RuneTowerSweepBuy') return dayTimesLimit + +#// A5 25 购买日常活动次数 #tagCMBuyDailyActionCnt +# +#struct tagCMBuyDailyActionCnt +#{ +# tagHead Head; +# DWORD ActionID; // ID +# BYTE AddType; // 0-花仙玉 1-用物品 +#}; +def OnDailyActionBuyCnt(index, clientData, tick): + curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) + dailyID = clientData.ActionID + addType = clientData.AddType #0花仙玉 1使用物品 + ipyData = IpyGameDataPY.GetIpyGameData('DailyAction', dailyID) + if not ipyData: + return + curDayTimes = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayTimes % dailyID) + curDayBuyTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayBuyTimes % dailyID) + curDayItemTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayItemTimes % dailyID) + if curDayBuyTimes + curDayItemTimes - curDayTimes >= 0: + GameWorld.DebugLog('剩余次数已达上限,不可增加!') + return + + if addType == 0: + dayBuyTimesLimit = ipyData.GetDayBuyTimes() + buyNeedMoney = ipyData.GetBuyNeedMoney() + if not dayBuyTimesLimit or not buyNeedMoney: + return + if curDayBuyTimes >= dayBuyTimesLimit: + GameWorld.DebugLog('今日购买次数已达上限,不可增加!') + return + if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, buyNeedMoney, ChConfig.Def_Cost_BuyDailyActionCnt, {'dailyID':dailyID, 'curDayBuyTimes':curDayBuyTimes}): + return + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyActionDayBuyTimes % dailyID, curDayBuyTimes + 1) + + elif addType == 1: + dayItemAddTimesLimit = ipyData.GetDayItemAddTimes() + dayItemID = ipyData.GetDayItemID() + if not dayItemAddTimesLimit or not dayItemID: + return + if curDayItemTimes >= dayItemAddTimesLimit: + GameWorld.DebugLog('今日使用物品增加次数已达上限,不可增加!') + return + itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) + enough, indexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(dayItemID, itemPack, 1) + if not enough: + return + ItemCommon.ReduceItem(curPlayer, itemPack, indexList, 1, False, "DailyActionCnt") + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyActionDayItemTimes % dailyID, curDayItemTimes + 1) + + else: + return + SyncDailyActionInfo(curPlayer, [dailyID]) + return + + ## 同步活跃度信息 # @param curPlayer # @param syncNum 默认-1时全部同步 # @return None -def SyncDailyActionInfo(curPlayer, syncNumList= []): +def SyncDailyActionInfo(curPlayer, syncNumList=[]): sendPack = ChPyNetSendPack.tagMCDailyActionCnt() sendPack.Clear() sendPack.ActionInfo = [] @@ -446,12 +578,15 @@ activityInfo.Clear() activityInfo.ActionID = activityNum activityInfo.DayFinishCnt = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayTimes % activityNum) + activityInfo.DayBuyTimes = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayBuyTimes % activityNum) + activityInfo.DayItemTimes = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayItemTimes % activityNum) activityInfo.WeekFinishCnt = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionWeekTimes % activityNum) sendPack.ActionInfo.append(activityInfo) sendPack.Count = len(sendPack.ActionInfo) NetPackCommon.SendFakePack(curPlayer, sendPack) return + ##################################副本类增加活跃########################################## ## 参加副本获得活跃度 @@ -462,4 +597,4 @@ activityNum = GetActivityNum(RelatedType_2, mapID) if activityNum: AddActivityFinishCnt(curPlayer, activityNum, curDayTimes, addCount) - return \ No newline at end of file + return -- Gitblit v1.8.0