| | |
| | | import PlayerViewCache
|
| | | import PlayerBillboard
|
| | | import GameServerRefresh
|
| | | import IPY_PlayerDefine
|
| | | import IPY_GameWorld
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | |
| | | import PlayerActivity
|
| | | import ChNetSendPack
|
| | | import PlayerState
|
| | | import PlayerBeauty
|
| | | import PlayerOnline
|
| | | import PlayerTask
|
| | | import PlayerMail
|
| | |
| | | # @remarks
|
| | | def FamilyNotify(familyID, msgMark, msgParamList=[]):
|
| | | #GameWorld.GetPlayerManager().BroadcastCountry_NotifyCode(0, familyID, msgMark, __GetNotifyCodeList(msgParamList))
|
| | | PlayerFamily.NotifyAllFamilyMemberMsg(familyID, msgMark, msgParamList)
|
| | | #PlayerFamily.NotifyAllFamilyMemberMsg(familyID, msgMark, msgParamList)
|
| | | return
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
| | | playerIDList.remove(playerID)
|
| | | return
|
| | |
|
| | |
|
| | | def OnPlayerLogin(curPlayer):
|
| | | DoGMForbidenTalkOnLogin(curPlayer)
|
| | | curPlayer.SetDict(ChConfig.Def_PDict_DayOnlineCalcTime, int(time.time()))
|
| | | return
|
| | |
|
| | | def PlayerOnDay(curPlayer):
|
| | | |
| | | PayCoinOnDay(curPlayer)
|
| | | |
| | | # 重置今日累计在线时长统计
|
| | | NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayOnlineTime, 0)
|
| | | curPlayer.SetDict(ChConfig.Def_PDict_DayOnlineCalcTime, int(time.time()))
|
| | | return
|
| | |
|
| | | def OnMinute(serverTime):
|
| | | |
| | | # 定时记录当前在线玩家今日总在线时长
|
| | | if [serverTime.hour, serverTime.minute] in [[23, 55], [23, 59]]:
|
| | | playerManager = GameWorld.GetPlayerManager()
|
| | | for i in xrange(playerManager.GetPlayerCount()):
|
| | | curPlayer = playerManager.GetPlayerByIndex(i)
|
| | | if not GameWorld.IsNormalPlayer(curPlayer):
|
| | | continue
|
| | | RecordTodayOnlineTime(curPlayer)
|
| | | return
|
| | |
|
| | | def RecordTodayOnlineTime(curPlayer):
|
| | | '''更新记录今日累计在线时长
|
| | | 【注】不能在onday调用,不然可能导致流向记录是错误的
|
| | | 比如玩家离线了多天后上线,会触发onday,此时记录的在线时长实际是上一次离线天的在线时长
|
| | | |
| | | 【正确调用时机】
|
| | | 1. 每次离线
|
| | | 2. 每日的 23:59 分触发一次,理论上可能最多少统计1分钟,暂无视
|
| | | '''
|
| | | onlineTime = GetOnlineTimeToday(curPlayer)
|
| | | DataRecordPack.DR_OnlineTimeToday(curPlayer, onlineTime)
|
| | | return
|
| | |
|
| | | def GetOnlineTimeToday(curPlayer):
|
| | | ## 获取今日累计在线时长,即使不离线过天也需要重置重新计算
|
| | | curTime = int(time.time())
|
| | | onlineTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayOnlineTime)
|
| | | calcTime = curPlayer.GetDictByKey(ChConfig.Def_PDict_DayOnlineCalcTime) # 计算用,不用存db
|
| | | if not calcTime:
|
| | | calcTime = curTime
|
| | | curPlayer.SetDict(ChConfig.Def_PDict_DayOnlineCalcTime, curTime)
|
| | | |
| | | passTime = curTime - calcTime
|
| | | if passTime > 0:
|
| | | onlineTime += passTime
|
| | | onlineTime = min(onlineTime, 86400) # 3600*24=86400 # 最大累计1天时长
|
| | | GameWorld.DebugLogEx("今日累计在线时长: %s, passTime=%s", onlineTime, passTime, curPlayer.GetPlayerID())
|
| | | NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayOnlineTime, onlineTime)
|
| | | return onlineTime
|
| | |
|
| | |
|
| | | ##更新保存玩家在线时间
|
| | | # @param curPlayer 玩家实例
|
| | | # @param tick 时间tick
|
| | |
| | | #宠物下线逻辑, 这里要进行排行榜, 优先做, 避免玩家光环等属性影响宠物属性失效
|
| | | PetControl.DoLogic_PetInfo_OnLeaveServer(curPlayer, tick)
|
| | |
|
| | | RecordTodayOnlineTime(curPlayer)
|
| | | #清除下线消失的buff, 在更新排行榜之前
|
| | | __DisconnectClearBuff(curPlayer, tick)
|
| | |
|
| | |
| | | #召唤兽死亡
|
| | | KillPlayerSummonNPC(curPlayer)
|
| | | #更新从本地图离线信息
|
| | | PyGameData.g_disconnectPlayer[curPlayer.GetPlayerID()] = [tick, curPlayer.GetPosX(), curPlayer.GetPosY()]
|
| | | GameWorld.DebugLog("玩家从本地图离线: %s" % PyGameData.g_disconnectPlayer, curPlayer.GetPlayerID())
|
| | | GameWorld.DebugLog("玩家从本地图离线", curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | def GetPlayerLeaveServerTick(playerID):
|
| | | # 获取玩家从本地图中离线时的tick, 最大支持1小时, 如果有需要大于1小时的请调整超时限制
|
| | | # 注: 返回值为0时,只能代表玩家不是在本地图离线1小时内,并不能代表玩家当前是否在线状态,可能在其他地图
|
| | | if playerID not in PyGameData.g_disconnectPlayer:
|
| | | return 0
|
| | | return PyGameData.g_disconnectPlayer[playerID][0]
|
| | |
|
| | | def GetPlayerLeaveServerPos(playerID):
|
| | | # 获取玩家从本地图中离线时的坐标
|
| | | # 注:使用本函数时,一定要先使用函数 GetPlayerLeaveServerTick 确保是从本地图中离线的才可使用
|
| | | # @return: posX, posY
|
| | | if playerID not in PyGameData.g_disconnectPlayer:
|
| | | return 0, 0
|
| | | return PyGameData.g_disconnectPlayer[playerID][1:3]
|
| | |
|
| | | def RemoveTimeoutLeaveServerPlayerInfo(tick):
|
| | | # 暂定每天凌晨5点执行一次
|
| | | for playerID, leaveInfo in PyGameData.g_disconnectPlayer.items():
|
| | | leaveTick = leaveInfo[0]
|
| | | if tick - leaveTick > 3600000: # 清除超时1小时的记录
|
| | | PyGameData.g_disconnectPlayer.pop(playerID)
|
| | | return
|
| | |
|
| | | def RemoveLeaveServerPlayerInfo(playerID):
|
| | | # 上线移除在本地图下线的记录
|
| | | if playerID in PyGameData.g_disconnectPlayer:
|
| | | PyGameData.g_disconnectPlayer.pop(playerID)
|
| | | GameWorld.DebugLog("进入本地图,移除上次在本地图离线记录!", playerID)
|
| | | return
|
| | |
|
| | |
|
| | | ##清除回收战
|
| | | # @param None
|
| | |
| | | # 累加未结算战锤 - 经验
|
| | | unXiantaoCntExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntExp)
|
| | | NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntExp, unXiantaoCntExp + price)
|
| | | # 累加最后一档品质装备保底
|
| | | lastColorEquipLucky = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LastColorEquipLucky)
|
| | | NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LastColorEquipLucky, lastColorEquipLucky + price)
|
| | | # 累加未结算战锤 - 装备
|
| | | AddUnXiantaoCntEquip(curPlayer, price)
|
| | | # 累加未结算战锤 - 战利品
|
| | |
| | | for itemID, upperCnt in DailyBootyUpperList:
|
| | | if upperCnt <= 0:
|
| | | continue
|
| | | upperCnt = GetBootyUpper(curPlayer, itemID, upperCnt)
|
| | | if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BootyDropToday % itemID) >= upperCnt:
|
| | | continue
|
| | | unXiantaoCntBooty = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntBooty % itemID)
|
| | |
| | |
|
| | | DataRecordPack.DR_UseMoney(curPlayer, eventName, type_Price, price, infoDict) # 流向
|
| | | return
|
| | |
|
| | | def GetBootyUpper(curPlayer, itemID, baseUpper):
|
| | | ## 战利品掉落上限
|
| | | dropUpper = baseUpper
|
| | | addPer = 0
|
| | | addPer += PlayerBeauty.GetBeautyEffInfo(curPlayer, PlayerBeauty.EffType_BootyPer)[0] # 战利品上限提高百分比
|
| | | |
| | | # 其他功能增加上限,可扩展
|
| | | |
| | | if addPer:
|
| | | dropUpper = int(baseUpper * (100 + addPer) / 100.0)
|
| | | GameWorld.DebugLogEx("提高战利品掉落上限: itemID=%s,baseUpper=%s,addPer=%s,dropUpper=%s", itemID, baseUpper, addPer, dropUpper)
|
| | | |
| | | return dropUpper
|
| | |
|
| | | ## 付款以后后续操作(金子)
|
| | | # @param curPlayer 玩家实例
|
| | |
| | | curPlayer.SetLV(aftLV, False) # 这里不再通知GameServer
|
| | | #PlayerTongTianLing.AddTongTianTaskValue(curPlayer, ChConfig.TTLTaskType_LVUp, aftLV - befLV)
|
| | | PlayerTask.UpdTaskValue(curPlayer, ChConfig.TaskType_LV)
|
| | | ChPlayer.OnPlayerBaseInfoChange(curPlayer, IPY_PlayerDefine.CDBPlayerRefresh_LV) # 等级
|
| | |
|
| | | #if aftFreePoint > befFreePoint:
|
| | | # curPlayer.SetFreePoint(aftFreePoint)
|
| | |
| | | def GetTitleID(curPlayer): return curPlayer.GetExAttr3()
|
| | | def SetTitleID(curPlayer, titleID):
|
| | | curPlayer.SetExAttr3(titleID, False, False)
|
| | | PlayerFamily.RefreshFamilyMember(curPlayer)
|
| | | ChPlayer.OnPlayerBaseInfoChange(curPlayer, IPY_PlayerDefine.CDBPlayerRefresh_ExAttr3) # 称号
|
| | | return
|
| | |
|
| | | ## 协助目标玩家ID
|
| | |
| | | return
|
| | |
|
| | | ## 玩家所属服务器组ID
|
| | | def GetPlayerServerGroupID(curPlayer): return curPlayer.GetExAttr13()
|
| | | def UpdPlayerServerGroupID(curPlayer):
|
| | | # 更新自己的服务器组ID, 跨服服务器不处理
|
| | | if GameWorld.IsCrossServer():
|
| | | return
|
| | | serverGroupID = GameWorld.GetServerGroupID()
|
| | | if not serverGroupID:
|
| | | return
|
| | | playerServerGroupID = curPlayer.GetExAttr13()
|
| | | if playerServerGroupID != serverGroupID:
|
| | | curPlayer.SetExAttr13(serverGroupID, False, True)
|
| | | GameWorld.DebugLog("更新玩家所属服务器组ID: serverGroupID=%s" % serverGroupID)
|
| | | return
|
| | | def GetPlayerServerGroupID(curPlayer): return 0
|
| | |
|
| | | # 境界难度等级
|
| | | def GetRealmDifficulty(curPlayer): return 0
|
| | |
| | | #PlayerBillboard.UpdatePlayerFPTotalBillboard(curPlayer)
|
| | | #if beforeFightPower != totalFightPower:
|
| | | # CrossPlayerData.OnPlayerFightPowerChange(curPlayer)
|
| | | ChPlayer.OnPlayerBaseInfoChange(curPlayer, IPY_PlayerDefine.CDBPlayerRefresh_FightPower) # 战力
|
| | | return
|
| | |
|
| | | ## 设置模块战斗力,支持超过20E = 模块公式战力 + 技能附加战力 + 其他附加战力
|
| | |
| | | # atkInterval *= 100
|
| | |
|
| | | return atkInterval
|
| | |
|
| | | ##玩家增加真气
|
| | | # @param curPlayer 玩家
|
| | | # @param value 增加数值
|
| | | # @param canOverbrim 可否溢出(默认不行) |
| | | # @param isSysMsg 是否系统提示(默认需要) |
| | | # @return None
|
| | | def PlayerAddZhenQi(curPlayer, addValue, canOverbrim=False, isSysMsg=True, eventName="unknown", eventData=""):
|
| | | if addValue <= 0:
|
| | | return True
|
| | | |
| | | curZhenQi = GetZhenQi(curPlayer) # 当前真气
|
| | | |
| | | value = curZhenQi + addValue
|
| | | |
| | | if value == curZhenQi:
|
| | | #真气值没有改变
|
| | | return False
|
| | | SetZhenQi(curPlayer, value)
|
| | | return True
|
| | |
|
| | |
|
| | | ##玩家减少真气
|
| | | # @param curPlayer 玩家
|
| | | # @param lostValue 减少数值
|
| | | # @return None
|
| | | def PlayerLostZhenQi(curPlayer, lostValue, eventName="unknown", eventData=""):
|
| | | if lostValue <= 0:
|
| | | return True
|
| | | |
| | | curZhenQi = GetZhenQi(curPlayer) # 当前真气
|
| | | |
| | | value = max(0, curZhenQi - lostValue)
|
| | | if value < 0:
|
| | | GameWorld.ErrLog("curZhenQi = %s, lostValue = %s" % (curZhenQi, lostValue))
|
| | | return False
|
| | | SetZhenQi(curPlayer, value)
|
| | | return True
|
| | |
|
| | | ## SP真气值 - 暂废弃 ExAttr7、ExAttr8 改为专精选择通知,用于前端表现其他玩家的不同专精特效
|
| | | def GetZhenQi(curPlayer): return 0
|
| | | def SetZhenQi(curPlayer, totalZhenQi): return
|
| | |
|
| | | #===============================================================================
|
| | | # #@warning: ExAttr6~ExAttr10, 新增2个布尔默认参数, 是否通知客户端, 是否通知GameServer, 默认值为False
|