From 19e0109ec1e936204cb85362d2e3f705b8b9554c Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 03 十二月 2020 11:19:38 +0800
Subject: [PATCH] 8585 【主干】【BT】【长尾】【后端】竞技场(封包)
---
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py | 333 ++++++++++++++----------------------------------------
1 files changed, 89 insertions(+), 244 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py
index 853e3f0..923067f 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py
@@ -19,11 +19,10 @@
import IpyGameDataPY
import PlayerViewCache
import IPY_GameServer
-import PlayerControl
+import PlayerAssist
import ShareDefine
import PyGameData
import GameWorld
-import ChConfig
import random
import time
@@ -31,7 +30,6 @@
MaxRobotID = 100 # 最大机器人NPC定义ID
Def_RecType_CheckInPlayer = ShareDefine.Def_UniversalGameRecType_FBHelpBattleCheckInPlayer
-Def_RecType_HelpRecord = ShareDefine.Def_UniversalGameRecType_FBHelpBattleRecord
## 助战玩家简要信息
class HelpBattlePlayer():
@@ -48,21 +46,7 @@
self.checkInCount = 0 # 累计登记次数
self.checkInTime = 0
self.todayHelpCountDict = {} # 今天已助战次数 {(mapID, lineID):count, ...}, 通用次数时lineID默认为0
- self.todayXianyuanCoin = 0 # 今日已获得仙缘币
- return
-
-## 助战记录 - 目前只记录未通知玩家的助战信息
-class FBHelpBattleRecord():
-
- def __init__(self):
- self.callPlayerID = 0 # 召唤他的玩家ID
- self.callPlayerName = ""
- self.mapID = 0
- self.funcLineID = 0
- self.xianyuanCoinAdd = 0 # 0代表到达上限
- self.relation = 0 # 当时的关系
- self.vipLV = 0 # 当时的VIP等级
- self.recordTime = 0 # 记录的时间
+ self.getThanksGiftCountDict = {} # 协助方今日接收该感谢礼盒次数 {itemID:count, ...}
return
def OnServerStart():
@@ -83,44 +67,28 @@
helpBattlePlayer.realmLV = int(str(value5)[-3:-1])
helpBattlePlayer.job = value5 % 10
helpBattlePlayer.playerName = recData.GetStrValue1()
- helpBattlePlayer.todayXianyuanCoin = int(recData.GetStrValue2())
- helpCountDictStr = recData.GetStrValue3()
+ strValue3 = recData.GetStrValue3()
+ strValue3List = strValue3.split("|")
+ helpCountDictStr = strValue3List[0] if len(strValue3List) > 0 else "{}"
+ getThanksGiftCountDictStr = strValue3List[1] if len(strValue3List) > 1 else "{}"
+
if helpCountDictStr.startswith("{") and helpCountDictStr.endswith("}"):
helpBattlePlayer.todayHelpCountDict = eval(helpCountDictStr)
else:
GameWorld.ErrLog("LoadCheckInPlayerError: helpCountDictStr=%s" % helpCountDictStr, playerID)
+
+ if getThanksGiftCountDictStr.startswith("{") and getThanksGiftCountDictStr.endswith("}"):
+ helpBattlePlayer.getThanksGiftCountDict = eval(getThanksGiftCountDictStr)
+ else:
+ GameWorld.ErrLog("LoadCheckInPlayerError: getThanksGiftCountDictStr=%s" % getThanksGiftCountDictStr, playerID)
PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID] = helpBattlePlayer
GameWorld.Log("加载助战登记玩家记录: %s" % len(PyGameData.g_fbHelpBattleCheckInPlayerDict))
-
- helpRecordRecList = universalRecMgr.GetTypeList(Def_RecType_HelpRecord)
- for index in xrange(helpRecordRecList.Count()):
- recData = helpRecordRecList.At(index)
- playerID = recData.GetValue1()
-
- helpRecord = FBHelpBattleRecord()
- helpRecord.callPlayerID = int(recData.GetStrValue2())
- helpRecord.callPlayerName = recData.GetStrValue1()
- helpRecord.mapID = recData.GetValue2()
- helpRecord.funcLineID = recData.GetValue3()
- helpRecord.xianyuanCoinAdd = recData.GetValue4()
- helpRecord.relation = recData.GetValue5() % 10
- helpRecord.vipLV = recData.GetValue5() / 10
- helpRecord.recordTime = recData.GetTime()
-
- unNotifyRecordList = PyGameData.g_fbHelpBattleRecord.get(playerID, [])
- unNotifyRecordList.append(helpRecord)
- PyGameData.g_fbHelpBattleRecord[playerID] = unNotifyRecordList
-
- GameWorld.Log("加载玩家未同步助战: %s" % len(PyGameData.g_fbHelpBattleRecord))
- for playerID, helpList in PyGameData.g_fbHelpBattleRecord.items():
- GameWorld.Log("加载玩家未同步助战记录: %s" % (len(helpList)), playerID)
return
def OnServerClose():
GameWorld.Log("关服保存助战相关信息...")
universalRecMgr = GameWorld.GetUniversalRecMgr()
universalRecMgr.Delete(Def_RecType_CheckInPlayer)
- universalRecMgr.Delete(Def_RecType_HelpRecord)
GameWorld.Log("保存助战登记玩家记录: %s" % len(PyGameData.g_fbHelpBattleCheckInPlayerDict))
checkInPlayerRecList = universalRecMgr.GetTypeList(Def_RecType_CheckInPlayer)
@@ -133,23 +101,10 @@
recData.SetValue4(checkInPlayer.checkInCount)
recData.SetValue5(int("%d%02d%02d%d" % (checkInPlayer.playerLV, checkInPlayer.vipLV, checkInPlayer.realmLV, checkInPlayer.job)))
recData.SetStrValue1(checkInPlayer.playerName)
- recData.SetStrValue2(str(checkInPlayer.todayXianyuanCoin))
- recData.SetStrValue3(str(checkInPlayer.todayHelpCountDict).replace(" ", ""))
+ strValue3 = "%s|%s" % (str(checkInPlayer.todayHelpCountDict).replace(" ", ""),
+ str(checkInPlayer.getThanksGiftCountDict).replace(" ", ""))
+ recData.SetStrValue3(strValue3)
- GameWorld.Log("保存助战未同步记录: %s" % len(PyGameData.g_fbHelpBattleRecord))
- helpRecordRecList = universalRecMgr.GetTypeList(Def_RecType_HelpRecord)
- for playerID, helpList in PyGameData.g_fbHelpBattleRecord.items():
- GameWorld.Log("玩家未同步助战记录: %s" % (len(helpList)), playerID)
- for helpRecord in helpList:
- recData = helpRecordRecList.AddRec()
- recData.SetTime(helpRecord.recordTime)
- recData.SetValue1(playerID)
- recData.SetValue2(helpRecord.mapID)
- recData.SetValue3(helpRecord.funcLineID)
- recData.SetValue4(helpRecord.xianyuanCoinAdd)
- recData.SetValue5(helpRecord.vipLV*10+helpRecord.relation)
- recData.SetStrValue1(helpRecord.callPlayerName)
- recData.SetStrValue2(str(helpRecord.callPlayerID))
return
def HelpBattleOnDay():
@@ -166,77 +121,7 @@
GameWorld.Log("清除超时助战登记玩家: curTime=%s,checkInTime=%s" % (curTime, checkInTime), playerID)
continue
checkInPlayer.todayHelpCountDict = {}
- checkInPlayer.todayXianyuanCoin = 0
- return
-
-def OnHelpPlayerLogin(curPlayer):
- playerID = curPlayer.GetPlayerID()
- if playerID not in PyGameData.g_fbHelpBattleRecord:
- return
- unNotifyRecordList = PyGameData.g_fbHelpBattleRecord.pop(playerID)
- SendMapServer_FBHelpBattleRecord(curPlayer, unNotifyRecordList, True)
- return
-
-def OnMinuteProcess():
- ''' 每分钟处理
- 前X次登记后,分别在登记后的第X分钟赠送玩家宗门试炼一层的助战仙缘币,并伪造一份助战记录。
- 助战记录随机从助战登记库里随机挑选1名除自己外的玩家,如果没有玩家,该特殊逻辑不生效
- '''
-
- if not PyGameData.g_fbHelpBattleCheckInPlayerDict:
- return
- helpPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()
-
- curTime = int(time.time())
-
- playerManager = GameWorld.GetPlayerManager()
- newbieCheckInCount = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 2) # 新手前X次登记特殊逻辑
- sysAutoCallHelpDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattleCheckIn", 3) # 系统自动召唤助战,默认功能线路0, {登记多少分钟后:[随机地图ID, ...], ...}
- for playerID, checkInPlayer in PyGameData.g_fbHelpBattleCheckInPlayerDict.items():
-
- curPlayer = playerManager.FindPlayerByID(playerID)
-
- if not curPlayer or PlayerControl.GetIsTJG(curPlayer):
- #GameWorld.DebugLog(" 离线或脱机不处理, playerID=%s" % playerID)
- continue
-
- checkInCount = checkInPlayer.checkInCount
- if checkInCount > newbieCheckInCount:
- #GameWorld.DebugLog(" 超过规定的登记次数,不处理, playerID=%s,checkInCount=%s > newbieCheckInCount=%s"
- # % (playerID, checkInCount, newbieCheckInCount))
- continue
-
- checkInTime = checkInPlayer.checkInTime
- checkInMinutes = (curTime - checkInTime) / 60
- if checkInMinutes not in sysAutoCallHelpDict:
- #GameWorld.DebugLog(" 签到时间不满足,不处理, playerID=%s,checkInMinutes=%s not in %s"
- # % (playerID, checkInMinutes, sysAutoCallHelpDict))
- continue
-
- randHelpMapList = sysAutoCallHelpDict[checkInMinutes]
- # 随机一个不是自己的登记玩家
- for _ in xrange(20):
- randPlayerID = random.choice(helpPlayerIDList)
- if randPlayerID != playerID:
- break
-
- # 只有自己不处理
- if randPlayerID == playerID:
- #GameWorld.DebugLog(" 登记玩家只有自己,不处理, playerID=%s" % (playerID))
- continue
-
- randHelpMapID = random.choice(randHelpMapList)
- lineID = 0 # 默认0
-
- helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[randPlayerID]
- relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)
- calledPlayerID = playerID # 因为这里是系统模拟玩家被召唤助战,所以被召唤玩家就是当前被处理的玩家ID
- GameWorld.DebugLog(" 系统模拟召唤新手登记玩家: checkInMinutes=%s,playerID=%s,callPlayerID=%s" % (checkInMinutes, playerID, randPlayerID))
-
- calledPlayerDict = {calledPlayerID:relation}
- msgList = ["Call", randHelpMapID, lineID, calledPlayerDict]
- __DoFBHelpBattleCall(randPlayerID, helpBattlePlayer.playerName, msgList)
-
+ checkInPlayer.getThanksGiftCountDict = {}
return
## 是否在助战登记列表里
@@ -266,7 +151,12 @@
# 扫荡召唤
elif cmd == "SweepCall":
result = __DoFBHelpBattleSweepCall(curPlayer, msgList)
-
+
+ # 协助完成
+ elif cmd == "AssistFinish":
+ __DoAssistFinish(curPlayer, msgList)
+ return
+
if result == None:
return
@@ -279,7 +169,6 @@
playerID = curPlayer.GetPlayerID()
curCache = PlayerViewCache.FindViewCache(playerID)
haveViewCache = 1 if curCache else 0
- todayXianyuanCoin = PlayerControl.GetTodayXianyuanCoin(curPlayer)
helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict.get(playerID)
if not helpBattlePlayer:
@@ -294,11 +183,10 @@
helpBattlePlayer.vipLV = curPlayer.GetVIPLv()
helpBattlePlayer.checkInCount = checkInCount + 1
helpBattlePlayer.checkInTime = curTime
- helpBattlePlayer.todayXianyuanCoin = todayXianyuanCoin
isOK = 1 # 默认成功
- GameWorld.Log("玩家助战登记: playerLV=%s,fightPower=%s,familyID=%s,vipLV=%s,todayXianyuanCoin=%s,checkInCount=%s,haveViewCache=%s"
- % (curPlayer.GetLV(), fightPower, curPlayer.GetFamilyID(), curPlayer.GetVIPLv(), todayXianyuanCoin, checkInCount + 1, haveViewCache), playerID)
+ GameWorld.Log("玩家助战登记: playerLV=%s,fightPower=%s,familyID=%s,vipLV=%s,checkInCount=%s,haveViewCache=%s"
+ % (curPlayer.GetLV(), fightPower, curPlayer.GetFamilyID(), curPlayer.GetVIPLv(), checkInCount + 1, haveViewCache), playerID)
return [isOK, haveViewCache]
def UpdateCheckInPlayerInfo(playerID, fightPower, familyID, playerName):
@@ -320,8 +208,6 @@
helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID]
if refreshType == IPY_GameServer.CDBPlayerRefresh_LV:
helpBattlePlayer.playerLV = value
- elif refreshType == IPY_GameServer.CDBPlayerRefresh_ExAttr11:
- helpBattlePlayer.todayXianyuanCoin = value
elif refreshType == IPY_GameServer.CDBPlayerRefresh_VIPLv:
helpBattlePlayer.vipLV = value
else:
@@ -357,9 +243,11 @@
onlyFree = False
goldCallCount = 0
- nowFreeRelationCount, nowRelationCount = 0, 0
+ nowFreeRelationCount, nowRelationCount, nowRobotCount = 0, 0, 0
atleastFreeRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 1) # 至少免费社交人数,无社交则忽略
atleastRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 2) # 至少社交人数,无社交则忽略(人数包含免费社交人数)
+ atmostRobotCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 3) # 助战列表机器人至多数量
+ allowNoRelation = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 4) # 助战列表是否出现非社交关系玩家
GameWorld.DebugLog(" atleastFreeRelationCount=%s,atleastRelationCount=%s" % (atleastFreeRelationCount, atleastRelationCount))
#已经召唤的保留
@@ -377,6 +265,7 @@
nowFreeRelationCount += 1
# 机器人NPC
elif 1 <= calledPlayerID <= MaxRobotID:
+ nowRobotCount += 1
helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, job)
else:
GameWorld.ErrLog("已召唤的助战玩家找不到镜像缓存!理论上不存在该情况,镜像缓存释放会比登记有效时长多半小时!")
@@ -386,7 +275,7 @@
GameWorld.Log("已召唤的助战: %s" % str(helpBattlePlayerDict), playerID)
curTime = int(time.time())
- maxHelpPlayerSelectCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall", 1) # 最大可以选择助战的玩家个数
+ maxHelpPlayerSelectCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall", 1) # 最大可以选择助战的玩家个数
maxGoldHelpPlayerCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall", 3) # 最大付费召唤人数
checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # 登记有效时长,小时
checkInValidSeconds = checkInValidHours * 3600
@@ -395,6 +284,10 @@
random.shuffle(checkInPlayerIDList)
GameWorld.Log(" 登记助战人数=%s" % (len(checkInPlayerIDList)), playerID)
+ if not allowNoRelation:
+ atleastRelationCount = maxHelpPlayerSelectCount
+ GameWorld.DebugLog("不允许出现非社交人数,默认设置至少社交人数为最大可选择人数! %s" % atleastRelationCount)
+
# 1. 至少社交关系人数还不足的,先处理至少社交关系人数
if nowRelationCount < atleastRelationCount:
relationIDList = []
@@ -421,7 +314,7 @@
if relationID not in checkInPlayerIDList:
continue
helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[relationID]
- canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, relationID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
+ canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, relationID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)
if not canHelp:
continue
@@ -443,35 +336,37 @@
__AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
# 2. 常规添加助战人数
- for checkInPlayerID in checkInPlayerIDList:
- if len(helpBattlePlayerDict) >= maxHelpPlayerSelectCount:
- GameWorld.DebugLog(" 超过最大个数了不处理, checkInPlayerID=%s" % checkInPlayerID)
- break
- helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]
- canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
- checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)
- if not canHelp:
- continue
-
- goldCallCount, nowRelationCount, nowFreeRelationCount = \
- __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
+ if allowNoRelation:
+ for checkInPlayerID in checkInPlayerIDList:
+ if len(helpBattlePlayerDict) >= maxHelpPlayerSelectCount:
+ GameWorld.DebugLog(" 超过最大个数了不处理, checkInPlayerID=%s" % checkInPlayerID)
+ break
+ helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]
+ canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
+ checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)
+ if not canHelp:
+ continue
+
+ goldCallCount, nowRelationCount, nowFreeRelationCount = \
+ __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
# 3. 不足的机器人NPC补足
openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # 开放的职业
lackCount = maxHelpPlayerSelectCount - len(helpBattlePlayerDict)
robotID = 0 # 机器人NPC定义ID从1开始
- while lackCount > 0 and robotID < MaxRobotID:
+ while lackCount > 0 and robotID < MaxRobotID and nowRobotCount < atmostRobotCount:
robotID += 1
if robotID in helpBattlePlayerDict:
continue
lackCount -= 1
+ nowRobotCount += 1
randJob = random.choice(openJobList)
helpBattlePlayerDict[robotID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, randJob)
GameWorld.Log(" helpBattlePlayerDict=%s" % (helpBattlePlayerDict), playerID)
return [helpBattlePlayerDict]
-def __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
+def __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree=False, goldCallCount=0, maxGoldHelpPlayerCount=0):
## 常规检查是否满足助战条件
if checkInPlayerID == playerID:
@@ -556,7 +451,7 @@
def __DoFBHelpBattleSweepCall(curPlayer, msgList):
''' 扫荡助战列表刷新且直接召唤
- 随机选择免费的玩家、过滤仙缘币已达上限或溢出的玩家
+ 随机选择免费的玩家
'''
mapID, funcLineID = msgList[1:]
@@ -568,7 +463,7 @@
return [helpBattlePlayerDict]
fightPowerMin = fbHelpIpyData.GetFightPowerMin()
- fightPowerMax = fbHelpIpyData.GetFightPowerMax()
+ fightPowerMax = 0#fbHelpIpyData.GetFightPowerMax() # 扫荡暂不限制最高战力
limitLV = fbHelpIpyData.GetLVLimit()
dayFreeHelpCountInfo = fbHelpIpyData.GetDayFreeHelpCount() # 每日免费助战次数,[每日免费助战次数, 是否所有层通用]
dayFreeHelpCount = 0 # 0为无限制次数
@@ -580,20 +475,16 @@
helpCountKey = (mapID, helpCountLineID)
playerID = curPlayer.GetPlayerID()
- tagPlayerID = playerID
- tagPlayerName = curPlayer.GetName()
GameWorld.Log("扫荡刷新助战列表: mapID=%s,funcLineID=%s,helpCountLineID=%s" % (mapID, funcLineID, helpCountLineID), playerID)
curTime = int(time.time())
- maxHelpPlayerCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall", 2) # 最大助战人数
+ maxHelpPlayerCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall", 2) # 最大助战人数
checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # 登记有效时长,小时
checkInValidSeconds = checkInValidHours * 3600
- xianyuanCoinUpper = IpyGameDataPY.GetFuncCfg("HelpBattlePoint", 1) # 每日仙缘币上限
- baseHelpPoint = fbFuncIpyData.GetHelpPoint() # 助战 - 基础仙缘币
- relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # 社交关系加成 {"社交关系":[过关加成, 助战加成], ...}
+ atmostRobotCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 3) # 助战列表机器人至多数量
+ allowNoRelation = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 4) # 助战列表是否出现非社交关系玩家
- isSweep = True
onlyFree = True
checkInPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()
random.shuffle(checkInPlayerIDList) # 刷新纯随机
@@ -603,88 +494,32 @@
GameWorld.DebugLog(" 超过最大个数了不处理, checkInPlayerID=%s" % checkInPlayerID)
break
helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]
- canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
+ canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree)
if not canHelp:
continue
-
relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)
- if not __DoCallHelpPlayer(tagPlayerID, tagPlayerName, helpBattlePlayer, relation, mapID, funcLineID, helpCountKey, isSweep,
- curTime, xianyuanCoinUpper, relationCoinAddDict, baseHelpPoint):
+ if not allowNoRelation and not relation:
continue
-
+ helpBattlePlayer.todayHelpCountDict[helpCountKey] = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0) + 1
helpBattlePlayerDict[checkInPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, helpBattlePlayer.job, relation)
+ nowRobotCount = 0
# 不足的机器人NPC补足
openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # 开放的职业
lackCount = maxHelpPlayerCount - len(helpBattlePlayerDict)
robotID = 0 # 机器人NPC定义ID从1开始
- while lackCount > 0 and robotID < MaxRobotID:
+ while lackCount > 0 and robotID < MaxRobotID and nowRobotCount < atmostRobotCount:
robotID += 1
if robotID in helpBattlePlayerDict:
continue
lackCount -= 1
+ nowRobotCount += 1
randJob = random.choice(openJobList)
helpBattlePlayerDict[robotID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, randJob)
GameWorld.Log(" helpBattlePlayerDict=%s" % (helpBattlePlayerDict), playerID)
return [helpBattlePlayerDict]
-
-def __DoCallHelpPlayer(callPlayerID, callPlayerName, helpBattlePlayer, relation, mapID, funcLineID, helpCountKey, isSweep, curTime,
- xianyuanCoinUpper, relationCoinAddDict, baseHelpPoint):
-
- calledPlayerID = helpBattlePlayer.playerID
- addCoinRate = 10000 # 基础倍率
- playerXianyuanCoinUpper = xianyuanCoinUpper
- relationAddList = relationCoinAddDict.get(str(relation), [])
- relationAdd = relationAddList[1] if len(relationAddList) == 2 else 0
-
- todayXianyuanCoin = helpBattlePlayer.todayXianyuanCoin # 今日已获得仙缘币
- vipLV = helpBattlePlayer.vipLV
- if vipLV:
- xianyuanCoinUpperAdd = PlayerControl.GetPrivilegeValue(vipLV, ChConfig.VIPPrivilege_XianyuanCoinUpperAdd)
- xianyuanCoinAddPer = PlayerControl.GetPrivilegeValue(vipLV, ChConfig.VIPPrivilege_XianyuanCoinAddPer)
-
- playerXianyuanCoinUpper += xianyuanCoinUpperAdd
- addCoinRate += xianyuanCoinAddPer
-
- # 仙缘币公式=(通关仙缘币或助战仙缘币+社交关系加成)*VIP倍数
- coinAdd = int((baseHelpPoint + relationAdd) * addCoinRate / 10000.0)
- canAddMax = max(playerXianyuanCoinUpper - todayXianyuanCoin, 0)
-
- # 扫荡不可溢出
- if isSweep and coinAdd > canAddMax:
- GameWorld.DebugLog(" 今日仙缘币已达上限, calledPlayerID=%s,coinAdd=%s > canAddMax=%s" % (calledPlayerID, coinAdd, canAddMax))
- return
- coinAddReal = min(coinAdd, canAddMax) # 实际加仙缘币
-
- todayMapHelpCount = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0) + 1
- helpBattlePlayer.todayHelpCountDict[helpCountKey] = todayMapHelpCount
- GameWorld.DebugLog(" 助战增加仙缘币: todayXianyuanCoin=%s,coinUpper=%s,canAddMax=%s,coinAdd=%s,coinAddReal=%s,todayMapHelpCount=%s"
- % (todayXianyuanCoin, playerXianyuanCoinUpper, canAddMax, coinAdd, coinAddReal, todayMapHelpCount), calledPlayerID)
-
- # GameServer 直接先加
- helpBattlePlayer.todayXianyuanCoin += coinAddReal
-
- helpRecord = FBHelpBattleRecord()
- helpRecord.callPlayerID = callPlayerID # 召唤他的玩家ID
- helpRecord.callPlayerName = callPlayerName
- helpRecord.mapID = mapID
- helpRecord.funcLineID = funcLineID
- helpRecord.xianyuanCoinAdd = coinAddReal
- helpRecord.relation = relation
- helpRecord.vipLV = vipLV
- helpRecord.recordTime = curTime
-
- calledPlayer = GameWorld.GetPlayerManager().FindPlayerByID(calledPlayerID)
- # 非脱机在线直接通知地图
- if calledPlayer and not PlayerControl.GetIsTJG(calledPlayer):
- SendMapServer_FBHelpBattleRecord(calledPlayer, [helpRecord])
- else:
- unNotifyRecordList = PyGameData.g_fbHelpBattleRecord.get(calledPlayerID, [])
- unNotifyRecordList.append(helpRecord)
- PyGameData.g_fbHelpBattleRecord[calledPlayerID] = unNotifyRecordList
- return True
def __DoFBHelpBattleCall(callPlayerID, callPlayerName, msgList):
''' 助战召唤,不管最终过关与否,被召唤方都直接算助战成功,这里处理被召唤的,主动方在地图直接处理
@@ -704,31 +539,41 @@
helpCountLineID = 0
helpCountKey = (mapID, helpCountLineID)
- curTime = int(time.time())
- xianyuanCoinUpper = IpyGameDataPY.GetFuncCfg("HelpBattlePoint", 1) # 每日仙缘币上限
- baseHelpPoint = fbFuncIpyData.GetHelpPoint() # 助战 - 基础仙缘币
- relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # 社交关系加成 {"社交关系":[过关加成, 助战加成], ...}
GameWorld.DebugLog("召唤助战: mapID=%s, funcLineID=%s, helpCountKey=%s, calledPlayerDict=%s" % (mapID, funcLineID, helpCountKey, calledPlayerDict), callPlayerID)
- isSweep = False
- for calledPlayerID, relation in calledPlayerDict.items():
+ for calledPlayerID in calledPlayerDict.keys():
if calledPlayerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:
continue
helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[calledPlayerID]
- __DoCallHelpPlayer(callPlayerID, callPlayerName, helpBattlePlayer, relation, mapID, funcLineID, helpCountKey, isSweep,
- curTime, xianyuanCoinUpper, relationCoinAddDict, baseHelpPoint)
+ helpBattlePlayer.todayHelpCountDict[helpCountKey] = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0) + 1
return
-def SendMapServer_FBHelpBattleRecord(curPlayer, syncHelpRecordList, isLogin=False):
- if not syncHelpRecordList:
- return
+def __DoAssistFinish(curPlayer, msgList):
+ ## 协助完成
- helpRecordList = []
- for record in syncHelpRecordList:
- helpRecordList.append([record.callPlayerID, record.callPlayerName, record.mapID, record.funcLineID,
- record.xianyuanCoinAdd, record.relation, record.vipLV, record.recordTime])
- addXianyuanCoinMsg = str(["HelpRecord", helpRecordList, isLogin])
- curPlayer.MapServer_QueryPlayerResult(0, 0, 'FBHelpBattle', addXianyuanCoinMsg, len(addXianyuanCoinMsg))
- GameWorld.DebugLog(" MapServer_QueryPlayerResult %s" % addXianyuanCoinMsg, curPlayer.GetPlayerID())
+ liheItemID, mapID, lineID, assistPlayerIDList = msgList[1:]
+
+ assistPlayerDict = {}
+ for assistPlayerID in assistPlayerIDList:
+ if assistPlayerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:
+ continue
+ helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[assistPlayerID]
+ assistPlayerDict[assistPlayerID] = {"PlayerName":helpBattlePlayer.playerName, "Job":helpBattlePlayer.job,
+ "LV":helpBattlePlayer.playerLV, "RealmLV":helpBattlePlayer.realmLV,
+ "TodayGiftCount":helpBattlePlayer.getThanksGiftCountDict.get(liheItemID, 0)}
+
+ # 插入新协助感谢
+ PlayerAssist.AddNewAssistThanks(curPlayer, liheItemID, mapID, lineID, assistPlayerDict)
+ return
+
+def UpdateGetThanksGiftCountDict(curPlayer, itemID, updateTodayGiftCount):
+ ## 更新今日接收感谢礼盒次数
+
+ playerID = curPlayer.GetPlayerID()
+ if playerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:
+ return
+ helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID]
+ helpBattlePlayer.getThanksGiftCountDict[itemID] = updateTodayGiftCount
+ GameWorld.DebugLog(" 更新镜像协助今日接收感谢礼盒次数: itemID=%s,updateTodayGiftCount=%s" % (itemID, updateTodayGiftCount), playerID)
return
--
Gitblit v1.8.0