6332 【后端】【2.0】主要是拍品相关规则调整及背包优化(邮件拍品处理,拍品奖励配置格式优化)
| | |
| | | PlayerID = 0 #(DWORD PlayerID)//玩家ID
|
| | | CompensationType = 0 #(BYTE CompensationType)//补偿类型 0 全服 1 个人
|
| | | GUID = "" #(char GUID[40])//对应的补偿ID
|
| | | CreateTime = "" #(char CreateTime[30])//邮件接收时间
|
| | | TextLen = 0 #(DWORD TextLen)//文字内容长度
|
| | | Text = "" #(String Text)//文字内容
|
| | | Count = 0 #(BYTE Count)//当前补偿物品数
|
| | |
| | | self.PlayerID,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.CompensationType,_pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| | | self.GUID,_pos = CommFunc.ReadString(_lpData, _pos,40)
|
| | | self.CreateTime,_pos = CommFunc.ReadString(_lpData, _pos,30)
|
| | | self.TextLen,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.Text,_pos = CommFunc.ReadString(_lpData, _pos,self.TextLen)
|
| | | self.Count,_pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| | |
| | | self.PlayerID = 0
|
| | | self.CompensationType = 0
|
| | | self.GUID = ""
|
| | | self.CreateTime = ""
|
| | | self.TextLen = 0
|
| | | self.Text = ""
|
| | | self.Count = 0
|
| | |
| | | length += 4
|
| | | length += 1
|
| | | length += 40
|
| | | length += 30
|
| | | length += 4
|
| | | length += len(self.Text)
|
| | | length += 1
|
| | |
| | | data = CommFunc.WriteDWORD(data, self.PlayerID)
|
| | | data = CommFunc.WriteBYTE(data, self.CompensationType)
|
| | | data = CommFunc.WriteString(data, 40, self.GUID)
|
| | | data = CommFunc.WriteString(data, 30, self.CreateTime)
|
| | | data = CommFunc.WriteDWORD(data, self.TextLen)
|
| | | data = CommFunc.WriteString(data, self.TextLen, self.Text)
|
| | | data = CommFunc.WriteBYTE(data, self.Count)
|
| | |
| | | PlayerID:%d,
|
| | | CompensationType:%d,
|
| | | GUID:%s,
|
| | | CreateTime:%s,
|
| | | TextLen:%d,
|
| | | Text:%s,
|
| | | Count:%d,
|
| | |
| | | self.PlayerID,
|
| | | self.CompensationType,
|
| | | self.GUID,
|
| | | self.CreateTime,
|
| | | self.TextLen,
|
| | | self.Text,
|
| | | self.Count,
|
| | |
| | | moneySource = gmList[5] if paramCnt > 5 else ChConfig.Def_GiveMoney_Mail
|
| | | paramList = gmList[6:]
|
| | |
|
| | | itemCfg = [(29,2000000000,1),(912,5,1),(10161,1,1),(10162,1,1),(10163,1,1)]
|
| | | itemCfg = [(29,2000000000,0),(912,5,1),(10161,1,1),(10162,1,0),(10163,1,0)]
|
| | | addItemList = itemCfg[0:itemCnt]
|
| | | content = "<MailTemplate>%s</MailTemplate>%s" % (mailNum, paramList)
|
| | | mailGUID = PlayerCompensation.SendPersonalItemMailEx("", content, 1, [curPlayer.GetPlayerID()], addItemList,
|
| | |
| | | # 竞拍成功邮件,发放物品
|
| | | paramList = [bidderPrice]
|
| | | detail = {"ItemGUID":itemGUID}
|
| | | addItemList = [{"ItemID":itemID, "Count":itemCount, "IsBind":True, "UserData":auctionItem.UserData}]
|
| | | addItemList = [{"ItemID":itemID, "Count":itemCount, "IsAuctionItem":False, "UserData":auctionItem.UserData}]
|
| | | PlayerCompensation.SendMailByKey("PaimaiMail3", [bidderID], addItemList, paramList, detail=detail)
|
| | | AddAuctionRecord(auctionItem, AuctionRecordResult_BidOK)
|
| | |
|
| | |
| | | # 流拍返还物品邮件
|
| | | paramList = []
|
| | | detail = {"ItemGUID":itemGUID}
|
| | | addItemList = [{"ItemID":itemID, "Count":itemCount, "IsBind":True, "UserData":auctionItem.UserData}]
|
| | | addItemList = [{"ItemID":itemID, "Count":itemCount, "IsAuctionItem":False, "UserData":auctionItem.UserData}]
|
| | | PlayerCompensation.SendMailByKey("PaimaiMail4", [playerID], addItemList, paramList, detail=detail)
|
| | |
|
| | | AddAuctionRecord(auctionItem, AuctionRecordResult_SellFail)
|
| | |
| | | #curItemData.GUID = curItemDict['GUID']
|
| | | curItemData.ItemID = curItemDict['ItemID']
|
| | | curItemData.Count = curItemDict['Count']
|
| | | curItemData.IsBind = curItemDict.get('IsBind',0)
|
| | | #curItemData.IsBind = curItemDict.get('IsBind',0)
|
| | | curItemData.IsBind = 1 if not curItemDict.get('IsAuctionItem',0) else 0
|
| | | curItemData.UserData = curItemDict.get('UserData', '')
|
| | | return curItemData
|
| | |
|
| | | # 此处货币playerIDList发放统一,如根据玩家不同而变,则应需修改
|
| | | ## 功能发放物品补偿/奖励邮件
|
| | | # @param addItemList [(itemID, itemCnt, isBind), {或物品信息字典}, ...]
|
| | | # @param addItemList [(itemID, itemCnt, 是否拍品), {或物品信息字典}, ...]
|
| | | # @return GUID
|
| | | def SendPersonalItemMailEx(title, content, getDays, playerIDList, addItemList, gold = 0, goldPaper = 0, silver = 0,
|
| | | detail="", moneySource=ChConfig.Def_GiveMoney_Mail):
|
| | |
| | |
|
| | | # 此处货币playerIDList发放统一,如根据玩家不同而变,则应需修改
|
| | | ## 功能发放物品补偿/奖励邮件
|
| | | # @param addItemList [(itemID, itemCnt, isBind), {或物品信息字典}, ...]
|
| | | # @param addItemList [(itemID, itemCnt, 是否拍品), {或物品信息字典}, ...]
|
| | | # @return GUID
|
| | | # @remarks addItemList支持append字典
|
| | | def SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList, gold = 0, goldPaper = 0, silver = 0,
|
| | |
| | |
|
| | |
|
| | | if len(itemInfo) == 3:
|
| | | itemID, itemCnt, isBind = itemInfo
|
| | | itemID, itemCnt, isAuctionItem = itemInfo
|
| | | else:
|
| | | continue
|
| | |
|
| | | addItemDict = {}
|
| | | addItemDict['ItemID'] = itemID
|
| | | addItemDict['Count'] = itemCnt
|
| | | addItemDict['IsBind'] = isBind
|
| | | addItemDict['IsAuctionItem'] = isAuctionItem
|
| | | addItemDictList.append(addItemDict)
|
| | |
|
| | | perMailItemCnt = IpyGameDataPY.GetFuncCfg("MailMaxItemCnt")
|
| | |
| | | curPlayer.SetDict(Def_RequestState, 0)#解锁
|
| | | GameWorld.DebugLog("Compensation### OnMGRequestCompensation no found")
|
| | | return
|
| | | Text, gold, goldPaper, silver, moneySource = curEntireRequire.Text, curEntireRequire.Gold, curEntireRequire.GoldPaper, curEntireRequire.Silver, curEntireRequire.Type
|
| | | #校验背包剩余空间是否足够
|
| | | #===========================================================================
|
| | | # curCUIDItemCount = GameWorld.GetCompensationMgr().FindItemCount(GUID)
|
| | |
| | | # return
|
| | | #===========================================================================
|
| | | #发送到MapServer给予奖励
|
| | | SendGMRequestCompensationResult(routeIndex, mapID, curPlayer, GUID, compensationType, Text, gold, goldPaper, silver, moneySource)
|
| | | SendGMRequestCompensationResult(routeIndex, mapID, curPlayer, GUID, compensationType, curEntireRequire)
|
| | | GameWorld.DebugLog("Compensation### OnMGRequestCompensation out")
|
| | |
|
| | | ##请求领取物品
|
| | |
| | | ##发送封包 03 02 玩家领取补偿结果#tagGMRequestCompensationResult
|
| | | # @param routeIndex, mapID, curPlayer, curItem
|
| | | # @return None
|
| | | def SendGMRequestCompensationResult(routeIndex, mapID, curPlayer, GUID, compensationType, Text,
|
| | | gold, goldPaper, silver, moneySource):
|
| | | def SendGMRequestCompensationResult(routeIndex, mapID, curPlayer, GUID, compensationType, curEntireRequire):
|
| | | |
| | | Text, gold, goldPaper, silver, moneySource, createTime = curEntireRequire.Text, curEntireRequire.Gold, \
|
| | | curEntireRequire.GoldPaper, curEntireRequire.Silver, curEntireRequire.Type, curEntireRequire.CreateTime
|
| | | sendPack = ChGameToMapPyPack.tagGMRequestCompensationResult()
|
| | | sendPack.PlayerID = curPlayer.GetID()
|
| | | sendPack.CompensationType = compensationType
|
| | | sendPack.GUID = GUID
|
| | | sendPack.CreateTime = createTime
|
| | | sendPack.Text = Text
|
| | | sendPack.TextLen = len(Text)
|
| | | sendPack.Gold = gold
|
| | |
| | | Def_IudetCreateTime = 44 # 时效物品的创建时间
|
| | | Def_IudetGatherSoulLV = 46 # 聚魂等级
|
| | | Def_IudetExpireTime = 48 # 时效物品指定有效时间,时间单位由时效类型决定
|
| | | Def_IudetAuctionItemCreateTime = 50 # 拍品创建时间
|
| | |
|
| | | # 200~300 宠物数据用
|
| | | Def_IudetPet_NPCID = 200 # npcID
|
| | | Def_IudetPet_ClassLV = 202 # 阶级
|
| | |
| | | PlayerID = 0 #(DWORD PlayerID)//玩家ID
|
| | | CompensationType = 0 #(BYTE CompensationType)//补偿类型 0 全服 1 个人
|
| | | GUID = "" #(char GUID[40])//对应的补偿ID
|
| | | CreateTime = "" #(char CreateTime[30])//邮件接收时间
|
| | | TextLen = 0 #(DWORD TextLen)//文字内容长度
|
| | | Text = "" #(String Text)//文字内容
|
| | | Count = 0 #(BYTE Count)//当前补偿物品数
|
| | |
| | | self.PlayerID,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.CompensationType,_pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| | | self.GUID,_pos = CommFunc.ReadString(_lpData, _pos,40)
|
| | | self.CreateTime,_pos = CommFunc.ReadString(_lpData, _pos,30)
|
| | | self.TextLen,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.Text,_pos = CommFunc.ReadString(_lpData, _pos,self.TextLen)
|
| | | self.Count,_pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| | |
| | | self.PlayerID = 0
|
| | | self.CompensationType = 0
|
| | | self.GUID = ""
|
| | | self.CreateTime = ""
|
| | | self.TextLen = 0
|
| | | self.Text = ""
|
| | | self.Count = 0
|
| | |
| | | length += 4
|
| | | length += 1
|
| | | length += 40
|
| | | length += 30
|
| | | length += 4
|
| | | length += len(self.Text)
|
| | | length += 1
|
| | |
| | | data = CommFunc.WriteDWORD(data, self.PlayerID)
|
| | | data = CommFunc.WriteBYTE(data, self.CompensationType)
|
| | | data = CommFunc.WriteString(data, 40, self.GUID)
|
| | | data = CommFunc.WriteString(data, 30, self.CreateTime)
|
| | | data = CommFunc.WriteDWORD(data, self.TextLen)
|
| | | data = CommFunc.WriteString(data, self.TextLen, self.Text)
|
| | | data = CommFunc.WriteBYTE(data, self.Count)
|
| | |
| | | PlayerID:%d,
|
| | | CompensationType:%d,
|
| | | GUID:%s,
|
| | | CreateTime:%s,
|
| | | TextLen:%d,
|
| | | Text:%s,
|
| | | Count:%d,
|
| | |
| | | self.PlayerID,
|
| | | self.CompensationType,
|
| | | self.GUID,
|
| | | self.CreateTime,
|
| | | self.TextLen,
|
| | | self.Text,
|
| | | self.Count,
|
| | |
| | | GameWorld.DebugAnswer(curPlayer, "非拍卖物品无法上架")
|
| | | return
|
| | | auctionItemList = []
|
| | | if itemCount < auctionGroup:
|
| | | GameWorld.DebugAnswer(curPlayer, "物品个数不能少于组数")
|
| | | return
|
| | | groupItemCount = itemCount / auctionGroup
|
| | | for i in xrange(auctionGroup):
|
| | | if i == auctionGroup - 1:
|
| | | groupItemCount += itemCount % auctionGroup
|
| | | curItem = ItemControler.GetOutPutItemObj(itemID, groupItemCount, isAuctionItem)
|
| | | for _ in xrange(auctionGroup):
|
| | | curItem = ItemControler.GetOutPutItemObj(itemID, itemCount, isAuctionItem)
|
| | | auctionItemList.append([curItem])
|
| | | PlayerAuctionHouse.__DoAddAuctionItem(curPlayer, auctionItemList)
|
| | |
|
| | |
| | | itemID = msgList[1]
|
| | | itemCount = max(1, msgList[2] if paramCount > 2 else 1)
|
| | | auctionGroup = max(1, msgList[3] if paramCount > 3 else 1)
|
| | | if itemCount < auctionGroup:
|
| | | GameWorld.DebugAnswer(curPlayer, "物品个数不能少于组数")
|
| | | return
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID)
|
| | | if not ipyData:
|
| | | GameWorld.DebugAnswer(curPlayer, "非拍卖物品无法上架")
|
| | |
| | | if playerID not in familyPlayerIDList:
|
| | | familyPlayerIDList.append(playerID)
|
| | |
|
| | | familyAuctionItemList = [[itemID, itemCount, auctionGroup]] |
| | | familyAuctionItemList = [[itemID, itemCount]] * auctionGroup
|
| | | familyAuctionItemDict = {familyID:[familyPlayerIDList, familyAuctionItemList]}
|
| | | PlayerAuctionHouse.DoAddFamilyAuctionItem(familyAuctionItemDict)
|
| | |
|
| | |
| | |
|
| | | def __Help(curPlayer):
|
| | | GameWorld.DebugAnswer(curPlayer, "清空所有拍品: AuctionItem 0")
|
| | | GameWorld.DebugAnswer(curPlayer, "添加个人拍品: AuctionItem 1 物品ID 个数 分几组")
|
| | | GameWorld.DebugAnswer(curPlayer, "添加仙盟拍品: AuctionItem 2 物品ID 个数 分几组 受益玩家IDA 玩家IDB...")
|
| | | GameWorld.DebugAnswer(curPlayer, "添加个人拍品: AuctionItem 1 物品ID 个数 几组")
|
| | | GameWorld.DebugAnswer(curPlayer, "添加仙盟拍品: AuctionItem 2 物品ID 个数 几组 受益玩家IDA 玩家IDB...")
|
| | | return
|
| | |
|
| | |
|
| | |
| | |
|
| | | #输入命令格式错误
|
| | | if len(msgList) < 1:
|
| | | GameWorld.DebugAnswer(curPlayer, "MakeItemCount ID (个数 拍品分组 全部传奇属性)")
|
| | | GameWorld.DebugAnswer(curPlayer, "MakeItemCount ID (个数 拍品组数 全部传奇属性)")
|
| | | return
|
| | |
|
| | | event = [ChConfig.ItemGive_GMMake, False, {"CMD":"MakeItemCount"}]
|
| | |
| | |
|
| | | # 拍品
|
| | | if auctionGroup > 0:
|
| | | isAuctionItem = True
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID)
|
| | | if not ipyData:
|
| | | GameWorld.DebugAnswer(curPlayer, "非可拍卖物品itemID=%s" % (itemID))
|
| | | return
|
| | | if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, auctionGroup, [IPY_GameWorld.rptItem], event=event):
|
| | | GameWorld.DebugAnswer(curPlayer, "###放入物品失败!")
|
| | | for _ in xrange(auctionGroup):
|
| | | if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, True, [IPY_GameWorld.rptItem], event=event):
|
| | | GameWorld.DebugAnswer(curPlayer, "###放入物品失败!")
|
| | | else:
|
| | | auctionGroup = 0
|
| | | isAuctionItem = False
|
| | | if not ItemCommon.GetIsEquip(itemData):
|
| | | if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, auctionGroup, [IPY_GameWorld.rptItem], event=event):
|
| | | if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, False, [IPY_GameWorld.rptItem], event=event):
|
| | | GameWorld.DebugAnswer(curPlayer, "###放入物品失败!")
|
| | | else:
|
| | | for _ in xrange(itemCount):
|
| | | __DoGMGivePlayerItem(curPlayer, playerItemControler, itemID, 1, isAuctionItem, isAllAttr, event)
|
| | | __DoGMGivePlayerItem(curPlayer, playerItemControler, itemID, 1, False, isAllAttr, event)
|
| | | return
|
| | |
|
| | | def __DoGMGivePlayerItem(curPlayer, playerItemControler, itemID, count, isAuctionItem, isAllAttr, event):
|
| | |
| | | return
|
| | |
|
| | | def GetJsonItemList(itemList):
|
| | | ## [[itemID,itemCount,isBind], curItem] -> [{"ItemID":101, "Count":10, "IsBind":1, "IsSuite":1, "UserData":"自定义属性字符串"}]
|
| | | ## [[itemID,itemCount,isAuctionItem], curItem] -> [{"ItemID":101, "Count":10, "IsAuctionItem":1, "UserData":"自定义属性字符串"}]
|
| | | jsonItemList = []
|
| | | for itemInfo in itemList:
|
| | | itemDict = {}
|
| | |
| | | if infolen > 1:
|
| | | itemDict['Count'] = itemInfo[1]
|
| | | if infolen > 2:
|
| | | itemDict['IsBind'] = int(itemInfo[2])
|
| | | itemDict['IsAuctionItem'] = int(itemInfo[2])
|
| | | elif isinstance(itemInfo, int):
|
| | | itemDict['ItemID'] = itemInfo
|
| | | else: #物品实例
|
| | |
| | | continue
|
| | | itemDict['ItemID'] = itemInfo.GetItemTypeID()
|
| | | itemDict['Count'] = itemInfo.GetCount()
|
| | | itemDict['IsBind'] = int(itemInfo.GetIsBind())
|
| | | itemDict['IsSuite'] = int(itemInfo.GetIsSuite())
|
| | | itemDict['IsAuctionItem'] = 0 if itemInfo.GetIsBind() else 1
|
| | | #itemDict['IsSuite'] = int(itemInfo.GetIsSuite())
|
| | | itemDict['UserData'] = itemInfo.GetUserData()
|
| | | jsonItemList.append(itemDict)
|
| | | return jsonItemList
|
| | |
| | |
|
| | | # 使用拍品
|
| | | if not curItem.GetIsBind():
|
| | | __DoLogic_PlayerUseAuctionItem(curPlayer, curItem, itemIndex, exData)
|
| | | DoLogic_PlayerUseAuctionItem(curPlayer, curItem)
|
| | | return
|
| | |
|
| | | if useCnt <= 0:
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def __DoLogic_PlayerUseAuctionItem(curPlayer, curItem, itemIndex, exData):
|
| | | def DoLogic_PlayerUseAuctionItem(curPlayer, curItem):
|
| | | ## 玩家使用拍品
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | itemID = curItem.GetItemTypeID()
|
| | |
|
| | | curItem.SetIsBind(1) # 设置为非拍品
|
| | | GameWorld.DebugLog("玩家使用拍品: itemIndex=%s,itemID=%s,exData=%s" % (itemID, itemIndex, exData), playerID)
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetAuctionItemCreateTime)
|
| | | GameWorld.DebugLog("玩家使用拍品: itemID=%s" % (itemID), playerID)
|
| | |
|
| | | if ItemCommon.GetIsEquip(curItem):
|
| | | # 生成传奇属性
|
| | |
| | | tagItemCount = GetItemCount(tagItem)
|
| | | isBind = tagItem.GetIsBind()
|
| | | isAuctionItem = not isBind
|
| | | auctionGroup = 1 if isAuctionItem else 0 # 物品实例默认一组
|
| | | if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), tagItemCount, auctionGroup, defaultPile):
|
| | | if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), tagItemCount, isAuctionItem, defaultPile):
|
| | | GameWorld.DebugLog("背包满,不能放入物品 count = %d"%GetItemCount(tagItem))
|
| | | tagItem.Clear()
|
| | | return False
|
| | |
| | | return True
|
| | | defaultPile = True
|
| | | maxPackCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的, 暂定堆叠上限20亿
|
| | | elif auctionGroup > 0:
|
| | | maxPackCount = max(1, tagItemCount / auctionGroup) # 每组至少1个
|
| | | elif isAuctionItem:
|
| | | maxPackCount = tagItemCount
|
| | | defaultPile = False # 新放入的拍品只能放空位置,所以不判断堆叠
|
| | | #isBind = False
|
| | | isNeedRecord = True # 拍品要记录
|
| | |
| | | # @param packIndex 背包索引
|
| | | # @param curItemID 当前物品ID
|
| | | # @param curItemCount 当前物品数量
|
| | | # @param auctionGroup 拍品组数
|
| | | # @param isAuctionItem 是否拍品
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @return True or False
|
| | | # @remarks 函数详细说明.
|
| | | def CanPutInItem(self, packIndex, curItemID, curItemCount, auctionGroup, defaultPile=True):
|
| | | def CanPutInItem(self, packIndex, curItemID, curItemCount, isAuctionItem, defaultPile=True):
|
| | | if GameWorld.IsCrossServer():
|
| | | return True
|
| | | checkRet, putIndex = self.CanPutInItemEx(packIndex, curItemID, curItemCount, auctionGroup, defaultPile)
|
| | | checkRet, putIndex = self.CanPutInItemEx(packIndex, curItemID, curItemCount, isAuctionItem, defaultPile)
|
| | | return checkRet
|
| | |
|
| | | ## 是否能放入物品
|
| | | # @param packIndex 背包索引
|
| | | # @param curItemID 当前物品ID
|
| | | # @param curItemCount 当前物品数量
|
| | | # @param auctionGroup 拍品组数
|
| | | # @param isAuctionItem 是否拍品
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @return True or False, 第一个可放入的位置
|
| | | # @remarks 函数详细说明.
|
| | | def CanPutInItemEx(self, packIndex, curItemID, curItemCount, auctionGroup, defaultPile=True):
|
| | | def CanPutInItemEx(self, packIndex, curItemID, curItemCount, isAuctionItem, defaultPile=True):
|
| | | gameData = GameWorld.GetGameData()
|
| | | curItemData = gameData.GetItemByTypeID(curItemID)
|
| | |
|
| | |
| | | if packIndex == IPY_GameWorld.rptItem:
|
| | | return True, 0
|
| | | maxPackCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的, 暂定堆叠上限20亿
|
| | | elif auctionGroup > 0:
|
| | | maxPackCount = max(1, curItemCount / auctionGroup) # 每组至少1个
|
| | | elif isAuctionItem:
|
| | | maxPackCount = curItemCount
|
| | | defaultPile = False # 新放入的拍品只能放空位置,所以不判断堆叠
|
| | | isBind = False
|
| | | else:
|
| | |
| | | #curItemGUID = curItem.GetGUID()
|
| | | curItemCount = curItem.GetCount()
|
| | | #curItemIsBind = curItem.GetIsBind()
|
| | | auctionGroup = 1 if not curItem.GetIsBind() else 0 # 已经生成的物品实例默认1组
|
| | | isAuctionItem = 0 if curItem.GetIsBind() else 1
|
| | | #toPackIndex = ChConfig.GetItemPackType(curItem.GetType(), toPackIndex)
|
| | |
|
| | | # 常规物品转移到虚拟符印背包
|
| | |
| | | return False
|
| | | return itemControl.PutItemInVPack(toPackIndex, curItem)
|
| | |
|
| | | checkRet, putIndex = itemControl.CanPutInItemEx(toPackIndex, curItemTypeID, curItemCount, auctionGroup)
|
| | | checkRet, putIndex = itemControl.CanPutInItemEx(toPackIndex, curItemTypeID, curItemCount, isAuctionItem)
|
| | | if not checkRet:
|
| | | return False
|
| | | return DragItem(curPlayer, fromPackIndex, itemIndex, toPackIndex, putIndex, curItemCount)
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def GivePlayerItem(curPlayer, itemID, itemCount, auctionGroup, packIndexList, event=["", False, {}]):
|
| | | def GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, packIndexList, event=["", False, {}]):
|
| | | '''给玩家物品
|
| | | @param auctionGroup: 拍品组数,0为非拍品,大于0为总给的物品数拆成的拍品组数;注意这个不一定按叠加拆分,策划自行决定非几组拍
|
| | | @param isAuctionItem: 是否拍品
|
| | | '''
|
| | | if itemCount <= 0:
|
| | | return False
|
| | |
| | | if not curItemData:
|
| | | return False
|
| | |
|
| | | if auctionGroup > 0:
|
| | | if isAuctionItem:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID)
|
| | | if not ipyData:
|
| | | GameWorld.ErrLog("非拍卖物品,不能按拍品分组,默认转为非拍品! itemID=%s,itemCount=%s,auctionGroup=%s" |
| | | % (itemID, itemCount, auctionGroup), curPlayer.GetPlayerID())
|
| | | auctionGroup = 0
|
| | | isAuctionItem = True if auctionGroup > 0 else False
|
| | | GameWorld.ErrLog("非拍卖物品,默认转为非拍品! itemID=%s,itemCount=%s,isAuctionItem=%s" |
| | | % (itemID, itemCount, isAuctionItem), curPlayer.GetPlayerID())
|
| | | isAuctionItem = 0
|
| | |
|
| | | defaultPack = IPY_GameWorld.rptItem if not packIndexList else packIndexList[0]
|
| | | packIndex = ChConfig.GetItemPackType(curItemData.GetType(), defaultPack)
|
| | |
| | | itemControl = PlayerItemControler(curPlayer)
|
| | | for packIndex in packIndexList:
|
| | | #可以放入背包
|
| | | if itemControl.CanPutInItem(packIndex, itemID, itemCount, auctionGroup):
|
| | | if itemControl.CanPutInItem(packIndex, itemID, itemCount, isAuctionItem):
|
| | | canPutIn = True
|
| | | break
|
| | | if not canPutIn:
|
| | |
| | | if not outPutEquip:
|
| | | return isOK
|
| | | if DoLogic_PutItemInPack(curPlayer, outPutEquip, event, packIndexList):
|
| | | isOK = True # 只要有成功的就返回成功,防止异常情况失败可能导致被刷
|
| | | return isOK
|
| | | |
| | | if auctionGroup > 0:
|
| | | isOK = False
|
| | | doCount = itemCount
|
| | | maxPackCount = max(1, itemCount / auctionGroup) # 每组至少1个
|
| | | while itemCount > 0 and doCount > 0:
|
| | | doCount -= 1
|
| | | giveCount = maxPackCount if itemCount >= maxPackCount else itemCount
|
| | | if giveCount <= 0:
|
| | | break
|
| | | itemCount -= giveCount
|
| | | giveItem = GetOutPutItemObj(itemID, giveCount, isAuctionItem, curPlayer=curPlayer)
|
| | | if not giveItem:
|
| | | return isOK
|
| | | if DoLogic_PutItemInPack(curPlayer, giveItem, event, packIndexList):
|
| | | isOK = True # 只要有成功的就返回成功,防止异常情况失败可能导致被刷
|
| | | return isOK
|
| | |
|
| | |
| | | return item.GetUserAttr(ShareDefine.Def_IudetItemCount)
|
| | | return item.GetCount()
|
| | |
|
| | | def GetItemNeedPackCount(packType, itemData, itemCount):
|
| | | def GetItemNeedPackCount(packType, itemData, itemCount, isAuctionItem=0):
|
| | | if isAuctionItem:
|
| | | return 1
|
| | | if itemData.GetItemTypeID() in ChConfig.Def_TransformItemIDList:
|
| | | # 货币直接转换的物品如果是放入背包的则不需要暂用格子,放入其他的背包的则按物品叠加上限算
|
| | | if packType == IPY_GameWorld.rptItem:
|
| | |
| | | curItem.Clear()
|
| | | return
|
| | |
|
| | | def PutItemInTempSwap(curPlayer, itemID, isBind=1):
|
| | | def PutItemInTempSwap(curPlayer, itemID, isAuctionItem=0):
|
| | | ## 临时背包放入物品
|
| | | # 临时交换背包目前只开放1个格子,每次放入前先清空再放入
|
| | | ClearPack(curPlayer, ShareDefine.rptTempSwap)
|
| | | auctionGroup = 1 if not isBind else 0
|
| | | return GivePlayerItem(curPlayer, itemID, 1, auctionGroup, [ShareDefine.rptTempSwap])
|
| | | return GivePlayerItem(curPlayer, itemID, 1, isAuctionItem, [ShareDefine.rptTempSwap])
|
| | |
|
| | | def OpenPickupItemPutInTemp(curPlayer, isClearItem):
|
| | | ''' 开启拾取的物品放入临时存放背包
|
| | |
| | | itemControl = PlayerItemControler(curPlayer)
|
| | | for tempItem in tempItemList:
|
| | | itemControl.PutInItem(IPY_GameWorld.rptItem, tempItem, event=event)
|
| | | for itemID, itemCnt, isBind in extraItemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isBind, [IPY_GameWorld.rptItem], event=event)
|
| | | for itemID, itemCnt, isAuctionItem in extraItemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)
|
| | |
|
| | | ClearPack(curPlayer, ShareDefine.rptTempItem)
|
| | | return
|
| | |
| | | def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}]):
|
| | | ##给物品,背包满则发邮件
|
| | | needPackSpaceDict = {}
|
| | | for itemID, itemCnt, isBind in itemList:
|
| | | for itemID, itemCnt, isAuctionItem in itemList:
|
| | | curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
|
| | | if not curItem:
|
| | | GameWorld.ErrLog('GivePlayerItemOrMail 物品ID不存在 itemID=%s'%itemID, curPlayer.GetID())
|
| | | return
|
| | | packType = ChConfig.GetItemPackType(curItem.GetType())
|
| | | needSpace = GetItemNeedPackCount(packType, curItem, itemCnt)
|
| | | needSpace = GetItemNeedPackCount(packType, curItem, itemCnt, isAuctionItem)
|
| | | needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace
|
| | | isSendMail = False
|
| | | for packType, needSpace in needPackSpaceDict.items():
|
| | |
| | | PlayerControl.SendMailByKey(mailKey, [curPlayer.GetPlayerID()], itemList)
|
| | | GameWorld.DebugLog("GivePlayerItemOrMail背包空间不够,发送邮件: mailItemList=%s" % str(itemList), curPlayer.GetPlayerID())
|
| | | else:
|
| | | for itemID, itemCnt, isBind in itemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isBind, [IPY_GameWorld.rptItem], event=event)
|
| | | for itemID, itemCnt, isAuctionItem in itemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)
|
| | | return
|
| | |
| | | return
|
| | | curSingleItem.SetRemainHour(outTimeServerDay)
|
| | |
|
| | | isBind = not isAuctionItem
|
| | | if isBind:
|
| | | curSingleItem.SetIsBind(1)
|
| | | if isAuctionItem:
|
| | | curSingleItem.SetUserAttr(ShareDefine.Def_IudetAuctionItemCreateTime, int(time.time()))
|
| | | else:
|
| | | curSingleItem.SetIsBind(1) |
| | |
|
| | | ItemControler.SetItemCount(curSingleItem, itemCount)
|
| | |
|
| | |
| | | addItemDict = {}
|
| | | addItemDict['ItemID'] = curItem.GetItemTypeID()
|
| | | addItemDict['Count'] = curItem.GetCount()
|
| | | addItemDict['IsBind'] = int(curItem.GetIsBind())
|
| | | addItemDict['IsAuctionItem'] = 0 if curItem.GetIsBind() else 1
|
| | | #addItemDict['IsBind'] = int(curItem.GetIsBind())
|
| | | #addItemDict['EquipGS'] = GetEquipGearScore(curItem)
|
| | | #addItemDict['ItemStarLV'] = curItem.GetItemStarLV()
|
| | | #addItemDict['CurDurg'] = GameWorld.GetIntUpper(curItem.GetCurDurg(), ChConfig.Def_EndureRepairParameter)
|
| | |
| | | #addItemDict['EquipMaxAtkValue'] = curItem.GetEquipMaxAtkValue()
|
| | | #addItemDict['FitLV'] = curItem.GetFitLV()
|
| | | #addItemDict['Proficiency'] = curItem.GetProficiency()
|
| | | addItemDict['IsSuite'] = int(curItem.GetIsSuite())
|
| | | #addItemDict['IsSuite'] = int(curItem.GetIsSuite())
|
| | | #addItemDict['BaseHP'] = curItem.GetBaseHP()
|
| | | #addItemDict['BaseMagicDef'] = curItem.GetBaseMagicDef()
|
| | | #addItemDict['MaxAddSkillCnt'] = curItem.GetMaxAddSkillCnt()
|
| | |
| | | import ItemControler
|
| | | import ItemCommon
|
| | | import ChConfig
|
| | | import ShareDefine
|
| | | import ChItem
|
| | |
|
| | | import time
|
| | |
|
| | | #// B5 13 拍卖行上架拍品 #tagCMSellAuctionItem
|
| | | #
|
| | |
| | | itemID = curItem.GetItemTypeID()
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID)
|
| | | if not ipyData:
|
| | | return
|
| | | auctionItemCreateTime = curItem.GetUserAttr(ShareDefine.Def_IudetAuctionItemCreateTime)
|
| | | if not auctionItemCreateTime:
|
| | | GameWorld.DebugLog("没有拍品创建时间,无法上架!", playerID)
|
| | | return
|
| | | curTime = int(time.time())
|
| | | if curTime - auctionItemCreateTime > IpyGameDataPY.GetFuncCfg("AuctionItem", 1) * 3600:
|
| | | GameWorld.DebugLog("拍品已过期,无法上架!auctionItemCreateTime=%s" % (GameWorld.ChangeTimeNumToStr(auctionItemCreateTime)), playerID)
|
| | | ChItem.DoLogic_PlayerUseAuctionItem(curPlayer, curItem)
|
| | | return
|
| | |
|
| | | QueryGameServer_AuctionHouse(playerID, "AddAuctionItemQuery", [itemIndex, itemGUID, itemID])
|
| | |
| | |
|
| | | def DoAddFamilyAuctionItem(familyAuctionItemDict):
|
| | | ''' 上架仙盟拍品,因为仙盟拍品默认上架,所以使用批量上架
|
| | | @param familyAuctionItemDict: {仙盟ID:[[享受收益的成员ID, ...], [[拍品ID,总个数,拍品组数], ...]], ...}
|
| | | @param familyAuctionItemDict: {仙盟ID:[[享受收益的成员ID, ...], [[拍品ID,个数], [拍品ID,个数,是否拍品], ...]], ...}
|
| | | '''
|
| | | GameWorld.Log("上架仙盟拍品: %s" % familyAuctionItemDict)
|
| | | isAuctionItem = True
|
| | | auctionItemList = []
|
| | | for familyID, auctionInfo in familyAuctionItemDict.items():
|
| | | familyPlayerIDList, familyAuctionItemList = auctionInfo
|
| | | for itemID, itemCount, auctionGroup in familyAuctionItemList:
|
| | | for itemInfo in familyAuctionItemList:
|
| | | if len(itemInfo) < 2:
|
| | | continue
|
| | | itemID, itemCount = itemInfo[:2]
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID)
|
| | | if not ipyData:
|
| | | GameWorld.ErrLog("非拍卖物品,无法上架仙盟拍品! familyID=%s,itemID=%s,itemCount=%s" % (familyID, itemID, itemCount))
|
| | | continue
|
| | | groupItemCount = itemCount / auctionGroup
|
| | | for i in xrange(auctionGroup):
|
| | | if i == auctionGroup - 1:
|
| | | groupItemCount += itemCount % auctionGroup
|
| | | curItem = ItemControler.GetOutPutItemObj(itemID, groupItemCount, isAuctionItem)
|
| | | if not curItem:
|
| | | continue
|
| | | auctionItemList.append([curItem, familyID, familyPlayerIDList])
|
| | | curItem = ItemControler.GetOutPutItemObj(itemID, itemCount, isAuctionItem)
|
| | | if not curItem:
|
| | | continue
|
| | | auctionItemList.append([curItem, familyID, familyPlayerIDList])
|
| | | __DoAddAuctionItem(None, auctionItemList)
|
| | | return
|
| | |
|
| | |
| | | import EventReport
|
| | | import ChConfig
|
| | | import PlayerControl
|
| | | import IpyGameDataPY
|
| | |
|
| | | import time
|
| | |
|
| | | ##A5 3B 请求领取补偿#tagCMRequestCompensation
|
| | | # @param index, clientPack, tick
|
| | |
| | | GameWorld.DebugLog(" PlayerID %s no found "%curPackData.PlayerID)
|
| | | return
|
| | |
|
| | | hasAuctionItem = False
|
| | | needPackSpaceDict = {}
|
| | | isPackSpaceEnough = True
|
| | | # 先汇总物品所属背包
|
| | |
| | | if not curItemData:
|
| | | continue
|
| | |
|
| | | isAuctionItem = not curPackItem.IsBind
|
| | | packType = ChConfig.GetItemPackType(curItemData.GetType())
|
| | | needSpace = ItemControler.GetItemNeedPackCount(packType, curItemData, curPackItem.Count)
|
| | | needSpace = ItemControler.GetItemNeedPackCount(packType, curItemData, curPackItem.Count, isAuctionItem)
|
| | | needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace
|
| | | if isAuctionItem:
|
| | | hasAuctionItem = True
|
| | |
|
| | | GameWorld.DebugLog(" needPackSpaceDict=%s" % str(needPackSpaceDict))
|
| | | for packType, needSpace in needPackSpaceDict.items():
|
| | |
| | | PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])
|
| | | isPackSpaceEnough = False
|
| | | break
|
| | | |
| | | auctionItemTimeout = False
|
| | | auctionItemCreateTime = 0
|
| | | if hasAuctionItem:
|
| | | auctionItemValidTimesMax = IpyGameDataPY.GetFuncCfg("AuctionItem", 1) * 3600 # 拍品有效时长
|
| | | auctionItemValidTimesMail = IpyGameDataPY.GetFuncCfg("AuctionItem", 2) * 3600 # 邮件拍品附加有效时长
|
| | | auctionItemValidTimesTotal = auctionItemValidTimesMail + auctionItemValidTimesMax
|
| | | mailCreateTimeStr = curPackData.CreateTime
|
| | | mailCreateTime = GameWorld.ChangeTimeStrToNum(mailCreateTimeStr)
|
| | | curTime = int(time.time())
|
| | | passTime = curTime - mailCreateTime
|
| | | if passTime <= auctionItemValidTimesMail:
|
| | | GameWorld.DebugLog("邮件拍品领取时间在附加保护时长内,拍品创建时间即领取邮件时间开始算!passTime(%s) <= auctionItemValidTimesMail(%s)" % (passTime, auctionItemValidTimesMail))
|
| | | pass
|
| | | elif auctionItemValidTimesMail < passTime < auctionItemValidTimesTotal:
|
| | | auctionItemCreateTime = curTime - (passTime - auctionItemValidTimesMail)
|
| | | GameWorld.DebugLog("邮件拍品领取时间超过邮件保护时间,拍品创建时间需扣除领取时的溢出时间!auctionItemValidTimesMail(%s) < passTime(%s) < auctionItemValidTimesTotal(%s), auctionItemCreateTime=%s" |
| | | % (auctionItemValidTimesMail, passTime, auctionItemValidTimesTotal, GameWorld.ChangeTimeNumToStr(auctionItemCreateTime)))
|
| | | elif passTime >= auctionItemValidTimesMax:
|
| | | auctionItemTimeout = True
|
| | | GameWorld.DebugLog("邮件中的拍品已过期,将自动转为非拍品!passTime(%s) >= auctionItemValidTimesMax(%s)" |
| | | % (passTime, auctionItemValidTimesMax))
|
| | |
|
| | | #背包空间不足
|
| | | if not isPackSpaceEnough:
|
| | |
| | | for i in xrange(curPackData.Count):
|
| | | curPackItem = curPackData.Items[i]
|
| | | itemID = curPackItem.ItemID
|
| | | isAuctionItem = not curPackItem.IsBind and not auctionItemTimeout
|
| | | if ItemControler.GetAppointItemRealID(itemID):
|
| | | #定制物品
|
| | | ItemControler.GivePlayerItem(curPlayer, itemID, curPackItem.Count, 0, [IPY_GameWorld.rptItem], |
| | | event=[ChConfig.ItemGive_Mail, False, {"MailGUID":curPackData.GUID}])
|
| | | continue
|
| | | |
| | | curCreateItem = ItemCommon.CreateSingleItem(itemID, curPackItem.Count, not curPackItem.IsBind)
|
| | | curCreateItem = ItemControler.GetItemByData(ItemControler.GetAppointItemDictData(itemID, isAuctionItem))
|
| | | else:
|
| | | curCreateItem = ItemCommon.CreateSingleItem(itemID, curPackItem.Count, isAuctionItem)
|
| | | if not curCreateItem:
|
| | | GameWorld.ErrLog("OnGMRequestCompensationResult CreateSingleItem %s Err "%itemID)
|
| | | continue
|
| | |
| | | #设置UserData
|
| | | UserData = "%s"%UserDataDict
|
| | | curCreateItem.SetUserData(UserData, len(UserData))
|
| | | |
| | | if isAuctionItem and auctionItemCreateTime:
|
| | | curCreateItem.SetUserAttr(ShareDefine.Def_IudetAuctionItemCreateTime, auctionItemCreateTime)
|
| | | |
| | | ItemCommon.MakeEquipGS(curCreateItem)
|
| | | #放入玩家背包
|
| | | ItemControler.PlayerItemControler(curPlayer).PutInItem(IPY_GameWorld.rptItem, curCreateItem,
|
| | |
| | | return
|
| | |
|
| | | ## 功能发放物品补偿/奖励邮件
|
| | | # @param addItemList [(itemID, itemCnt, isBind), {或物品信息字典}, ...]
|
| | | # @param addItemList [(itemID, itemCnt, 是否拍品), {或物品信息字典}, ...]
|
| | | # @return
|
| | | def SendMail(title, content, getDays, playerIDList, addItemList, gold=0, goldPaper=0, silver=0, detail="", moneySource=ChConfig.Def_GiveMoney_Mail):
|
| | | if not playerIDList:
|
| | |
| | | if len(mailItem) != 3:
|
| | | continue
|
| | |
|
| | | itemID, itemCnt, isBind = mailItem
|
| | | itemID, itemCnt, isAuctionItem = mailItem
|
| | |
|
| | | if ItemControler.GetAppointItemRealID(itemID):
|
| | | # 定制物品转化为物品信息字典
|
| | | appointItemObj = ItemControler.GetItemByData(ItemControler.GetAppointItemDictData(itemID, False))
|
| | | appointItemObj = ItemControler.GetItemByData(ItemControler.GetAppointItemDictData(itemID, isAuctionItem))
|
| | | if not appointItemObj:
|
| | | GameWorld.ErrLog("邮件定制物品转化失败!itemID, itemCnt, isBind" % (itemID, itemCnt, isBind))
|
| | | GameWorld.ErrLog("邮件定制物品转化失败!itemID, itemCnt, isAuctionItem" % (itemID, itemCnt, isAuctionItem))
|
| | | continue
|
| | | combineItemList.append(ItemCommon.GetMailItemDict(appointItemObj))
|
| | | appointItemObj.Clear()
|
| | | elif isAuctionItem:
|
| | | combineItemList.append((itemID, itemCnt, isAuctionItem))
|
| | | else:
|
| | | key = (itemID, isBind)
|
| | | key = (itemID, isAuctionItem)
|
| | | itemCountDict[key] = itemCountDict.get(key, 0) + itemCnt
|
| | |
|
| | | for key, itemCnt in itemCountDict.items():
|
| | | itemID, isBind = key
|
| | | combineItemList.append((itemID, itemCnt, isBind))
|
| | | itemID, isAuctionItem = key
|
| | | combineItemList.append((itemID, itemCnt, isAuctionItem))
|
| | | cmdList = [title, content, getDays, playerIDList, combineItemList, gold, goldPaper, silver, detail, moneySource]
|
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "SendMail", '%s' % (cmdList), len(str(cmdList)))
|
| | | return True
|
| | |
| | | Def_IudetCreateTime = 44 # 时效物品的创建时间
|
| | | Def_IudetGatherSoulLV = 46 # 聚魂等级
|
| | | Def_IudetExpireTime = 48 # 时效物品指定有效时间,时间单位由时效类型决定
|
| | | Def_IudetAuctionItemCreateTime = 50 # 拍品创建时间
|
| | |
|
| | | # 200~300 宠物数据用
|
| | | Def_IudetPet_NPCID = 200 # npcID
|
| | | Def_IudetPet_ClassLV = 202 # 阶级
|