From 5d7c40ddd0f7a7589f5dd2e7835de8094f63d803 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 04 十二月 2018 15:16:53 +0800
Subject: [PATCH] 1 已删除 PyNetPack
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py | 143 ++++++++++++++++++++++++++++++++++-------------
1 files changed, 102 insertions(+), 41 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py
index e766f97..dc8ef28 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py
@@ -34,17 +34,31 @@
import IPY_GameWorld
import PlayerActivity
+import time
+
def DoPlayerOnDay(curPlayer):
checkInInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HelpBattleCheckInCount)
checkInCount = checkInInfo / 10 # 累计登记
todayIsCheckIn = checkInInfo % 10 # 今天是否已登记
if todayIsCheckIn:
- checkInInfo = (checkInCount + 1) * 10 + 0
+ checkInInfo = checkInCount * 10 + 0
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HelpBattleCheckInCount, checkInInfo)
SyncCheckInState(curPlayer, 0, False)
# 重置每日已获得仙缘币
- PlayerControl.SetTodayXianyuanCoin(curPlayer, 0)
+ ondaySetXianyuanCoin = 0
+ ondayLoginSetXianyuanCoin = curPlayer.GetDictByKey(ChConfig.Def_PDict_TodayXianyuanCoinOnLogin)
+ if ondayLoginSetXianyuanCoin:
+ # 这里做时间比较,预防玩家登录后就没有再切换地图,再次在该地图过天会导致设置值错误问题
+ loginAddCoinTime = curPlayer.GetDictByKey(ChConfig.Def_PDict_LoginAddTodayXianyuanCoinTime)
+ if GameWorld.CheckTimeIsSameServerDayEx(loginAddCoinTime):
+ ondaySetXianyuanCoin = ondayLoginSetXianyuanCoin
+ GameWorld.DebugLog("玩家过天时,登录增加仙缘币有值,仍然是同一天,仙缘币重置为登录时增加的仙缘币!ondayLoginSetXianyuanCoin=%s" % ondayLoginSetXianyuanCoin)
+ else:
+ GameWorld.DebugLog("玩家过天时,登录增加仙缘币有值,但是不是同一天了,仙缘币重置为0!")
+ PlayerControl.SetTodayXianyuanCoin(curPlayer, ondaySetXianyuanCoin)
+ GameWorld.DebugLog("玩家过天设置今日已获得仙缘币: ondaySetXianyuanCoin=%s,ondayLoginSetXianyuanCoin=%s"
+ % (ondaySetXianyuanCoin, ondayLoginSetXianyuanCoin))
return
def DoPlayerLogin(curPlayer):
@@ -382,7 +396,7 @@
def __OnHelpBattleRecord(curPlayer, msgList, tick):
## 助战记录同步
- cmd, helpRecordList = msgList
+ cmd, helpRecordList, isLogin = msgList
playerID = curPlayer.GetPlayerID()
GameWorld.DebugLog("__OnHelpBattleRecord %s,helpRecordList=%s" % (cmd, helpRecordList), playerID)
@@ -420,12 +434,16 @@
NetPackCommon.SendFakePack(curPlayer, recordPack)
addDataDict = {"HelpList":drList}
- GameWorld.DebugLog(" addXianyuanCoinTotal=%s,addXianyuanCoinTotalTotay=%s,totalHelpCount=%s"
- % (addXianyuanCoinTotal, addXianyuanCoinTotalTotay, totalHelpCount), playerID)
+ GameWorld.DebugLog(" addXianyuanCoinTotal=%s,addXianyuanCoinTotalTotay=%s,totalHelpCount=%s,isLogin=%s"
+ % (addXianyuanCoinTotal, addXianyuanCoinTotalTotay, totalHelpCount, isLogin), playerID)
PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_XianyuanCoin, addXianyuanCoinTotal, addDataDict=addDataDict, isSysHint=False)
if addXianyuanCoinTotalTotay:
PlayerControl.AddTodayXianyuanCoin(curPlayer, addXianyuanCoinTotalTotay)
-
+ if isLogin:
+ curPlayer.SetDict(ChConfig.Def_PDict_TodayXianyuanCoinOnLogin, addXianyuanCoinTotalTotay)
+ curPlayer.SetDict(ChConfig.Def_PDict_LoginAddTodayXianyuanCoinTime, int(time.time()))
+ GameWorld.Log(" 登录时今日助战信息: addXianyuanCoinTotalTotay=%s" % (addXianyuanCoinTotalTotay), playerID)
+
# 更新总助战次数,更新排行榜
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HelpBattleTotalCount, totalHelpCount)
if totalHelpCount >= IpyGameDataPY.GetFuncCfg("HelpBattleRefresh", 4):
@@ -474,20 +492,25 @@
# % (todayXianyuanCoin, playerXianyuanCoinUpper), playerID)
# return
- relationAdd, relationPlayerID, relationPlayerName = 0, 0, ""
+ relation, relationAdd, relationPlayerID, relationPlayerName = 0, 0, 0, ""
fbType = GameWorld.GetMap().GetMapFBType()
if fbType == IPY_GameWorld.fbtSingle:
+ gameFB = GameWorld.GetGameFB()
helpBattlePlayerDict = PyGameData.g_fbHelpBattlePlayerDict.get(playerID, {})
- for helpPlayerInfoDict in helpBattlePlayerDict.values():
+ for helpPlayerID, helpPlayerInfoDict in helpBattlePlayerDict.items():
+ objID = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_HelpBattleFBObjID % helpPlayerID)
+ if not objID:
+ continue
relation = helpPlayerInfoDict.get("Relation", 0)
if not relation:
continue
relationAddList = relationCoinAddDict.get(str(relation), [])
relationAdd += relationAddList[0] if len(relationAddList) == 2 else 0
elif fbType == IPY_GameWorld.fbtTeam:
- relationAdd, relationPlayerID, relationPlayerName = __GetTeamFBMemRelationInfo(curPlayer, relationCoinAddDict, isHelp)
-
+ if playerID in PyGameData.g_teamFBMemRelationAddDict:
+ relation, relationAdd, relationPlayerID, relationPlayerName = PyGameData.g_teamFBMemRelationAddDict.pop(playerID)
+
coinAdd = 0
if baseFBPoint:
coinAdd = int((baseFBPoint + relationAdd) * addCoinRate / 10000.0)
@@ -507,62 +530,100 @@
msgPack = ChPyNetSendPack.tagMCAddXianyuanCoinMsg()
msgPack.MapID = mapID
msgPack.FuncLineID = lineID
+ msgPack.Relation = relation
+ msgPack.RelationCoinAdd = relationAdd
msgPack.XianyuanCoinAdd = coinAddReal
+ msgPack.Reason = reason
msgPack.CallPlayerID = relationPlayerID
msgPack.CallPlayerName = relationPlayerName
msgPack.NameLen = len(msgPack.CallPlayerName)
- msgPack.Reason = reason
NetPackCommon.SendFakePack(curPlayer, msgPack)
return coinAddReal, reason
-def __GetTeamFBMemRelationInfo(curPlayer, relationCoinAddDict, isHelp):
+def __GetTeamFBMemRelationInfo(curPlayer, isHelp, leavePlayerID):
+ ## 计算队员间相互加成信息,离线玩家不算
+ relation = 0
relationAdd = 0 # 社交关系加成
relationPlayerID = 0
relationPlayerName = ""
teamID = curPlayer.GetTeamID()
if teamID not in PyGameData.g_teamFBMemRelationDict:
- return relationAdd, relationPlayerID, relationPlayerName
+ return relation, relationAdd, relationPlayerID, relationPlayerName
+ playerManager = GameWorld.GetMapCopyPlayerManager()
friendList, memFamilyIDDict, memNameDict = PyGameData.g_teamFBMemRelationDict[teamID]
relationList = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 3, []) # 社交关系优先级
+ relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # 社交关系加成 {"社交关系":[过关加成, 助战加成], ...}
playerID = curPlayer.GetPlayerID()
familyID = curPlayer.GetFamilyID()
if isHelp:
# 助战的随便取一位优先级最高的即可
- for checkRelation in relationList:
- memRelation, relationPlayerID = 0, 0
- if checkRelation == 1:
- for memPlayerID in memFamilyIDDict.keys():
- if [playerID, memPlayerID] in friendList:
- memRelation = checkRelation
- relationPlayerID = memPlayerID
- break
- if checkRelation == 2:
- for memPlayerID, memFamilyID in memFamilyIDDict.items():
- if playerID != memPlayerID and familyID and familyID == memFamilyID:
- memRelation = checkRelation
- relationPlayerID = memPlayerID
- break
- if memRelation and relationPlayerID:
- relationAddList = relationCoinAddDict.get(str(memRelation), [])
- relationAdd += relationAddList[1] if len(relationAddList) == 2 else 0
- relationPlayerName = memNameDict[relationPlayerID]
- return relationAdd, relationPlayerID, relationPlayerName
+ for memPlayerID, memFamilyID in memFamilyIDDict.items():
+ memRelation, relationPlayerID = __GetTemMemRelation(playerManager, playerID, familyID, memPlayerID, memFamilyID, relationList, friendList, leavePlayerID)
+ if not memRelation:
+ continue
+ relation = memRelation
+ relationAddList = relationCoinAddDict.get(str(memRelation), [])
+ relationAdd += relationAddList[1] if len(relationAddList) == 2 else 0
+ relationPlayerName = memNameDict[relationPlayerID]
+ return relation, relationAdd, relationPlayerID, relationPlayerName
+
else:
# 非助战享受所有队员加成
for memPlayerID, memFamilyID in memFamilyIDDict.items():
- memRelation = 0
- for checkRelation in relationList:
- if [playerID, memPlayerID] in friendList:
- memRelation = checkRelation
- break
- if playerID != memPlayerID and familyID and familyID == memFamilyID:
- memRelation = checkRelation
- break
+ memRelation = __GetTemMemRelation(playerManager, playerID, familyID, memPlayerID, memFamilyID, relationList, friendList, leavePlayerID)[0]
if not memRelation:
continue
+ if memRelation == relationList[0]:
+ relation = memRelation
+ elif relation:
+ relation = memRelation
relationAddList = relationCoinAddDict.get(str(memRelation), [])
relationAdd += relationAddList[0] if len(relationAddList) == 2 else 0
- return relationAdd, relationPlayerID, relationPlayerName
+ return relation, relationAdd, relationPlayerID, relationPlayerName
+
+def __GetTemMemRelation(playerManager, playerID, familyID, memPlayerID, memFamilyID, relationList, friendList, leavePlayerID):
+ ## 离线玩家不算社交关系
+ if leavePlayerID and memPlayerID == leavePlayerID:
+ return 0, 0
+ memPlayer = playerManager.FindPlayerByID(memPlayerID)
+ if memPlayer == None or memPlayer.IsEmpty():
+ return 0, 0
+ for checkRelation in relationList:
+ if checkRelation == 1:
+ if [playerID, memPlayerID] in friendList:
+ return checkRelation, memPlayerID
+ if checkRelation == 2:
+ if playerID != memPlayerID and familyID and familyID == memFamilyID:
+ return checkRelation, memPlayerID
+ return 0, 0
+
+def RefershTeamFBMemRelation(tick, leavePlayerID=0):
+ ## 刷新组队副本队员关系
+ playerManager = GameWorld.GetMapCopyPlayerManager()
+ for i in xrange(playerManager.GetPlayerCount()):
+ player = playerManager.GetPlayerByIndex(i)
+ if player == None or player.IsEmpty():
+ continue
+ if leavePlayerID and player.GetPlayerID() == leavePlayerID:
+ PyGameData.g_teamFBMemRelationAddDict.pop(leavePlayerID, 0)
+ continue
+ relation, relationAdd, relationPlayerID, relationPlayerName = __GetTeamFBMemRelationInfo(player, FBCommon.GetIsHelpFight(player), leavePlayerID)
+ PyGameData.g_teamFBMemRelationAddDict[player.GetPlayerID()] = [relation, relationAdd, relationPlayerID, relationPlayerName]
+
+ for index in xrange(playerManager.GetPlayerCount()):
+ player = playerManager.GetPlayerByIndex(index)
+ if player == None or player.IsEmpty():
+ continue
+ if leavePlayerID and player.GetPlayerID() == leavePlayerID:
+ continue
+ FBLogic.DoFBHelp(player, tick)
+
+ return
+
+def GetTeamFBMemRelationInfo(playerID):
+ if playerID not in PyGameData.g_teamFBMemRelationAddDict:
+ return 0, 0
+ return PyGameData.g_teamFBMemRelationAddDict[playerID][:2]
--
Gitblit v1.8.0