| | |
| | | import CrossPlayerData
|
| | | import CalcLineEffect
|
| | | import PlayerActivity
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import PlayerHorse
|
| | | import GameObj
|
| | |
|
| | |
| | | # GameWorld.DebugLog("自动出战新手宠!petNPCID=%s,petItemIndex=%s" % (petNPCID, petItemIndex))
|
| | | # DoChangePetState(curPlayer, petItemIndex, ShareDefine.Def_PetState_Fight)
|
| | |
|
| | | for trainType in xrange(1, GetPetTrainTypes() + 1):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PetTrainLV % trainType, 1)
|
| | | Sync_PetTrainData(curPlayer)
|
| | | return True
|
| | |
|
| | | ## 功能开启后, 角色升级需要的处理
|
| | |
| | | allAttrListPetSoul = [{} for _ in range(4)]
|
| | | skillAttrList = [{} for _ in range(4)]
|
| | | allAttrListPetSkin = [{} for _ in range(4)]
|
| | | allAttrListTrain = [{} for _ in range(4)]
|
| | | totalMinAtk, totalMaxAtk = GetPetAtkValue(curPlayer)
|
| | | PlayerControl.CalcAttrDict_Type(ShareDefine.Def_Effect_PetMinAtk, totalMinAtk, allAttrListPet)
|
| | | PlayerControl.CalcAttrDict_Type(ShareDefine.Def_Effect_PetMaxAtk, totalMaxAtk, allAttrListPet)
|
| | |
| | | continue
|
| | | SkillShell.CalcBuffEffAttr(curPlayer, curEffect, skillAttrList)
|
| | |
|
| | | # 新培养属性
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in xrange(ipyDataMgr.GetPetTrainCount()):
|
| | | trainIpyData = ipyDataMgr.GetPetTrainByIndex(index)
|
| | | trainType = trainIpyData.GetTrainType()
|
| | | dataTrainLV = trainIpyData.GetTrainLV()
|
| | | trainLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PetTrainLV % trainType)
|
| | | |
| | | if dataTrainLV > trainLV:
|
| | | continue
|
| | | elif dataTrainLV == trainLV:
|
| | | trainItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PetTrainItemCount % trainType)
|
| | | else:
|
| | | trainItemCount = trainIpyData.GetEatCntTotal()
|
| | | |
| | | # 等阶额外属性
|
| | | lvAttrTypeList = trainIpyData.GetLVAttrTypeList()
|
| | | lvAttrValueList = trainIpyData.GetLVAttrValueList()
|
| | | for i, attrID in enumerate(lvAttrTypeList):
|
| | | attrValue = lvAttrValueList[i]
|
| | | PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrListTrain)
|
| | | |
| | | # 培养丹增加属性
|
| | | eatCntEverytime = trainIpyData.GetEatCntEverytime()
|
| | | if trainItemCount and eatCntEverytime:
|
| | | eatItemAttrTypeList = trainIpyData.GetEatItemAttrTypeList()
|
| | | eatItemAttrValueList = trainIpyData.GetEatItemAttrValueList()
|
| | | attrMultiple = trainItemCount / eatCntEverytime
|
| | | for i, attrID in enumerate(eatItemAttrTypeList):
|
| | | attrValue = eatItemAttrValueList[i]
|
| | | PlayerControl.CalcAttrDict_Type(attrID, attrValue * attrMultiple, allAttrListTrain)
|
| | | |
| | | PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_PetTarin, allAttrListTrain)
|
| | |
|
| | | PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Pet, allAttrListPet)
|
| | | PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_PetSoul, allAttrListPetSoul)
|
| | |
| | | totalMaxAtk = classAddAtk
|
| | | return totalMinAtk, totalMaxAtk
|
| | |
|
| | | def OnPlayerPetLogin(curPlayer):
|
| | | ## 登录处理
|
| | | if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Pet):
|
| | | return
|
| | |
|
| | | # 培养是后面加的功能,每次登录补检查一下功能开始时设置为培养1级
|
| | | for trainType in xrange(1, GetPetTrainTypes() + 1):
|
| | | if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PetTrainLV % trainType) == 0:
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PetTrainLV % trainType, 1)
|
| | | |
| | | Sync_PetTrainData(curPlayer)
|
| | | return
|
| | |
|
| | | def GetPetTrainTypes():
|
| | | return len(IpyGameDataPY.GetFuncEvalCfg("PetUpItem", 3))
|
| | |
|
| | | #// A7 05 宠物培养 #tagCMPetTrain
|
| | | #
|
| | | #struct tagCMPetTrain
|
| | | #{
|
| | | # tagHead Head;
|
| | | # BYTE TrainType; //培养类型: 1-基础培养,2-特殊培养,3-百分比培养
|
| | | # WORD UseItemCnt; //消耗材料个数
|
| | | #};
|
| | | def OnPetTrain(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | trainType = clientData.TrainType # 培养类型
|
| | | costItemCount = clientData.UseItemCnt # 消耗材料个数
|
| | | |
| | | trainLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PetTrainLV % trainType)
|
| | | curEatItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PetTrainItemCount % trainType)
|
| | | GameWorld.DebugLog("灵宠培养: trainType=%s,trainLV=%s,costItemCount=%s,curEatItemCount=%s" |
| | | % (trainType, trainLV, costItemCount, curEatItemCount))
|
| | | |
| | | if trainType <= 0 or trainType > GetPetTrainTypes():
|
| | | return
|
| | | |
| | | if trainLV <= 0:
|
| | | GameWorld.DebugLog(" 培养未激活 trainType=%s" % trainType)
|
| | | return
|
| | | |
| | | trainIpyData = IpyGameDataPY.GetIpyGameData("PetTrain", trainType, trainLV)
|
| | | if not trainIpyData:
|
| | | return
|
| | | |
| | | needRealmLV = trainIpyData.GetNeedRealmLV()
|
| | | curRealmLV = curPlayer.GetOfficialRank()
|
| | | if curRealmLV < needRealmLV:
|
| | | GameWorld.DebugLog(" 境界不足,无法培养! curRealmLV(%s) < needRealmLV(%s)" % (curRealmLV, needRealmLV))
|
| | | return
|
| | | |
| | | needEatCountTotal = trainIpyData.GetEatCntTotal()
|
| | | if not needEatCountTotal:
|
| | | GameWorld.DebugLog(" 该培养已满级!")
|
| | | return
|
| | | |
| | | costItemIDList = IpyGameDataPY.GetFuncEvalCfg("PetUpItem", 3)
|
| | | costItemID = costItemIDList[trainType - 1]
|
| | | 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
|
| | | |
| | | delCnt = costItemCount
|
| | | |
| | | # 扣除消耗
|
| | | if delCnt:
|
| | | ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, ChConfig.ItemDel_Pet)
|
| | | |
| | | updClassLV = trainLV
|
| | | updEatItemCount = curEatItemCount + costItemCount
|
| | | GameWorld.DebugLog(" updEatItemCount=%s,needEatCountTotal=%s" % (updEatItemCount, needEatCountTotal))
|
| | | |
| | | if updEatItemCount >= needEatCountTotal:
|
| | | updClassLV += 1
|
| | | updEatItemCount -= needEatCountTotal
|
| | | GameWorld.DebugLog(" 进阶: updClassLV=%s,updEatItemCount=%s" % (updClassLV, updEatItemCount))
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PetTrainLV % trainType, updClassLV)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PetTrainItemCount % trainType, updEatItemCount)
|
| | | |
| | | # 升阶
|
| | | if updClassLV > trainLV:
|
| | | pass
|
| | | |
| | | Sync_PetTrainData(curPlayer)
|
| | | # 刷属性,更新排行榜
|
| | | RefreshPetItemAddAttr(curPlayer, True)
|
| | | return
|
| | |
|
| | | def Sync_PetTrainData(curPlayer):
|
| | | clientPack = ChPyNetSendPack.tagMCPetTrainInfo()
|
| | | clientPack.TrainLVList = []
|
| | | clientPack.TrainItemCountList = []
|
| | | for trainType in xrange(1, GetPetTrainTypes() + 1):
|
| | | clientPack.TrainLVList.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PetTrainLV % trainType))
|
| | | clientPack.TrainItemCountList.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PetTrainItemCount % trainType))
|
| | | clientPack.TrainTypes = len(clientPack.TrainLVList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|