#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package Player.PlayerLianTi # # @todo:Á¶Ìå # @author hxp # @date 2022-22-23 # @version 1.0 # # ÏêϸÃèÊö: Á¶Ìå # #------------------------------------------------------------------------------- #"""Version = 2022-22-23 15:30""" #------------------------------------------------------------------------------- import GameWorld import IpyGameDataPY import PlayerControl import FunctionNPCCommon import ChPyNetSendPack import NetPackCommon import ItemCommon import ChConfig import SkillCommon def DoLianTiOpen(curPlayer): ## ¹¦ÄÜ¿ªÆô lianTiLV = 1 ipyData = IpyGameDataPY.GetIpyGameData("LianTi", lianTiLV) if not ipyData: return PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LianTiLV, lianTiLV) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LianTiEatItemCount, 0) GameWorld.DebugLog("Á¶Ì幦ÄÜ¿ªÆô! lianTiLV=%s" % lianTiLV) SyncLianTiInfo(curPlayer) RefreshLianTiAttr(curPlayer) return True def OnPlayerLogin(curPlayer): if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LianTiLV): return SyncLianTiInfo(curPlayer) return #// A5 33 Á¶ÌåÌáÉý #tagCMLianTiUp # #struct tagCMLianTiUp #{ # tagHead Head; # DWORD UseItemCnt; //ÏûºÄ²ÄÁϸöÊý # BYTE IsAutoBuy; //ÊÇ·ñ×Ô¶¯¹ºÂò #}; def OnLianTiUp(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) costItemCount = clientData.UseItemCnt # ÏûºÄ²ÄÁϸöÊý isAutoBuy = clientData.IsAutoBuy # ÊÇ·ñ×Ô¶¯¹ºÂò lianTiLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LianTiLV) curEatItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LianTiEatItemCount) if not lianTiLV: return ipyData = IpyGameDataPY.GetIpyGameData("LianTi", lianTiLV) if not ipyData: return needEatCount = ipyData.GetNeedEatCount() if not needEatCount: GameWorld.DebugLog("Á¶ÌåÒÑÂú¼¶£¡ lianTiLV=%s" % lianTiLV) return if curEatItemCount >= needEatCount: GameWorld.DebugLog("±¾¼¶ÒѳÔÂú£¡ lianTiLV=%s,curEatItemCount=%s >= %s" % (lianTiLV, curEatItemCount, needEatCount)) return costItemID = IpyGameDataPY.GetFuncCfg("LianTiUpItem", 1) if not costItemID or not costItemCount: return costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount) lackCnt = costItemCount - bindCnt - unBindCnt if lackCnt > 0 and not isAutoBuy: GameWorld.DebugLog("µÀ¾ß²»×㣬ÎÞ·¨ÌáÉýÁ¶Ìå! costItemID=%s,costItemCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s" % (costItemID, costItemCount, bindCnt, unBindCnt, lackCnt)) return delCnt = costItemCount if lackCnt > 0: autoBuyMoneyType = IpyGameDataPY.GetFuncCfg("LianTiUpItem", 2) if not autoBuyMoneyType: return infoDict = {ChConfig.Def_Cost_Reason_SonKey:costItemID} if not FunctionNPCCommon.PayAutoBuyItem(curPlayer, {costItemID:lackCnt}, autoBuyMoneyType, ChConfig.Def_Cost_LianTi, infoDict): return delCnt -= lackCnt # ¿Û³ýÏûºÄ if delCnt: ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, ChConfig.ItemDel_LianTi) updEatItemCount = curEatItemCount + costItemCount GameWorld.DebugLog("Á¶ÌåÌáÉý: lianTiLV=%s,curEatItemCount=%s,costItemCount=%s,updEatItemCount=%s,needEatCount=%s" % (lianTiLV, curEatItemCount, costItemCount, updEatItemCount, needEatCount)) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LianTiEatItemCount, updEatItemCount) SyncLianTiInfo(curPlayer) RefreshLianTiAttr(curPlayer) return #// A5 34 Á¶ÌåÍ»ÆÆ #tagCMLianTiLVUp # #struct tagCMLianTiLVUp #{ # tagHead Head; #}; def OnLianTiLVUp(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) lianTiLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LianTiLV) curEatItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LianTiEatItemCount) if not lianTiLV: return ipyData = IpyGameDataPY.GetIpyGameData("LianTi", lianTiLV) if not ipyData: return needEatCount = ipyData.GetNeedEatCount() if not needEatCount: GameWorld.DebugLog("Á¶ÌåÒÑÂú¼¶£¡ lianTiLV=%s" % lianTiLV) return if curEatItemCount < needEatCount: GameWorld.DebugLog("Á¶ÌåÅàÑøÎïÆ·¸öÊý²»×㣬ÎÞ·¨Í»ÆÆ£¡ lianTiLV=%s,curEatItemCount=%s < %s" % (lianTiLV, curEatItemCount, needEatCount)) return costItemInfo = ipyData.GetLVUpCostItemInfo() if not costItemInfo or len(costItemInfo) != 2: return costItemID, costItemCount = costItemInfo if not costItemID or not costItemCount: return costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount) lackCnt = costItemCount - bindCnt - unBindCnt if lackCnt > 0: GameWorld.DebugLog("µÀ¾ß²»×㣬ÎÞ·¨Í»ÆÆÁ¶Ìå! costItemID=%s,costItemCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s" % (costItemID, costItemCount, bindCnt, unBindCnt, lackCnt)) return nextLianTiLv = lianTiLV + 1 nextIpyData = IpyGameDataPY.GetIpyGameDataNotLog("LianTi", nextLianTiLv) if not nextIpyData: return curRealmLV = curPlayer.GetOfficialRank() if nextLianTiLv > curRealmLV: GameWorld.DebugLog("Á¶ÌåÍ»ÆƲ»Äܳ¬¹ýµ±Ç°¾³½ç! nextLianTiLv=%s > curRealmLV(%s)" % (nextLianTiLv, curRealmLV)) return # ¿Û³ýÏûºÄ ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, costItemCount, ChConfig.ItemDel_LianTi) updEatItemCount = curEatItemCount - needEatCount activateSkillID = nextIpyData.GetActivateSkillID() GameWorld.DebugLog("Á¶ÌåÍ»ÆÆ: lianTiLV=%s,curEatItemCount=%s,needEatCount=%s,updEatItemCount=%s,nextLianTiLv=%s,activateSkillID=%s" % (lianTiLV, curEatItemCount, needEatCount, updEatItemCount, nextLianTiLv, activateSkillID)) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LianTiLV, nextLianTiLv) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LianTiEatItemCount, updEatItemCount) if activateSkillID: SkillCommon.GivePlayerSkillByJobSkill(curPlayer, [activateSkillID]) SyncLianTiInfo(curPlayer) RefreshLianTiAttr(curPlayer) return def RefreshLianTiAttr(curPlayer): CalcLianTiAttr(curPlayer) PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState() return def CalcLianTiAttr(curPlayer): lianTiLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LianTiLV) if not lianTiLV: return allAttrList = [{} for _ in range(4)] ipyDataMgr = IpyGameDataPY.IPY_Data() for index in xrange(ipyDataMgr.GetLianTiCount()): lvupIpyData = ipyDataMgr.GetLianTiByIndex(index) dataLV = lvupIpyData.GetLianTiLV() if dataLV > lianTiLV: break upItemCount = lvupIpyData.GetNeedEatCount() if dataLV == lianTiLV: upItemCount = min(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LianTiEatItemCount), upItemCount) #GameWorld.DebugLog("dataLV=%s,upItemCount=%s" % (dataLV, upItemCount)) # ¹Ì¶¨ÊôÐÔ fixedAttrTypeList = lvupIpyData.GetFixedAttrType() fixedAttrValueList = lvupIpyData.GetFixedAttrValue() for i, attrID in enumerate(fixedAttrTypeList): attrValue = fixedAttrValueList[i] if len(fixedAttrValueList) > i else 0 PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList) #GameWorld.DebugLog(" %s, attrID=%s,attrValue=%s,%s" % (i, attrID, attrValue, allAttrList)) # ÅàÑøµ¤Ôö¼ÓÊôÐÔ upItemPerCount = lvupIpyData.GetEatPerCount() if upItemCount and upItemPerCount: upItemAttrTypeList = lvupIpyData.GetEatItemAttrType() upItemAttrValueList = lvupIpyData.GetEatItemAttrValue() attrMultiple = upItemCount / upItemPerCount #GameWorld.DebugLog(" upItemCount=%s,upItemPerCount=%s,attrMultiple=%s" % (upItemCount, upItemPerCount, attrMultiple)) for i, attrID in enumerate(upItemAttrTypeList): attrValue = upItemAttrValueList[i] if len(upItemAttrValueList) > i else 0 attrValue *= attrMultiple PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList) #GameWorld.DebugLog(" %s, attrID=%s,attrValue=%s,%s" % (i, attrID, attrValue, allAttrList)) # ÔöÇ¿ÊôÐÔÍò·ÖÂÊÀÛ¼Ó plusAttrTypeList = lvupIpyData.GetPlusAttrType() plusAttrRateList = lvupIpyData.GetPlusAttrRate() for i, attrID in enumerate(plusAttrTypeList): attrValue = plusAttrRateList[i] if len(plusAttrRateList) > i else 0 PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList) #GameWorld.DebugLog(" allAttrList=%s" % allAttrList) # ±£´æ¼ÆËãÖµ PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_LianTi, allAttrList) return def SyncLianTiInfo(curPlayer): clientPack = ChPyNetSendPack.tagMCLianTiInfo() clientPack.LianTiLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LianTiLV) clientPack.EatItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LianTiEatItemCount) NetPackCommon.SendFakePack(curPlayer, clientPack) return