#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package GameWorldLogic.FBProcess.GameLogic_MainLevel # # @todo:Ö÷Ï߹ؿ¨ # @author hxp # @date 2025-07-10 # @version 1.0 # # ÏêϸÃèÊö: Ö÷Ï߹ؿ¨ # #------------------------------------------------------------------------------- #"""Version = 2025-07-10 17:00""" #------------------------------------------------------------------------------- import ChConfig import GameWorld import ShareDefine import IpyGameDataPY import PlayerControl import ChPyNetSendPack import ItemControler import IPY_GameWorld import NetPackCommon import ItemCommon import NPCCommon import ChEquip import ObjPool import random def OnFBPlayerOnLogin(curPlayer): SyncDropBootyInfo(curPlayer) return def OnFBPlayerOnDay(curPlayer): ResetBootyDropToday(curPlayer) return def ResetBootyDropToday(curPlayer): bootyItemIDList = GetBootyItemIDList() for itemID in bootyItemIDList: PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntBooty % itemID, 0) if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BootyDropToday % itemID): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BootyDropToday % itemID, 0) SyncDropBootyInfo(curPlayer) return def SetBootyDropToday(curPlayer, itemID, updDropToday): updDropToday = min(updDropToday, ChConfig.Def_UpperLimit_DWord) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BootyDropToday % itemID, updDropToday) GameWorld.DebugLog("¸üнñÈÕµôÂäÕ½ÀûÆ·Êý: itemID=%s,updDropToday=%s" % (itemID, updDropToday), curPlayer.GetPlayerID()) SyncDropBootyInfo(curPlayer, itemID) return def GetBootyItemIDList(): ## »ñÈ¡ËùÓеÄÕ½ÀûÆ·ID ipyDataMgr = IpyGameDataPY.IPY_Data() chapterCount = ipyDataMgr.GetMainChapterCount() if not chapterCount: return [] ipyData = ipyDataMgr.GetMainChapterByIndex(chapterCount - 1) return [booty[0] for booty in ipyData.GetDailyBootyUpperList()] def OnPlayerLineupAttackResult(curPlayer, atkObj, killObjIDList, useSkill, mapID, funcLineID): ## »ØºÏÕ½¶·Ö÷¶¯·¢ÆðµÄÍæ¼ÒÕóÈݹ¥»÷½á¹û¶îÍâ´¦Àí £¬Ò»°ã´¦Àí¸±±¾Ïà¹ØµÄµôÂä¡¢½±ÀøµÈ if mapID == ChConfig.Def_FBMapID_Main: __doKillAward(curPlayer, atkObj, killObjIDList) return def __doKillAward(curPlayer, atkObj, killObjIDList): ## ¼ÆËã»÷ɱ½±Àø if not killObjIDList: GameWorld.DebugLog("ûÓл÷ɱ²»ÐèÒª´¦Àí!") return # ½áËã¾­Ñé unXiantaoCntExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntExp) if unXiantaoCntExp: PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntExp, 0) perExp = IpyGameDataPY.GetFuncCfg("Mainline", 1) # ÿ¸öÕ½´¸Ôö¼Ó¾­Ñé totalExp = unXiantaoCntExp * perExp GameWorld.DebugLog("Ôö¼Ó¾­Ñé: totalExp=%s,unXiantaoCntExp=%s" % (totalExp, unXiantaoCntExp)) PlayerControl.PlayerControl(curPlayer).AddExp(totalExp, ShareDefine.Def_ViewExpType_KillNPC) __doMainDrop(curPlayer) return def __doMainDrop(curPlayer): # ×°±¸µôÂä if __doDropEquip(curPlayer) == -1: return playerID = curPlayer.GetPlayerID() DailyBootyUpperList = [] chapterID = PlayerControl.GetMainLevelNowInfo(curPlayer)[0] chapterIpyData = IpyGameDataPY.GetIpyGameData("MainChapter", chapterID) if chapterIpyData: DailyBootyUpperList = chapterIpyData.GetDailyBootyUpperList() GameWorld.DebugLog("¿ÉµôÂäÕ½ÀûÆ·ÉÏÏÞ: chapterID=%s, %s" % (chapterID, DailyBootyUpperList), playerID) # Õ½ÀûÆ·µôÂäĬÈϲ»¶Ñµþ£¬¹Ê×î¶àÖ»ÄܵôÂäÊ£Óà¿Õ¸ñ×Ó¸öÊýµÄÎïÆ· spaceCount = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptIdentify) # ÆäËûÕ½ÀûÆ·µôÂä bootyDropNeedDict = IpyGameDataPY.GetFuncEvalCfg("MainBootyDrop", 1, {}) bootyDropCntDict = IpyGameDataPY.GetFuncEvalCfg("MainBootyDrop", 2, {}) for itemID, dropUpper in DailyBootyUpperList: if spaceCount <= 0: GameWorld.DebugLog("µôÂä±³°üÒÑÂú!", playerID) break if dropUpper <= 0: continue todyDropCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BootyDropToday % itemID) if todyDropCnt >= dropUpper: GameWorld.DebugLog("Õ½ÀûÆ·ÒÑ´ï½ñÈÕµôÂäÉÏÏÞ! itemID=%s,todyDropCnt=%s >= %s" % (itemID, todyDropCnt, dropUpper), playerID) continue if itemID not in bootyDropNeedDict or itemID not in bootyDropCntDict: continue dropOneNeed = bootyDropNeedDict[itemID] unXiantaoCntBooty = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntBooty % itemID) dropBootyCnt = unXiantaoCntBooty / dropOneNeed if dropBootyCnt <= 0: continue dropCntRange = bootyDropCntDict[itemID] if not isinstance(dropCntRange, (list, tuple)) or len(dropCntRange) != 2: continue dropMin = dropCntRange[0] dropMax = dropCntRange[1] dropCntTotal = 0 for _ in range(dropBootyCnt): if dropMin == dropMax: dropCnt = dropMin else: dropCnt = random.randint(dropMin, dropMax) dropCntTotal += dropCnt dropCntTotal = min(dropCntTotal, dropUpper - todyDropCnt) if dropCntTotal <= 0: continue GameWorld.DebugLog("µôÂäÕ½ÀûÆ·! itemID=%s,unXiantaoCntBooty=%s,´ÎÊý=%s,dropCntTotal=%s,spaceCount=%s" % (itemID, unXiantaoCntBooty, dropBootyCnt, dropCntTotal, spaceCount), playerID) curItem = ItemControler.GetOutPutItemObj(itemID, dropCntTotal, False, curPlayer=curPlayer) if curItem == None: continue curItem.SetIsBind(1) # Ϊ1ʱ´ú±íÊǵôÂä if not ItemControler.DoLogic_PutItemInPack(curPlayer, curItem, packIndexList=[IPY_GameWorld.rptIdentify]): continue unXiantaoCntBooty = unXiantaoCntBooty % dropOneNeed PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntBooty % itemID, unXiantaoCntBooty) SetBootyDropToday(curPlayer, itemID, todyDropCnt + dropCntTotal) spaceCount -= 1 return def __doDropEquip(curPlayer): ## Ö÷ÏßµôÂä×°±¸ playerID = curPlayer.GetPlayerID() unXiantaoCntEquip = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntEquip) dropOneNeed = IpyGameDataPY.GetFuncCfg("MainEquipDrop", 1) # ÿÏûºÄX¸öÕ½´¸µôÂäÒ»¼þ×°±¸ dropEquipCnt = unXiantaoCntEquip / dropOneNeed if dropEquipCnt <= 0: GameWorld.DebugLog("Ö÷ÏßÔݲ»ÄܵôÂä! unXiantaoCntEquip=%s,dropOneNeed=%s,dropEquipCnt=%s" % (unXiantaoCntEquip, dropOneNeed, dropEquipCnt), playerID) return dropEquipCnt = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptIdentify, dropEquipCnt) if not dropEquipCnt: GameWorld.DebugLog("µôÂä±³°üÒÑÂú!", playerID) return -1 treeLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreeLV) ipyData = IpyGameDataPY.GetIpyGameData("TreeLV", treeLV) if not ipyData: return equipColorRateList = ipyData.GetEquipColorRateList() GameWorld.DebugLog("Ö÷ÏßµôÂä×°±¸: unXiantaoCntEquip=%s,dropEquipCnt=%s,treeLV=%s,equipColorRateList=%s" % (unXiantaoCntEquip, dropEquipCnt, treeLV, equipColorRateList), playerID) maxRate = 10000 totalRate = 0 colorRateList = [] for equipColor, colorRate in enumerate(equipColorRateList, 1): if not colorRate: continue totalRate += colorRate colorRateList.append([totalRate, equipColor]) if totalRate != maxRate: GameWorld.SendGameError("GameWarning", "CutTreeTotalRateError:%s!=%s,treeLV=%s" % (totalRate, maxRate, treeLV)) if not colorRateList: return GameWorld.DebugLog(" colorRateList=%s,totalRate=%s" % (colorRateList, totalRate), playerID) for _ in range(dropEquipCnt): itemColor = GameWorld.GetResultByRandomList(colorRateList) if not itemColor: continue equipIDList = NPCCommon.__GetEquipIDList(0, color=itemColor, placeList=ChConfig.Def_MainEquipPlaces, findType="MainEquipDrop") if not equipIDList: continue randEquipID = random.choice(equipIDList) curItem = ItemControler.GetOutPutItemObj(randEquipID, 1, False, curPlayer=curPlayer) if curItem == None: continue curItem.SetIsBind(1) # Ϊ1ʱ´ú±íÊǵôÂä #GameWorld.DebugLog("µôÂä×°±¸: randEquipID=%s,%s" % (randEquipID, curItem.GetGUID()), playerID) if not ItemControler.DoLogic_PutItemInPack(curPlayer, curItem, packIndexList=[IPY_GameWorld.rptIdentify]): continue unXiantaoCntEquip -= dropOneNeed PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntEquip, unXiantaoCntEquip) return def GMTestKillDrop(curPlayer, unXiantao): ## GM²âÊÔµôÂä unXiantaoCntEquip = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntEquip) + unXiantao PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntEquip, unXiantaoCntEquip) GameWorld.DebugAnswer(curPlayer, "δ½áËã×°±¸Õ½´¸Êý: %s" % unXiantaoCntEquip) chapterID = PlayerControl.GetMainLevelNowInfo(curPlayer)[0] chapterIpyData = IpyGameDataPY.GetIpyGameData("MainChapter", chapterID) if chapterIpyData: DailyBootyUpperList = chapterIpyData.GetDailyBootyUpperList() for itemID, upperCnt in DailyBootyUpperList: if upperCnt <= 0: continue unXiantaoCntBooty = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntBooty % itemID) + unXiantao PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntBooty % itemID, unXiantaoCntBooty) GameWorld.DebugAnswer(curPlayer, "δ½áËãÕ½ÀûÆ·(%s)Õ½´¸Êý: %s" % (itemID, unXiantaoCntBooty)) __doMainDrop(curPlayer) return #// B4 15 Ö÷ÏßµôÂäÎïÆ·²Ù×÷ #tagCSMainDropItemOP # #struct tagCSMainDropItemOP #{ # tagHead Head; # BYTE Count; # WORD IndexList[Count]; // µôÂä±³°üÖеÄÎïÆ·¸ñ×ÓË÷ÒýÁбí # BYTE OPType; // 0 - ʰȡ·Ç×°±¸ÎïÆ·£»1 - ·Ö½â£»2 - ´©´÷/Ìæ»»£» # BYTE OPValue; // ²Ù×÷¶îÍâÖ¸ÁîÖµ£¬ÓɲÙ×÷ÀàÐ;ö¶¨£¬Èç´©´÷ʱ¿É·¢ËÍ´©´÷ºóÊÇ·ñ×Ô¶¯·Ö½â #}; def OnMainDropItemOP(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) itemIndexList = clientData.IndexList opType = clientData.OPType opValue = clientData.OPValue if opType == 2: __doEquipMainEquip(curPlayer, itemIndexList, opValue) elif opType == 1: __doDecomposeMainEquip(curPlayer, itemIndexList) else: __doPickupMainItem(curPlayer, itemIndexList) ItemCommon.SyncMakeItemAnswer(curPlayer, ShareDefine.Def_mitMainDropItemOP, ChConfig.Def_ComposeState_Sucess, opType) return def __doEquipMainEquip(curPlayer, itemIndexList, isAutoDecompose): playerID = curPlayer.GetPlayerID() GameWorld.DebugLog("´©´÷Ö÷Ïß×°±¸: itemIndexList=%s,isAutoDecompose=%s" % (itemIndexList, isAutoDecompose), playerID) IdentifyPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptIdentify) decomposeIndexList = [] for itemIndex in itemIndexList: if itemIndex < 0 or itemIndex >= IdentifyPack.GetCount(): continue curEquip = IdentifyPack.GetAt(itemIndex) if not ItemCommon.CheckItemCanUse(curEquip): GameWorld.DebugLog("ÎïÆ·Îª¿Õ»ò²»¿ÉÓÃ: itemIndex=%s" % itemIndex, playerID) continue if not ItemCommon.GetIsMainEquip(curEquip): GameWorld.DebugLog("·ÇÖ÷Ïß×°±¸: itemIndex=%s" % itemIndex, playerID) continue itemID = curEquip.GetItemTypeID() equipPlace = curEquip.GetEquipPlace() equipPlaceIndex = equipPlace - 1 # Ôݹ̶¨Ö±½Ó×°±¸Î»-1 GameWorld.DebugLog(" itemIndex=%s,itemID=%s,equipPlace=%s,equipPlaceIndex=%s" % (itemIndex, itemID, equipPlace, equipPlaceIndex), playerID) equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip) if equipPlaceIndex < 0 or equipPlaceIndex >= equipPack.GetCount(): GameWorld.ErrLog("Ö÷Ïß×°±¸¶ÔӦװ±¸Î»ÖÃË÷ÒýÒì³£: itemIndex=%s,equipPlace=%s,equipPlaceIndex=%s" % (itemIndex, equipPlace, equipPlaceIndex), playerID) continue destEquip = equipPack.GetAt(equipPlaceIndex) canDecomp = ItemCommon.CheckItemCanUse(destEquip) curEquip.GetItem().SetIsBind(0) # ´©´÷Ê±ÖØÖã¬È¡Ô´SingleItemÐ޸IJ»Í¨Öª if not ItemCommon.DoLogicSwitchItem(curPlayer, curEquip, destEquip, IPY_GameWorld.rptEquip): continue if isAutoDecompose and canDecomp: decomposeIndexList.append(itemIndex) if decomposeIndexList: __doDecomposeMainEquip(curPlayer, decomposeIndexList) # Ë¢ÊôÐÔ ChEquip.RefreshRoleEquipAttr(curPlayer) return def __doDecomposeMainEquip(curPlayer, itemIndexList): playerID = curPlayer.GetPlayerID() GameWorld.DebugLog("·Ö½âÖ÷Ïß×°±¸: itemIndexList=%s" % (itemIndexList), playerID) IdentifyPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptIdentify) moneyType = IpyGameDataPY.GetFuncCfg("MainEquipDrop", 2) if not moneyType: return moneyTotal = 0 decomposeIndexList = [] for itemIndex in itemIndexList: if itemIndex < 0 or itemIndex >= IdentifyPack.GetCount(): continue curEquip = IdentifyPack.GetAt(itemIndex) if not ItemCommon.CheckItemCanUse(curEquip): GameWorld.DebugLog("ÎïÆ·Îª¿Õ»ò²»¿ÉÓÃ: itemIndex=%s" % itemIndex, playerID) continue if not ItemCommon.GetIsMainEquip(curEquip): GameWorld.DebugLog("·ÇÖ÷Ïß×°±¸: itemIndex=%s" % itemIndex, playerID) continue itemColor = curEquip.GetItemColor() colorIpyData = IpyGameDataPY.GetIpyGameData("EquipColor", itemColor) if not colorIpyData: return moneyBase = colorIpyData.GetMoneyBase() # ·Ö½â»õ±Ò»ù´¡ if not moneyBase: return # ¿ÉÒÔ´¦ÀíһЩ¼Ó³É decomposeMoney = moneyBase moneyTotal += decomposeMoney GameWorld.DebugLog(" itemIndex=%s,itemColor=%s,moneyBase=%s,decomposeMoney=%s,%s" % (itemIndex, itemColor, moneyBase, decomposeMoney, moneyTotal), playerID) ItemCommon.DelItem(curPlayer, curEquip, curEquip.GetCount(), True, ChConfig.ItemDel_EquipDecompose) decomposeIndexList.append(itemIndex) if not moneyTotal: return PlayerControl.GiveMoney(curPlayer, moneyType, moneyTotal, "DecomposeMainEquip", isSysHint=False) return def __doPickupMainItem(curPlayer, itemIndexList): playerID = curPlayer.GetPlayerID() GameWorld.DebugLog("ʰȡÖ÷ÏßµôÂäÕ½ÀûÆ·! itemIndexList=%s" % itemIndexList, playerID) IdentifyPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptIdentify) itemControl = ItemControler.PlayerItemControler(curPlayer) for itemIndex in itemIndexList: if itemIndex < 0 or itemIndex >= IdentifyPack.GetCount(): continue curItem = IdentifyPack.GetAt(itemIndex) if not ItemCommon.CheckItemCanUse(curItem): GameWorld.DebugLog("ÎïÆ·Îª¿Õ»ò²»¿ÉÓÃ: itemIndex=%s" % itemIndex, playerID) continue if ItemCommon.GetIsMainEquip(curItem): GameWorld.DebugLog("Ö÷Ïß×°±¸²»¿Éʰȡ: itemIndex=%s" % itemIndex, playerID) continue itemID = curItem.GetItemTypeID() item = curItem.GetItem() itemCount = ItemControler.GetItemCount(curItem) GameWorld.DebugLog("Ö÷ÏßÎïÆ·Ê°È¡: itemIndex=%s,itemID=%s,itemCount=%s" % (itemIndex, itemID, itemCount), playerID) if not itemControl.PutInItem(IPY_GameWorld.rptItem, item): return curItem.Wipe() return def SyncDropBootyInfo(curPlayer, itemID=0): if not itemID: syncItemIDList = GetBootyItemIDList() else: syncItemIDList = [itemID] poolMgr = ObjPool.GetPoolMgr() clientPack = poolMgr.acquire(ChPyNetSendPack.tagSCDropBootyInfo) clientPack.DropBootyList = [] for itemID in syncItemIDList: dropBooty = poolMgr.acquire(ChPyNetSendPack.tagSCDropBooty) dropBooty.ItemID = itemID dropBooty.TodayDropCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BootyDropToday % itemID) clientPack.DropBootyList.append(dropBooty) clientPack.Count = len(clientPack.DropBootyList) NetPackCommon.SendFakePack(curPlayer, clientPack) return