| | |
| | | import ShareDefine
|
| | | import NetPackCommon
|
| | | import PlayerControl
|
| | | import OpenServerActivity
|
| | | import ChPyNetSendPack
|
| | | import IPY_GameWorld
|
| | | import ItemControler
|
| | | import IpyGameDataPY
|
| | | import PyGameData
|
| | | import ObjPool
|
| | |
|
| | | #成就奖励是否已领取
|
| | | def GetSuccHasGot(curPlayer, succID):
|
| | |
| | | SyncSuccessAwardRecord(curPlayer)
|
| | | return
|
| | |
|
| | | def ResetSuccessByType(curPlayer, succType, ignoreFinish=True):
|
| | | def ResetSuccessByTypes(curPlayer, succTypeList, ignoreFinish=True, isNotify=True):
|
| | | ## 重置成就
|
| | | for succType in succTypeList:
|
| | | ResetSuccessByType(curPlayer, succType, ignoreFinish, isNotify)
|
| | | return
|
| | |
|
| | | def ResetSuccessByType(curPlayer, succType, ignoreFinish=True, isNotify=True):
|
| | | #重置某类型成就进度,一般用于先重置次数再重新计数,或者活动类
|
| | | ipyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("Success", succType)
|
| | | if not ipyDataList:
|
| | | return
|
| | | succIDList = []
|
| | | syncTypeCondList = []
|
| | | for ipyData in ipyDataList:
|
| | | succID = ipyData.GetSuccID()
|
| | | if ignoreFinish and GetSuccHasGot(curPlayer, succID):
|
| | | continue
|
| | | conds = ipyData.GetCondition()
|
| | | SetSuccValue(curPlayer, succType, conds, 0)
|
| | | SetSuccHasGot(curPlayer, succID, 0)
|
| | | succIDList.append(succID)
|
| | | if [succType, conds] not in syncTypeCondList:
|
| | | syncTypeCondList.append([succType, conds])
|
| | | if isNotify:
|
| | | succIDList and SyncSuccessAwardRecord(curPlayer, succIDList, True)
|
| | | syncTypeCondList and SyncSuccessInfo(curPlayer, syncTypeCondList, True)
|
| | | return
|
| | |
|
| | | #def UpdateSuccessProgressByConditions(curPlayer, successType, conditionCountDict):
|
| | | # ## 根据多种条件更新进度,如装备多品质的
|
| | | # ipyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("Success", successType)
|
| | | # if not ipyDataList:
|
| | | # return
|
| | | # updIDList = []
|
| | | # updsuccDataList = []
|
| | | # updConditionDict = {}
|
| | | # |
| | | # for condition, newCount in conditionCountDict.items():
|
| | | # addCondList = [] # 不同的成就ID条件可能相同,只是最大进度不同,故传入的条件计数针对相同成就条件只能累加一次
|
| | | # for ipyData in ipyDataList:
|
| | | # succID = ipyData.GetSuccID()
|
| | | # conds = ipyData.GetCondition()
|
| | | # needCnt = ipyData.GetNeedCnt()
|
| | | # |
| | | # tupleCond = tuple(conds) # 作为字典key用
|
| | | # |
| | | # if tupleCond not in updConditionDict:
|
| | | # updConditionDict[tupleCond] = [conds, 0, 0] # [条件, 更新值, 最大进度值]
|
| | | # updInfo = updConditionDict[tupleCond]
|
| | | # if updInfo[2] < needCnt:
|
| | | # updInfo[2] = needCnt
|
| | | # |
| | | # if not __CheckCanAddSuccess(curPlayer, ipyData, list(condition)):
|
| | | # continue
|
| | | # |
| | | # if succID not in updIDList:
|
| | | # updIDList.append(succID)
|
| | | # updsuccDataList.append(ipyData)
|
| | | # |
| | | # if tupleCond not in addCondList:
|
| | | # addCondList.append(tupleCond)
|
| | | # updConditionDict[tupleCond][1] = updConditionDict[tupleCond][1] + newCount # 更新进度值
|
| | | # |
| | | # # 没有找到更新目标不处理
|
| | | # #GameWorld.DebugLog(" updConditionDict=%s" % updConditionDict)
|
| | | # #GameWorld.DebugLog(" updIDList=%s" % updIDList)
|
| | | # if not updIDList:
|
| | | # return
|
| | | # |
| | | # # 先更新成就记录值后再判断完成与否
|
| | | # for cond, updCnt, maxCnt in updConditionDict.values():
|
| | | # if not updCnt:
|
| | | # continue
|
| | | # updCnt = min(maxCnt, updCnt)
|
| | | # if GetSuccValue(curPlayer, successType, cond) == updCnt:
|
| | | # continue
|
| | | # SetSuccValue(curPlayer, successType, cond, updCnt)
|
| | | # SyncSuccessInfo(curPlayer, syncTypeCondList)
|
| | | # return
|
| | | def UpdateEquipSuccess(curPlayer):
|
| | | # 装备相关成就
|
| | | |
| | | colorCountDict = {}
|
| | | equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
|
| | | for equipPlace in ChConfig.Def_MainEquipPlaces:
|
| | | equipIndex = equipPlace - 1
|
| | | if equipIndex < 0 or equipIndex >= equipPack.GetCount():
|
| | | continue
|
| | | curEquip = equipPack.GetAt(equipIndex)
|
| | | if not curEquip or curEquip.IsEmpty():
|
| | | continue
|
| | | itemColor = curEquip.GetItemColor()
|
| | | condKey = (itemColor, )
|
| | | colorCountDict[condKey] = colorCountDict.get(condKey, 0) + 1
|
| | | |
| | | UpdateSuccessProgressByConditions(curPlayer, ShareDefine.SuccType_OSAEquipColor, colorCountDict)
|
| | | return
|
| | |
|
| | | def UpdateSuccessProgressByConditions(curPlayer, successType, conditionCountDict):
|
| | | ## 根据多种条件更新进度,如装备多品质的
|
| | | # @param conditionCountDict: 条件对应件数,条件需用元组为key {(c, ...):cnt, ..}
|
| | | if successType in ShareDefine.OSASuccTypeList:
|
| | | if OpenServerActivity.GetOSACelebrationState(curPlayer) > 1:
|
| | | return
|
| | | ipyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("Success", successType)
|
| | | if not ipyDataList:
|
| | | return
|
| | | |
| | | updIDList = []
|
| | | updsuccDataList = []
|
| | | updConditionDict = {}
|
| | | |
| | | for condition, newCount in conditionCountDict.items():
|
| | | addCondList = [] # 不同的成就ID条件可能相同,只是最大进度不同,故传入的条件计数针对相同成就条件只能累加一次
|
| | | for ipyData in ipyDataList:
|
| | | succID = ipyData.GetSuccID()
|
| | | conds = ipyData.GetCondition()
|
| | | needCnt = ipyData.GetNeedCnt()
|
| | | |
| | | tupleCond = tuple(conds) # 作为字典key用
|
| | | |
| | | if tupleCond not in updConditionDict:
|
| | | updConditionDict[tupleCond] = [conds, 0, 0] # [条件, 更新值, 最大进度值]
|
| | | updInfo = updConditionDict[tupleCond]
|
| | | if updInfo[2] < needCnt:
|
| | | updInfo[2] = needCnt
|
| | | |
| | | if not __CheckCanAddSuccess(curPlayer, ipyData, list(condition)):
|
| | | continue
|
| | | |
| | | if succID not in updIDList:
|
| | | updIDList.append(succID)
|
| | | updsuccDataList.append(ipyData)
|
| | | |
| | | if tupleCond not in addCondList:
|
| | | addCondList.append(tupleCond)
|
| | | updConditionDict[tupleCond][1] = updConditionDict[tupleCond][1] + newCount # 更新进度值
|
| | | |
| | | # 没有找到更新目标不处理
|
| | | #GameWorld.DebugLog(" conditionCountDict=%s" % conditionCountDict)
|
| | | #GameWorld.DebugLog(" updConditionDict=%s" % updConditionDict)
|
| | | #GameWorld.DebugLog(" updIDList=%s" % updIDList)
|
| | | if not updIDList:
|
| | | return
|
| | | |
| | | # 先更新成就记录值后再判断完成与否
|
| | | syncTypeCondList = []
|
| | | for conds, updCnt, maxCnt in updConditionDict.values():
|
| | | if not updCnt:
|
| | | continue
|
| | | updCnt = min(maxCnt, updCnt)
|
| | | if GetSuccValue(curPlayer, successType, conds) == updCnt:
|
| | | continue
|
| | | SetSuccValue(curPlayer, successType, conds, updCnt)
|
| | | if [successType, conds] not in syncTypeCondList:
|
| | | syncTypeCondList.append([successType, conds])
|
| | | #GameWorld.DebugLog(" syncTypeCondList=%s" % syncTypeCondList)
|
| | | syncTypeCondList and SyncSuccessInfo(curPlayer, syncTypeCondList, True)
|
| | | return
|
| | |
|
| | | def UptateSuccessProgress(curPlayer, successType, newCnt, condition=[]):
|
| | | if successType in ShareDefine.OSASuccTypeList:
|
| | | if OpenServerActivity.GetOSACelebrationState(curPlayer) > 1:
|
| | | return
|
| | | ipyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("Success", successType)
|
| | | if not ipyDataList:
|
| | | return
|
| | |
| | | return
|
| | | if successType not in ShareDefine.SuccessTypeList:
|
| | | return
|
| | | |
| | | if successType in ShareDefine.OSASuccTypeList:
|
| | | if OpenServerActivity.GetOSACelebrationState(curPlayer) > 1:
|
| | | return
|
| | | ipyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("Success", successType)
|
| | | if not ipyDataList:
|
| | | GameWorld.DebugLog("找不到成就数据successType=%s" % successType)
|
| | |
| | | needCnt = ipyData.GetNeedCnt()
|
| | | curValue = GetSuccValue(curPlayer, succType, conds)
|
| | | if curValue < needCnt:
|
| | | GameWorld.DebugLog("该成就未完成! succID=%s,curValue=%s < %s" % (succID, curValue, needCnt))
|
| | | GameWorld.DebugLog("该成就未完成! succID=%s,succType=%s,conds=%s,curValue=%s < %s" % (succID, succType, conds, curValue, needCnt))
|
| | | return
|
| | |
|
| | | SetSuccHasGot(curPlayer, succID)
|
| | |
| | | syncTypeCondList.append(tcList)
|
| | |
|
| | | successInfoList = []
|
| | | objPoolMgr = ObjPool.GetPoolMgr()
|
| | | for succType, conds in syncTypeCondList:
|
| | | curValue = GetSuccValue(curPlayer, succType, conds)
|
| | | # 不发送为0的数据
|
| | | if not isSendZero and curValue <= 0:
|
| | | continue
|
| | | succInfo = objPoolMgr.acquire(ChPyNetSendPack.tagSCSuccessInfo)
|
| | | succInfo = ChPyNetSendPack.tagSCSuccessInfo()
|
| | | succInfo.SuccType = succType
|
| | | succInfo.Conds = conds
|
| | | succInfo.CLen = len(succInfo.Conds)
|
| | |
| | | if not successInfoList:
|
| | | return
|
| | |
|
| | | clientPack = objPoolMgr.acquire(ChPyNetSendPack.tagSCSuccessInfoList)
|
| | | clientPack = ChPyNetSendPack.tagSCSuccessInfoList()
|
| | | clientPack.SuccessInfoList = successInfoList
|
| | | clientPack.Count = len(clientPack.SuccessInfoList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | |
| | | maxSuccID = ipyDataMgr.GetSuccessByIndex(succCnt - 1).GetSuccID()
|
| | | recordIndexList = xrange(maxSuccID / 31 + 1)
|
| | |
|
| | | objPoolMgr = ObjPool.GetPoolMgr()
|
| | | recordList = []
|
| | | for i in recordIndexList:
|
| | | awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuccessAward % i)
|
| | | if not isSyncZero and not awardRecord:
|
| | | continue
|
| | | recordInfo = objPoolMgr.acquire(ChPyNetSendPack.tagSCSuccessAwardRecord)
|
| | | recordInfo = ChPyNetSendPack.tagSCSuccessAwardRecord()
|
| | | recordInfo.RecordIndex = i
|
| | | recordInfo.Record = awardRecord
|
| | | recordList.append(recordInfo)
|
| | |
| | | if not recordList:
|
| | | return
|
| | |
|
| | | clientPack = objPoolMgr.acquire(ChPyNetSendPack.tagSCSuccessAwardRecordList)
|
| | | clientPack = ChPyNetSendPack.tagSCSuccessAwardRecordList()
|
| | | clientPack.RecordList = recordList
|
| | | clientPack.RecordCnt = len(clientPack.RecordList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|