#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package Player.PlayerFaQi # # @todo:·¨Æ÷ϵͳ # @author hxp # @date 2021-10-13 # @version 1.0 # # ÏêϸÃèÊö: ·¨Æ÷ϵͳ # # ×¢£º Óë·¨±¦ÏµÍ³Ã»ÓйØÏµ #------------------------------------------------------------------------------- #"""Version = 2021-10-14 15:00""" #------------------------------------------------------------------------------- import GameWorld import IPY_GameWorld import PlayerControl import ChPyNetSendPack import FunctionNPCCommon import NetPackCommon import IpyGameDataPY import ItemCommon import ChConfig def DoFaQiOpen(curPlayer): ## ¹¦ÄÜ¿ªÆô faQiLV = 1 ipyData = IpyGameDataPY.GetIpyGameData("FaQiLVUp", faQiLV) if not ipyData: return PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaQiLV, faQiLV) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaQiEatItemCount, 0) GameWorld.DebugLog("·¨Æ÷¹¦ÄÜ¿ªÆô! faQiLV=%s" % faQiLV) Sync_FaQiLVInfo(curPlayer) RefreshFaQiAttr(curPlayer) return True def PlayerFaQiLogin(curPlayer): if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaQiLV): return Sync_FaQiLVInfo(curPlayer) return #// A5 32 ·¨Æ÷Éý¼¶ #tagCMFaQiLVUp # #struct tagCMFaQiLVUp #{ # tagHead Head; # WORD UseItemCnt; //ÏûºÄ²ÄÁϸöÊý # BYTE IsAutoBuy; //ÊÇ·ñ×Ô¶¯¹ºÂò #}; def OnFaQiLVUp(index, curPackData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) costItemCount = curPackData.UseItemCnt # ÏûºÄ²ÄÁϸöÊý isAutoBuy = curPackData.IsAutoBuy # ÊÇ·ñ×Ô¶¯¹ºÂò faQiLV = max(1, curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaQiLV)) curEatItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaQiEatItemCount) ipyData = IpyGameDataPY.GetIpyGameData("FaQiLVUp", faQiLV) if not ipyData: return needEatCount = ipyData.GetNeedEatCount() if not needEatCount: GameWorld.DebugLog("·¨Æ÷ÒÑÂú¼¶£¡faQiLV=%s" % faQiLV) return costItemID = IpyGameDataPY.GetFuncCfg("FaQiUpItem", 1) autoBuyShopIndex = IpyGameDataPY.GetFuncCfg("FaQiUpItem", 2) 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 = IPY_GameWorld.TYPE_Price_Gold_Money infoDict = {ChConfig.Def_Cost_Reason_SonKey:costItemID} if not FunctionNPCCommon.PayAutoBuyItem(curPlayer, {costItemID:lackCnt}, autoBuyMoneyType, ChConfig.Def_Cost_FaQi, infoDict, shopItemIndexDict={costItemID:autoBuyShopIndex}): return delCnt -= lackCnt # ¿Û³ýÏûºÄ if delCnt: ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, ChConfig.ItemDel_FaQi) updClassLV = faQiLV updEatItemCount = curEatItemCount + costItemCount GameWorld.DebugLog("·¨Æ÷ÅàÑø: faQiLV=%s,curEatItemCount=%s,costItemCount=%s,updEatItemCount=%s,needEatCount=%s" % (faQiLV, curEatItemCount, costItemCount, updEatItemCount, needEatCount)) if updEatItemCount >= needEatCount: updClassLV += 1 updEatItemCount -= needEatCount GameWorld.DebugLog(" Éý½×: updClassLV=%s,updEatItemCount=%s" % (updClassLV, updEatItemCount)) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaQiLV, updClassLV) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaQiEatItemCount, updEatItemCount) # Éý½× if updClassLV > faQiLV: pass Sync_FaQiLVInfo(curPlayer) # Ë¢ÊôÐÔ£¬¸üÐÂÅÅÐаñ RefreshFaQiAttr(curPlayer) return def RefreshFaQiAttr(curPlayer): CalcFaQiAttr(curPlayer) PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState() return def CalcFaQiAttr(curPlayer): faQiLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaQiLV) if not faQiLV: return allAttrList = [{} for _ in range(4)] customAttrDictFaQi = {} faQiAllAttrInfo = {} ipyDataMgr = IpyGameDataPY.IPY_Data() for index in xrange(ipyDataMgr.GetFaQiLVUpCount()): lvupIpyData = ipyDataMgr.GetFaQiLVUpByIndex(index) dataLV = lvupIpyData.GetFaQiLV() if dataLV > faQiLV: break elif dataLV == faQiLV: upItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaQiEatItemCount) else: upItemCount = lvupIpyData.GetNeedEatCount() # µÈ½×¶îÍâÊôÐÔ lvAttrTypeList = lvupIpyData.GetLVAttrType() lvAttrValueList = lvupIpyData.GetLVAttrValue() for i, attrID in enumerate(lvAttrTypeList): attrValue = lvAttrValueList[i] faQiAllAttrInfo[attrID] = faQiAllAttrInfo.get(attrID, 0) + attrValue PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList) # ÅàÑøµ¤Ôö¼ÓÊôÐÔ upItemPerCount = lvupIpyData.GetUpEatItemPerCount() if upItemCount and upItemPerCount: upItemAttrTypeList = lvupIpyData.GetUpItemAttrType() upItemAttrValueList = lvupIpyData.GetUpItemAttrValue() attrMultiple = upItemCount / upItemPerCount for i, attrID in enumerate(upItemAttrTypeList): attrValue = upItemAttrValueList[i] faQiAllAttrInfo[attrID] = faQiAllAttrInfo.get(attrID, 0) + attrValue PlayerControl.CalcAttrDict_Type(attrID, attrValue * attrMultiple, allAttrList) customAttrDictFaQi["faQiAllAttrInfo"] = faQiAllAttrInfo # ±£´æ¼ÆËãÖµ PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_FaQi, allAttrList, customAttrDict=customAttrDictFaQi) return def Sync_FaQiLVInfo(curPlayer): clientPack = ChPyNetSendPack.tagMCFaQiInfo() clientPack.Clear() clientPack.LV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaQiLV) clientPack.EatItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaQiEatItemCount) NetPackCommon.SendFakePack(curPlayer, clientPack) return