| | |
| | | import GameWorld
|
| | | import ChConfig
|
| | | import PlayerControl
|
| | | import PlayerBillboard
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import PlayerViewCacheTube
|
| | |
| | | import NPCCommon
|
| | | import FBLogic
|
| | | import PlayerVip
|
| | | import IPY_GameWorld
|
| | | import PlayerActivity
|
| | |
|
| | | def DoPlayerOnDay(curPlayer):
|
| | | checkInInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HelpBattleCheckInCount)
|
| | | checkInCount = checkInInfo / 10 # 累计登记
|
| | | checkInInfo = (checkInCount + 1) * 10 + 0
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HelpBattleCheckInCount, checkInInfo)
|
| | | todayIsCheckIn = checkInInfo % 10 # 今天是否已登记
|
| | | if todayIsCheckIn:
|
| | | checkInInfo = (checkInCount + 1) * 10 + 0
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HelpBattleCheckInCount, checkInInfo)
|
| | | SyncCheckInState(curPlayer, 0, False)
|
| | | |
| | | # 重置每日已获得仙缘币
|
| | | PlayerControl.SetTodayXianyuanCoin(curPlayer, 0)
|
| | | return
|
| | |
|
| | | def DoPlayerLogin(curPlayer):
|
| | | checkInInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HelpBattleCheckInCount)
|
| | | todayIsCheckIn = checkInInfo % 10 # 今天是否已登记
|
| | | if todayIsCheckIn:
|
| | | SyncCheckInState(curPlayer, 1, True)
|
| | | return
|
| | |
|
| | | def SyncCheckInState(curPlayer, checkInState, isLogin):
|
| | | ## 同步登记状态
|
| | | checkInPack = ChPyNetSendPack.tagMCHelpBattleCheckInResult()
|
| | | checkInPack.IsOK = checkInState
|
| | | checkInPack.IsLogin = int(isLogin)
|
| | | NetPackCommon.SendFakePack(curPlayer, checkInPack)
|
| | | return
|
| | |
|
| | | def GameServer_FBHelpBattleResult(curPlayer, msgList, tick):
|
| | |
| | | if isOK:
|
| | | checkInInfo = (checkInCount + 1) * 10 + 1
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HelpBattleCheckInCount, checkInInfo)
|
| | | PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_HelpBattleCheckIn)
|
| | |
|
| | | # 没有数据缓存的话,马上同步一次
|
| | | if not haveViewCache:
|
| | | PlayerViewCacheTube.UpdateGameServerPlayerCache(curPlayer, tick, False)
|
| | |
|
| | | checkInPack = ChPyNetSendPack.tagMCHelpBattleCheckInResult()
|
| | | checkInPack.IsOK = isOK
|
| | | NetPackCommon.SendFakePack(curPlayer, checkInPack)
|
| | | SyncCheckInState(curPlayer, 1, False)
|
| | |
|
| | | GameWorld.DebugLog("FBHelpBattleResult: %s,checkInCount=%s,fightPower=%s,isOK=%s,haveViewCache=%s"
|
| | | % (cmd, checkInCount, fightPower, isOK, haveViewCache), curPlayer.GetPlayerID())
|
| | |
| | | for helpPlayerID, helpPlayerInfoDict in helpBattlePlayerDict.items():
|
| | | objID = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_HelpBattleFBObjID % helpPlayerID)
|
| | | if objID:
|
| | | if helpPlayerID == calledPlayerID:
|
| | | GameWorld.DebugLog("该助战机器人ID已经召唤过,不允许重复召唤!calledPlayerID=%s" % calledPlayerID)
|
| | | return
|
| | | calledCount += 1
|
| | | # 统计免费的未召唤的
|
| | | elif not helpPlayerInfoDict.get("NeedGoldCall", 0):
|
| | |
| | | objID = helpBattleNPC.GetID()
|
| | | GameWorld.Log("召唤助战成功: calledPlayerID=%s,objID=%s,fightPower=%s" % (calledPlayerID, objID, fightPower), playerID)
|
| | | gameFB.SetGameFBDict(ChConfig.Def_FB_HelpBattleFBObjID % calledPlayerID, objID)
|
| | | helpBattleNPC.SetDict(ChConfig.Def_NPC_Dict_AtkDelayTick, calledCount * 1000) # 按转换顺序每个延长1秒攻击,防止动作一致
|
| | | calledCount += 1
|
| | | # 设置助战属性
|
| | | npcControl = NPCCommon.NPCControl(helpBattleNPC)
|
| | | npcControl.SetHelpBattleRobotRebornAttr(fightPower)
|
| | | __DoGiveHelpBattleRobotSkill(helpBattleNPC, jobSkillDict, job, npcLV)
|
| | |
|
| | | # 通知前端召唤成功
|
| | | callResultPack = ChPyNetSendPack.tagMCHelpBattleCallResult()
|
| | | callResultPack.ObjID = objID
|
| | | callResultPack.PlayerID = calledPlayerID
|
| | | callResultPack.Job = job
|
| | | NetPackCommon.SendFakePack(curPlayer, callResultPack)
|
| | |
|
| | | # 召唤满后
|
| | |
| | | SendGameServer_RefreshHelpBattlePlayer(curPlayer, isClientRefresh=True)
|
| | | return
|
| | |
|
| | | def SendGameServer_RefreshHelpBattlePlayer(curPlayer, mapID=0, funcLineID=0, isClientRefresh=True):
|
| | | def SendGameServer_RefreshHelpBattlePlayer(curPlayer, mapID=0, funcLineID=0, isClientRefresh=False):
|
| | | ## 发送GameServer请求刷新助战玩家列表
|
| | | if not mapID:
|
| | | mapID = FBCommon.GetRecordMapID(curPlayer.GetMapID())
|
| | |
| | | costMoneyList = []
|
| | | calledPlayerIDDict = {} # 已经召唤的玩家ID字典 {playerID:[是否付费召唤, 职业], ...}
|
| | |
|
| | | refreshCount = gameFB.GetPlayerGameFBDictByKey(playerID, ChConfig.FBPD_HelpBattleRefreshCount)
|
| | | if isClientRefresh:
|
| | | refreshCount = gameFB.GetPlayerGameFBDictByKey(playerID, ChConfig.FBPD_HelpBattleRefreshCount)
|
| | | freeRefreshCount = IpyGameDataPY.GetFuncCfg("HelpBattleRefresh", 1)
|
| | | goldRefreshCount = IpyGameDataPY.GetFuncCfg("HelpBattleRefresh", 2)
|
| | | if refreshCount >= (freeRefreshCount + goldRefreshCount):
|
| | |
| | |
|
| | | # 非客户端刷新的视为重新开始,重置刷新次数
|
| | | else:
|
| | | gameFB.SetPlayerGameFBDict(playerID, ChConfig.FBPD_HelpBattleRefreshCount, 0)
|
| | | if not refreshCount:
|
| | | gameFB.SetPlayerGameFBDict(playerID, ChConfig.FBPD_HelpBattleRefreshCount, 0)
|
| | | gameFB.SetGameFBDict(ChConfig.FBPD_HelpBattleFBFightPower, ipyData.GetFightPowerMin())
|
| | | gameFB.SetGameFBDict(ChConfig.FBPD_HelpBattleFBBaseHurt, ipyData.GetRobotBaseHurt())
|
| | | GameWorld.DebugLog("设置副本战力=%s,保底伤害=%s" % (ipyData.GetFightPowerMin(), ipyData.GetRobotBaseHurt()))
|
| | |
|
| | | msgInfo = str(["Refresh", mapID, funcLineID, isClientRefresh, costMoneyList, calledPlayerIDDict])
|
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, "FBHelpBattle", msgInfo, len(msgInfo))
|
| | |
| | | return
|
| | |
|
| | | def __OnHelpBattleRecord(curPlayer, msgList, tick):
|
| | | ## 助战记录同步
|
| | | cmd, helpRecordList = msgList
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.DebugLog("__OnHelpBattleRecord %s,helpRecordList=%s" % (cmd, helpRecordList), playerID)
|
| | |
| | | addXianyuanCoinTotalTotay = 0 # 累计需要增加的今日仙缘币
|
| | | drList = []
|
| | |
|
| | | totalHelpCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HelpBattleTotalCount)
|
| | | recordPack = ChPyNetSendPack.tagMCHelpBattleRecordList()
|
| | | recordPack.RecordList = []
|
| | | for recordInfo in helpRecordList:
|
| | |
| | | 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" % (addXianyuanCoinTotal, addXianyuanCoinTotalTotay), playerID)
|
| | | GameWorld.DebugLog(" addXianyuanCoinTotal=%s,addXianyuanCoinTotalTotay=%s,totalHelpCount=%s" |
| | | % (addXianyuanCoinTotal, addXianyuanCoinTotalTotay, totalHelpCount), playerID)
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_XianyuanCoin, addXianyuanCoinTotal, addDataDict=addDataDict, isSysHint=False)
|
| | | if addXianyuanCoinTotalTotay:
|
| | | PlayerControl.AddTodayXianyuanCoin(curPlayer, addXianyuanCoinTotalTotay)
|
| | | |
| | | |
| | | # 更新总助战次数,更新排行榜
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HelpBattleTotalCount, totalHelpCount)
|
| | | if totalHelpCount >= IpyGameDataPY.GetFuncCfg("HelpBattleRefresh", 4):
|
| | | PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_FBHelpBattle, totalHelpCount)
|
| | | return
|
| | |
|
| | | def DoSingleFBAddXianyuanCoin(curPlayer, mapID, lineID):
|
| | | ## 挑战单人副本增加仙缘币,仅适用于召唤镜像助战挑战的副本
|
| | | def DoFBAddXianyuanCoin(curPlayer, mapID, lineID, isHelp=False):
|
| | | '''真人挑战副本增加仙缘币,包含过关或助战(不含镜像助战)
|
| | | @param isHelp: 是否助战的
|
| | | @return: 获得的仙缘币, 无法获得仙缘币原因(1-达到助战次数上限,2-达到每日获得仙缘币上限)
|
| | | '''
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | fbFuncIpyData = IpyGameDataPY.GetIpyGameData("FBFunc", mapID)
|
| | | fbHelpIpyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, lineID)
|
| | | if not fbFuncIpyData or not fbHelpIpyData:
|
| | | return
|
| | | if not fbFuncIpyData:
|
| | | return 0, 0
|
| | |
|
| | | reason = 0
|
| | | addCoinRate = 10000 # 基础倍率
|
| | | baseFBPoint = fbFuncIpyData.GetFBPoint() # 过关 - 基础仙缘币
|
| | | 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 += 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 todayXianyuanCoin >= playerXianyuanCoinUpper:
|
| | | # GameWorld.DebugLog("玩家今日仙缘币已达上限!todayXianyuanCoin=%s,playerXianyuanCoinUpper=%s" |
| | | # % (todayXianyuanCoin, playerXianyuanCoinUpper), playerID)
|
| | | # return
|
| | |
|
| | | relationAdd = 0
|
| | | helpBattlePlayerDict = PyGameData.g_fbHelpBattlePlayerDict.get(playerID, {})
|
| | | for helpPlayerInfoDict in helpBattlePlayerDict.values():
|
| | | relation = helpPlayerInfoDict.get("Relation", 0)
|
| | | if not relation:
|
| | | continue
|
| | | relationAddList = relationCoinAddDict.get(str(relation), [])
|
| | | relationAdd += relationAddList[1] if len(relationAddList) == 2 else 0
|
| | | relationAdd, relationPlayerID, relationPlayerName = 0, 0, ""
|
| | | |
| | | fbType = GameWorld.GetMap().GetMapFBType()
|
| | | if fbType == IPY_GameWorld.fbtSingle:
|
| | | helpBattlePlayerDict = PyGameData.g_fbHelpBattlePlayerDict.get(playerID, {})
|
| | | for helpPlayerInfoDict in helpBattlePlayerDict.values():
|
| | | 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)
|
| | |
|
| | | coinAdd = int((baseFBPoint + relationAdd) * addCoinRate / 10000.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,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.XianyuanCoinAdd = coinAddReal
|
| | | 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):
|
| | | relationAdd = 0 # 社交关系加成
|
| | | relationPlayerID = 0
|
| | | relationPlayerName = ""
|
| | | teamID = curPlayer.GetTeamID()
|
| | | if teamID not in PyGameData.g_teamFBMemRelationDict:
|
| | | return relationAdd, relationPlayerID, relationPlayerName
|
| | |
|
| | | GameWorld.DebugLog("挑战单人副本增加仙缘币: coinAdd=%s,canAddMax=%s,coinAddReal=%s" % (coinAdd, canAddMax, coinAddReal), playerID)
|
| | | addDataDict = {"MapID":mapID, "FuncLineID":lineID}
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_XianyuanCoin, coinAddReal, addDataDict=addDataDict)
|
| | | PlayerControl.AddTodayXianyuanCoin(curPlayer, coinAddReal)
|
| | | return
|
| | |
|
| | | def DoTeamFBAddXianyuanCoin(curPlayer, mapID, lineID, callPlayerID, callPlayerName, relation):
|
| | | ## 挑战组队副本增加仙缘币
|
| | | return
|
| | |
|
| | |
|
| | | friendList, memFamilyIDDict, memNameDict = PyGameData.g_teamFBMemRelationDict[teamID]
|
| | | relationList = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 3, []) # 社交关系优先级
|
| | | 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
|
| | | 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
|
| | | if not memRelation:
|
| | | continue
|
| | | relationAddList = relationCoinAddDict.get(str(memRelation), [])
|
| | | relationAdd += relationAddList[0] if len(relationAddList) == 2 else 0
|
| | | |
| | | return relationAdd, relationPlayerID, relationPlayerName
|
| | |
|