hxp
5 天以前 67a84dc38db8f7d0f85b03e2b06ba728d95c1e82
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Zhenbaoge.py
@@ -15,53 +15,124 @@
#"""Version = 2024-10-29 17:30"""
#-------------------------------------------------------------------------------
import GameWorld
import PlayerControl
import PlayerFamily
import ChConfig
import GameWorld
import CrossPlayer
import PlayerControl
import PlayerFamilyZhenbaoge
import PlayerFamily
import DBDataMgr
import random
import time
## GM命令执行入口
#  @param curPlayer 当前玩家
#  @param msgList 参数列表 [addSkillID]
#  @return None
#  @remarks 函数详细说明.
def GetGMServerIDList(curPlayer):
    ## 获取命令额外发送到其他服务器,如跨服
    crossServerID = DBDataMgr.GetFamilyMgr().GetCurCrossServerID()
    if crossServerID:
        GameWorld.DebugAnswer(curPlayer, "本服公会已互通跨服ID:%s" % crossServerID)
        return [crossServerID]
    GameWorld.DebugAnswer(curPlayer, "本服公会未互通")
    return []
def OnExec(curPlayer, msgList):
    
    isMainServer = GameWorld.IsMainServer()
    if not msgList:
        GameWorld.DebugAnswer(curPlayer, "重置仙盟珍宝阁: Zhenbaoge 0")
        if not isMainServer:
            return
        GameWorld.DebugAnswer(curPlayer, "-----%s-----" % GameWorld.GetCurrentDataTimeStr())
        GameWorld.DebugAnswer(curPlayer, "重置公会珍宝阁: Zhenbaoge 0")
        GameWorld.DebugAnswer(curPlayer, "重置今日状态值: Zhenbaoge d")
        GameWorld.DebugAnswer(curPlayer, "设置退仙盟时间: Zhenbaoge ft x分钟前")
        GameWorld.DebugAnswer(curPlayer, "设置退公会时间: Zhenbaoge ft x分钟前")
        GameWorld.DebugAnswer(curPlayer, "新增假砍价数据: Zhenbaoge 次数 [随机A值 至B值]")
        GameWorld.DebugAnswer(curPlayer, "AB值没有填则按常规砍价价格计算")
        return
    
    if not curPlayer.GetFamilyID():
        GameWorld.DebugAnswer(curPlayer, "没有仙盟")
    crossPlayer = CrossPlayer.GetCrossPlayerMgr().FindCrossPlayer(curPlayer.GetPlayerID())
    if not crossPlayer:
        return
    
    isSendGameServer = False
    familyID = crossPlayer.GetFamilyID()
    if not familyID:
        GameWorld.DebugAnswer(crossPlayer, "没有仙盟")
        return
    value1 = msgList[0]
    if value1 == 0:
        isSendGameServer = True
    elif value1 == "d":
    # 默认本服执行的
    if value1 == "d":
        if not isMainServer:
            return
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyZhenbaogeCut, 0)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyZhenbaogeBuy, 0)
        PlayerFamily.Sync_ZhenbaogeInfo(curPlayer)
        PlayerFamilyZhenbaoge.Sync_ZhenbaogeInfo(curPlayer)
        GameWorld.DebugAnswer(curPlayer, "重置珍宝阁玩家今日状态OK")
        return
    
    elif value1 == "ft":
        if not isMainServer:
            return
        minutes = msgList[1] if len(msgList) > 1 else 0
        leaveFamilyTimeEx = int(time.time()) - minutes * 60
        PlayerControl.SetLeaveFamilyTimeEx(curPlayer, leaveFamilyTimeEx)
        GameWorld.DebugAnswer(curPlayer, "设置退仙盟时间:%s" % GameWorld.ChangeTimeNumToStr(leaveFamilyTimeEx))
        return
    
    else:
        isSendGameServer = True
    if isMainServer:
        crossServerID = DBDataMgr.GetFamilyMgr().GetCurCrossServerID()
        if crossServerID:
            # 本服公会已互通不再执行本服命令
            return
        
    return isSendGameServer
    # 本服、跨服通用
    familyMgr = DBDataMgr.GetFamilyMgr()
    curFamily = familyMgr.FindFamily(familyID)
    if not curFamily:
        GameWorld.DebugAnswer(crossPlayer, "玩家未加入公会!")
        return
    if GameWorld.IsCrossServer():
        zoneID = familyMgr.GetFamilyZoneID(familyID)
        GameWorld.DebugAnswer(crossPlayer, "跨服公会ID:%s,zoneID=%s" % (familyID, zoneID))
    if value1 == 0:
        PlayerFamilyZhenbaoge.OnZhenbaogeReset(curFamily)
        GameWorld.DebugAnswer(crossPlayer, "重置仙盟珍宝阁OK")
        return
    #添加假砍价
    gActionData = PlayerFamilyZhenbaoge.GetZhenbaogeActionData(familyID, PlayerFamilyZhenbaoge.ActionGlobalID)
    if not gActionData:
        GameWorld.DebugAnswer(crossPlayer, "请先重置珍宝阁")
        return
    familyAction = DBDataMgr.GetFamilyActionMgr().GetFamilyAction(familyID, PlayerFamilyZhenbaoge.ActionType)
    actionCount = familyAction.Count()
    fackCount = value1
    randValue1 = msgList[1] if len(msgList) > 1 else 0
    randValue2 = msgList[2] if len(msgList) > 2 else 0
    syncActionDataList = [gActionData]
    startFackID = 1000 + actionCount
    FakeName = GameWorld.GbkToCode("假名字")
    for fackID in range(startFackID, startFackID + fackCount):
        playerID = fackID
        playerName = "%s%s" % (FakeName, fackID)
        if randValue1 and randValue2 and randValue1 <= randValue2:
            cutPrice = random.randint(randValue1, randValue2)
        else:
            cutPrice = PlayerFamilyZhenbaoge.CalcCutPrice(curFamily, gActionData, playerID)
        if not cutPrice:
            continue
        actionData = PlayerFamilyZhenbaoge.AddCutPrice(familyID, playerID, playerName, cutPrice, gActionData, False)
        syncActionDataList.append(actionData)
        nowPrice = PlayerFamilyZhenbaoge.GetFAPriceFinal(gActionData)
        GameWorld.DebugAnswer(crossPlayer, "砍价人次:%s,砍价:%s,现价:%s" % (fackID % 1000, cutPrice, nowPrice))
    PlayerFamily.SendFamilyAction(syncActionDataList)
    nowPrice = PlayerFamilyZhenbaoge.GetFAPriceFinal(gActionData)
    GameWorld.DebugAnswer(crossPlayer, "添加假砍价数:%s,总砍价数:%s,当前价格:%s" % (fackCount, familyAction.Count() - 1, nowPrice))
    return