| | |
| | | decompoundItemInfo = [] # 拆解返还物品列表 [装备ID,材料1ID,个数,是否绑定,材料2ID,个数,是否绑定,...]
|
| | |
|
| | | itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | itemExpireTime = 0
|
| | | wingItemExpInfo = None #材料翅膀精炼信息
|
| | | dogzEquipPlusExp = 0 #神兽装备强化熟练度
|
| | | # 检查不固定消耗道具
|
| | |
| | | unfixedItemIDList, needUnfixedItemCount)
|
| | | if not unfixedItemCostInfo:
|
| | | return
|
| | | unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp = unfixedItemCostInfo
|
| | | unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp, expireTime = unfixedItemCostInfo
|
| | | if expireTime:
|
| | | itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
|
| | |
|
| | | # 检查固定消耗道具
|
| | | if fixedItemIDList:
|
| | | fixedItemInfo = __CheckFixedItem(playerID, compoundID, itemPack, fixedItemIndexList, fixedItemIDList, fixedItemCountList, compoundCnt)
|
| | | if not fixedItemInfo:
|
| | | return
|
| | | fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt = fixedItemInfo
|
| | | fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt, expireTime = fixedItemInfo
|
| | | if expireTime:
|
| | | itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
|
| | |
|
| | | # 检查附加道具增加成功率消耗
|
| | | addSuccRate, addSuccRateItemInfo = 0, []
|
| | |
| | | addSuccRateInfo = __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax)
|
| | | if addSuccRateInfo == None:
|
| | | return
|
| | | addSuccRate, addSuccRateItemInfo = addSuccRateInfo
|
| | | addSuccRate, addSuccRateItemInfo, expireTime = addSuccRateInfo
|
| | | if expireTime:
|
| | | itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
|
| | |
|
| | | # 检查提升概率道具
|
| | | incRateItemCostList, needIncRateItemCount, incRate = [], 0, 0
|
| | |
| | | incRateItemInfo = __CheckIncRateItem(playerID, compoundID, itemPack, incRateItemIndexList, incRateItemID, needIncRateItemCount)
|
| | | if not incRateItemInfo:
|
| | | return
|
| | | incRateItemCostList = incRateItemInfo
|
| | | incRateItemCostList, expireTime = incRateItemInfo
|
| | | if expireTime:
|
| | | itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
|
| | |
|
| | | # 扣铜钱
|
| | | PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalNeedMoney, ChConfig.Def_Cost_ItemProduce,
|
| | | {ChConfig.Def_Cost_Reason_SonKey:makeItemID, "CompoundCount":compoundCnt})
|
| | |
|
| | | drDict = {"CompoundID":compoundID, "MakeItemID":makeItemID, "CompoundCount":compoundCnt}
|
| | | drDict = {"CompoundID":compoundID, "MakeItemID":makeItemID, "CompoundCount":compoundCnt, "itemExpireTime":itemExpireTime}
|
| | | makeItemBind = False
|
| | |
|
| | | # 扣不固定消耗物品
|
| | |
| | | DataRecordPack.SendEventPack("ItemCompound", drDict, curPlayer)
|
| | |
|
| | | if canHappen:
|
| | | GameWorld.DebugLog("合成成功: makeItemID=%s,compoundCnt=%s,compoundBindCnt=%s" % (makeItemID, compoundCnt, compoundBindCnt), playerID)
|
| | | userData = GiveNewCompoundItem(curPlayer, makeItemID, compoundCnt, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo)
|
| | | GameWorld.DebugLog("合成成功: makeItemID=%s,compoundCnt=%s,compoundBindCnt=%s,itemExpireTime=%s" % (makeItemID, compoundCnt, compoundBindCnt, itemExpireTime), playerID)
|
| | | userData = GiveNewCompoundItem(curPlayer, makeItemID, compoundCnt, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime)
|
| | |
|
| | | msgMark = ipyData.GetSysMark()
|
| | | paramType = ipyData.GetSysMarkParamType()
|
| | |
| | |
|
| | | def __CheckUnfixedItem(playerID, compoundID, makeItemData, itemPack, unfixedItemIndexList, unfixedItemIDList, needUnfixedItemCount):
|
| | | ## 检查不固定消耗道具, 只要客户端提交的数据有不符合要求的,则直接返回 None
|
| | | expireTime = 0
|
| | | wingItemExpInfo = None
|
| | | dogzEquipPlusExp = 0
|
| | | unfixedItemTotalCount = 0
|
| | |
| | | GameWorld.Log("该物品不可用于合成目标物品!ID=%s,index=%s,itemID=%s not in unfixedItemIDList=%s"
|
| | | % (compoundID, index, itemID, unfixedItemIDList), playerID)
|
| | | return
|
| | | |
| | | isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
|
| | | if isExpireItem:
|
| | | if not remainingTime:
|
| | | GameWorld.Log("不固定消耗道具时效物品已失效,无法合成! index=%s,itemID=%s" % (index, itemID), playerID)
|
| | | return
|
| | | expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
|
| | |
|
| | | isBind = curItem.GetIsBind()
|
| | | itemCount = curItem.GetCount()
|
| | |
| | | % (compoundID, unfixedItemIDList, needUnfixedItemCount, unfixedItemTotalCount), playerID)
|
| | | return
|
| | |
|
| | | return unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp
|
| | | return unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp, expireTime
|
| | |
|
| | |
|
| | | def __CheckFixedItem(playerID, compoundID, itemPack, fixedItemIndexList, fixedItemIDList, fixedItemCountList, compoundCnt):
|
| | |
| | | % (fixedItemIDList, fixedItemCountList), playerID)
|
| | | return
|
| | |
|
| | | expireTime = 0
|
| | | for index in fixedItemIndexList:
|
| | | if index >= maxPackCount:
|
| | | GameWorld.Log("该物品格子索引不存在!无法合成!index=%s,maxPackCount=%s" % (index, maxPackCount), playerID)
|
| | |
| | | GameWorld.Log("该物品不可用于合成目标物品!ID=%s,index=%s,fixedItemID=%s not in fixedItemIDList=%s"
|
| | | % (compoundID, index, fixedItemID, fixedItemIDList), playerID)
|
| | | return
|
| | | |
| | | isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
|
| | | if isExpireItem:
|
| | | if not remainingTime:
|
| | | GameWorld.Log("固定消耗道具时效物品已失效,无法合成! index=%s,fixedItemID=%s" % (index, fixedItemID), playerID)
|
| | | return
|
| | | expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
|
| | |
|
| | | isBind = curItem.GetIsBind()
|
| | | itemCount = curItem.GetCount()
|
| | |
| | | return
|
| | |
|
| | | GameWorld.DebugLog("最终消耗材料个数: %s" % (fixedItemNeedCntDict))
|
| | | return fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt
|
| | | return fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt, expireTime
|
| | |
|
| | |
|
| | | def __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax):
|
| | |
| | | % (addonsItemIndexList, addonsItemCountList), playerID)
|
| | | return
|
| | |
|
| | | expireTime = 0
|
| | | useCount = 0
|
| | | addTotalSuccRate = 0
|
| | | for i, index in enumerate(addonsItemIndexList):
|
| | |
| | | GameWorld.Log("附加物品总个数超出限制,无法合成! useCount=%s > addonsCountMax=%s" % (useCount, addonsCountMax), playerID)
|
| | | return
|
| | |
|
| | | isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
|
| | | if isExpireItem:
|
| | | if not remainingTime:
|
| | | GameWorld.Log("附加材料时效物品已失效,无法合成! index=%s,itemID=%s" % (index, itemID), playerID)
|
| | | return
|
| | | expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
|
| | | |
| | | addSuccRate = eval(FormulaControl.GetCompileFormula("ComposeAddonsFormula", ComposeAddonsFormula))
|
| | | addTotalSuccRate += (addSuccRate*costCount)
|
| | | addSuccRateItemInfo.append({"ItemID":itemID, "ItemColor":itemColor, "ItemClassLV":itemClassLV, "addSuccRate":addSuccRate, "costCount":costCount})
|
| | |
|
| | | return int(addTotalSuccRate), addSuccRateItemInfo
|
| | | return int(addTotalSuccRate), addSuccRateItemInfo, expireTime
|
| | |
|
| | | def __CheckIncRateItem(playerID, compoundID, itemPack, incRateItemIndexList, incRateItemID, needIncRateItemCount):
|
| | | ## 检查提升概率道具, 只要客户端提交的数据有不符合要求的,则直接返回 None
|
| | | expireTime = 0
|
| | | incRateItemTotalCount = 0
|
| | | incRateItemCostList = [[], []] # [[绑定索引], [非绑定索引]]
|
| | | maxPackCount = itemPack.GetCount()
|
| | |
| | | GameWorld.Log("该物品不可用于提升合成目标物品概率!ID=%s,index=%s,itemID=%s != incRateItemID=%s"
|
| | | % (compoundID, index, itemID, incRateItemID), playerID)
|
| | | return
|
| | | isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
|
| | | if isExpireItem:
|
| | | if not remainingTime:
|
| | | GameWorld.Log("提升概率时效物品已失效,无法合成! index=%s,itemID=%s" % (index, itemID), playerID)
|
| | | return
|
| | | expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
|
| | |
|
| | | isBind = curItem.GetIsBind()
|
| | | itemCount = curItem.GetCount()
|
| | |
| | | % (compoundID, incRateItemID, needIncRateItemCount, incRateItemTotalCount), playerID)
|
| | | return
|
| | |
|
| | | return incRateItemCostList
|
| | | return incRateItemCostList, expireTime
|
| | |
|
| | | def __CheckItemCanUseCompound(playerID, index, curItem):
|
| | | if not ItemCommon.CheckItemCanUse(curItem):
|
| | |
| | | # @param newItem: 新物品
|
| | | # @param itemCount: 合成数量
|
| | | # @return None
|
| | | def GiveNewCompoundItem(curPlayer, newItemID, itemCount, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo):
|
| | | def GiveNewCompoundItem(curPlayer, newItemID, itemCount, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime):
|
| | | compoundUnBindCnt = itemCount - compoundBindCnt
|
| | |
|
| | | if compoundBindCnt > 0:
|
| | | userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundBindCnt, True, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo)
|
| | | userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundBindCnt, True, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime)
|
| | | if compoundUnBindCnt > 0:
|
| | | userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundUnBindCnt, False, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo)
|
| | | userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundUnBindCnt, False, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime)
|
| | |
|
| | | if not userData:
|
| | | return ""
|
| | | return userData
|
| | |
|
| | | def __GivePlayerCompoundItem(curPlayer, newItemID, itemCount, isBind, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo):
|
| | | def __GivePlayerCompoundItem(curPlayer, newItemID, itemCount, isBind, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, expireTime):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | curSingleItem = ItemControler.GetOutPutItemObj(newItemID, itemCount, isBind)
|
| | | curSingleItem = ItemControler.GetOutPutItemObj(newItemID, itemCount, isBind, expireTime)
|
| | | if not curSingleItem:
|
| | | GameWorld.ErrLog("创造物品失败, give item itemid:%s,count:%s" % (newItemID, itemCount), playerID)
|
| | | return
|
New file |
| | |
| | | #!/usr/bin/python
|
| | | # -*- coding: GBK -*-
|
| | | #-------------------------------------------------------------------------------
|
| | | #
|
| | | ##@package GM.Commands.SetItemTime
|
| | | #
|
| | | # @todo:设置物品剩余有效期
|
| | | # @author hxp
|
| | | # @date 2018-12-30
|
| | | # @version 1.0
|
| | | #
|
| | | # 详细描述: 设置物品剩余有效期
|
| | | #
|
| | | #-------------------------------------------------------------------------------
|
| | | #"""Version = 2018-12-30 15:00"""
|
| | | #-------------------------------------------------------------------------------
|
| | |
|
| | | import IPY_GameWorld
|
| | | import ShareDefine
|
| | | import GameWorld
|
| | | import ChConfig
|
| | | import time
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | #全局变量
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | #逻辑实现
|
| | | ## GM命令执行入口
|
| | | # @param curPlayer 当前玩家
|
| | | # @param paramList 参数列表 [index,1True]
|
| | | # @return None
|
| | | # @remarks 函数详细说明.
|
| | | def OnExec(curPlayer, paramList):
|
| | | if not paramList or len(paramList) != 2:
|
| | | GameWorld.DebugAnswer(curPlayer, "SetItemTime index ʱЧֵ")
|
| | | GameWorld.DebugAnswer(curPlayer, "时效值具体由物品的时效类型决定")
|
| | | return
|
| | | |
| | | index, expireTime = paramList
|
| | | |
| | | curItem = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem).GetAt(index)
|
| | | if not curItem or curItem.IsEmpty():
|
| | | GameWorld.DebugAnswer(curPlayer, "找不到该物品!")
|
| | | return
|
| | | |
| | | if curItem.GetEndureReduceType() not in [ChConfig.Def_EquipReduceType_Time, ChConfig.Def_EquipReduceType_RTimeItem]:
|
| | | GameWorld.DebugAnswer(curPlayer, "非时效物品或不支持该时效类型设置")
|
| | | return
|
| | | |
| | | curItem.SetUserAttr(ShareDefine.Def_IudetCreateTime, int(time.time()))
|
| | | curItem.SetUserAttr(ShareDefine.Def_IudetExpireTime, expireTime)
|
| | | GameWorld.DebugAnswer(curPlayer, "设置物品[%s-%s]时效: %s" % (curItem.GetItemTypeID(), curItem.GetName(), expireTime))
|
| | | return
|
| | |
| | |
|
| | | if not ItemCommon.CheckItemCanUseByExpireTime(curItem):
|
| | | # 过期
|
| | | GameWorld.DebugLog("装备已过期!")
|
| | | return False
|
| | |
|
| | | changeItemEquipPlace = curItem.GetEquipPlace()
|
| | |
| | | #---无空位置,替换---
|
| | | return placeList[0]
|
| | |
|
| | | def GetOutPutItemObj(itemID, itemCount=1, isBind=0):
|
| | | def GetOutPutItemObj(itemID, itemCount=1, isBind=0, expireTime=0):
|
| | | ''' 获取功能产出的物品实例
|
| | | '''
|
| | | curItem = ItemCommon.CreateSingleItem(itemID, itemCount, isBind)
|
| | | curItem = ItemCommon.CreateSingleItem(itemID, itemCount, isBind, expireTime)
|
| | | if not curItem:
|
| | | GameWorld.ErrLog("产出物品异常,无法创建物品 = %s" % (itemID))
|
| | | return
|
| | |
| | | # @param itemID 物品ID
|
| | | # @return curSingleItem
|
| | | # @remarks 函数详细说明.
|
| | | def CreateSingleItem(itemID, itemCount=1, isBind=0):
|
| | | def CreateSingleItem(itemID, itemCount=1, isBind=0, expireTime=0):
|
| | | curSingleItem = GameWorld.GetItemFactory().CreateItem(itemID)
|
| | | if not curSingleItem:
|
| | | return
|
| | |
| | | curSingleItem.SetIsBind(1)
|
| | |
|
| | | ItemControler.SetItemCount(curSingleItem, itemCount)
|
| | | |
| | | if expireTime > 0:
|
| | | curSingleItem.SetUserAttr(ShareDefine.Def_IudetExpireTime, expireTime)
|
| | |
|
| | | #这里返回的是SingleItem , 如果创建了,未使用,会找出C++内存泄露!!!
|
| | | return curSingleItem
|
| | |
| | | # 特殊判定根据时效时间判定物品是否可以使用
|
| | | # 过期物品不能使用或装备但是可以出售续费
|
| | | def CheckItemCanUseByExpireTime(curItem):
|
| | | curItemCreateTime = curItem.GetCreateTime()
|
| | | curItemExpireTime = curItem.GetExpireTime()
|
| | | curItemPastTime = GameWorld.GetPastSeconds(curItemCreateTime)
|
| | | # curItemCreateTime = curItem.GetCreateTime()
|
| | | # curItemExpireTime = curItem.GetExpireTime()
|
| | | # curItemPastTime = GameWorld.GetPastSeconds(curItemCreateTime)
|
| | | # |
| | | # reduceType = curItem.GetEndureReduceType()
|
| | | # if reduceType == ChConfig.Def_EquipReduceType_RTimeItem and \
|
| | | # curItemPastTime >= curItemExpireTime:
|
| | | # # 过期了
|
| | | # return False
|
| | | # |
| | | # if reduceType == ChConfig.Def_EquipReduceType_Time:
|
| | | # # 开始装备时间
|
| | | # startTime = curItem.GetUserAttr(ShareDefine.Def_IudetCreateTime)
|
| | | # if startTime == 0:
|
| | | # return True
|
| | | # if time.time() - startTime > curItemExpireTime:
|
| | | # return False
|
| | |
|
| | | reduceType = curItem.GetEndureReduceType()
|
| | | if reduceType == ChConfig.Def_EquipReduceType_RTimeItem and \
|
| | | curItemPastTime >= curItemExpireTime:
|
| | | # 过期了
|
| | | isExpireItem, expireTime = GetItemRemainingTime(curItem)
|
| | | if isExpireItem:
|
| | | if expireTime <= 0:
|
| | | return False
|
| | | return True
|
| | |
|
| | | if reduceType == ChConfig.Def_EquipReduceType_Time:
|
| | | def GetItemRemainingTime(curItem):
|
| | | ''' 获取物品剩余时间,秒
|
| | | @return: 是否时效物品, 剩余时间 |
| | | '''
|
| | | |
| | | isExpireItem = False
|
| | | reduceType = curItem.GetEndureReduceType()
|
| | | remainingTime = 0
|
| | | |
| | | if reduceType in [ChConfig.Def_EquipReduceType_Time, ChConfig.Def_EquipReduceType_RTimeItem]:
|
| | | isExpireItem = True
|
| | | # 装备后开始计时
|
| | | curItemExpireTime = curItem.GetUserAttr(ShareDefine.Def_IudetExpireTime)
|
| | | if not curItemExpireTime:
|
| | | curItemExpireTime = curItem.GetExpireTime()
|
| | | |
| | | # 开始装备时间
|
| | | startTime = curItem.GetUserAttr(ShareDefine.Def_IudetCreateTime)
|
| | | if startTime == 0:
|
| | | return True
|
| | | if time.time() - startTime > curItemExpireTime:
|
| | | return False
|
| | | return True
|
| | | remainingTime = curItemExpireTime
|
| | | else:
|
| | | curItemPastTime = max(0, int(time.time()) - startTime)
|
| | | remainingTime = max(0, curItemExpireTime - curItemPastTime)
|
| | | return isExpireItem, remainingTime
|
| | | |
| | | return isExpireItem, remainingTime
|
| | |
|
| | | ##检查该物品是否合法,类型验证
|
| | | # @param curItem 物品实例
|
| | |
| | | ## 装备有效时间到了需要脱下,有效时间物品改成不消失,但是无使用效果 可出售和续费
|
| | | def __DoLogic_ProcessTimeEquip(curPlayer, curItem, equipIndex):
|
| | | #验证物品是否过期
|
| | | curItemExpireTime = curItem.GetUserAttr(ShareDefine.Def_IudetExpireTime)
|
| | | if not curItemExpireTime:
|
| | | curItemExpireTime = curItem.GetExpireTime()
|
| | | curItemPastTime = time.time() - curItem.GetUserAttr(ShareDefine.Def_IudetCreateTime)
|
| | | if curItemExpireTime - curItemPastTime > 0:
|
| | |
| | | Def_IudetWingProgressValue = 42 #羽翼精炼值
|
| | | Def_IudetCreateTime = 44 # 时效物品的创建时间
|
| | | Def_IudetGatherSoulLV = 46 # 聚魂等级
|
| | | Def_IudetExpireTime = 48 # 时效物品指定有效时间,时间单位由时效类型决定
|
| | | # 200~300 宠物数据用
|
| | | Def_IudetPet_NPCID = 200 # npcID
|
| | | Def_IudetPet_ClassLV = 202 # 阶级
|