| | |
| | | AssistType_TeamFB, # 组队副本
|
| | | ) = range(3)
|
| | |
|
| | | def RemoveOutofdateAssistThanks():
|
| | | ## 移除过期的未完结感谢数据
|
| | | |
| | | timeoutDate = GameWorld.GetDatetimeByDiffDays(-7)
|
| | | assistThanksMgr = PyDataManager.GetPlayerAssistThanksPyManager()
|
| | | maxDoCount = len(assistThanksMgr.allAssistThanksList)
|
| | | syncPlayerIDList = []
|
| | | removeCountTotal, delNoThanksCount, delUnGetThanksCount = 0, 0, 0
|
| | | doCount = 0
|
| | | while doCount < maxDoCount and assistThanksMgr.allAssistThanksList:
|
| | | doCount += 1
|
| | | thanks = assistThanksMgr.allAssistThanksList[0]
|
| | | thanksDate = GameWorld.ChangeStrToDatetime(thanks.TimeStr)
|
| | | if thanksDate > timeoutDate:
|
| | | break
|
| | | |
| | | removeCountTotal += 1
|
| | | # 移除过期的感谢数据
|
| | | popThanks = assistThanksMgr.allAssistThanksList.pop(0)
|
| | | playerID = popThanks.PlayerID
|
| | | GUID = popThanks.GUID
|
| | | assistPlayerIDList = popThanks.AssistPlayerDict.keys()
|
| | | |
| | | if playerID in assistThanksMgr.playerThanksDict:
|
| | | playerThanksList = assistThanksMgr.playerThanksDict[playerID]
|
| | | for i, thanks in enumerate(playerThanksList):
|
| | | if GUID == thanks.GUID:
|
| | | delNoThanksCount += 1
|
| | | playerThanksList.pop(i)
|
| | | #GameWorld.DebugLog(" 移除未感谢的数据: i=%s,GUID=%s,len=%s" % (i, thanks.GUID, len(playerThanksList)))
|
| | | break
|
| | | |
| | | for assistPlayerID in assistPlayerIDList:
|
| | | if assistPlayerID not in assistThanksMgr.assistPlayerThanksDict:
|
| | | continue
|
| | | assistThanksList = assistThanksMgr.assistPlayerThanksDict[assistPlayerID]
|
| | | for i, thanks in enumerate(assistThanksList):
|
| | | if GUID == thanks.GUID:
|
| | | delUnGetThanksCount += 1
|
| | | assistThanksList.pop(i)
|
| | | #GameWorld.DebugLog(" 移除未接受感谢的数据: i=%s,GUID=%s,assistPlayerID=%s,len=%s" % (i, thanks.GUID, assistPlayerID, len(assistThanksList)))
|
| | | if assistPlayerID not in syncPlayerIDList:
|
| | | syncPlayerIDList.append(assistPlayerID)
|
| | | break
|
| | | |
| | | playerMgr = GameWorld.GetPlayerManager()
|
| | | for playerID in syncPlayerIDList:
|
| | | assistPlayer = playerMgr.FindPlayerByID(playerID)
|
| | | if assistPlayer:
|
| | | SyncCanGetAssistThanksGiftCount(assistPlayer, isForce=True)
|
| | | |
| | | if removeCountTotal:
|
| | | GameWorld.DebugLog("移除过期的未完结感谢数据: doCount=%s,maxDoCount=%s,removeCountTotal=%s,delNoThanksCount=%s,delUnGetThanksCount=%s,remainCount=%s" |
| | | % (doCount, maxDoCount, removeCountTotal, delNoThanksCount, delUnGetThanksCount, len(assistThanksMgr.allAssistThanksList)))
|
| | | return
|
| | |
|
| | |
|
| | | def OnPlayerLogin(curPlayer, isTJ=False):
|
| | | ## 玩家上线
|
| | |
| | | assistObj = assistMgr.playerAssistingDict[leavePlayerID]
|
| | | OnCancelPlayerAssist(leavePlayer, leavePlayerID, assistObj, "LeaveFamily", True)
|
| | |
|
| | | return
|
| | |
|
| | | def OnPlayerTeamChange(curPlayer):
|
| | | ## 玩家队伍变更
|
| | | |
| | | if curPlayer.GetTeamID():
|
| | | return
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | |
| | | assistMgr = PyDataManager.GetPlayerAssistPyManager()
|
| | | if playerID not in assistMgr.playerNoSaveDBAssistDict:
|
| | | return
|
| | | playerAssistList = assistMgr.playerNoSaveDBAssistDict[playerID]
|
| | | |
| | | for assistObj in playerAssistList[::-1]:
|
| | | gameMap = GameWorld.GetMap(assistObj.MapID)
|
| | | if gameMap and gameMap.GetMapFBType() == ChConfig.fbtTeam:
|
| | | OnCancelPlayerRequestAssist(assistObj, "LeaveTeam", True)
|
| | | |
| | | return
|
| | |
|
| | | def OnInitAssistData(dbData, isSaveDB):
|
| | |
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
|
| | | assistObj = None
|
| | | addNewAssist = True
|
| | | reqAssistObj = None
|
| | | addNewAssist = False
|
| | | assistMgr = PyDataManager.GetPlayerAssistPyManager()
|
| | | if playerID in assistMgr.playerNoSaveDBAssistDict:
|
| | | playerAssistList = assistMgr.playerNoSaveDBAssistDict[playerID]
|
| | |
| | | if npcID != assistObj.NPCID or lineID != assistObj.LineID or objID != assistObj.ObjID:
|
| | | OnCancelPlayerRequestAssist(assistObj, "RequestNewAssistBoss", True)
|
| | | else:
|
| | | addNewAssist = False
|
| | | reqAssistObj = assistObj
|
| | | break
|
| | |
|
| | | if addNewAssist:
|
| | | assistObj = __AddNewAssist(assistMgr, curPlayer, mapID, lineID, npcID, objID)
|
| | | if not reqAssistObj:
|
| | | addNewAssist = True
|
| | | reqAssistObj = __AddNewAssist(assistMgr, curPlayer, mapID, lineID, npcID, objID)
|
| | |
|
| | | if not assistObj:
|
| | | if not reqAssistObj:
|
| | | return
|
| | |
|
| | | # 通知本仙盟玩家
|
| | | PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack([assistObj]))
|
| | | PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack([reqAssistObj]))
|
| | | # 求助信息已发送,请等待盟友支援
|
| | | PlayerControl.NotifyCode(curPlayer, "AssistRequestOK")
|
| | |
|
| | |
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
|
| | | assistObj = None
|
| | | reqAssistObj = None
|
| | | addNewAssist = False
|
| | | assistMgr = PyDataManager.GetPlayerAssistPyManager()
|
| | | if playerID in assistMgr.playerNoSaveDBAssistDict:
|
| | |
| | | continue
|
| | | if mapID != assistObj.MapID or lineID != assistObj.LineID:
|
| | | OnCancelPlayerRequestAssist(assistObj, "RequestNewAssistTeamFB", True)
|
| | | addNewAssist = True
|
| | | break
|
| | | else:
|
| | | else:
|
| | | reqAssistObj = assistObj
|
| | | break
|
| | | |
| | | if not reqAssistObj:
|
| | | addNewAssist = True
|
| | | reqAssistObj = __AddNewAssist(assistMgr, curPlayer, mapID, lineID)
|
| | |
|
| | | if addNewAssist:
|
| | | assistObj = __AddNewAssist(assistMgr, curPlayer, mapID, lineID)
|
| | | |
| | | if not assistObj:
|
| | | if not reqAssistObj:
|
| | | return
|
| | |
|
| | | # 通知本仙盟玩家
|
| | | PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack([assistObj]))
|
| | | PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack([reqAssistObj]))
|
| | | # 求助信息已发送,请等待盟友支援
|
| | | PlayerControl.NotifyCode(curPlayer, "AssistRequestOK")
|
| | | # 广播仙盟请求
|
| | |
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | assistThanksMgr = PyDataManager.GetPlayerAssistThanksPyManager()
|
| | | useThanks = None
|
| | | if playerID not in assistThanksMgr.playerThanksDict:
|
| | | GameWorld.ErrLog("玩家没有可使用的协助感谢礼盒!", playerID)
|
| | | return
|
| | | useThanks = None
|
| | | playerThanksList = assistThanksMgr.playerThanksDict[playerID]
|
| | | for thanks in playerThanksList:
|
| | | if itemID == thanks.ItemID:
|
| | | useThanks = thanks
|
| | | break
|
| | | else:
|
| | | playerThanksList = assistThanksMgr.playerThanksDict[playerID]
|
| | | for thanks in playerThanksList:
|
| | | if itemID == thanks.ItemID:
|
| | | useThanks = thanks
|
| | | break
|
| | | if not useThanks:
|
| | | GameWorld.ErrLog("玩家没有该协助感谢礼盒!itemID=%s" % (itemID), playerID)
|
| | | return
|
| | | #20210226 优化为找不到协助信息也可以使用,防止地图扣除物品失败导致协助礼盒一直留着而无法使用
|
| | | #return
|
| | |
|
| | | GameWorld.DebugLog("玩家使用协助感谢礼盒!itemID=%s,isPreview=%s" % (itemID, isPreview), playerID)
|
| | | # 预览
|
| | | if isPreview:
|
| | | previewPack = ChPyNetSendPack.tagGCUseAssistThanksGiftPreview()
|
| | | if not useThanks:
|
| | | previewPack.ItemID = itemID
|
| | | previewPack.MapID = 31140 # 暂随意给一个可协助的地图ID
|
| | | NetPackCommon.SendFakePack(curPlayer, previewPack)
|
| | | return
|
| | | previewPack.ItemID = useThanks.ItemID
|
| | | previewPack.MapID = useThanks.MapID
|
| | | previewPack.LineID = useThanks.LineID
|
| | |
| | | ipyData = IpyGameDataPY.GetIpyGameData("AssistThanksGift", itemID)
|
| | | if not ipyData:
|
| | | return
|
| | | |
| | | useThanks.ThanksState = 1 # 设置为已感谢
|
| | | playerThanksList.remove(useThanks) # 移除已感谢
|
| | | |
| | | queryData = [itemID]
|
| | | QueryPlayerResult_PlayerAssist(curPlayer, "UseAssistThanksGift", queryData)
|
| | |
|
| | | if not useThanks:
|
| | | return
|
| | | useThanks.ThanksState = 1 # 设置为已感谢
|
| | | playerThanksList.remove(useThanks) # 移除已感谢
|
| | | |
| | | # 通知协助玩家可接收的感谢个数
|
| | | playerMgr = GameWorld.GetPlayerManager()
|
| | | for assistPlayerID in useThanks.AssistPlayerDict.keys():
|