| | |
| | | list Condition; //辅助条件
|
| | | list PreSuccess; //需要达成前置成就
|
| | | dict AwardItem; //奖励物品列表
|
| | | dict AwardItem2; //通行证奖励物品列表
|
| | | dict Money; //金钱
|
| | | DWORD Exp; //经验
|
| | | dict AwardAttr; //奖励属性
|
| | |
| | | ("Cmd", c_ubyte),
|
| | | ("SubCmd", c_ubyte),
|
| | | ("SuccID", c_int), #成就ID
|
| | | ("IsPassport", c_ubyte), #是否通行证奖励
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | |
| | | self.Cmd = 0xA5
|
| | | self.SubCmd = 0x42
|
| | | self.SuccID = 0
|
| | | self.IsPassport = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | |
| | | DumpString = '''// A5 42 领取成就奖励 //tagMCGetSuccessAward:
|
| | | Cmd:%s,
|
| | | SubCmd:%s,
|
| | | SuccID:%d
|
| | | SuccID:%d,
|
| | | IsPassport:%d
|
| | | '''\
|
| | | %(
|
| | | self.Cmd,
|
| | | self.SubCmd,
|
| | | self.SuccID
|
| | | self.SuccID,
|
| | | self.IsPassport
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
| | | _fields_ = [
|
| | | ("RecordIndex", c_ushort), #第几个记录值 每个key存31个succid 0-30为0, 31-61为1..
|
| | | ("Record", c_int), #对应是否领取值
|
| | | ("PassportRecord", c_int), #通行证奖励是否领取值
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | |
| | | def Clear(self):
|
| | | self.RecordIndex = 0
|
| | | self.Record = 0
|
| | | self.PassportRecord = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | |
| | | def OutputString(self):
|
| | | DumpString = '''//A3 42 成就完成领奖记录列表 //tagMCSuccessFinishAwardRecordList:
|
| | | RecordIndex:%d,
|
| | | Record:%d
|
| | | Record:%d,
|
| | | PassportRecord:%d
|
| | | '''\
|
| | | %(
|
| | | self.RecordIndex,
|
| | | self.Record
|
| | | self.Record,
|
| | | self.PassportRecord
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
| | | Def_PDict_GoldInvest_GotRewardValue = "Invest_GotRewardValue_%s_%s" # 等级回报已领取数值,参数为投资类型 索引
|
| | |
|
| | | # 成就 Def_PDictType_Success
|
| | | Def_PDict_Success_AwardRecord = "Succ_AwardRecord_%s" # 成就领奖记录,参数(成就类型),按索引位存储0-未领,1-已领
|
| | | Def_PDict_Success_AwardRecord = "Succ_AwardRecord_%s" # 成就领奖记录,参数(key编号),按索引位存储0-未领,1-已领
|
| | | Def_PDict_Success_LastDay = "Succ_LastDay_%s" # 连续类型上一次更新进度时的开服天数,参数(成就编号)
|
| | | Def_PDict_Success_CntValue = "Su_%s_%s" # 当前次数值,参数(成就类型、条件)
|
| | | Def_PDict_Success_FinishTime = "Succ_FinishTime_%s" # 成就是否已完成,参数(索引)
|
| | | Def_PDict_Success_CheckVersion = "Succ_CheckVersion" #老玩家某些功能成就检查版本
|
| | | Def_PDict_Success_PassportAward = "Succ_PassportAward_%s" #成就通行证领奖状态,参数(key编号),按索引位存储0-未领,1-已领
|
| | |
|
| | | # 大师 Def_PDictType_GreatMaster
|
| | | Def_PDict_Master_Exp = "Master_Exp" # 当前大师经验
|
| | |
| | | PowerDownType_ResetPoint:'ResetPoint',
|
| | | PowerDownType_ResetTalent:'ResetTalent',
|
| | | PowerDownType_GatherSoul:'GatherSoul',
|
| | | } |
| | | }
|
| | |
|
| | | # CTG ID 定义
|
| | | Def_CTGID_SuccessPassport = 117 # 成就通行证
|
| | |
| | | ("Cmd", c_ubyte),
|
| | | ("SubCmd", c_ubyte),
|
| | | ("SuccID", c_int), #成就ID
|
| | | ("IsPassport", c_ubyte), #是否通行证奖励
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | |
| | | self.Cmd = 0xA5
|
| | | self.SubCmd = 0x42
|
| | | self.SuccID = 0
|
| | | self.IsPassport = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | |
| | | DumpString = '''// A5 42 领取成就奖励 //tagMCGetSuccessAward:
|
| | | Cmd:%s,
|
| | | SubCmd:%s,
|
| | | SuccID:%d
|
| | | SuccID:%d,
|
| | | IsPassport:%d
|
| | | '''\
|
| | | %(
|
| | | self.Cmd,
|
| | | self.SubCmd,
|
| | | self.SuccID
|
| | | self.SuccID,
|
| | | self.IsPassport
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
| | | _fields_ = [
|
| | | ("RecordIndex", c_ushort), #第几个记录值 每个key存31个succid 0-30为0, 31-61为1..
|
| | | ("Record", c_int), #对应是否领取值
|
| | | ("PassportRecord", c_int), #通行证奖励是否领取值
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | |
| | | def Clear(self):
|
| | | self.RecordIndex = 0
|
| | | self.Record = 0
|
| | | self.PassportRecord = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | |
| | | def OutputString(self):
|
| | | DumpString = '''//A3 42 成就完成领奖记录列表 //tagMCSuccessFinishAwardRecordList:
|
| | | RecordIndex:%d,
|
| | | Record:%d
|
| | | Record:%d,
|
| | | PassportRecord:%d
|
| | | '''\
|
| | | %(
|
| | | self.RecordIndex,
|
| | | self.Record
|
| | | self.Record,
|
| | | self.PassportRecord
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
| | | if succType not in resetTypeList:
|
| | | resetTypeList.append(succType)
|
| | | PlayerSuccess.SetSuccHasGot(curPlayer, succID, False)
|
| | | PlayerSuccess.SetSuccPassportAwardHasGot(curPlayer, succID, False)
|
| | | PlayerSuccess.SetSuccFinish(curPlayer, succID, False)
|
| | | PlayerSuccess.SetPDictValue(curPlayer, ChConfig.Def_PDict_Success_LastDay % (succID), 0)
|
| | | PlayerSuccess.SetSuccFinishValue(curPlayer, succType, succDataObj.condition, 0)
|
| | |
| | |
|
| | | for succDataObj in succDataList:
|
| | | succID = succDataObj.succID
|
| | | if not PlayerSuccess.GetSuccHasGot(curPlayer, succID):
|
| | | if not PlayerSuccess.GetSuccHasGot(curPlayer, succID) and not PlayerSuccess.GetSuccPassportAwardHasGot(curPlayer, succID):
|
| | | continue
|
| | | PlayerSuccess.SetSuccHasGot(curPlayer, succID, False)
|
| | | PlayerSuccess.SetSuccPassportAwardHasGot(curPlayer, succID, False)
|
| | | PlayerSuccess.SetSuccFinish(curPlayer, succID) # 有重置领奖的ID需要重新设置为已完成
|
| | | resetIDList.append(succID)
|
| | |
|
| | | # 同步成就领奖记录
|
| | |
| | | GameWorld.DebugAnswer(curPlayer, "成就类型: %s" % succType)
|
| | | isFinish = PlayerSuccess.GetSuccIsFinish(curPlayer, succID)
|
| | | hasGot = PlayerSuccess.GetSuccHasGot(curPlayer, succID)
|
| | | GameWorld.DebugAnswer(curPlayer, " id=%s 条件:%s 进度:%s/%s 完成:%s 领奖:%s" |
| | | % (succID, succDataObj.condition, value, succDataObj.needCnt, isFinish, hasGot))
|
| | | passportHasGot = PlayerSuccess.GetSuccPassportAwardHasGot(curPlayer, succID)
|
| | | GameWorld.DebugAnswer(curPlayer, " id=%s 条件:%s 进度:%s/%s 完成:%s 领奖:%s %s" |
| | | % (succID, succDataObj.condition, value, succDataObj.needCnt, isFinish, hasGot, passportHasGot))
|
| | |
|
| | | return
|
| | |
|
| | |
| | | ("list", "Condition", 0),
|
| | | ("list", "PreSuccess", 0),
|
| | | ("dict", "AwardItem", 0),
|
| | | ("dict", "AwardItem2", 0),
|
| | | ("dict", "Money", 0),
|
| | | ("DWORD", "Exp", 0),
|
| | | ("dict", "AwardAttr", 0),
|
| | |
| | | self.Condition = []
|
| | | self.PreSuccess = []
|
| | | self.AwardItem = {}
|
| | | self.AwardItem2 = {}
|
| | | self.Money = {}
|
| | | self.Exp = 0
|
| | | self.AwardAttr = {}
|
| | |
| | | def GetCondition(self): return self.Condition # 辅助条件
|
| | | def GetPreSuccess(self): return self.PreSuccess # 需要达成前置成就
|
| | | def GetAwardItem(self): return self.AwardItem # 奖励物品列表
|
| | | def GetAwardItem2(self): return self.AwardItem2 # 通行证奖励物品列表
|
| | | def GetMoney(self): return self.Money # 金钱
|
| | | def GetExp(self): return self.Exp # 经验
|
| | | def GetAwardAttr(self): return self.AwardAttr # 奖励属性
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def GetSuccPassportAwardHasGot(curPlayer, succID):
|
| | | #获取成就通行证奖励是否已领取
|
| | | return GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_Success_PassportAward, succID)
|
| | | def SetSuccPassportAwardHasGot(curPlayer, succID, hasGot=True):
|
| | | #设置成就通行证奖励领取状态
|
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_Success_PassportAward, succID, hasGot)
|
| | | return
|
| | | |
| | | def SetSuccFinishValue(curPlayer, succType, condition, value):
|
| | | #设置成就完成度
|
| | | key = ChConfig.Def_PDict_Success_CntValue % (succType, condition)
|
| | |
| | | self.preSuccIDList = [] # 前置成就ID
|
| | | self.condition = [] # 辅助条件(根据类型自定义配置)
|
| | | self.awardItemDict = {} # 完成成就可领取的奖励物品{itemid:itemcnt}
|
| | | self.awardItemDict2 = {} # 完成成就可领取的奖励物品,通行证奖励{itemid:itemcnt}
|
| | | self.moneyDict = {} # 完成成就获得的金钱 {moneyType:money}
|
| | | self.exp = 0 # 完成成就获得的经验
|
| | | self.attrDict = {} # 完成成就获得的属性 {attrid:attrvalue}
|
| | |
| | | succData.preSuccIDList = list(successIpyData.GetPreSuccess())
|
| | | succData.condition = list(successIpyData.GetCondition())
|
| | | succData.awardItemDict = successIpyData.GetAwardItem()
|
| | | succData.awardItemDict2 = successIpyData.GetAwardItem2()
|
| | | succData.moneyDict = successIpyData.GetMoney()
|
| | | succData.exp = successIpyData.GetExp()
|
| | | succData.attrDict = successIpyData.GetAwardAttr()
|
| | |
| | | magicWeaponExp = successIpyData.GetMagicWeaponExp()
|
| | | if magicWeaponID and magicWeaponExp:
|
| | | succData.magicWeaponExp[magicWeaponID] = magicWeaponExp
|
| | | succData.hasAward = bool(succData.awardItemDict or succData.moneyDict or succData.exp or succData.attrDict or succData.redPacketID or succData.magicWeaponExp)
|
| | | succData.hasAward = bool(succData.awardItemDict or succData.moneyDict or succData.exp or succData.attrDict or succData.redPacketID or succData.magicWeaponExp \
|
| | | or succData.awardItemDict2)
|
| | | successDataObjDict[succData.succID]=succData
|
| | | if tuple(succData.condition) not in conditionDict:
|
| | | conditionDict[tuple(succData.condition)] = [succData.succID]
|
| | |
| | | awardDict[itemID] = awardDict.get(itemID, 0)+itemCnt
|
| | | return awardDict
|
| | |
|
| | | def GetSuccessPassportState(curPlayer):
|
| | | ## 成就通行证状态
|
| | | return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGGoodsBuyCount % ChConfig.Def_CTGID_SuccessPassport) > 0
|
| | |
|
| | | #// A5 42 领取成就奖励 #tagMCGetSuccessAward
|
| | | #
|
| | | #struct tagMCGetSuccessAward
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD SuccID; //成就ID
|
| | | # BYTE IsPassport; //是否通行证奖励
|
| | | #};
|
| | | ## 领取成就奖励
|
| | | # @param None
|
| | | # @return
|
| | | def OnGetSuccessAward(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | succID = clientData.SuccID
|
| | | __DoGetSuccTypeIndexAward(curPlayer, succID)
|
| | | isPassport = clientData.IsPassport
|
| | | __DoGetSuccTypeIndexAward(curPlayer, succID, isPassport=isPassport)
|
| | | return
|
| | |
|
| | | ## 领取某个成就奖励
|
| | | # @param None
|
| | | # @return
|
| | | def __DoGetSuccTypeIndexAward(curPlayer, succID, isGiveItem=True):
|
| | | GameWorld.DebugLog("领取成就奖励succID=%s" % (succID))
|
| | | def __DoGetSuccTypeIndexAward(curPlayer, succID, isGiveItem=True, isPassport=False):
|
| | | GameWorld.DebugLog("领取成就奖励succID=%s,isPassport=%s" % (succID, isPassport))
|
| | |
|
| | | succData = GetSuccDataMng().GetSuccessData(succID)
|
| | | if not succData:
|
| | | GameWorld.DebugLog(" 成就数据不存在!succID=%s" % (succID))
|
| | | return
|
| | | |
| | | finishTime = GetSuccIsFinish(curPlayer, succID)
|
| | | if finishTime <= 0:
|
| | | GameWorld.DebugLog(" 该成就未完成!")
|
| | | return
|
| | | |
| | | if GetSuccHasGot(curPlayer, succID):
|
| | | GameWorld.DebugLog(" 该成就奖励已经领取过!")
|
| | | return
|
| | | |
| | | |
| | | if not succData.hasAward:
|
| | | GameWorld.DebugLog(" 该成就没有配置奖励!")
|
| | | return
|
| | |
|
| | | itemDict = succData.awardItemDict
|
| | | finishTime = GetSuccIsFinish(curPlayer, succID)
|
| | | hasGot = GetSuccHasGot(curPlayer, succID) # 因为普通奖励领取后会重置是否已完成,所以如果已经领取普通奖励也代表已完成
|
| | | if finishTime <= 0 and not hasGot:
|
| | | GameWorld.DebugLog(" 该成就未完成!")
|
| | | return
|
| | | |
| | | if isPassport:
|
| | | if GetSuccPassportAwardHasGot(curPlayer, succID):
|
| | | GameWorld.DebugLog(" 该成就通行证奖励已经领取过!")
|
| | | return
|
| | | |
| | | if not GetSuccessPassportState(curPlayer):
|
| | | GameWorld.DebugLog(" 未开通成就通行证,无法领取通行证奖励!")
|
| | | return
|
| | | itemDict = succData.awardItemDict2
|
| | | if not itemDict:
|
| | | GameWorld.DebugLog(" 该成就没用通行证奖励!")
|
| | | return
|
| | | else:
|
| | | if hasGot:
|
| | | GameWorld.DebugLog(" 该成就奖励已经领取过!")
|
| | | return
|
| | | itemDict = succData.awardItemDict
|
| | | |
| | | # if awardItemDict and '[' in str(awardItemDict):
|
| | | # #修行成就奖励根据境界等级变
|
| | | # curRealmLV = curPlayer.GetOfficialRank()
|
| | |
| | | # else:
|
| | | # itemDict = awardItemDict
|
| | |
|
| | | |
| | | |
| | | |
| | | # 检查背包
|
| | | if isGiveItem:
|
| | | packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem)
|
| | |
| | | return
|
| | |
|
| | | # 更新领奖记录
|
| | | SetSuccHasGot(curPlayer, succID)
|
| | | if isPassport:
|
| | | SetSuccPassportAwardHasGot(curPlayer, succID)
|
| | | else:
|
| | | SetSuccHasGot(curPlayer, succID)
|
| | |
|
| | | # 给物品
|
| | | if isGiveItem:
|
| | | for itemID, itemCnt in itemDict.items():
|
| | | isPutIn = ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere])
|
| | |
|
| | | if isPassport:
|
| | | # 通行证奖励只给物品
|
| | | return itemDict
|
| | | |
| | | #给钱
|
| | | for moneyType, value in succData.moneyDict.items():
|
| | | PlayerControl.GiveMoney(curPlayer, moneyType, value)
|
| | |
| | | if succIDList:
|
| | | recordIndexList = []
|
| | | for succID in succIDList:
|
| | | recordIndexList.append(succID / 31)
|
| | | recordIndex = succID / 31
|
| | | if recordIndex not in recordIndexList:
|
| | | recordIndexList.append(recordIndex)
|
| | | else:
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | succCnt = ipyDataMgr.GetSuccessCount()
|
| | | if not succCnt:
|
| | | return
|
| | | maxSuccid = ipyDataMgr.GetSuccessByIndex(succCnt-1).GetID()
|
| | | recordIndexList = range(maxSuccid / 31+1)
|
| | | recordIndexList = xrange(maxSuccid / 31+1)
|
| | |
|
| | | succFARPack = ChPyNetSendPack.tagMCSuccessFinishAwardRecordList()
|
| | | succFARPack.Clear()
|
| | | succFARPack.RecordList = []
|
| | | for i in recordIndexList:
|
| | | awardRecord=curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Success_AwardRecord%i)
|
| | | if not isSyncZero and not awardRecord:
|
| | | passportAwardRecord=curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Success_PassportAward%i)
|
| | | if not isSyncZero and not awardRecord and not passportAwardRecord:
|
| | | continue
|
| | | recordInfo = ChPyNetSendPack.tagMCSuccessFinishAwardRecord()
|
| | | recordInfo.RecordIndex = i
|
| | | recordInfo.Record = awardRecord
|
| | | recordInfo.PassportRecord = passportAwardRecord
|
| | | succFARPack.RecordList.append(recordInfo)
|
| | | |
| | | |
| | | succFARPack.RecordCnt = len(succFARPack.RecordList)
|
| | | NetPackCommon.SendFakePack(curPlayer, succFARPack)
|
| | | return
|