| | |
| | | #"""Version = 2024-03-07 19:30"""
|
| | | #-------------------------------------------------------------------------------
|
| | |
|
| | | import ChConfig
|
| | | import GameWorld
|
| | | import NetPackCommon
|
| | | import PyDataManager
|
| | |
| | | self.viewAreaPlayerIDDict = {} # 正在查看某个福地中的玩家ID {areaPlayerID:[viewPlayerID, ...], ...}
|
| | |
|
| | | self.neighborIDListDict = {} # 玩家周围福地玩家ID列表 {playerID:[playerID, ...], ...}
|
| | | self.socialIDListDict = {} # 玩家有关系道友福地玩家ID列表 {playerID:[playerID, ...], ...} playerID列表倒序
|
| | | return
|
| | |
|
| | | def AddViewAreaPlayerID(self, viewPlayerID, areaPlayerID):
|
| | |
| | | AddMineItemRecord(awardPlayerID, MineAreaRecordType_Pull, areaPlayerID, mineID, curTime)
|
| | | if areaPlayerID != awardPlayerID:
|
| | | AddMineItemRecord(areaPlayerID, MineAreaRecordType_BeRobbed, awardPlayerID, mineID, curTime)
|
| | | DecRobValue(awardPlayerID, areaPlayerID, 1)
|
| | | AddRobValue(areaPlayerID, awardPlayerID, 1)
|
| | |
|
| | | # 被抢的
|
| | | if IpyGameDataPY.GetFuncCfg("MineAreaSysRefresh", 3) > 0:
|
| | |
| | | recordMgr = PyDataManager.GetDBPyMineAreaRecordManager()
|
| | | recordList = recordMgr.AddPlayerRecord(recordData)
|
| | |
|
| | | # 被人抢,更新关系福地ID记录
|
| | | if recordData.RecordType == MineAreaRecordType_BeRobbed:
|
| | | __DoUpdSocialPlayerIDList(playerID)
|
| | | |
| | | if len(recordList) > Def_RecordMax:
|
| | | recordList.pop(0) # 删除最早一条
|
| | | return
|
| | |
|
| | | def __DoUpdSocialPlayerIDList(playerID):
|
| | | ## 更新有关系的道友ID列表
|
| | | recordMgr = PyDataManager.GetDBPyMineAreaRecordManager()
|
| | | recordList = recordMgr.playerMineRecordListDict.get(playerID, [])
|
| | | |
| | | socialAreaMax = IpyGameDataPY.GetFuncCfg("MineAreaRob", 1) # 道友福地个数
|
| | | socialIDList = [] # 反序
|
| | | for recData in recordList[::-1]:
|
| | | if recData.RecordType != MineAreaRecordType_BeRobbed:
|
| | | ## 优先保留被抢记录关系玩家
|
| | | def DecRobValue(playerID, tagPlayerID, decValue):
|
| | | ## 减少敌对值
|
| | | playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
|
| | | robRecData = playerRecMgr.GetPlayerRecDataFirst(ShareDefine.Def_PlayerRecType_MineAreaRecord, playerID, False)
|
| | | if not robRecData:
|
| | | GameWorld.DebugLog("没有敌对福地记录!", playerID)
|
| | | return 0
|
| | | # 抢劫的人减少与对方敌对值
|
| | | setRobValue = 0
|
| | | robValueList = robRecData.GetUserDataByKey(ChConfig.Def_RecDataKey_RobValueList, [])
|
| | | GameWorld.DebugLog("减少与对方敌对值: tagPlayerID=%s,decValue=%s" % (tagPlayerID, decValue), playerID)
|
| | | GameWorld.DebugLog(" bef robValueList=%s" % robValueList, playerID)
|
| | | for index, robValueInfo in enumerate(robValueList):
|
| | | robValue, pID = robValueInfo
|
| | | if pID != tagPlayerID:
|
| | | continue
|
| | | if recData.TagPlayerID not in socialIDList:
|
| | | socialIDList.append(recData.TagPlayerID)
|
| | | if len(socialIDList) >= socialAreaMax:
|
| | | robValue -= decValue
|
| | | GameWorld.DebugLog(" tagPlayerID=%s,更新敌对值=%s" % (tagPlayerID, robValue), playerID)
|
| | | if robValue <= 0:
|
| | | robValueList.pop(index)
|
| | | else:
|
| | | robValueList[index] = [robValue, pID]
|
| | | setRobValue = robValue
|
| | | robRecData.SetUserDataByKey(ChConfig.Def_RecDataKey_RobValueList, robValueList, True)
|
| | | break
|
| | |
|
| | | mineItemMgr = PyDataManager.GetDBPyMineAreaItemManager()
|
| | | socialIDListBef = mineItemMgr.socialIDListDict.get(playerID, [])
|
| | | # 优先使用历史记录
|
| | | if len(socialIDList) < socialAreaMax:
|
| | | for socialIDBef in socialIDListBef:
|
| | | if socialIDBef not in socialIDList:
|
| | | socialIDList.append(socialIDBef)
|
| | | if len(socialIDList) >= socialAreaMax:
|
| | | break
|
| | | robValueList = robRecData.GetUserDataByKey(ChConfig.Def_RecDataKey_RobValueList, [])
|
| | | GameWorld.DebugLog(" aft robValueList=%s" % robValueList, playerID)
|
| | | return setRobValue
|
| | |
|
| | | # 优先随机真人
|
| | | if len(socialIDList) < socialAreaMax and mineItemMgr.realAreaPlayerIDList:
|
| | | random.shuffle(mineItemMgr.realAreaPlayerIDList)
|
| | | for areaPlayerID in mineItemMgr.realAreaPlayerIDList:
|
| | | if areaPlayerID not in socialIDList and areaPlayerID != playerID:
|
| | | socialIDList.append(areaPlayerID)
|
| | | if len(socialIDList) >= socialAreaMax:
|
| | | break
|
| | | def AddRobValue(playerID, tagPlayerID, addValue):
|
| | | ## 被抢的人增加与对方敌对值,并置顶
|
| | |
|
| | | # 不够补充假人
|
| | | if len(socialIDList) < socialAreaMax and mineItemMgr.fackAreaPlayerIDList:
|
| | | random.shuffle(mineItemMgr.fackAreaPlayerIDList)
|
| | | for areaPlayerID in mineItemMgr.fackAreaPlayerIDList:
|
| | | if areaPlayerID not in socialIDList:
|
| | | socialIDList.append(areaPlayerID)
|
| | | if len(socialIDList) >= socialAreaMax:
|
| | | break
|
| | | if playerID <= Def_FakeAreaCount:
|
| | | return 0
|
| | |
|
| | | mineItemMgr.socialIDListDict[playerID] = socialIDList
|
| | | return socialIDList
|
| | | GameWorld.DebugLog("增加与对方敌对值: tagPlayerID=%s,addValue=%s" % (tagPlayerID, addValue), playerID)
|
| | | setRobValue = 0
|
| | | playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
|
| | | robRecData = playerRecMgr.GetPlayerRecDataFirst(ShareDefine.Def_PlayerRecType_MineAreaRecord, playerID, True)
|
| | | robValueList = robRecData.GetUserDataByKey(ChConfig.Def_RecDataKey_RobValueList, [])
|
| | | GameWorld.DebugLog(" bef robValueList=%s" % robValueList, playerID)
|
| | | for index, robValueInfo in enumerate(robValueList):
|
| | | robValue, pID = robValueInfo
|
| | | if pID != tagPlayerID:
|
| | | continue
|
| | | robValueList.pop(index)
|
| | | setRobValue = robValue
|
| | | break
|
| | | setRobValue += addValue
|
| | | GameWorld.DebugLog(" tagPlayerID=%s,更新敌对值=%s" % (tagPlayerID, setRobValue), playerID)
|
| | | |
| | | robValueList.insert(0, [setRobValue, tagPlayerID])
|
| | | robRecData.SetUserDataByKey(ChConfig.Def_RecDataKey_RobValueList, robValueList)
|
| | | |
| | | robValueList = robRecData.GetUserDataByKey(ChConfig.Def_RecDataKey_RobValueList, [])
|
| | | GameWorld.DebugLog(" aft robValueList=%s" % robValueList, playerID) |
| | | return setRobValue
|
| | |
|
| | | def GetRobPlayerIDList(playerID):
|
| | | ## 获取敌对玩家ID列表
|
| | | if playerID <= Def_FakeAreaCount:
|
| | | return []
|
| | | playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
|
| | | robRecData = playerRecMgr.GetPlayerRecDataFirst(ShareDefine.Def_PlayerRecType_MineAreaRecord, playerID, False)
|
| | | if not robRecData:
|
| | | return []
|
| | | robIDList = []
|
| | | rPlayerRobValueList = robRecData.GetUserDataByKey(ChConfig.Def_RecDataKey_RobValueList, [])
|
| | | for robValueInfo in rPlayerRobValueList:
|
| | | _, pID = robValueInfo
|
| | | robIDList.append(pID)
|
| | | return robIDList
|
| | |
|
| | | def GetRobValueDict(playerID):
|
| | | ## 获取敌对玩家敌对值字典
|
| | | if playerID <= Def_FakeAreaCount:
|
| | | return {}
|
| | | playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
|
| | | robRecData = playerRecMgr.GetPlayerRecDataFirst(ShareDefine.Def_PlayerRecType_MineAreaRecord, playerID, False)
|
| | | if not robRecData:
|
| | | return {}
|
| | | robValueDict = {}
|
| | | rPlayerRobValueList = robRecData.GetUserDataByKey(ChConfig.Def_RecDataKey_RobValueList, [])
|
| | | for robValueInfo in rPlayerRobValueList:
|
| | | robValue, pID = robValueInfo
|
| | | robValueDict[pID] = robValue
|
| | | return robValueDict
|
| | |
|
| | | def OnTurnFightRequest(curPlayer, mapID, funcLineID, tagPlayerID, valueList):
|
| | |
|
| | |
| | | # 地图结算奖励OK
|
| | | elif msgType == "MineAreaAwardGetOK":
|
| | | __DoMineAreaAwardGetOK(curPlayer, dataMsg)
|
| | | |
| | | # 刷新周围玩家
|
| | | elif msgType == "MineRobRefresh":
|
| | | tick = GameWorld.GetGameWorld().GetTick()
|
| | | queryType, queryValue = 3, 1
|
| | | SyncNeighborAreaInfo(curPlayer, tick, queryType, queryValue)
|
| | |
|
| | | if ret == None:
|
| | | return
|
| | |
| | |
|
| | | # 查看周围随机福地列表
|
| | | elif queryType == 3:
|
| | | queryValue = 0 # GameServer默认只给查询,刷新列表改为从MapServer发起 B0 31 福地物品刷新 #tagCMMineItemRefresh 请求
|
| | | SyncNeighborAreaInfo(curPlayer, tick, queryType, queryValue)
|
| | |
|
| | | # 退出他人福地
|
| | |
| | | notifyPlayerIDList.append(areaPlayerID)
|
| | |
|
| | | # 列表中
|
| | | for playerID, socialIDList in mineItemMgr.socialIDListDict.items():
|
| | | if areaPlayerID in socialIDList:
|
| | | notifyPlayerIDList.append(playerID)
|
| | | robPlayerIDList = GetRobPlayerIDList(areaPlayerID)
|
| | | if robPlayerIDList:
|
| | | notifyPlayerIDList += robPlayerIDList
|
| | | for playerID, neighborIDList in mineItemMgr.neighborIDListDict.items():
|
| | | if areaPlayerID in neighborIDList:
|
| | | notifyPlayerIDList.append(playerID)
|
| | |
| | | return
|
| | |
|
| | | def SyncSocialAreaInfo(curPlayer, queryType=0, queryValue=0):
|
| | | ## 同步有关系的道友福地列表
|
| | | ## 同步有关系的道友福地列表 - 敌对列表
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | mineItemMgr = PyDataManager.GetDBPyMineAreaItemManager()
|
| | | if playerID in mineItemMgr.socialIDListDict:
|
| | | socialIDList = mineItemMgr.socialIDListDict[playerID]
|
| | | else:
|
| | | socialIDList = __DoUpdSocialPlayerIDList(playerID)
|
| | | |
| | | socialIDList = GetRobPlayerIDList(playerID)
|
| | | robValueDict = GetRobValueDict(playerID)
|
| | | areaMineList = [[areaPlayerID, []] for areaPlayerID in socialIDList]
|
| | | clientPack = __GetMineAreaInfoPack(areaMineList, queryType, queryValue)
|
| | | clientPack = __GetMineAreaInfoPack(areaMineList, queryType, queryValue, robValueDict)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | |
| | | if neighborIDBef in areaPlayerIDList:
|
| | | areaPlayerIDList.remove(neighborIDBef)
|
| | | neighborCount = IpyGameDataPY.GetFuncCfg("MineAreaRob", 2)
|
| | | realmLV = curPlayer.GetOfficialRank()
|
| | | officialNeighborCountList = IpyGameDataPY.GetFuncEvalCfg("MineAreaRob2", 1)
|
| | | for needRLV, nCount in officialNeighborCountList:
|
| | | if realmLV >= needRLV:
|
| | | neighborCount = nCount
|
| | | neighborIDList = areaPlayerIDList[:neighborCount]
|
| | | mineItemMgr.neighborIDListDict[playerID] = neighborIDList
|
| | | GameWorld.DebugLog("刷新周围随机福地: %s" % neighborIDList, playerID)
|
| | | GameWorld.DebugLog("刷新周围随机福地: realmLV=%s,neighborCount=%s,%s" % (realmLV, neighborCount, neighborIDList), playerID)
|
| | |
|
| | | areaMineList = [[areaPlayerID, []] for areaPlayerID in neighborIDList]
|
| | | clientPack = __GetMineAreaInfoPack(areaMineList, queryType, queryValue)
|
| | |
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | def __GetMineAreaInfoPack(areaMineList, queryType=0, queryValue=0):
|
| | | def __GetMineAreaInfoPack(areaMineList, queryType=0, queryValue=0, robValueDict=None):
|
| | | ''' 获取同步福地详细信息包
|
| | | @param areaMineList: [[areaPlayerID, mineIndexList], ...] 按指定福地ID顺序列表获取,mineIndexList为空时同步该福地全部物品,否则只同步指定索引物品
|
| | | '''
|
| | |
| | | areaInfo.Job = cacheDict.get("Job", 0)
|
| | | areaInfo.Face = cacheDict.get("Face", 0)
|
| | | areaInfo.FacePic = cacheDict.get("FacePic", 0)
|
| | | areaInfo.RobValue = robValueDict.get(areaPlayerID, 0) if robValueDict else 0 # 敌对值,前端仅queryType为2时才更新敌对值
|
| | |
|
| | | areaInfo.MineItemList = []
|
| | | if not mineIndexList:
|