| | |
| | | if ipyData.GetUnlockDefault():
|
| | | # 默认激活的不处理
|
| | | continue
|
| | | lightTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceLightTime % faceID)
|
| | | expireTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceExpireTimes % faceID) # 有效时长,秒
|
| | | if not lightTime or not expireTimes:
|
| | | # 未激活或永久的不处理
|
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID):
|
| | | # 未激活的不处理
|
| | | continue
|
| | | endTime = lightTime + expireTimes
|
| | | if endTime > curTime:
|
| | | endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceEndTime % faceID)
|
| | | if not endTime or endTime > curTime:
|
| | | # 永久或未过期
|
| | | continue
|
| | | if DelFace(curPlayer, faceID, False, "FaceTimeout"):
|
| | | delFaceList.append(faceID)
|
| | |
| | | if ipyData.GetUnlockDefault():
|
| | | # 默认激活的不处理
|
| | | continue
|
| | | lightTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicLightTime % facePicID)
|
| | | expireTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicExpireTimes % facePicID) # 有效时长,秒
|
| | | if not lightTime or not expireTimes:
|
| | | # 未激活或永久的不处理
|
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID):
|
| | | # 未激活的不处理
|
| | | continue
|
| | | endTime = lightTime + expireTimes
|
| | | if endTime > curTime:
|
| | | endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicEndTime % facePicID)
|
| | | if not endTime or endTime > curTime:
|
| | | # 永久或未过期
|
| | | continue
|
| | | if DelFacePic(curPlayer, facePicID, False, "FacePicTimeout"):
|
| | | delFacePicList.append(facePicID)
|
| | |
| | | ipyExpireSeconds = ipyData.GetExpireMinutes() * 60
|
| | |
|
| | | curTime = int(time.time())
|
| | | lightTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceLightTime % faceID)
|
| | | expireTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceExpireTimes % faceID) # 有效时长,秒
|
| | | GameWorld.Log("添加头像: faceID=%s,setExpireTimes=%s,lightTime=%s,expireTimes=%s,ipyExpireSeconds=%s,curTime=%s" |
| | | % (faceID, setExpireTimes, lightTime, expireTimes, ipyExpireSeconds, curTime), playerID)
|
| | | updLightTime = lightTime
|
| | | updExpireTimes = expireTimes
|
| | | state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID)
|
| | | endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceEndTime % faceID)
|
| | | GameWorld.Log("添加头像: faceID=%s,setExpireTimes=%s,state=%s,endTime=%s,ipyExpireSeconds=%s,curTime=%s" |
| | | % (faceID, setExpireTimes, state, endTime, ipyExpireSeconds, curTime), playerID)
|
| | | updEndTime = endTime
|
| | |
|
| | | # 指定时长的,如GM指定
|
| | | if setExpireTimes >= 0:
|
| | | updLightTime = curTime
|
| | | updExpireTimes = setExpireTimes
|
| | | GameWorld.Log(" 指定头像时长: faceID=%s,updLightTime=%s,updExpireTimes=%s" % (faceID, updLightTime, updExpireTimes), playerID)
|
| | | if setExpireTimes > 0:
|
| | | updEndTime = curTime + setExpireTimes
|
| | | GameWorld.Log(" 指定头像时长: faceID=%s,updEndTime=%s" % (faceID, updEndTime), playerID)
|
| | |
|
| | | # 永久
|
| | | elif ipyExpireSeconds == 0:
|
| | | updLightTime = curTime
|
| | | updExpireTimes = 0
|
| | | GameWorld.Log(" 添加永久头像: faceID=%s,updLightTime=%s,updExpireTimes=%s" % (faceID, updLightTime, updExpireTimes), playerID)
|
| | | elif ipyExpireSeconds == 0 or setExpireTimes == 0:
|
| | | updEndTime = 0
|
| | | GameWorld.Log(" 添加永久头像: faceID=%s,updEndTime=%s" % (faceID, updEndTime), playerID)
|
| | |
|
| | | else:
|
| | | # 未过期
|
| | | if lightTime and expireTimes and (lightTime + expireTimes) > curTime:
|
| | | updExpireTimes = expireTimes + ipyExpireSeconds
|
| | | GameWorld.Log(" 累加头像时长: faceID=%s,updLightTime=%s,updExpireTimes=%s" % (faceID, updLightTime, updExpireTimes), playerID)
|
| | | if endTime > curTime:
|
| | | updEndTime = endTime + ipyExpireSeconds
|
| | | GameWorld.Log(" 累加头像时长: faceID=%s,updEndTime=%s" % (faceID, updEndTime), playerID)
|
| | | else:
|
| | | updLightTime = curTime
|
| | | updExpireTimes = ipyExpireSeconds
|
| | | GameWorld.Log(" 重新激活头像: faceID=%s,updLightTime=%s,updExpireTimes=%s" % (faceID, updLightTime, updExpireTimes), playerID)
|
| | | updEndTime = curTime + ipyExpireSeconds
|
| | | GameWorld.Log(" 重新激活头像: faceID=%s,updEndTime=%s" % (faceID, updEndTime), playerID)
|
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceLightTime % faceID, updLightTime)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceExpireTimes % faceID, updExpireTimes)
|
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID, 1)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceEndTime % faceID, updEndTime)
|
| | | RefreshFaceAttr(curPlayer)
|
| | | SyncFaceInfo(curPlayer, [faceID])
|
| | | return True
|
| | |
| | | if ipyData.GetUnlockDefault():
|
| | | return
|
| | | GameWorld.Log("删除头像: faceID=%s,notifyMail=%s" % (faceID, notifyMail), playerID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceLightTime % faceID, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceExpireTimes % faceID, 0)
|
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FaceEndTime % faceID, 0)
|
| | | # 星级不重置,重新激活后再次生效
|
| | |
|
| | | if curPlayer.GetFace() == faceID:
|
| | |
| | | ipyExpireSeconds = ipyData.GetExpireMinutes() * 60
|
| | |
|
| | | curTime = int(time.time())
|
| | | lightTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicLightTime % facePicID)
|
| | | expireTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicExpireTimes % facePicID) # 有效时长,秒
|
| | | GameWorld.Log("添加头像框: facePicID=%s,setExpireTimes=%s,lightTime=%s,expireTimes=%s,ipyExpireSeconds=%s,curTime=%s" |
| | | % (facePicID, setExpireTimes, lightTime, expireTimes, ipyExpireSeconds, curTime), playerID)
|
| | | updLightTime = lightTime
|
| | | updExpireTimes = expireTimes
|
| | | state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID)
|
| | | endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicEndTime % facePicID)
|
| | | GameWorld.Log("添加头像框: facePicID=%s,setExpireTimes=%s,state=%s,endTime=%s,ipyExpireSeconds=%s,curTime=%s" |
| | | % (facePicID, setExpireTimes, state, endTime, ipyExpireSeconds, curTime), playerID)
|
| | | updEndTime = endTime
|
| | |
|
| | | # 指定时长的,如GM指定
|
| | | if setExpireTimes >= 0:
|
| | | updLightTime = curTime
|
| | | updExpireTimes = setExpireTimes
|
| | | GameWorld.Log(" 指定头像框时长: facePicID=%s,updLightTime=%s,updExpireTimes=%s" % (facePicID, updLightTime, updExpireTimes), playerID)
|
| | | if setExpireTimes > 0:
|
| | | updEndTime = curTime + setExpireTimes
|
| | | GameWorld.Log(" 指定头像框时长: facePicID=%s,updEndTime=%s" % (facePicID, updEndTime), playerID)
|
| | |
|
| | | # 永久
|
| | | elif ipyExpireSeconds == 0:
|
| | | updLightTime = curTime
|
| | | updExpireTimes = 0
|
| | | GameWorld.Log(" 添加永久头像框: facePicID=%s,updLightTime=%s,updExpireTimes=%s" % (facePicID, updLightTime, updExpireTimes), playerID)
|
| | | elif ipyExpireSeconds == 0 or setExpireTimes == 0:
|
| | | updEndTime = 0
|
| | | GameWorld.Log(" 添加永久头像框: facePicID=%s,updEndTime=%s" % (facePicID, updEndTime), playerID)
|
| | |
|
| | | else:
|
| | | # 未过期
|
| | | if lightTime and expireTimes and (lightTime + expireTimes) > curTime:
|
| | | updExpireTimes = expireTimes + ipyExpireSeconds
|
| | | GameWorld.Log(" 累加头像框时长: facePicID=%s,updLightTime=%s,updExpireTimes=%s" % (facePicID, updLightTime, updExpireTimes), playerID)
|
| | | if endTime > curTime:
|
| | | updEndTime = endTime + ipyExpireSeconds
|
| | | GameWorld.Log(" 累加头像框时长: facePicID=%s,updEndTime=%s" % (facePicID, updEndTime), playerID)
|
| | | else:
|
| | | updLightTime = curTime
|
| | | updExpireTimes = ipyExpireSeconds
|
| | | GameWorld.Log(" 重新激活头像框: facePicID=%s,updLightTime=%s,updExpireTimes=%s" % (facePicID, updLightTime, updExpireTimes), playerID)
|
| | | updEndTime = curTime + ipyExpireSeconds
|
| | | GameWorld.Log(" 重新激活头像框: facePicID=%s,updEndTime=%s" % (facePicID, updEndTime), playerID)
|
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicLightTime % facePicID, updLightTime)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicExpireTimes % facePicID, updExpireTimes)
|
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID, 1)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicEndTime % facePicID, updEndTime)
|
| | | RefreshFacePicAttr(curPlayer)
|
| | | SyncFacePicInfo(curPlayer, [facePicID])
|
| | | return True
|
| | |
| | | if ipyData.GetUnlockDefault():
|
| | | return
|
| | | GameWorld.Log("删除头像框: facePicID=%s,notifyMail=%s" % (facePicID, notifyMail), playerID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicLightTime % facePicID, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicExpireTimes % facePicID, 0)
|
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FacePicEndTime % facePicID, 0)
|
| | | # 星级不重置,重新激活后再次生效
|
| | |
|
| | | if curPlayer.GetFacePic() == facePicID:
|
| | |
| | | PlayerControl.SendMailByKey(notifyMail, [playerID], [], [facePicID])
|
| | | return True
|
| | |
|
| | | def GetFaceEndTime(curPlayer, faceID, ipyData=None):
|
| | | ## 头像结束时间戳
|
| | | # @return: -1-未激活;0-永久;>0-具体结束时间戳
|
| | | lightTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceLightTime % faceID)
|
| | | expireTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceExpireTimes % faceID)
|
| | | if lightTime:
|
| | | if expireTimes:
|
| | | return lightTime + expireTimes
|
| | | return 0
|
| | | if not ipyData:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFace", faceID)
|
| | | if ipyData and ipyData.GetUnlockDefault():
|
| | | return 0
|
| | | return -1
|
| | |
|
| | | def IsFaceCanUse(curPlayer, faceID, ipyData=None):
|
| | | ## 头像是否可用
|
| | | # 这里不判断严谨的过期时间,即不对比当前时间,只要endTime>=0即可
|
| | | # 过期逻辑由过期函数定时处理删除即可,可能有1分钟延迟
|
| | | return GetFaceEndTime(curPlayer, faceID, ipyData) >= 0
|
| | | state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID)
|
| | | if state:
|
| | | return True
|
| | |
|
| | | def GetFacePicEndTime(curPlayer, facePicID, ipyData=None):
|
| | | ## 头像框结束时间戳
|
| | | # @return: -1-未激活;0-永久;>0-具体结束时间戳
|
| | | lightTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicLightTime % facePicID)
|
| | | expireTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicExpireTimes % facePicID)
|
| | | if lightTime:
|
| | | if expireTimes:
|
| | | return lightTime + expireTimes
|
| | | return 0
|
| | | if not ipyData:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFacePic", facePicID)
|
| | | if ipyData and ipyData.GetUnlockDefault():
|
| | | return 0
|
| | | return -1
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFace", faceID)
|
| | | if ipyData:
|
| | | if ipyData.GetUnlockDefault():
|
| | | return True
|
| | | |
| | | return False
|
| | |
|
| | | def IsFacePicCanUse(curPlayer, facePicID, ipyData=None):
|
| | | ## 头像框是否可用
|
| | | # 这里不判断严谨的过期时间,即不对比当前时间,只要endTime>=0即可
|
| | | # 过期逻辑由过期函数定时处理删除即可,可能有1分钟延迟
|
| | | return GetFacePicEndTime(curPlayer, facePicID, ipyData) >= 0
|
| | | state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID)
|
| | | if state:
|
| | | return True
|
| | |
|
| | | def GetEndTimeStr(endTime):
|
| | | endTimeStr = "未激活"
|
| | | if endTime == 0:
|
| | | endTimeStr = "永久"
|
| | | elif endTime > 0:
|
| | | endTimeStr = GameWorld.ChangeTimeNumToStr(endTime)
|
| | | return endTimeStr
|
| | | if not ipyData:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("PlayerFacePic", facePicID)
|
| | | if ipyData:
|
| | | if ipyData.GetUnlockDefault():
|
| | | return True
|
| | | |
| | | return False
|
| | |
|
| | | def RefreshFaceAttr(curPlayer):
|
| | | CalcFaceAttr(curPlayer)
|
| | |
| | |
|
| | | faceList = []
|
| | | for faceID in syncIDList:
|
| | | lightTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceLightTime % faceID)
|
| | | if not lightTime and faceIDList == None:
|
| | | state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FaceState, faceID)
|
| | | if not state and faceIDList == None:
|
| | | continue
|
| | | face = ChPyNetSendPack.tagMCFace()
|
| | | face.FaceID = faceID
|
| | | face.LightTime = lightTime
|
| | | face.ExpireTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceExpireTimes % faceID)
|
| | | face.State = state
|
| | | face.EndTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceEndTime % faceID)
|
| | | face.Star = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FaceStar % faceID)
|
| | | faceList.append(face)
|
| | |
|
| | |
| | |
|
| | | facePicList = []
|
| | | for facePicID in syncIDList:
|
| | | lightTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicLightTime % facePicID)
|
| | | if not lightTime and facePicIDList == None:
|
| | | state = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_FacePicState, facePicID)
|
| | | if not state and facePicIDList == None:
|
| | | continue
|
| | | facePic = ChPyNetSendPack.tagMCFacePic()
|
| | | facePic.FacePicID = facePicID
|
| | | facePic.LightTime = lightTime
|
| | | facePic.ExpireTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicExpireTimes % facePicID)
|
| | | facePic.State = state
|
| | | facePic.EndTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicEndTime % facePicID)
|
| | | facePic.Star = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FacePicStar % facePicID)
|
| | | facePicList.append(facePic)
|
| | |
|