From 56ae47514b78d6b4ae0019e4fccc8837df076be4 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期二, 24 十二月 2019 19:48:06 +0800 Subject: [PATCH] 8361 【主干】首充三天领取 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerRefineStove.py | 472 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 234 insertions(+), 238 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerRefineStove.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerRefineStove.py index 5c38b75..6b44bc0 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerRefineStove.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerRefineStove.py @@ -6,13 +6,13 @@ ##@package PlayerRefineStove # @todo: 玩家炼丹炉 # -# @author: sgj -# @date 2017-11-07 +# @author: xdh +# @date 2019-4-12 # @version 1.0 # # @note: #--------------------------------------------------------------------- -#"""Version = 2017-11-07 16:40""" +#"""Version = 2019-4-12 16:40""" #--------------------------------------------------------------------- import ChConfig import GameWorld @@ -30,9 +30,15 @@ import EventShell import PlayerActivity import PlayerFairyCeremony +import PlayerNewFairyCeremony +import PlayerActLogin import PlayerVip import copy +import time + +DefStoveType1 = 1 #1灵丹 +DefStoveType2 = 2 #2仙丹 ##功能开启 @@ -42,24 +48,27 @@ Sycn_AlchemyMsg(curPlayer) return True + ##登录处理 def DoOnLogin(curPlayer, tick): Sycn_AlchemyMsg(curPlayer) Sycn_AlchemyPrayMsg(curPlayer) return + def OnDay(curPlayer): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyPrayCnt, 0) Sycn_AlchemyPrayMsg(curPlayer) return + #// A5 76 玩家炼丹 #tagCMPlayerRefine # #struct tagCMPlayerRefine #{ # tagHead Head; -# WORD RefineNum; // 配方编号 -# DWORD UseRateItem; // 附加材料ID +# DWORD AlchemyID; // 丹药ID +# BYTE DoType; // 0-学习 1-开始炼丹 2-停止炼丹 3-开炉取丹 #}; def PlayerRefineItem(index, clientPack, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) @@ -67,190 +76,194 @@ if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_RefineStove): GameWorld.DebugLog("炼丹炉功能未开启!", playerID) return - - alchemyID = clientPack.RefineNum - specID = clientPack.UseRateItem # 特殊炼丹ID - GameWorld.DebugLog("玩家炼丹: alchemyID=%s,specID=%s" % (alchemyID, specID), playerID) + refineTimes = max(1, clientPack.AlchemyTimes) + alchemyID = clientPack.AlchemyID + doType = clientPack.DoType + GameWorld.DebugLog("玩家炼丹: alchemyID=%s, doType=%s" % (alchemyID, doType), playerID) alchemyIpyData = IpyGameDataPY.GetIpyGameData("Alchemy", alchemyID) if not alchemyIpyData: GameWorld.DebugLog("配方不存在!alchemyID=%s" % alchemyID, playerID) return - - specAlchemyIpyData = None - if specID: - specAlchemyIDList = alchemyIpyData.GetSpecAlchemyID() - if specID not in specAlchemyIDList: - GameWorld.DebugLog("非法特殊配方!alchemyID=%s,specID=%s" % (alchemyID, specID), playerID) - return - specAlchemyIpyData = IpyGameDataPY.GetIpyGameData("AlchemySpec", specID) - if not specAlchemyIpyData: - GameWorld.DebugLog("特殊配方不存在!alchemyID=%s,specID=%s" % (alchemyID, specID), playerID) - return - - # 等级判断 + alchemType = alchemyIpyData.GetAlchemType() + alchemyItemID = alchemyIpyData.GetAlchemItemID() + alchemyQuality = alchemyIpyData.GetAlchemyQuality() + hasLearn = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_AlchemyLearnState, alchemyID) alchemyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV) - if alchemyLV < alchemyIpyData.GetNeedAlchemyLV(): - GameWorld.DebugLog("配方未开启!alchemyID=%s,needAlchemyLV=%s,curAlchemyLV=%s" - % (alchemyID, alchemyIpyData.GetNeedAlchemyLV(), alchemyLV), playerID) - return - if specAlchemyIpyData: - if alchemyLV < specAlchemyIpyData.GetNeedAlchemyLV(): - GameWorld.DebugLog("特殊配方未开启!alchemyID=%s,specID=%s,needAlchemyLV=%s,curAlchemyLV=%s" - % (alchemyID, specID, specAlchemyIpyData.GetNeedAlchemyLV(), alchemyLV), playerID) + curAlchemyItemID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyItemID % alchemType) #正在炼的丹 + curLuckValue = curPlayer.GetLuckValue() + curTime = int(time.time()) + + if doType == 0: + if hasLearn: + GameWorld.DebugLog('丹方已学习!,不可重复学') return - - alchemyItemList = specAlchemyIpyData.GetAlchemyItem() - alchemyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyCountSpec % specID) - SpecialAlchemyDict = IpyGameDataPY.GetFuncEvalCfg("SpecialAlchemy", 2) - SpecialAlchemyCountItemDict = SpecialAlchemyDict.get(specID, {}) - else: - alchemyItemList = alchemyIpyData.GetAlchemyItem() - alchemyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyCount % alchemyID) - SpecialAlchemyDict = IpyGameDataPY.GetFuncEvalCfg("SpecialAlchemy", 1) - SpecialAlchemyCountItemDict = SpecialAlchemyDict.get(alchemyID, {}) - - updAlchemyCount = 0 - if SpecialAlchemyCountItemDict: - nextAlchemyCount = alchemyCount + 1 - if nextAlchemyCount <= max(SpecialAlchemyCountItemDict): - updAlchemyCount = nextAlchemyCount # 只要还没达到最大洗练次数特殊产出,则每次累加次数 - # 非特殊材料配方的情况下,达到指定次数则使用特殊次数指定产出库 - if nextAlchemyCount in SpecialAlchemyCountItemDict: - alchemyItemList = SpecialAlchemyCountItemDict[nextAlchemyCount] - GameWorld.DebugLog("炼丹次数特殊产出库: 炼丹编号=%s,特殊ID=%s,次数=%s,特殊产出库=%s" - % (alchemyID, specID, nextAlchemyCount, alchemyItemList), playerID) - - # 去除限制产出的物品 - outPutCountLimitDict = IpyGameDataPY.GetFuncEvalCfg("SpecialAlchemy", 3) - if outPutCountLimitDict: - limitItemInfoList = [] - alchemyItemList = copy.copy(alchemyItemList) - for itemInfo in alchemyItemList: - itemID = itemInfo[1] - if itemID not in outPutCountLimitDict: - continue - limitCount = outPutCountLimitDict[itemID] - outputCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyOutputCount % itemID) - if outputCount >= limitCount: - limitItemInfoList.append(itemInfo) - GameWorld.DebugLog("已达到最大产出次数,从产出库中移除! alchemyItemList=%s,itemID=%s,outputCount=%s,limitCount=%s" - % (alchemyItemList, itemID, outputCount, limitCount), playerID) - - for limitItemInfo in limitItemInfoList: - alchemyItemList.remove(limitItemInfo) + learnNeedAlchemLV = alchemyIpyData.GetLearnNeedAlchemLV() + if alchemyLV < learnNeedAlchemLV: + GameWorld.DebugLog('丹方学习需要炼丹等级 %s' % learnNeedAlchemLV) + return + learnNeedLingGenPoint = alchemyIpyData.GetLearnNeedLingGenPoint() + if PlayerControl.GetTotalLingGenPoint(curPlayer) < learnNeedLingGenPoint: + GameWorld.DebugLog('丹方学习需要总灵根点 %s' % learnNeedLingGenPoint) + return + learnNeedItemID = alchemyIpyData.GetLearnNeedItemID() + itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) + enough, indexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(learnNeedItemID, itemPack, 1) + if not enough: + return + ItemCommon.ReduceItem(curPlayer, itemPack, indexList, 1, False, "RefineStove") + GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_AlchemyLearnState, alchemyID, 1) + Sycn_AlchemyMsg(curPlayer, alchemyID, False) + elif doType == 1: + if not hasLearn: + GameWorld.DebugLog('丹方未学习!,不可炼丹') + return + if curAlchemyItemID: + GameWorld.DebugLog('当前丹类型已在炼丹中! curAlchemyItemID=%s' % curAlchemyItemID) + return + if refineTimes < 1: + return + # 基础固定消耗 + needMaterialDict = alchemyIpyData.GetMaterial() + needMaterialDict = {itemID:itemCnt*refineTimes for itemID, itemCnt in needMaterialDict.items()} + itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) + lackItemDict, delInfoDict = ItemCommon.GetCostItemIndexList(needMaterialDict, itemPack, False) + if lackItemDict: + GameWorld.DebugLog("配方材料不足!alchemyID=%s,needMaterialDict=%s,lackItemDict=%s,hasItemDict=%s" + % (alchemyItemID, needMaterialDict, lackItemDict, delInfoDict), playerID) + return + #任务 + for _ in xrange(refineTimes): + EventShell.EventRespons_RefineItem(curPlayer, alchemyQuality, alchemyItemID) - if not alchemyItemList: - GameWorld.DebugLog("配方产出物品配置错误!alchemyID=%s,specID=%s" % (alchemyID, specID), playerID) - return - - packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, 1) - if not packSpace: - PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371") - return - - # 基础固定消耗 - needMaterialDict = alchemyIpyData.GetMaterial() - # 特殊配方额外消耗 - if specAlchemyIpyData: - needMaterialDict = copy.deepcopy(needMaterialDict) - needMaterialDict[specAlchemyIpyData.GetMaterialID()] = specAlchemyIpyData.GetMaterialCnt() - - itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) - lackItemDict, delInfoDict = ItemCommon.GetCostItemIndexList(needMaterialDict, itemPack, False) - if lackItemDict: - GameWorld.DebugLog("配方材料不足!alchemyID=%s,specID=%s,needMaterialDict=%s,lackItemDict=%s,hasItemDict=%s" - % (alchemyID, specID, needMaterialDict, lackItemDict, delInfoDict), playerID) - return - - makeItemInfo = GameWorld.GetResultByWeightList(alchemyItemList) - if not makeItemInfo: - GameWorld.ErrLog("配方合成结果错误!alchemyID=%s,specID=%s" % (alchemyID, specID), playerID) - return - makeItemID, itemCount = makeItemInfo - GameWorld.DebugLog("合成配方: alchemyID=%s,specID=%s,makeItemID=%s,itemCount=%s,alchemyItemList=%s" - % (alchemyID, specID, makeItemID, itemCount, alchemyItemList), playerID) - #检查按丹炉等级进阶的丹药 - makeItemID = __GetAlchemyUpItemID(makeItemID, alchemyLV, alchemyIpyData.GetAlchemyUp()) - makeItemData = GameWorld.GetGameData().GetItemByTypeID(makeItemID) - if not makeItemData: - return - - if updAlchemyCount: - if specID: - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyCountSpec % specID, updAlchemyCount) - else: - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyCount % alchemyID, updAlchemyCount) - GameWorld.DebugLog("更新炼丹次数累计: alchemyID=%s,特殊ID=%s,次数=%s" % (alchemyID, specID, updAlchemyCount), playerID) - - #扣消耗 - delItemHasBind = ItemCommon.DelCostItem(curPlayer, itemPack, delInfoDict, ChConfig.ItemDel_Alchemy) - - #加经验 - addExp = alchemyIpyData.GetAlchemyExp() - if specAlchemyIpyData: - addExp += specAlchemyIpyData.GetAlchemyExp() - AddRefineExp(curPlayer, addExp) - - #加产出次数 - if makeItemID in outPutCountLimitDict: - outputCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyOutputCount % makeItemID) + 1 - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyOutputCount % makeItemID, outputCount) - GameWorld.DebugLog("更新炼丹产出特殊物品次数: makeItemID=%s,outputCount=%s" % (makeItemID, outputCount), playerID) - - #给物品 - ItemControler.GivePlayerItem(curPlayer, makeItemID, itemCount, delItemHasBind, [IPY_GameWorld.rptItem], - event=[ChConfig.ItemGive_Refine, False, {}]) - - Sycn_AlchemyMsg(curPlayer, makeItemID) - - #紫色及以上全服广播 - notifyColor = IpyGameDataPY.GetFuncCfg("AlchemyNotify", 1) - needNotifyItemIDList = IpyGameDataPY.GetFuncEvalCfg("AlchemyNotify", 2) - notNotifyItemIDList = IpyGameDataPY.GetFuncEvalCfg("AlchemyNotify", 3) - if makeItemID not in notNotifyItemIDList and (makeItemID in needNotifyItemIDList or makeItemData.GetItemColor() >= notifyColor): - PlayerControl.WorldNotify(0, "AchemyGreatSuccess", [curPlayer.GetPlayerName(), makeItemID]) - - #完成1次炼丹成就 - PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_RefineItem, 1) - #完成1次X品质物品炼丹成就 - PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_RefineStoveColor, 1, [makeItemData.GetItemColor()]) - #任务 - EventShell.EventRespons_RefineItem(curPlayer, alchemyIpyData.GetNeedAlchemyLV()) - #日常任务 - costItemCnt = sum(needMaterialDict.values()) - PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_RefineStove, costItemCnt) - PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_RefineStove, 1) - return + #扣消耗 + ItemCommon.DelCostItem(curPlayer, itemPack, delInfoDict, ChConfig.ItemDel_Alchemy) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyItemID % alchemType, alchemyItemID) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyStartTime % alchemyID, curTime) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyTimes % alchemyID, refineTimes) -def __GetAlchemyUpItemID(itemID, alchemyLV, alchemyUpCfg): - #获取按丹炉等级进阶的丹药ID - if not alchemyUpCfg: - return itemID - itemIDStr = str(itemID) - upItemList = [] - for alchemyUpItemDict in alchemyUpCfg: - if itemIDStr in alchemyUpItemDict: - for upID, upLV in alchemyUpItemDict.items(): - upItemList.append([upLV, int(upID)]) - - if not upItemList: - return itemID - upItemList.sort(reverse=True) - for upLV, makeItemID in upItemList: - if alchemyLV >= upLV: - GameWorld.DebugLog(" 获得进阶丹药: itemID=%s to upItemID=%s" % (itemID, makeItemID)) - return makeItemID - return itemID + Sycn_AlchemyMsg(curPlayer, alchemyID, False) + #日常任务 + costItemCnt = sum(needMaterialDict.values()) + #PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_RefineStove, costItemCnt) -def AddRefineExp(curPlayer, addExp): + elif doType == 2: + if curAlchemyItemID != alchemyItemID: + GameWorld.DebugLog('停止丹药ID错误 curAlchemyItemID=%s' % curAlchemyItemID) + return + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyItemID % alchemType, 0) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyStartTime % alchemyID, 0) + Sycn_AlchemyMsg(curPlayer, alchemyID, False) + elif doType == 3: + if curAlchemyItemID != alchemyItemID: + GameWorld.DebugLog('开炉丹药ID错误 curAlchemyItemID=%s' % curAlchemyItemID) + return + refineTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyTimes % alchemyID) + refineTimes = max(1, refineTimes) + startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyStartTime % alchemyID) + passTime = max(0, curTime - startTime) + if passTime < alchemyIpyData.GetNeedTime() * refineTimes: + GameWorld.DebugLog('开炉丹药,时间未到 passTime=%s' % passTime) + return + alchemyQuality = alchemyIpyData.GetAlchemyQuality() + + alchemyAppointCntDict = {} #定制配置 {次数:[数量,成功率]} + alchemyCustomizedDict = IpyGameDataPY.GetFuncEvalCfg('alchemyCustomized', 1, {}) + if alchemyID in alchemyCustomizedDict: + alchemyCnt = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_AlchemyCnt, alchemyID, False) + alchemyAppointCntDict = alchemyCustomizedDict[alchemyID] + + resultIpyData = IpyGameDataPY.InterpolationSearch('AlchemyResult', 'LuckValue', curLuckValue, {'AlchemyQuality':alchemyIpyData.GetAlchemyQuality()}) + if not resultIpyData: + GameWorld.ErrLog('AlchemyResult 配置错误 未找到该丹方数量 alchemyItemID=%s' % alchemyItemID, playerID) + return + makeItemData = GameWorld.GetGameData().GetItemByTypeID(alchemyItemID) + if not makeItemData: + return + #灵丹成功率公式 参数 curLuckValue:慧根 alchemyLV:炼丹等级 alchemyQuality:丹药等级 qualityNeedLuck:要求慧根 + qualityNeedLuck = IpyGameDataPY.GetFuncEvalCfg('alchemySuccess', 2, {}).get(str(alchemyQuality), 0) + nomalsuccessRate = eval(IpyGameDataPY.GetFuncCompileCfg('alchemySuccess')) + + resultCnt = 0 #丹药数量 0代表失败 + for i in xrange(refineTimes): + #成功率 + appointInfo = [] #[数量,成功率] + if alchemyAppointCntDict and alchemyCnt+1+i in alchemyAppointCntDict: + appointInfo = alchemyAppointCntDict[alchemyCnt+1+i] + if appointInfo: + successRate = appointInfo[1] + elif alchemType == DefStoveType2: + successRate = ShareDefine.Def_MaxRateValue #仙丹必定成功 + elif alchemType == DefStoveType1: + successRate = nomalsuccessRate + else: + return + isSuccess = GameWorld.CanHappen(successRate) + if isSuccess: + if alchemType == DefStoveType2: + resultCnt += 1 #仙丹必定为1 + elif alchemType == DefStoveType1: + if appointInfo: + resultCnt += appointInfo[0] + else: + resultCnt += GameWorld.GetResultByRandomList(resultIpyData.GetCntRateList()) + if not resultCnt: + GameWorld.ErrLog('AlchemyResult 配置错误 未随机出该丹方数量alchemyItemID=%s' % alchemyItemID, playerID) + return + if resultCnt: + needSpace = 1 + packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace) + if needSpace > packSpace: + PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371") + return + + + ItemControler.GivePlayerItem(curPlayer, alchemyItemID, resultCnt, 0, [IPY_GameWorld.rptItem], + event=[ChConfig.ItemGive_Refine, False, {}]) + #紫色及以上全服广播 + notifyColor = IpyGameDataPY.GetFuncCfg("AlchemyNotify", 1) + needNotifyItemIDList = IpyGameDataPY.GetFuncEvalCfg("AlchemyNotify", 2) + notNotifyItemIDList = IpyGameDataPY.GetFuncEvalCfg("AlchemyNotify", 3) + if alchemyItemID not in notNotifyItemIDList and (alchemyItemID in needNotifyItemIDList or makeItemData.GetItemColor() >= notifyColor): + PlayerControl.WorldNotify(0, "AchemyGreatSuccess", [curPlayer.GetPlayerName(), alchemyItemID]) + +# #任务,改为开始炼丹触发 +# for _ in xrange(refineTimes): +# EventShell.EventRespons_RefineItem(curPlayer, alchemyQuality, alchemyItemID) + #重置 + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyItemID % alchemType, 0) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyStartTime % alchemyID, 0) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyTimes % alchemyID, 0) + #加经验 + addExp = alchemyIpyData.GetAlchemyExp() * refineTimes + AddRefineExp(curPlayer, addExp, alchemyLV) + #加次数 + if alchemyID in alchemyCustomizedDict: + GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_AlchemyCnt, alchemyID, min(alchemyCnt + refineTimes, 9), False) + + GameWorld.DebugLog('炼丹结果 alchemyItemID=%s,refineTimes=%s,isSuccess=%s,resultCnt=%s' % (alchemyItemID, refineTimes, isSuccess, resultCnt), playerID) + + Sycn_AlchemyMsg(curPlayer, alchemyID, False, alchemyItemID, resultCnt) + + #完成1次炼丹成就 + PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_RefineItem, refineTimes) + #完成1次X品质物品炼丹成就 + #PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_RefineStoveColor, 1, [makeItemData.GetItemColor()]) + + + PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_RefineStove, refineTimes) + PlayerNewFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_RefineStove, refineTimes) + PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_Alchemy, refineTimes) + return + + +def AddRefineExp(curPlayer, addExp, alchemyLV): #增加炼丹炉经验 if addExp <= 0: return - - alchemyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV) + alchemyExp = min(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyExp) + addExp, ShareDefine.Def_UpperLimit_DWord) GameWorld.DebugLog("增加炼丹经验: alchemyLV=%s,addExp=%s,alchemyExp=%s" % (alchemyLV, addExp, alchemyExp), curPlayer.GetPlayerID()) - + isLVUp = False stoveIpyData = IpyGameDataPY.GetIpyGameDataNotLog("RefineStove", alchemyLV) while stoveIpyData and stoveIpyData.GetUpNeedExp() and alchemyExp >= stoveIpyData.GetUpNeedExp(): @@ -260,7 +273,7 @@ if not stoveIpyData: GameWorld.DebugLog("没有下一级数据了,已满级!不可升级!", curPlayer.GetPlayerID()) break - + alchemyExp -= needExp alchemyLV += 1 GameWorld.DebugLog(" 炼丹升级: alchemyLV=%s,alchemyExp=%s" % (alchemyLV, alchemyExp), curPlayer.GetPlayerID()) @@ -269,76 +282,58 @@ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyExp, alchemyExp) if not isLVUp: return False - + GameWorld.DebugLog("升级后剩余经验: %s" % alchemyExp, curPlayer.GetPlayerID()) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyLV, alchemyLV) PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_AlchemyLV, alchemyLV) - - RefreshStoveAttr(curPlayer) - - # 解锁广播 - ipyGameData = IpyGameDataPY.IPY_Data() - for i in xrange(ipyGameData.GetAlchemyCount()): - ipyData = ipyGameData.GetAlchemyByIndex(i) - if alchemyLV == ipyData.GetNeedAlchemyLV(): - PlayerControl.WorldNotify(0, "FurnaceLVUp", [curPlayer.GetPlayerName(), alchemyLV, ipyData.GetAlchemyID()]) - break - return True -def Sycn_AlchemyMsg(curPlayer, itemID=0): + +def Sycn_AlchemyMsg(curPlayer, alchemyID=0, isAll=True, itemID=0, itemCnt=0): # 通知客户端炼丹炉信息 - if not itemID and not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_RefineStove): + if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_RefineStove): return pack = ChPyNetSendPack.tagMCPlayerStoveMsg() pack.StoveExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyExp) pack.StoveLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV) pack.ItemID = itemID + pack.ItemCnt = itemCnt + pack.InfoList = [] + syncItemIDList = [] + if isAll: + ipyMgr = IpyGameDataPY.IPY_Data() + for i in xrange(ipyMgr.GetAlchemyCount()): + ipyData = ipyMgr.GetAlchemyByIndex(i) + alchemyID = ipyData.GetID() + if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_AlchemyLearnState, alchemyID): + syncItemIDList.append(alchemyID) + elif alchemyID and GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_AlchemyLearnState, alchemyID): + syncItemIDList = [alchemyID] + + for alchemyID in syncItemIDList: + StoveInfo = ChPyNetSendPack.tagMCPlayerStoveInfo() + StoveInfo.AlchemyID = alchemyID + StoveInfo.StartTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyStartTime % alchemyID) + StoveInfo.AlchemyTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyTimes % alchemyID) + pack.InfoList.append(StoveInfo) + pack.StoveCnt = len(pack.InfoList) NetPackCommon.SendFakePack(curPlayer, pack) return + def RefreshStoveAttr(curPlayer): CalcStoveAttr(curPlayer) PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState() return + def CalcStoveAttr(curPlayer): # 果实加成 allAttrYaoList = [{} for _ in range(4)] - PlayerAttrFruit.CalcAttrFruitAddAtrr(curPlayer, allAttrYaoList, ShareDefine.Def_AttrFruitFunc_Stove) + fightPowerEx = PlayerAttrFruit.CalcAttrFruitAddAtrr(curPlayer, allAttrYaoList, ShareDefine.Def_AttrFruitFunc_Stove) PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_StoveYao, allAttrYaoList) - - allAttrList = [{} for _ in range(4)] - alchemyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV) - stoveIpyData = IpyGameDataPY.GetIpyGameData("RefineStove", alchemyLV) - if stoveIpyData: - attrTypeList = stoveIpyData.GetAddAttrType() - attrValueList = stoveIpyData.GetAddAttrNum() - for i, attrID in enumerate(attrTypeList): - PlayerControl.CalcAttrDict_Type(attrID, attrValueList[i], allAttrList) - - PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Stove, allAttrList) + curPlayer.SetDict(ChConfig.Def_PlayerKey_MFPEx % ShareDefine.Def_MFPType_StoveYao, fightPowerEx) return - -g_needAlchemyLVDict = {} -def GetIsCanOutByAlchemyLV(curPlayer, itemID): - #判断当前丹炉等级是否可产出该丹药 - global g_needAlchemyLVDict - if not g_needAlchemyLVDict: - ipyMgr = IpyGameDataPY.IPY_Data() - for i in xrange(ipyMgr.GetAlchemyCount()): - ipyData = ipyMgr.GetAlchemyByIndex(i) - needAlchemyLV = ipyData.GetNeedAlchemyLV() - itemList = ipyData.GetAlchemyItem() - for itemInfo in itemList: - g_needAlchemyLVDict[itemInfo[1]] = needAlchemyLV - for i in xrange(ipyMgr.GetAlchemySpecCount()): - ipyData = ipyMgr.GetAlchemySpecByIndex(i) - needAlchemyLV = ipyData.GetNeedAlchemyLV() - itemList = ipyData.GetAlchemyItem() - for itemInfo in itemList: - g_needAlchemyLVDict[itemInfo[1]] = needAlchemyLV - return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV) >= g_needAlchemyLVDict.get(itemID, 0) #// A5 14 祈福丹药 #tagCMPrayElixir @@ -353,21 +348,21 @@ prayCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyPrayCnt) limitCnt = PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_PrayElixir) if prayCnt >= limitCnt: - GameWorld.DebugLog('今日祈福丹药次数已满!prayCnt=%s'%prayCnt) + GameWorld.DebugLog('今日祈福丹药次数已满!prayCnt=%s' % prayCnt) return - packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, 1) + packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, 1) if not packSpace: PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371") return - + alchemyItemList = IpyGameDataPY.GetFuncEvalCfg('GodAlchemy') - + newItemInfoList = [] for itemInfo in alchemyItemList: itemID = itemInfo[1] - if not GetIsCanOutByAlchemyLV(curPlayer, itemID): - #GameWorld.DebugLog('祈福丹药,炼丹等级未达到,移除产出库!itemID=%s'%itemID) - continue +# if not GetIsCanOutByAlchemyLV(curPlayer, itemID): +# #GameWorld.DebugLog('祈福丹药,炼丹等级未达到,移除产出库!itemID=%s'%itemID) +# continue if PlayerAttrFruit.IsFruitEatFull(curPlayer, itemID): #GameWorld.DebugLog('祈福丹药,使用次数已满,移除产出库!itemID=%s'%itemID) continue @@ -375,39 +370,40 @@ if not newItemInfoList: GameWorld.DebugLog('祈福丹药,没有丹药可产出!!') return - + makeItemInfo = GameWorld.GetResultByWeightList(newItemInfoList) if not makeItemInfo: GameWorld.DebugLog("祈福丹药, 结果错误!") return - + makeItemID, itemCount = makeItemInfo makeItemData = GameWorld.GetGameData().GetItemByTypeID(makeItemID) if not makeItemData: return - + costMoney = IpyGameDataPY.GetFuncCfg('GodAlchemy', 2) if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costMoney, ChConfig.Def_Cost_AlchemyPray): return #给物品 - ItemControler.GivePlayerItem(curPlayer, makeItemID, itemCount, True, [IPY_GameWorld.rptItem], + ItemControler.GivePlayerItem(curPlayer, makeItemID, itemCount, 0, [IPY_GameWorld.rptItem], event=[ChConfig.ItemGive_Refine, False, {}]) #GameWorld.DebugLog('makeItemID=%s,newItemInfoList=%s'%(makeItemID, newItemInfoList)) - - + #紫色及以上全服广播 notifyColor = IpyGameDataPY.GetFuncCfg("AlchemyNotify", 1) needNotifyItemIDList = IpyGameDataPY.GetFuncEvalCfg("AlchemyNotify", 2) notNotifyItemIDList = IpyGameDataPY.GetFuncEvalCfg("AlchemyNotify", 3) if makeItemID not in notNotifyItemIDList and (makeItemID in needNotifyItemIDList or makeItemData.GetItemColor() >= notifyColor): PlayerControl.WorldNotify(0, "BlastfurnaceBlessing", [curPlayer.GetPlayerName(), makeItemID]) - + #更新次数 - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyPrayCnt, prayCnt+1) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AlchemyPrayCnt, prayCnt + 1) Sycn_AlchemyPrayMsg(curPlayer, makeItemID) return + def Sycn_AlchemyPrayMsg(curPlayer, itemID=0): + return #祈福丹药结果 if not itemID and not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_RefineStove): return @@ -415,4 +411,4 @@ pack.PrayCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyPrayCnt) pack.ItemID = itemID NetPackCommon.SendFakePack(curPlayer, pack) - return \ No newline at end of file + return -- Gitblit v1.8.0