#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package GM.Commands.GMT_Worship
|
#
|
# @todo:ºǫ́¹ÜÀíĤ°Ý
|
# @author hxp
|
# @date 2024-07-02
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ºǫ́¹ÜÀíĤ°Ý
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2024-07-02 16:30"""
|
#-------------------------------------------------------------------------------
|
|
import GMCommon
|
import ChConfig
|
import GameWorship
|
import PyDataManager
|
import PlayerViewCache
|
import IpyGameDataPY
|
import ShareDefine
|
import GameWorld
|
|
|
## Ö´ÐÐÂß¼
|
# @param curPlayer µ±Ç°Íæ¼Ò
|
# @param gmCmdDict: ÃüÁî×Öµä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def OnExec(orderId, gmCmdDict):
|
GameWorld.Log("GMT_Worship %s" % gmCmdDict)
|
queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
|
playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
|
worshipType = GameWorld.ToIntDef(gmCmdDict.get('worshipType', ''), 0)
|
worshipValue = GameWorld.ToIntDef(gmCmdDict.get('worshipValue', ''), 0)
|
zoneID = GameWorld.ToIntDef(gmCmdDict.get('zoneID', ''), 0)
|
days = GameWorld.ToIntDef(gmCmdDict.get('days', ''), 0)
|
|
opType = gmCmdDict.get('opType', '')
|
|
if not opType or not worshipType:
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_ParamErr)
|
return
|
|
if opType == "view":
|
worshipList = __GetServerWorshipList()
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_Success, {"WorshipList":worshipList})
|
return
|
|
if worshipType in ShareDefine.Def_WorshipTypeCross:
|
if not GameWorld.IsCrossServer():
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_ParamErr, "player run in cross server.")
|
return
|
else:
|
if GameWorld.IsCrossServer():
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_ParamErr, "do not run in cross server.")
|
return
|
|
ipyData = IpyGameDataPY.GetIpyGameData("Worship", worshipType, worshipValue)
|
if not ipyData:
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_ParamErr, "worshipType value ipyData is not exist.")
|
return
|
|
playerManager = GameWorld.GetPlayerManager()
|
|
if queryType == "playerID":
|
tagPlayerID = GameWorld.ToIntDef(playerFind, 0)
|
else:
|
if queryType == GMCommon.Def_GMKey_PlayerAccID:
|
queryType = ChConfig.queryType_sqtPlayerByAccID
|
tagPlayer = playerManager.FindPlayerByAccID(str(playerFind))
|
|
elif queryType == GMCommon.Def_GMKey_PlayerName:
|
queryType = ChConfig.queryType_sqtPlayerByName
|
tagPlayer = playerManager.FindPlayerByName(str(playerFind))
|
|
else:
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_ParamErr)
|
return
|
|
if not tagPlayer:
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_PlayerOfLine)
|
return
|
tagPlayerID = tagPlayer.GetPlayerID()
|
|
cacheDict = PlayerViewCache.GetCachePropDataDict(PlayerViewCache.FindViewCache(tagPlayerID))
|
if not cacheDict:
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_NoTag, "can not found player view cache")
|
return {}
|
Name = cacheDict.get("Name", "")
|
AccID = cacheDict.get("AccID", "")
|
|
if opType == "add":
|
if not GameWorship.AddWorshipPlayer(tagPlayerID, worshipType, worshipValue, days, zoneID):
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_Unknow, "add error.")
|
return
|
|
elif opType == "del":
|
GameWorship.DelWorshipPlayer(worshipType, worshipValue, tagPlayerID)
|
|
else:
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_ParamErr)
|
return
|
|
worshipList = __GetServerWorshipList()
|
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_Success, {"AccID":AccID, "Name":Name, "PlayerID":tagPlayerID, "WorshipList":worshipList})
|
return
|
|
def __GetServerWorshipList():
|
worshipList = []
|
playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
|
recDict = playerRecMgr.GetPlayerRecDataDict(ShareDefine.Def_PlayerRecType_WorshipPlayer)
|
for recDataList in recDict.values():
|
for recData in recDataList:
|
playerInfo = GameWorship.GetModelShowInfo(recData)
|
worshipList.append({"PlayerID":recData.GetPlayerID(),
|
"AddTime":GameWorld.ChangeTimeNumToStr(recData.GetTime()),
|
"WorshipType":GameWorship.GetWorshipType(recData),
|
"WorshipValue":GameWorship.GetWorshipValue(recData),
|
"Days":GameWorship.GetWorshipDays(recData),
|
"ZoneID":GameWorship.GetWorshipZoneID(recData),
|
"AccID":playerInfo.get("AccID", ""),
|
"Name":playerInfo.get("Name", ""),
|
})
|
return worshipList
|
|
|