| | |
| | | import GameWorld
|
| | | import ChConfig
|
| | | import PlayerControl
|
| | | import PlayerBillboard
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import PlayerViewCacheTube
|
| | |
| | | import GameMap
|
| | | import NPCCommon
|
| | | import FBLogic
|
| | | import PlayerVip
|
| | | import IPY_GameWorld
|
| | | import PlayerActivity
|
| | | import ItemControler
|
| | |
|
| | | import time
|
| | | MaxRobotID = 100 # 最大机器人NPC定义ID
|
| | |
|
| | | def DoPlayerOnDay(curPlayer):
|
| | | checkInInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HelpBattleCheckInCount)
|
| | |
| | | checkInInfo = checkInCount * 10 + 0
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HelpBattleCheckInCount, checkInInfo)
|
| | | SyncCheckInState(curPlayer, 0, False)
|
| | | |
| | | # 重置每日已获得仙缘币
|
| | | 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):
|
| | |
| | | # 刷新
|
| | | elif cmd == "Refresh":
|
| | | __OnHelpBattleRefreshResult(curPlayer, msgList, tick)
|
| | | |
| | | # 助战记录
|
| | | elif cmd == "HelpRecord":
|
| | | __OnHelpBattleRecord(curPlayer, msgList, tick)
|
| | |
|
| | | # 扫荡召唤
|
| | | elif cmd == "SweepCall":
|
| | |
| | | if not fbFuncIpyData:
|
| | | return
|
| | |
|
| | | reason = 0
|
| | | addCoinRate = 10000 # 基础倍率
|
| | | baseFBPoint = fbFuncIpyData.GetFBPoint() # 过关 - 基础仙缘币
|
| | | |
| | | xianyuanCoinUpper = IpyGameDataPY.GetFuncCfg("HelpBattlePoint", 1) # 每日仙缘币上限
|
| | | relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # 社交关系加成 {"社交关系":[过关加成, 助战加成], ...} |
| | | todayXianyuanCoin = PlayerControl.GetTodayXianyuanCoin(curPlayer) # 今日已获得仙缘币
|
| | | playerXianyuanCoinUpper = xianyuanCoinUpper
|
| | | if curPlayer.GetVIPLv():
|
| | | playerXianyuanCoinUpper += PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_XianyuanCoinUpperAdd)
|
| | | addCoinRate += PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_XianyuanCoinAddPer)
|
| | | |
| | | relation, relationAdd = 0, 0
|
| | | for helpPlayerInfoDict in helpBattlePlayerDict.values():
|
| | | relation = helpPlayerInfoDict.get("Relation", 0)
|
| | | if not relation:
|
| | | assistPlayerIDList = []
|
| | | for helpPlayerID in helpBattlePlayerDict.keys():
|
| | | if helpPlayerID <= MaxRobotID:
|
| | | continue
|
| | | relationAddList = relationCoinAddDict.get(str(relation), [])
|
| | | relationAdd += relationAddList[0] if len(relationAddList) == 2 else 0
|
| | | |
| | | coinAdd = 0
|
| | | if baseFBPoint:
|
| | | coinAdd = int((baseFBPoint + relationAdd) * addCoinRate / 10000.0)
|
| | | canAddMax = max(playerXianyuanCoinUpper - todayXianyuanCoin, 0)
|
| | | coinAddReal = min(coinAdd, canAddMax) # 实际加仙缘币
|
| | | if canAddMax == 0 and not reason:
|
| | | reason = 2
|
| | | |
| | | GameWorld.DebugLog("扫荡副本增加仙缘币: baseFBPoint=%s,relationAdd=%s,addCoinRate=%s,coinAdd=%s,canAddMax=%s,coinAddReal=%s" |
| | | % (baseFBPoint, relationAdd, addCoinRate, coinAdd, canAddMax, coinAddReal), playerID)
|
| | | if coinAddReal:
|
| | | addDataDict = {"MapID":mapID, "FuncLineID":funcLineID, "IsSweep":1}
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_XianyuanCoin, coinAddReal, addDataDict=addDataDict)
|
| | | PlayerControl.AddTodayXianyuanCoin(curPlayer, coinAddReal)
|
| | | |
| | | assistPlayerIDList.append(helpPlayerID)
|
| | | __DoGivePlayerAssistLihe(curPlayer, mapID, funcLineID, assistPlayerIDList)
|
| | | |
| | | #扫荡结果给奖励等
|
| | | FBLogic.OnPlayerFBHelpBattleSweepResult(curPlayer, mapID, funcLineID, helpBattlePlayerDict, coinAddReal, reason)
|
| | | |
| | | # 通知自己获得仙缘币
|
| | | msgPack = ChPyNetSendPack.tagMCAddXianyuanCoinMsg()
|
| | | msgPack.MapID = mapID
|
| | | msgPack.FuncLineID = funcLineID
|
| | | msgPack.Relation = relation
|
| | | msgPack.RelationCoinAdd = relationAdd
|
| | | msgPack.XianyuanCoinAdd = coinAddReal
|
| | | msgPack.Reason = reason
|
| | | #msgPack.CallPlayerID = relationPlayerID
|
| | | #msgPack.CallPlayerName = relationPlayerName
|
| | | msgPack.NameLen = len(msgPack.CallPlayerName)
|
| | | msgPack.IsSweep = 1
|
| | | NetPackCommon.SendFakePack(curPlayer, msgPack)
|
| | | FBLogic.OnPlayerFBHelpBattleSweepResult(curPlayer, mapID, funcLineID, helpBattlePlayerDict)
|
| | | return
|
| | |
|
| | | def __OnHelpBattleRecord(curPlayer, msgList, tick):
|
| | | ## 助战记录同步
|
| | | cmd, helpRecordList, isLogin = msgList
|
| | | def DoFBHelpBattleFinish(curPlayer, mapID, lineID):
|
| | | ## 副本助战完成
|
| | | |
| | | assistPlayerIDList = []
|
| | | gameFB = GameWorld.GetGameFB()
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.DebugLog("__OnHelpBattleRecord %s,helpRecordList=%s" % (cmd, helpRecordList), playerID)
|
| | | helpBattlePlayerDict = PyGameData.g_fbHelpBattlePlayerDict.get(playerID, {})
|
| | | for helpPlayerID in helpBattlePlayerDict.keys():
|
| | | objID = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_HelpBattleFBObjID % helpPlayerID)
|
| | | if not objID:
|
| | | continue
|
| | | if helpPlayerID <= MaxRobotID:
|
| | | continue
|
| | | assistPlayerIDList.append(helpPlayerID)
|
| | | __DoGivePlayerAssistLihe(curPlayer, mapID, lineID, assistPlayerIDList)
|
| | |
|
| | | addXianyuanCoinTotal = 0 # 累计需要增加的仙缘币
|
| | | addXianyuanCoinTotalTotay = 0 # 累计需要增加的今日仙缘币
|
| | | drList = []
|
| | | |
| | | totalHelpCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HelpBattleTotalCount)
|
| | | recordPack = ChPyNetSendPack.tagMCHelpBattleRecordList()
|
| | | recordPack.RecordList = []
|
| | | for recordInfo in helpRecordList:
|
| | | callPlayerID, callPlayerName, mapID, funcLineID, xianyuanCoinAdd, relation, vipLV, recordTime = recordInfo
|
| | | timeStr = GameWorld.ChangeTimeNumToStr(recordTime)
|
| | | isSameDay = GameWorld.CheckTimeIsSameServerDayEx(recordTime)
|
| | | |
| | | record = ChPyNetSendPack.tagMCHelpBattleRecord()
|
| | | record.CallPlayerID = callPlayerID
|
| | | record.CallPlayerName = callPlayerName
|
| | | record.NameLen = len(record.CallPlayerName)
|
| | | record.MapID = mapID
|
| | | record.FuncLineID = funcLineID
|
| | | record.XianyuanCoinAdd = xianyuanCoinAdd
|
| | | record.Relation = relation
|
| | | record.VIPLV = vipLV
|
| | | record.HelpTime = timeStr
|
| | | recordPack.RecordList.append(record)
|
| | | drList.append({"CallPlayerID":callPlayerID, "MapID":mapID, "FuncLineID":funcLineID, "XianyuanCoinAdd":xianyuanCoinAdd, |
| | | "Relation":relation, "VIPLV":vipLV, "HelpTime":timeStr, "IsSameDay":isSameDay})
|
| | | addXianyuanCoinTotal += xianyuanCoinAdd
|
| | | if isSameDay:
|
| | | addXianyuanCoinTotalTotay += xianyuanCoinAdd
|
| | | totalHelpCount += 1
|
| | | |
| | | recordPack.RecordCount = len(recordPack.RecordList)
|
| | | NetPackCommon.SendFakePack(curPlayer, recordPack)
|
| | | |
| | | addDataDict = {"HelpList":drList}
|
| | | 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):
|
| | | PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_FBHelpBattle, totalHelpCount)
|
| | | return
|
| | |
|
| | | def DoFBAddXianyuanCoin(curPlayer, mapID, lineID, isHelp=False):
|
| | | '''真人挑战副本增加仙缘币,包含过关或助战(不含镜像助战)
|
| | | @param isHelp: 是否助战的
|
| | | @return: 获得的仙缘币, 无法获得仙缘币原因(1-达到助战次数上限,2-达到每日获得仙缘币上限)
|
| | | '''
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | fbFuncIpyData = IpyGameDataPY.GetIpyGameData("FBFunc", mapID)
|
| | | if not fbFuncIpyData:
|
| | | return 0, 0
|
| | | def __DoGivePlayerAssistLihe(curPlayer, mapID, lineID, assistPlayerIDList):
|
| | | ## 给玩家协助礼盒奖励
|
| | |
|
| | | reason = 0
|
| | | addCoinRate = 10000 # 基础倍率
|
| | | if not isHelp:
|
| | | baseFBPoint = fbFuncIpyData.GetFBPoint() # 过关 - 基础仙缘币
|
| | | else:
|
| | | baseFBPoint = fbFuncIpyData.GetHelpPoint() # 助战
|
| | | dayHelpCountMax = fbFuncIpyData.GetDayHelpCountMax() # 真实助战每日可获得仙缘币次数
|
| | | if dayHelpCountMax:
|
| | | todayHelpCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FBRealHelpCount % mapID)
|
| | | if todayHelpCount >= dayHelpCountMax:
|
| | | baseFBPoint = 0
|
| | | reason = 1
|
| | | GameWorld.DebugLog("达到每日助战可获得仙缘币次数上限!无法再获得!mapID=%s" % (mapID), playerID)
|
| | | else:
|
| | | todayHelpCount += 1
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FBRealHelpCount % mapID, todayHelpCount)
|
| | | GameWorld.DebugLog("增加每日助战可获得仙缘币次数!mapID=%s,todayHelpCount=%s" % (mapID, todayHelpCount), playerID)
|
| | | |
| | | xianyuanCoinUpper = IpyGameDataPY.GetFuncCfg("HelpBattlePoint", 1) # 每日仙缘币上限
|
| | | relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # 社交关系加成 {"社交关系":[过关加成, 助战加成], ...} |
| | | todayXianyuanCoin = PlayerControl.GetTodayXianyuanCoin(curPlayer) # 今日已获得仙缘币
|
| | | playerXianyuanCoinUpper = xianyuanCoinUpper
|
| | | if curPlayer.GetVIPLv():
|
| | | playerXianyuanCoinUpper += PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_XianyuanCoinUpperAdd)
|
| | | addCoinRate += PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_XianyuanCoinAddPer)
|
| | | |
| | | #达到上限也需要记录,所以这里暂不限制
|
| | | #if todayXianyuanCoin >= playerXianyuanCoinUpper:
|
| | | # GameWorld.DebugLog("玩家今日仙缘币已达上限!todayXianyuanCoin=%s,playerXianyuanCoinUpper=%s" |
| | | # % (todayXianyuanCoin, playerXianyuanCoinUpper), playerID)
|
| | | # return
|
| | | if not assistPlayerIDList:
|
| | | return
|
| | |
|
| | | relation, relationAdd, relationPlayerID, relationPlayerName = 0, 0, 0, ""
|
| | | liheItemID = 0
|
| | | mapAssistGiftDict = IpyGameDataPY.GetFuncEvalCfg("AssistAward", 2, {})
|
| | | mapID = FBCommon.GetRecordMapID(mapID)
|
| | | if str(mapID) in mapAssistGiftDict:
|
| | | liheItemID = mapAssistGiftDict[str(mapID)][0]
|
| | | if not liheItemID:
|
| | | return
|
| | |
|
| | | fbType = GameWorld.GetMap().GetMapFBType()
|
| | | if fbType == IPY_GameWorld.fbtSingle:
|
| | | gameFB = GameWorld.GetGameFB()
|
| | | helpBattlePlayerDict = PyGameData.g_fbHelpBattlePlayerDict.get(playerID, {})
|
| | | 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:
|
| | | 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)
|
| | | canAddMax = max(playerXianyuanCoinUpper - todayXianyuanCoin, 0)
|
| | | coinAddReal = min(coinAdd, canAddMax) # 实际加仙缘币
|
| | | if canAddMax == 0 and not reason:
|
| | | reason = 2
|
| | | |
| | | if isHelp and not relationPlayerID:
|
| | | relationPlayerID = 1
|
| | | #GameWorld.DebugLog("没有助战目标则设置relationPlayerID为1,标记是助战的!")
|
| | | |
| | | GameWorld.DebugLog("挑战副本增加仙缘币: baseFBPoint=%s,relationAdd=%s,addCoinRate=%s,coinAdd=%s,canAddMax=%s,coinAddReal=%s,relationPlayerID=%s" |
| | | % (baseFBPoint, relationAdd, addCoinRate, coinAdd, canAddMax, coinAddReal, relationPlayerID), playerID)
|
| | | if coinAddReal:
|
| | | addDataDict = {"MapID":mapID, "FuncLineID":lineID}
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_XianyuanCoin, coinAddReal, addDataDict=addDataDict)
|
| | | PlayerControl.AddTodayXianyuanCoin(curPlayer, coinAddReal)
|
| | | |
| | | # 通知自己获得仙缘币
|
| | | 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)
|
| | | NetPackCommon.SendFakePack(curPlayer, msgPack)
|
| | | return coinAddReal, reason
|
| | | ItemControler.GivePlayerItemOrMail(curPlayer, [[liheItemID, 1, 0]])
|
| | | |
| | | msgInfo = str(["AssistFinish", liheItemID, mapID, lineID, assistPlayerIDList])
|
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, "FBHelpBattle", msgInfo, len(msgInfo))
|
| | | return
|
| | |
|
| | |
|
| | | def __GetTeamFBMemRelationInfo(curPlayer, isHelp, leavePlayerID):
|
| | | ## 计算队员间相互加成信息,离线玩家不算
|