%% ---------------------------------------------------------------------------
%% @doc pp_gm
%% @author ming_up@foxmail.com
%% @since  2016-08-31
%% @deprecated  秘籍文件
%% ---------------------------------------------------------------------------
-module(pp_gm).
-include("common.hrl").
-include("server.hrl").
-include("figure.hrl").
-include("attr.hrl").
-include("predefine.hrl").
-include("server_env.hrl").
-include("server_kv.hrl").
-include("scene.hrl").
-include("goods.hrl").
-include("battle.hrl").
-include("guild.hrl").
-include("team.hrl").
-include("def_daily.hrl").
-include("def_module.hrl").
-include("def_recharge.hrl").
-include("rec_recharge.hrl").
-include("skill.hrl").
-include("daily.hrl").
-include("def_id_create.hrl").
-include("custom_act.hrl").
-include("def_goods.hrl").
-include("dungeon.hrl").
-include("relationship.hrl").
-include("clusters_zone.hrl").
-include("def_fun.hrl").
-include("errcode.hrl").
-include("task.hrl").
-include("chat.hrl").
-include("transform.hrl").
-include("equipment.hrl").
-include("vip.hrl").
-include("server_env.hrl").
-export([handle/3]).

handle(Cmd, Status, Data) ->
    case config:get_server_debug() of
        true  ->
            do_handle(Cmd, Status, Data);
        false ->
            ignore
    end.

%% [{秘籍代码指令，秘籍名称，秘籍参数},...].
get_gm_ui_data(Status) ->
    [
        {"id", "角色id", [Status#player_status.id]}
        , {"goods",   "增加物品", ["物品类型id", "数量"]}
        , {"scurrency",   "增加特殊货币", ["物品类型id", "数量"]}
        , {"clean", "清理背包", []}
        , {"money", "设置金钱", ["100000"]}
        , {"recharge", "充值商品", ["商品id:如1"]}
        , {"pt",    "调试协议", ["协议编号", "协议数据"]}
        , {"mon",   "创建怪物", ["10000001", "1"]}
        , {"startgather", "开始录制(战士)", []}
        , {"stopgather", "结束录制", []}
        , {"addgrowth", "增加公会成长值", ["1000"]}
        , {"adddonate", "增加公会贡献", ["1000"]}
        , {"addgfunds", "增加公会资金", ["1000"]}
        , {"dummy", "创建假人", ["人数","分组(0不会打架)"]}
        , {"scene", "强制切换场景", ["1000"]}
        , {"addsceneline", "当前场景加分线", []}
        , {"exp",   "增加经验", ["1000"]}
        , {"gmexp", "增加经验(GM)", ["1000"]}
        , {"lv",    "升级",     ["10"]}
        , {"lv2",   "升级到N级",   ["300"]}
        , {"turn",  "转生",     []}
        , {"task",  "接任务",   ["任务id"]}
        , {"dtask", "移除任务",   ["任务id"]}
        , {"finishtask", "完成任务", ["任务id"]}
        , {"finishalltask", "完成所有的任务", []}
        , {"cleanactask", "清理已接任务", ["0:当前已接;1:历史所有"]}
        , {"finitask", "完成当前主线任务", []}
        , {"attr",  "改变属性",  [uio:format("[{{1},1000000000}, {{2}, 1000000}]", [?ATT, ?HP])]}
        , {"speed", "改变速度",  [uio:format("[{18, 1000}]", [?SPEED])]}
        , {"opday",  uio:format("开服天数({1})天", [util:get_open_day()]), ["开服天数"]}
        , {"mergeday",  uio:format("合服天数({1})天", [util:get_merge_day()]), ["合服天数"]}
        , {"worldlv", uio:format("世界等级({1})级", [util:get_world_lv()]), ["等级"]}
        , {"regtime", "创建角色天数", ["创建角色天数"]}
        , {"mail", "增加测试邮件", ["标题", "内容"]}
        , {"rewardmail", "增加奖励邮件", ["[{0,102003,5},{0,102100,10}]"]}
        , {"auctionmail", "增加交易邮件", ["[{0, 102000, 2},{0,102100,3}, {0,102300,5}]"]}
        , {"dungeon", "副本", ["副本id"]}
        , {"childdun", "完成宝宝副本到48波", []}
        , {"dsgtgoods", "激活称号", ["物品id"]}
        , {"arenawin", "竞技场胜利", []}
        , {"arenatimer", "竞技场结算", []}
        , {"arenaseason", "竞技场赛季结算", []}
        , {"cdaily", "清除个人日常", []}
        , {"closedungeon", "关闭副本", []}
        , {"dunquit", "退出副本", []}
        , {"addlive", "增加活跃度",["活动ID", "活动子ID"]}
        , {"addlive2", "增加活跃度2",["数量"]}
        , {"addlive3", "增加昨日活跃度",["数量"]}
        , {"addlive4", "修改昨日活跃",["数量"]}
        , {"copyscene", "开启线路", ["场景id", "进程池id", "线"]}
        , {"skills", "学习技能", []}
        , {"dropdebug", "掉落模拟", ["[{1203001,1}]"]}
        , {"cweek", "清理周计数器", []}
        , {"counter", "清理终生计数器", []}
        , {"beskills", "学习被动技能", ["[]:所有;[{id,lv}]"]}
        , {"cleanskills", "清除被动技能", []}
        , {"setskillpoint", "设置天赋技能点",["100"]}
        , {"nocd", "设置技能cd", ["1没有cd;0恢复cd"]}
        , {"card", "礼包卡", ["卡号"]}
        , {"toppkstart", "开启巅峰竞技", ["300"]}
        , {"toppkend", "关闭巅峰竞技", []}
        , {"toppkseasonend", "巅峰竞技赛季结算", []}
        , {"gwarconfirm", "确认公会战C赛区", []}
        , {"gwarstart", "开始公会战", []}
        , {"gwartest", "公会战调试", []}
        , {"gwarreset", "公会战重置", []}
        , {"gwarend", "公会战关闭", []}
        , {"resourcebacktest", "资源找回刷新", []}
        , {"plusstarvalue", "增加星力", ["数值"]}
        , {"investsetbuytime", "投资设置已购买时间", ["投资类型","天数"]}
        , {"startvoidfam", "开启无尽领域", ["持续时间(s)"]}
        , {"customactoplist", "打印已开启的定制活动", []}
        , {"reloadccustom", "重新加载定制活动", []}
        , {"configaccustom", "生成定制活动查看文件",[]}
        , {"rushrankclear", "开服冲榜结算", []}
        , {"commonranktitle", "排行榜称号结算", []}
        , {"beachnext", "海滩下一阶段", []}
        , {"finishachievement", "完成成就", ["成就大类_成就小类_成就Id"]}
        , {"autoachieve", "完成所有成就(谨慎使用!)", []}
        , {"clearachv", "重置玩家成就", []}
        , {"addachvexp", "增加成就经验", ["经验值"]}
        , {"addhonour", "增加荣誉值", ["数量"]}
        , {"modifyannounce", "修改公会公告", ["公告"]}
        , {"modifyguildname", "修改公会名字", ["名字"]}
        , {"disbandguild", "解散公会", []}
        , {"clearmail", "删除过期邮件", []}
        , {"addgoods", "增加物品", ["物品类型", "物品类型id", "物品数量"]}
        , {"buydun", "增加副本次数", ["副本id", "次数"]}
        , {"ghost", "变幽灵", ["1"]}
        , {"addbuff", "添加buff", ["技能id"]}
        , {"rmbuff", "移除buff", ["技能id"]}
        , {"addhipoints", "加狂欢值", ["值"]}
        , {"onetouchfriend", "一键加好友(会掉线)", ["数量"]}
        , {"hipointclearflag", "嗨点限制解除", []}
        , {"clearcollect", "收集活动清理", ["类型（1为全服 2为全服和个人）"]}
        , {"firstrechargeclear", "清空首充奖励", []}
        , {"firstrechargedays", "首充天数", ["天数"]}
        , {"auctionguild", "公会拍卖", []}
        , {"auctionworld", "世界拍卖", ["配置ID:如1"]}
        , {"closeauction", "关闭拍卖", []}
        , {"addloginday", "登录天数加一", []}
        , {"resetloginday", "重置登录天数", []}
        , {"addskillbuff", "增加技能buff", ["技能id", "技能等级"]}
        , {"3v3", "开启3v3", ["持续时间"]}
        , {"3v3timemb", "开启3v3(限制人数)", ["持续时间", "队伍人数"]}
        , {"3v3mb", "3v3限制人数", ["队伍人数"]}
        , {"3v3season", "3v3赛季结算", []}
        , {"startdrum", "进入擂台赛准备期", ["X秒后"]}
        , {"startdrumrank", "进入擂台赛16强(要在准备场景内)", []}
        , {"closedrum", "结束擂台赛结算(要已经进入16强)", []}
        , {"1vn1", "开启1vn淘汰赛", ["报名时间","进入时间", "淘汰赛时间"]}
        , {"finishlvtask","完成该等级前任务",[]}
        , {"1vnnextstage", "1vn下一个阶段", []}
        , {"1vnauctionop", "开启1vn拍卖", ["拍卖时间(s)"]}
        , {"1vnauctioned", "结算1vn拍卖", []}
        , {"race2match", "测试1vn守擂赛匹配", ["轮数", "赛区", "擂主战力"]}
        , {"liveskilllv", "生活技能等级", ["技能类型","技能等级","经验"]}
        , {"setexpiredtime", "设置物品过期时间", ["物品类型id", "多少秒后过期"]}
        , {"updateguildtime", "更改加入公会时间", ["入会时间戳"]}
        , {"giveuphusong", "放弃护送", []}
        , {"stopcharmbeach", "关闭海滩", []}
        , {"fishingmastery", "增加钓鱼熟练度", ["熟练度"]}
        , {"onlinetime","增加在线时间(秒)", ["时长"]}
        , {"endonlinetime", "结算在线时间", []}
        , {"activegoal", "激活已开放限时目标", ["目标ID"]}
        , {"resetgoal", "重置限时目标", []}
        , {"finishgoal", "完成限时目标任务", ["目标ID", "任务ID"]}
        , {"updaterank", "刷新排行榜", ["榜单类型"]}
        , {"addkfteam", "随机增加跨服队伍", ["数量"]}
        , {"removekfteam", "随机移除增加的跨服队伍", ["数量"]}
        , {"searchonhookplayer", "查询离线挂机分布点", []}
        , {"fullbag", "自动塞满背包", ["不可重叠物品id"]}
        , {"endrechargeact", "结算充值榜", ["活动子类型"]}
        , {"endconsumeact", "结算消费榜", ["活动子类型"]}
        , {"airshipspeed", "护送飞艇加速", []}
        , {"calcrace", "竞榜结算秘籍", ["类型", "子类型"]}
        , {"attrgoods", "获得带属性物品", ["物品类型id", "属性(1多久过期)", "数量"]}
        , {"refreshkfrank", "刷新跨服榜单", []}
        , {"settlementkfrank", "跨服榜单结算", []}
        , {"costgoodslist", "消费物品", ["[{物品类型，物品id，物品数量}]"]}
        , {"synclocalrank", "同步本服榜单数据到跨服榜", []}
        , {"repairequiprank", "修复装备榜", []}
        , {"clean", "清理背包", ["背包位置"]}
        , {"taskdunreset", "清理次数限制的副本", ["副本id"]}
        , {"getscene", "当前场景线路坐标", []}
        , {"quickfindegreetask", "快速完成指定的学位日常功课", ["功课Id"]}
        , {"cleardegreeclasswork", "清理当天已经完成的日常功课", []}
        , {"power1","战力(预览)",["[{1,100},{2,200}]"]}
        , {"power2","战力(拥有)",["[{1,100},{2,200}]"]}
        , {"guildlabor","社团劳务",["类型"]}
        , {"gmred","累冲红包",["累充"]}
        , {"petsupportrank", "模拟登录更新宠物支援", ["类型 1- 每秒登录10人, 2- 每秒登录50人, 3- 每秒登录100人(所有类型持续10秒)"]}
        , {"enterglamour","进入跑马",["10"]}
        , {"changechildlinkheartexp", "增加孩子同心经验", []}
        , {"worldbossinit", "生成世界BOSS", []}
        , {"worldbossweekrank", "世界BOSS周榜结算", []}
        , {"gboss", "社团BOSS", ["3"]}
        , {"gfire", "社团篝火",["0"]}
        , {"rewardbossborth", "生成赏金BOSS", ["13010101"]}
        , {"guildcollect", "开始/结束社团采集", ["开启1关闭0"]}
        , {"setvehiclestage", "设置孩子载具的阶级", ["载具Id", "阶数"]}
        , {"resetvip", "重置vip", ["等级"]}
        , {"resetsupvip", "重置贵族", []}
        , {"resettowerdun", "重置爬塔副本", []}
        , {"quickopenslot", "快速开启玩具槽位&打造位", []}
        , {"anger", "vip怒气", ["数值(上限500)"]}
        , {"trialfashion", "限时时装激活", ["物品id"]}
        , {"setdevourlv", "设置吞噬等级", ["0"]}
        , {"taskfresh", "刷新任务", []}
	    , {"sendtv", "发送传闻", ["Module", "Id", "参数,格式[1,2...]"]}
        , {"autoequip", "一键穿装备", ["套数", "品质"]}
        , {"sreward", "发奖", ["[{type,id,num}]"]}
        , {"autofoster","一键进阶满级",[]}
        , {"autovisus","一键幻光满级",[]}
        , {"autodsgt", "一键称号激活", []}
        , {"resetvisusdun", "重置幻光副本", ["层数", "波数"]}
        , {"resetlattice", "重置格子玩法", []}
        , {"customactdel", "清除活动数据", ["活动类型", "子类"]}
        , {"resetinvest", "清除投资计划", ["类型"]}
        , {"rrsettlement", "跨服竞榜活动排行榜结算", ["竞榜活动Id"]}
        , {"gwbegin", "开始百团大战", []}
        , {"gwend", "结束百团大战", []}
        , {"cmd", "请求执行协议接口, cmd_12002_[]", []}
        , {"resetgod", "重置唤神", []}
        , {"finishelitetask", "完成精英考核本章节任务", ["章节Id"]}
        , {"guildrace", "社团竞速结算", []}
        , {"cz", "跨服分区单步", ["[pre | confirm | notice | rezone]"]}
        , {"cz", "初始跨服分区", ["cl"]}
        , {"cz", "跨服分区N次", ["Num"]}
        , {"cz", "在跨服中心执行游戏服注册", ["reg"]}
        , {"campwar", "跨服团战", ["0开始1结束", "0本服1跨服"]}
        , {"sethostvalue", "设置托管值", ["100"]}
        , {"cgwar", "开启国战", ["N秒后直接进入报名"]}
        , {"showattr", "基础属性", []}
        , {"showmonattr", "怪物基础属性", ["怪物id"]}
        , {"noticepowerrank", "唤神本战力排行更新", []}
        , {"wasteland", "开启/结束废土战场", ["1-开始 0-结束"]}
        , {"madnessbegin", "狂战开启", []}
        , {"madnessnext", "狂战下一阶段", []}
        , {"goddunrank", "唤神积分排行结算", []}
        , {"singlechargereset", "单笔充值重置", []}
        , {"monopolyreset", "富豪重置", ["1次数2所有"]}
        , {"bcbegin", "靓丽大赛开启", []}
        , {"bcnext", "靓丽大赛下一阶段", []}
        , {"ctreset", "宝典重置", []}
        , {"ctaddscore", "宝典增加积分", ["活动子类型", "增加积分"]}
        , {"cleardunpetrank", "清理宠物副本日奖励", []}
        , {"montalk", "怪物说话", ["模块id", "配置id"]}
        , {"simupt", "模拟给前端发协议", ["协议id", ["[参数(参考文档)]"]]}
        , {"resetgalaxydun", "重置星辰副本", []}
        , {"phantomreset", "重置幻魔宝典", []}
        , {"addphantomscore", "增加幻魔宝典积分", ["活动子类型", "增加积分"]}
        , {"addscorevalue", "增加刮刮卡积分",["活动子类","增加积分"]}
        , {"resetcoupon", "重置票券", []}
        , {"vierank","封榜结算",["1"]}
        , {"autowarsoul","一键穿戴战魂",[]},
        {"activealldress", "激活所有装扮", []}
        , {"activeallfashion", "激活所有时装", []}
        , {"gmauto","一键变强",[]}
        , {"adventurereset", "重置冒险征途", []}
        , {"adventurescore", "设置冒险征途热点值和进度值", ["活动子类型", "热点值", "进度值"]}
        , {"resetroute", "指定黑白棋路径", ["活动子类型", "route_id"]}
        , {"checkroute", "检验黑白棋路径是否正确", []}
        , {"resetreversi", "重置黑白棋活动数据", ["活动子类型"]}
        , {"actbossinit", "活动BOSS开始", []}
        , {"actbossclean", "活动BOSS结束", []}
        , {"guardassistacc", "信标支援周榜结算", []}
        , {"permitloginaddday", "通行证登录增加天数", ["活动子类型","增加天数"]}
        , {"sevendaygoal", "增加七日目标登录天数", ["增加天数"]}
        , {"moninfo", "场景怪物属性", []}
        , {"cpend", "沙盘赛季切换", []}
        , {"gmcgwsign","国战快捷",[]}
        , {"addlegionscore","增加军功",["增加值"]}
        , {"jumpact", "跳一跳开始", [3600]}
        , {"jumpstart","跳一跳匹配成功",[]}
        , {"director","副官任命",[]}
        , {"expdropreset", "重置个人经验本数据", ["波数"]}
        , {"addrunassist", "添加跑环协助", ["任务类型"]}
        , {"resetgodcd", "重置唤神cd", ["位置"]}
        , {"gmreselectegg", "重置自选扭蛋次数", ["SubType"]}
        , {"resettowercount", "重置爬塔次数", []}
        , {"resetexpsea", "重置经验海时间", []}
        , {"resetwishcount", "重置货币祈愿次数", ["祈愿类型"]}
    ].

%% 请求秘籍界面
do_handle(11100, Status, _) ->
    Data = get_gm_ui_data(Status),
    {ok, BinData} = pt_111:write(11100, [Data]),
    lib_server_send:send_to_sid(Status#player_status.sid, BinData),
    ok;

%% 执行秘籍
do_handle(11101, Status, [Data]) when is_list(Data) ->
    Args = string:tokens(Data, "_"),
    case Args of
        [FunName|_] ->
            GMList = get_gm_ui_data(Status),
            case lists:keyfind(FunName, 1, GMList) of
                {FunName, FunDesc, _} ->
                    lib_log_api:log_gm_use(Status#player_status.id, Status#player_status.figure#figure.lv, Status#player_status.scene, FunDesc, Data);
                _ ->
                    skip
            end;
        _ ->
            skip
    end,

    NewStatus =
    case Args of
        %% 增加物品
        ["goods", _GoodsId, _Num] ->
            Id = list_to_integer(_GoodsId),
            Num = list_to_integer(_Num),
            lib_goods_api:send_reward_by_id([{?TYPE_GOODS, Id, Num}], gm, Status#player_status.id),
            %% lib_goods_api:give_goods_by_list(Status, [{Id, Num}], gm, 0),
            ok;
        %% 自动塞满背包
        ["fullbag", _GoodsId] ->
            Id = list_to_integer(_GoodsId),
            Num = lib_goods_api:get_cell_num(Status),
            ?IF(Num > 0, lib_goods_api:send_reward_by_id([{?TYPE_GOODS, Id, Num}], gm, Status#player_status.id), skip),
            ok;
        %% 发特殊类型货币
        ["scurrency", _GoodsId, _Num] ->
            Id = list_to_integer(_GoodsId),
            Num = list_to_integer(_Num),
            lib_goods_api:send_reward_by_id([{?TYPE_CURRENCY, Id, Num}], gm, Status#player_status.id),
            ok;
        %% 清理背包
        ["clean"] ->
            GoodsStatus = lib_goods_do:get_goods_status(),
            List0 = lib_goods_util:get_goods_list(Status#player_status.id, ?GOODS_LOC_BAG, GoodsStatus#goods_status.dict),
            List1 = lib_goods_util:get_goods_list(Status#player_status.id, ?GOODS_LOC_GALAXY_BAG, GoodsStatus#goods_status.dict),
            List  = List0++List1,
            List =/= [] andalso lib_goods_api:delete_more_by_list(Status, [{GoodsInfo#goods.id, GoodsInfo#goods.goods_id, GoodsInfo#goods.num}||GoodsInfo<-List], gm),
            lib_fishing:update_fishing_rod_usage_count(Status, List);
        %% 清理背包
        ["clean", Pos] ->
            GoodsStatus = lib_goods_do:get_goods_status(),
            List = lib_goods_util:get_goods_list(Status#player_status.id, list_to_integer(Pos), GoodsStatus#goods_status.dict),
            lib_goods_api:delete_more_by_list(Status, [{GoodsInfo#goods.id, GoodsInfo#goods.goods_id, GoodsInfo#goods.num}||GoodsInfo<-List], gm),
            lib_fishing:update_fishing_rod_usage_count(Status, List);
        %% 设置金钱
        ["money", _Money] ->
            Money = list_to_integer(_Money),
            db:execute(io_lib:format(<<"update `player_high` set coin = ~p, gcoin = ~p, bgold = ~p, gold = ~p,gfame=~p, honour=~p where id=~p">>, [Money, Money, Money, Money,Money,Money, Status#player_status.id])),
            StatusMoney =  Status#player_status{gold = Money, bgold = Money, coin = Money, gcoin = Money,gfame=Money, honour = Money},
            lib_player:send_attribute_change_notify(StatusMoney, ?NOTIFY_MONEY),
            StatusMoney;
        %% 调试协议
        ["pt", _Cmd, _CmdData] ->
            Cmd = list_to_integer(_Cmd),
            CmdData = util:string_to_term(_CmdData),
            %% catch，方便报错后能还原现场，继续调试
            io:format("~p[~p] Cmd:~p, Data:~p~n", [?MODULE, ?LINE,  Cmd, CmdData]),
            case protocol_routing:map(Cmd div 100) of
                {role, _ProtoMod, Mod} ->
                    case catch Mod:handle(Cmd, Status, CmdData) of
                        {'EXIT', _} = ExitReason ->
                            ?PRINT("'EXIT' gm_handle args: ~p~n reason = ~p~n", [[_Cmd, _CmdData], ExitReason]),
                            ?ERR("'EXIT' gm_handle args: ~p~n reason = ~p~n", [[_Cmd, _CmdData], ExitReason]),
                            ok;
                        Other -> Other
                    end;
                _ -> ignore
            end;
        ["mon", MonTypeIdStr, NumStr] ->
            MonTypeId = list_to_integer(MonTypeIdStr),
            Num = list_to_integer(NumStr),
            MonArgs = [],
            case data_mon:get(MonTypeId) of
                #mon{type=Type} ->
                    [lib_mon:async_create_mon(MonTypeId, Status#player_status.scene, Status#player_status.scene_pool_id,
                            Status#player_status.x, Status#player_status.y, Type, Status#player_status.copy_id, 1, MonArgs)  ||_N  <- lists:seq(1, Num) ];
                _ -> skip
            end,
            ok;
        ["scene", SceneIdStr] ->
            SceneId = list_to_integer(SceneIdStr),
            case data_scene:get(SceneId) of
                #ets_scene{} ->
                    lib_scene:change_scene(Status, SceneId, 0, 0, []);
                _ -> Status
            end;
        ["scene", SceneIdStr, _X, _Y] ->
            SceneId = list_to_integer(SceneIdStr),
            X = list_to_integer(_X),
            Y = list_to_integer(_Y),
            case data_scene:get(SceneId) of
                #ets_scene{} ->
                    io:format("gm enter scene:~p, auto pool~n", [{SceneId, X, Y}]),
                    lib_scene:change_scene(Status, SceneId, 0, 0, X, Y, []);
                _ -> Status
            end;
        ["scene", SceneIdStr, PoolIdStr, _X, _Y] ->
            SceneId = list_to_integer(SceneIdStr),
            PoolId  = list_to_integer(PoolIdStr),
            X = list_to_integer(_X),
            Y = list_to_integer(_Y),
            case data_scene:get(SceneId) of
                #ets_scene{} ->
                    io:format("gm enter scene:~p~n", [{SceneId, PoolId, X, Y}]),
                    lib_scene:change_scene(Status, SceneId, PoolId, 0, X, Y, false, []);
                _ -> Status
            end;
        ["dummy", Num, GroupStr] ->
            Group = list_to_integer(GroupStr),
            SkillList = lib_dummy_api:get_skill_list(Status),
            [begin
                        MyArgs0 = [{figure, lib_dummy_api:change_figure(Status#player_status.figure, [rand_wing,create_name])}, {battle_attr, Status#player_status.battle_attr}, {skill, SkillList},{group, Group},{ghost,0}],
                        if
                            Group > 0 ->
                                MyArgs = [{find_target, 3000}|MyArgs0];
                            true ->
                                MyArgs = MyArgs0
                        end,
                        lib_scene_object:async_create_object(?BATTLE_SIGN_DUMMY, 0, Status#player_status.scene, Status#player_status.scene_pool_id,
                            Status#player_status.x, Status#player_status.y, 1, Status#player_status.copy_id, 1, MyArgs)
                end|| _ <- lists:seq(1, list_to_integer(Num))];
        ["lv", AddLvStr] ->
            AddLv = list_to_integer(AddLvStr),
            RealAddLv = AddLv, %% min(AddLv, 60),
            F = fun(_, TmpStatus) ->
                    Exp = max(0, data_exp:get(TmpStatus#player_status.figure#figure.lv) - TmpStatus#player_status.exp),
                    UpExpStatus = lib_player:add_exp(TmpStatus, Exp, gm),
                    {ok, UpExpStatus}
            end,
            {ok, UpLvStatus} = util:for(Status#player_status.figure#figure.lv, min(999999,Status#player_status.figure#figure.lv+RealAddLv-1), F, Status),
            UpLvStatus;
        ["lv2", LvStr] ->
            ToLv = list_to_integer(LvStr),
            AddLv = ToLv - Status#player_status.figure#figure.lv,
            if
                AddLv > 0 ->
                    NewData = ulists:concat(["lv", "_", AddLv]),
                    handle(11101, Status, [NewData]);
                true -> skip
            end;
        ["setlv", StrLv] ->
            MaxLev = data_exp:get_max_lv(),
            RealAddLv = min(list_to_integer(StrLv), MaxLev),
            Figure = Status#player_status.figure,
            TmpStatus = Status#player_status{exp = 0, figure = Figure#figure{lv = RealAddLv}},
            UpExpStatus = lib_player:add_exp(TmpStatus, 1, gm),
            pp_player:handle(13001, UpExpStatus, []),
            UpExpStatus;
        ["turn"] ->
            turn(Status);
        ["gmexp", AddExpStr] ->
            AddExp = list_to_integer(AddExpStr),
            lib_player:add_exp(Status, AddExp, gm);
        ["taskfresh"] ->
            lib_task_api:refresh_task(Status);
        ["exp", AddExpStr] ->
            AddExp = list_to_integer(AddExpStr),
            case AddExp > 0 of
                true  -> lib_player:add_exp(Status, AddExp, gm);
                false -> Status
            end;
        ["task", TaskIdStr] -> %% 强制接取某个任务
            TaskId = list_to_integer(TaskIdStr),
            case data_task:get(TaskId) of
                null -> skip;
                _    -> lib_task:force_trigger(TaskId, lib_task_api:ps2task_args(Status))
            end,
            ok;
        ["dtask", TaskIdStr] -> %% 移除某个任务
            TaskId = list_to_integer(TaskIdStr),
            case data_task:get(TaskId) of
                null -> skip;
                _    ->  lib_task:del_task(TaskId, lib_task_api:ps2task_args(Status))
            end,
            ok;
        ["cleanactask", Type] ->
            lib_task:gm_refresh_task(list_to_integer(Type), lib_task_api:ps2task_args(Status)),
            ok;
        ["finishtask", TaskIdStr] ->
            TaskId = list_to_integer(TaskIdStr),
            lib_task_api:finish(Status, TaskId),
            ok;
        %% 完成所有的任务
        ["finishalltask"] ->
            lib_task:gm_finish_lv_task(Status);
        ["finitask"] ->
            TaskData = lib_task_api:ps2task_args(Status),
            lib_task:gm_finitask(TaskData#task_args{source = <<"robot">>}),
            ok;
        ["quickfindegreetask", ClassId] ->
            IntClassId = list_to_integer(ClassId),
            lib_degree:gm_quick_finish_classwork(Status, IntClassId);
        ["cleardegreeclasswork"] ->
            lib_degree:gm_clear_received_classwork(Status);
        ["attr", AttrListStr] ->
            AttrList = util:string_to_term(AttrListStr),
            BA = Status#player_status.battle_attr,
            OldAttrList = attr_conv:to_attr_tuple_list(BA#battle_attr.attr),
            F = fun({Index, Value}, Result) ->
                    [{Index, Value} | lists:keydelete(Index, 1, Result)]
            end,
            CombineAttrList = lists:foldl(F, OldAttrList, AttrList),
            Attr = attr_conv:to_attr_record(CombineAttrList),
            HpLim = Attr#attr.hp,
            TmpStatus = Status#player_status{battle_attr = BA#battle_attr{hp_lim=HpLim, hp=HpLim, attr=Attr}},
            mod_scene_agent:update(TmpStatus, [{battle_attr, TmpStatus#player_status.battle_attr}]),
            lib_player:send_attribute_change_notify(TmpStatus, ?NOTIFY_ATTR),
            TmpStatus;
        ["speed", AttrListStr] ->
            AttrList = util:string_to_term(AttrListStr),
            BA = Status#player_status.battle_attr,
            case lists:keyfind(18, 1, AttrList) of
                false -> Speed = BA#battle_attr.speed;
                {18, Speed} -> ok
            end,
            NewBA = BA#battle_attr{speed = Speed},
            TmpStatus = Status#player_status{battle_attr = NewBA},
            mod_scene_agent:update(TmpStatus, [{battle_attr, TmpStatus#player_status.battle_attr}]),
            lib_player:send_attribute_change_notify(TmpStatus, ?NOTIFY_ATTR),
            TmpStatus;
        ["attr"] ->
            lib_battle_hurt_calc:print_attr(Status);
        ["hp", _Hp] ->
            Hp = list_to_integer(_Hp),
            BA = Status#player_status.battle_attr,
            TmpStatus = Status#player_status{battle_attr = BA#battle_attr{hp=Hp}},
            mod_scene_agent:update(TmpStatus, [{battle_attr, TmpStatus#player_status.battle_attr}]),
            lib_player:send_attribute_change_notify(TmpStatus, ?NOTIFY_ATTR),
            TmpStatus;
        ["anger", _Val] ->
            Val = list_to_integer(_Val),
            NewAnger = min(Val, ?ANGER_MAX),
            #player_status{battle_attr = BattleAttr} = Status,
            TmpStatus = Status#player_status{battle_attr = BattleAttr#battle_attr{anger = NewAnger}},
            mod_scene_agent:update(TmpStatus, [{anger, NewAnger}]),
            pp_player:handle(13086, TmpStatus, []),
            {ok, TmpStatus};
        %% 设置开服天数
        ["opday", Day] ->
            ?INFO("【~p】Change Open Day>>>>>>>>>>>>>>:~p", [Status#player_status.id, Day]),
            Time = list_to_integer(Day),
            Day2 = case Time > 0 of
                true -> Time - 1;
                false -> Time
            end,
            Now = utime:unixtime(),
            OpenTime = utime:unixdate() - 86400*Day2,
            db:execute(io_lib:format(?SERVER_ENV_REPLACE, [OpenTime, ?SERVER_ENV_OPENTIME])),
            ets:update_element(?SERVER_ENV, open_time, {#server_env.value, OpenTime}),
            ets:update_element(?SERVER_ENV, real_open_time, {#server_env.value, OpenTime}),
            MergeTime = util:get_merge_time(),
            MergeStartTime = util:get_merge_day_start_time(),
            MergeCount = util:get_merge_count(),
            UnixDate = utime:unixdate(),
            WorldLv = util:get_world_lv(),
            {ok, Bin} = pt_102:write(10201, [OpenTime, MergeTime, MergeStartTime, MergeCount, UnixDate, WorldLv]),
            [lib_server_send:send_to_sid(E#ets_online.sid, Bin) || E <- ets:tab2list(?ETS_ONLINE)],
            % pp_game:handle(10201, Status, []),
            mod_pushmail:open_day(),
            lib_custom_act_api:reload_custom_act_cfg(),
            czone_api:notice_city_state(Status#player_status.sid),
            lib_player:apply_cast_online(lib_task_api,opday_change,[]),
            %% 广播一下
            Msg = io_lib:format("GM修改开服天数：第~p天", [Time]),
            {ok, BinData1} = pt_110:write(11020, [Msg]),
            lib_server_send:send_to_all(BinData1),
            #player_status{id = RoleId,server_id = SerId, server_num = ServerNum, figure = Figure} = Status,
            TimeStr = utime:unixtime_to_timestr(Now),
            PackData = [?CHAT_CHANNEL_WORLD, SerId, ServerNum, "", RoleId, Figure, "【" ++ binary_to_list(TimeStr) ++ "】  " ++ Msg, util:term_to_string([]), 0, Now],
            {ok, BinData2} = pt_110:write(11001, PackData ++ [0, 0]),
            {ok, Status1} = lib_chat:send_text_msg(Status, ?CHAT_CONTENT_TEXT, ?CHAT_CHANNEL_WORLD, 0, PackData, BinData2),
            
            handle(11100, Status1, []),
            Status1;
        %% 设置合服天数
        ["mergeday", Day] ->
            Time = list_to_integer(Day),
            Day2 = case Time > 0 of
                true -> Time - 1;
                false -> Time
            end,
            case Time == 0 of
                true -> MergeTime = 0;
                false -> MergeTime = utime:get_logic_day_start_time() - 86400*Day2
            end,
            db:execute(io_lib:format(?SERVER_ENV_REPLACE, [MergeTime, ?SERVER_ENV_MERGETIME])),
            ets:update_element(?SERVER_ENV, merge_time, {#server_env.value, MergeTime}),
            pp_game:handle(10201, Status, []),
            mod_pushmail:merge_day(),
            lib_custom_act_api:reload_custom_act_cfg(),
            handle(11100, Status, []);
        %% 设置世界等级
        ["worldlv", _Lv] ->
            Lv = list_to_integer(_Lv),
            ets:insert(?SERVER_KV, #server_kv{key = ?SERVER_KV_WORLD_LV, value=Lv, time=utime:unixtime()}),
            ets:insert(?SERVER_KV, #server_kv{key = ?SERVER_KV_IS_GM_WORLD_LV, value=1, time=utime:unixtime()}),
            pp_game:handle(10201, Status, []),
            mod_pushmail:open_day(),
            lib_custom_act_api:reload_custom_act_cfg(),
            util:cast_event_to_players({'refresh_average_lv'}),
            handle(11100, Status, []);
        %% 创建角色天数(邮件推送测试使用)
        ["regtime", _Day] ->
            NowTime = utime:unixtime(),
            RealDay = list_to_integer(_Day),
            RegTime = NowTime - (RealDay*86400),
            SQL = io_lib:format(<<"update player_login set reg_time = ~p where id = ~p">>,[RegTime, Status#player_status.id]),
            db:execute(SQL),
            Status#player_status{reg_time = RegTime};
        %% 邮件
        ["mail", _Title, _Content] ->
            lib_mail_api:send_sys_mail([Status#player_status.id], _Title, _Content, []);
        %% 奖励邮件
        ["rewardmail", _Reward] ->
            Reward = util:string_to_term(_Reward),
            lib_mail_api:send_sys_mail([Status#player_status.id], "测试奖励邮件", "测试", Reward);
        %% 交易邮件
        ["auctionmail", _Reward] ->
            Reward = util:string_to_term(_Reward),
            lib_mail_api:send_auction_mail([Status#player_status.id], ?MOD_MARKET, "测试交易邮件", "邮件内容", Reward);
        ["addgfunds", _AddGfunds] ->
            mod_guild:add_gfunds(Status#player_status.id, Status#player_status.guild#status_guild.id, list_to_integer(_AddGfunds), gm);
        ["addgrowth", _Val] ->
            mod_guild:add_growth(Status#player_status.id, Status#player_status.guild#status_guild.id, list_to_integer(_Val), gm, gm);
        ["adddonate", _Val] ->
            mod_guild:add_donate_api(Status#player_status.id, list_to_integer(_Val));
        ["auctionguild"] ->
            PlayerId = Status#player_status.id,
            GuildId = Status#player_status.guild#status_guild.id,
            case GuildId=/=0  of
                true ->
                    % OpdaySlot = lib_auction_data:get_opday_slot(),
                    % CfgIdList = data_auction:cfg_id_list(OpdaySlot),
                    % GoodsList = lib_auction_mod:get_sys_goods(OpdaySlot, urand:list_rand(CfgIdList)),
                    ModuleId = 402, SubModuleId = 4,
                    lib_auction_api:add_join(PlayerId, GuildId, ModuleId, SubModuleId),
                    GoodsList = [{?TYPE_GOODS, 17020003, 1}, {?TYPE_GOODS, 20040002, 2}, {?TYPE_GOODS, 32080132, 2}],
                    GuildGoodsList = [{GuildId, GoodsList}],
                    lib_auction_api:start_guild_auction_gm(utime:unixtime()+5, ModuleId, SubModuleId, GuildGoodsList);
                _ -> skip
            end;
        ["auctionworld", _CfgId] ->
            CfgId = list_to_integer(_CfgId),
            OpdaySlot = lib_auction_data:get_opday_slot(),
            mod_auction:start_system_auction(OpdaySlot, CfgId);
        ["closeauction"] ->
            mod_auction:close_all_auction_gm();
        ["joinlog", _ModuleId, _SubModuleId] ->
            ModuleId = list_to_integer(_ModuleId),
            SubModuleId = list_to_integer(_SubModuleId),
            PlayerId = Status#player_status.id,
            GuildId = Status#player_status.guild#status_guild.id,
            lib_auction_api:add_join(PlayerId, GuildId, ModuleId, SubModuleId);
        ["dungeon", _DunId] ->
            pp_dungeon:handle(61001, Status, [list_to_integer(_DunId), 0]);
        ["childdun"] ->
            Status1 = lib_dungeon_child:gm_set_max(Status),
            Status1;
        ["recharge", _ProductId] ->
            NowTime = utime:unixtime(),
            ProductId = list_to_integer(_ProductId),
            IdList = data_recharge:get_all_product_ids(),
            case lists:member(ProductId, IdList) of
                true ->
                    #base_recharge_product{money = Money, game_currency = Gold} = lib_recharge_check:get_product(ProductId),
                    #player_status{id = PlayerId, accname = AccName, figure = #figure{lv = Lv, name = Name}} = Status,

                    PayNo = mod_id_create:get_new_id(?CHARGE_PAY_NO_CREATE),
                    Sql = io_lib:format(?sql_pay_insert_gm, [1, PayNo, AccName, PlayerId, Name, ProductId, Money, Gold, NowTime, 0, Lv]),
                    db:execute(Sql),
                    lib_recharge_api:nofity_pay(PlayerId);
                false -> skip
            end;
        ["eventprint"] ->
            gen_server:cast(Status#player_status.copy_id, {'event_print'});
        ["dsgtgoods", GoodsId] ->
            Id = list_to_integer(GoodsId),
            lib_goods_api:send_reward_by_id([{?TYPE_DESIGN, Id}], gm, Status#player_status.id),
            ok;
        ["arenaseason"] ->
            erlang:send(mod_arena, {season_settlement});
        %% 清除个人日常
        ["cdaily"] ->
            ?ERR("CDaily_RoleId:~p", [Status#player_status.id]),
            mod_daily_dict:daily_clear_one(Status#player_status.id),
            mod_daily:daily_clear_role_all(Status#player_status.id, ?TWELVE),
            mod_daily:daily_clear_role_all(Status#player_status.id, ?FOUR),
            gen_server:cast(Status#player_status.pid, {'refresh_and_clear_daily', ?TWELVE}),
            gen_server:cast(Status#player_status.pid, {'refresh_and_clear_daily', ?FOUR}),
            {ok, Status1} = lib_resource_back:refresh_4_clock_res_act(Status),
            {ok, Status2} = cross_guild_war_api:gm_reset_data(Status1),
            {ok, Status3} = mate_logic:gm_refresh_task(Status2),
            handle(13914, Status, []),
            Status3;
        ["closedungeon"] ->
            case lib_dungeon:is_on_dungeon(Status) of
                true -> mod_dungeon:close_dungeon(Status#player_status.copy_id);
                false -> skip
            end;
        ["dunquit"] ->
            pp_dungeon:handle(61002, Status, []);
        ["guilddayclear"] ->
            mod_guild:day_clear(?TWELVE, 0),
            mod_guild:day_clear(?FOUR, 0);
        ["modifyannounce", AnnounceStr] ->
            lib_guild_api:modify_announce_by_gm(Status#player_status.guild#status_guild.id, AnnounceStr);
        ["modifyguildname", NameStr] ->
            lib_guild_api:modify_guild_name_by_gm(Status#player_status.guild#status_guild.id, NameStr);
        ["disbandguild"] ->
            lib_guild_api:disband_guild_by_gm(Status#player_status.guild#status_guild.id);
        ["guildcreatetime", _CreateTime] ->
            mod_guild:update_guild_create_time(Status#player_status.guild#status_guild.id, list_to_integer(_CreateTime));
        ["delmail"] ->
            db:execute(io_lib:format(<<"DELETE FROM mail WHERE rid = ~p">>, [Status#player_status.id]));
        ["dailycount", _ModuleId, _Type, _Count] ->
            lib_daily:set_count(Status#player_status.id, list_to_integer(_ModuleId), list_to_integer(_Type), list_to_integer(_Count));
        ["addlive", Module, ModuleSub] ->
            lib_activitycalen_api:role_success_end_activity(Status, list_to_integer(Module), list_to_integer(ModuleSub));
        ["addlive2", Num] ->
            OldLive = lib_daily:get_count(Status#player_status.id, ?MOD_ACTIVITY, ?ACTIVITY_LIVE_DAILY),
            LiveLimit = lib_daily:get_count_limit(?MOD_ACTIVITY, ?ACTIVITY_LIVE_DAILY),
            Add = min(list_to_integer(Num), LiveLimit - OldLive),
            lib_daily:plus_count(Status#player_status.id, ?MOD_ACTIVITY, ?ACTIVITY_LIVE_DAILY, Add),
            {ok, Status2} = lib_liveness:add_liveness(Status, list_to_integer(Num)),
            lib_activitycalen:update_ets_live(Status2, Add),
            custom_act_days_plan:update_days_plan_task(Status2, 3, list_to_integer(Num), false),
            Status2;
        ["addlive3", Num] ->
            lib_activitycalen:gm_update_ets_live(Status#player_status.id, list_to_integer(Num)),
            Status;
        ["addlive4",Num]->
            Status2 = lib_liveness:gm_olive(Status, list_to_integer(Num)),
            Status2;
        ["skills"] ->
            Sql = io_lib:format(<<"delete from `skill` where id = ~p ">>, [Status#player_status.id]),
            db:execute(Sql),
            #player_status{id = RoleId, figure = #figure{career = Career, lv = RoleLv}, vip_status = #vip_status{trial_lv = TrialLv, lv = VipLv, type = VipType}} = Status,
            SkillStatus = lib_skill:skill_online(RoleId, Career, RoleLv, 0, {VipType, VipLv, TrialLv}),
            Status1 = Status#player_status{skill = SkillStatus, quickbar = []},
            {ok, Status2} = lib_skill:auto_learn_skill(Status1, login),
            {ok, BinData} = pt_130:write(13007, [Status2#player_status.quickbar]),
            lib_server_send:send_to_sid(Status2#player_status.sid, BinData),
            pp_skill:handle(21002, Status2, []),
            Status2;
        ["beskills", SkillListStr] ->
            PassiveSkillList = util:string_to_term(SkillListStr),
            if
                PassiveSkillList == [] ->
                    auto_skill(Status);
                true ->
                    #player_status{skill = SkillStatus, figure = #figure{lv = RoleLv}} = Status,
                    #status_skill{
                        skill_list = SkillList,
                        skill_passive = OPassiveSkillList
                    } = SkillStatus,
                    F = fun({SkillId, SLv}, TSkills) -> lists:keystore(SkillId, 1, TSkills, {SkillId, SLv}) end,
                    NewSkillList = lists:foldl(F, SkillList, PassiveSkillList),
                    NewPassiveSkill = lists:foldl(F, OPassiveSkillList, PassiveSkillList),
                    AttrList = lib_skill_attr:get_passive_skill_attr(NewSkillList, RoleLv),
                    NewSkillStatus = SkillStatus#status_skill{skill_list = NewSkillList,
                        skill_passive = NewPassiveSkill,
                        skill_attr = AttrList},
                    Status11 = Status#player_status{ skill = NewSkillStatus},
                    Status1 = lib_player:count_player_attribute(Status11),
                    mod_scene_agent:update(Status1, [{passive_skill, NewPassiveSkill}]),
                    Status1
            end;
        ["cleanskills"] ->
            #player_status{skill = SkillStatus, figure = #figure{lv = RoleLv}} = Status,
            #status_skill{skill_list = SkillList} = SkillStatus,
            F = fun({SkillId, SkillLv}, TL) ->
                    case data_skill:get(SkillId, SkillLv) of
                        #skill{type = 2} ->
                            Sql0 = io_lib:format(<<"delete from skill where id = ~p and skill_id = ~p and lv = ~p ">>, [Status#player_status.id, SkillId, SkillLv]),
                            db:execute(Sql0),
                            TL;
                        _ ->
                            [{SkillId, SkillLv}|TL]
                    end
            end,
            NewSkillList = lists:foldl(F, [], SkillList),
            {SkillAttr, SkillAttrOhter} = lib_skill_attr:get_passive_skill_attr(NewSkillList, RoleLv),
            NewSkillStatus = SkillStatus#status_skill{skill_list = NewSkillList,
                skill_passive = [],
                skill_attr = SkillAttr,
                skill_attr_other = SkillAttrOhter},
            Status11 = Status#player_status{ skill = NewSkillStatus},
            Status1 = lib_player:count_player_attribute(Status11),
            mod_scene_agent:update(Status1, [{delete_passive_skill, SkillList}]),
            %% mod_scene_agent:update(Status1, [{battle_attr, Status1#player_status.battle_attr}]),
            Status1;

        ["setskillpoint", StrPoint] ->
            #player_status{id = RoleId, sid = _Sid, skill = SkillStatus} = Status,
            NewSkillStatus = SkillStatus#status_skill{point = list_to_integer(StrPoint)},
            db:execute(io_lib:format(?sql_update_talent_skill_point, [list_to_integer(StrPoint), RoleId])),
            Status1 = Status#player_status{skill = NewSkillStatus},
            pp_skill:handle(21010, Status1, []),
            Status1;
        ["nocd", Type] ->
            mod_scene_agent:update(Status, [{nocd, list_to_integer(Type)}]),
            Status;
        ["cweek"] ->
            mod_week:week_clear_role_all(Status#player_status.id);
        ["ccounter"] ->
            lib_counter:gm_clean(Status#player_status.id);
        ["card", StrCardNo] ->
            pp_goods:handle(41715, Status, [StrCardNo]);
        ["toppkstart", TimeStr] ->
            Time = list_to_integer(TimeStr),
            mod_top_pk_local:apply_cast({'gm_start', Time});
        ["toppkend"] ->
            mod_top_pk_local:apply_cast({'gm_end'});
        ["toppkseasonend"] ->
            mod_top_pk_local:apply_cast({'gm_season_end'});
        ["resourcebacktest"] ->
            ?ERR("gm clear resource_back!~n", []),
            lib_resource_back:refresh(0);
        ["investsetbuytime", _T, _Day] ->
            Status;
            % Type = list_to_integer(T),
            % NewDay = list_to_integer(Day),
            % lib_investment:gm_set_buy_time(Status, Type, NewDay);
        ["sreward", List] ->
            Rewards = util:string_to_term(List),
            NewPS = lib_goods_api:send_reward(Status, Rewards, gm, "gm"),
            NewPS;
        ["costobj", List] ->
            ObjList = util:string_to_term(List),
            case lib_goods_api:cost_object_list_with_check(Status, ObjList, 0, "gm") of
                {true, NewPS,_} ->
                    NewPS;
                _ ->
                    Status
            end;
        ["startvoidfam", StrDuration] ->
            Duration = list_to_integer(StrDuration),
            mod_void_fam_local:gm_start(Duration);
        ["configaccustom"] ->
            lib_custom_act_dynamic_compile:product_debug_ac_custom_info();
        ["customactoplist"] ->
            List = lib_custom_act_util:get_custom_act_open_list(),
            List1 = [T#act_info.key || T <- List],
            #player_status{server_id = SerId, server_num = SerNum, server_name = ServerName, id = RoleId, figure = Figure} = Status,
            Msg = io_lib:format("已开启定制活动列表:~p", [List1]),
            PackData = [1, SerId, SerNum, ServerName, RoleId, Figure, Msg, util:term_to_string([]), 0, utime:unixtime(), 0, 0],
            {ok, BinData} = pt_110:write(11001, PackData),
            lib_server_send:send_to_all(BinData);
        ["customactdel", _Type, _SubType] ->
            Type = list_to_integer(_Type), SubType = list_to_integer(_SubType),
            db:execute(<<"delete from custom_act_receive_reward where role_id=~p and type = ~p and subtype = ~p">>, [Status#player_status.id, Type, SubType]);
        ["reloadccustom"] ->
            lib_custom_act_api:reload_custom_act_cfg();
        ["rushrankclear"] ->
            mod_rush_rank:day_clear(0);
        ["commonranktitle"] ->
            mod_common_rank:day_clear(0);
        ["beachnext"] ->
            lib_charm_beach:gm_next();
        ["addhonour", _Num] ->
            Num = list_to_integer(_Num),
            lib_goods_api:send_reward_by_id([{?TYPE_HONOUR, 0, Num}], gm, Status#player_status.id);
        ["addgoods", SGoodsType, SGoodsTypeId, SNum] ->
            GoodsType = list_to_integer(SGoodsType),
            GoodsTypeId = list_to_integer(SGoodsTypeId),
            Num = list_to_integer(SNum),
            RewardList = [{GoodsType, GoodsTypeId, Num}],
            NewPlayer = lib_goods_api:send_reward(Status, RewardList, gm, 0),
            NewPlayer;
        ["buydun", DunIdS, NumS] ->
            DunId = list_to_integer(DunIdS),
            Num = list_to_integer(NumS),
            case data_dungeon:get_dun(DunId) of
                #dun_cfg{type = DunType} ->
                    CountType = lib_dungeon_api:get_daily_buy_type(DunType, DunId),
                    lib_daily:plus_count(Status#player_status.id, ?MOD_DUNGEON, ?MOD_DUNGEON_BUY, CountType, Num);
                _ ->
                    ok
            end;
        ["ghost", Ghost] ->
            mod_server_cast:set_data_sub([{ghost, list_to_integer(Ghost)}], Status);
        ["clearmail"] ->
            lib_mail:clean_mail();
        ["addbuff", SkillId] ->
            ?PRINT("????? ~p~n", [SkillId]),
            lib_goods_buff:add_skill_buff(Status, list_to_integer(SkillId), 1);
        ["rmbuff", SkillId] ->
            lib_goods_buff:remove_skill_buff(Status, list_to_integer(SkillId));
        ["addhipoints", NumS] ->
            Num = list_to_integer(NumS),
            mod_hi_point:gm_add_points(1, Num, Status#player_status.id);
        %% 一键加好友，不需要对方同意
        ["onetouchfriend", NumStr] ->
            #player_status{id = RoleId} = Status,
            Num = list_to_integer(NumStr),
            NowTime = utime:unixtime(),
            List = db:get_all(io_lib:format(<<"select id from player_low where id != ~p and lv >= 120">>, [RoleId])),
            F = fun([TId], Acc) when Acc < Num ->
                    case db:get_row(io_lib:format(<<"select rela_type from relationship where role_id = ~p and other_rid = ~p">>, [RoleId, TId])) of
                        [A2BRelaType] -> skip;
                        _ -> A2BRelaType = ?RELA_TYPE_NONE
                    end,
                    case db:get_row(io_lib:format(<<"select rela_type from relationship where role_id = ~p and other_rid = ~p">>, [TId, RoleId])) of
                        [B2ARelaType] -> skip;
                        _ -> B2ARelaType = ?RELA_TYPE_NONE
                    end,
                    InBlackL = lib_chat_limit:is_blocked(Status, TId),
                    InFriendL = case lists:member(A2BRelaType, ?RELA_FRIEND_TYPES) of
                        false ->
                            lists:member(B2ARelaType, ?RELA_FRIEND_TYPES);
                        true -> true
                    end,
                    case not InBlackL andalso not InFriendL of
                        true ->
                            NewA2BRelaType = lib_relationship:rela_type_change(A2BRelaType, ?RELA_TYPE_FRIEND, add_friend),
                            NewB2ARelaType = lib_relationship:rela_type_change(B2ARelaType, ?RELA_TYPE_FRIEND, add_friend),
                            db:execute(io_lib:format(?sql_save_role_rela, [RoleId, TId, NewA2BRelaType, 0, 0, 0, NowTime])),
                            db:execute(io_lib:format(?sql_save_role_rela, [TId, RoleId, NewB2ARelaType, 0, 0, 0, NowTime])),
                            Acc + 1;
                        _ -> Acc
                    end;
                (_, Acc) -> Acc
            end,
            F1 = fun() ->
                    lists:foldl(F, 0, List),
                    ok
            end,
            case catch db:transaction(F1) of
                ok ->
                    1;
                _Err ->
                    ?ERR(">>>>>>>>>>:~p", [_Err]),
                    Status
            end;
        ["payment", Order] ->
            case Order of
                "1" ->
                    case lib_consume_data:advance_cost_objects(Status, [{0, 18010003, 1}], buy_goods, "18010003", true) of
                        {true, Status1, Ref} ->
                            put("payment_test", Ref),
                            Status1;
                        _ ->
                            ok
                    end;
                "2" ->
                    Ref = get("payment_test"),
                    lib_consume_data:advance_payment_done(Status#player_status.id, Ref);
                "3" ->
                    Ref = get("payment_test"),
                    lib_consume_data:advance_payment_fail(Status#player_status.id, Ref, []);
                _ ->
                    ok
            end;
        ["worldbossinit"]->
            world_boss_mgr:gm_reborn(),
            Status;
        ["worldbossweekrank"] ->
            world_boss_mgr:gm_monday(),
            Status;
        ["rewardbossborth", BossId] ->
            reward_boss_mgr:gm_reborn_boss(list_to_integer(BossId)),
            Status;
        ["guildcollect", OpenSign] ->
            guild_collect_mgr:gm_act(list_to_integer(OpenSign));
        ["firstrechargeclear"] ->
            {ok, Status2} = lib_recharge_first:gm_clear_award(Status),
            Status2;
        ["firstrechargedays", Days] ->
            lib_recharge_first:gm_update_days(Status, list_to_integer(Days));
        ["closebonfire"] ->
            erlang:whereis(mod_guild_bonfire) ! {end_war};
        ["addloginday"] ->
            lib_login_reward:gm_add_day(Status);
        ["resetloginday"] ->
            lib_login_reward:gm_reset_loginday(Status);
        ["addskillbuff", _SkillId, _SkillLv] ->
            SkillId = list_to_integer(_SkillId),
            SkillLv = list_to_integer(_SkillLv),
            {ok, Status2} = lib_skill_buff:add_buff(Status, SkillId, SkillLv),
            {no_notify_attr, Status2};
        ["3v3", LastTime] ->
            clusters_node:apply_cast(mod_3v3_center, gm_start_3v3_2, [list_to_integer(LastTime)]);
        ["3v3timemb", LastTime, LimitMember] ->
            clusters_node:apply_cast(mod_3v3_center, gm_start_3v3, [list_to_integer(LastTime), list_to_integer(LimitMember)]);
        ["3v3mb", LimitMember] ->
            clusters_node:apply_cast(mod_3v3_center, gm_set_member_limit, [list_to_integer(LimitMember)]);
        ["3v3season"] ->
            clusters_node:apply_cast(mod_3v3_rank, gm_empty_3v3_rank, []),
            Status;
        ["finishachievement", _Type, _SubType, _Id] ->
            Type = list_to_integer(_Type),
            SubType = list_to_integer(_SubType),
            Id = list_to_integer(_Id),
            lib_achievement_api:gm_set_finish(Status, Type, SubType, Id),
            Status;
        ["autoachieve"] ->
            lib_achievement_api:gm_finish_all_type(Status);
        ["clearachv"] ->
            lib_achievement_api:gm_reset(Status#player_status.id);
        ["addachvexp", _Exp] ->
            Exp = list_to_integer(_Exp),
            lib_achievement_api:gm_add_achv_exp(Status, Exp);
        ["startdrum",Time] ->
            mod_drumwar_mgr:gm_start(list_to_integer(Time)),
            Status;
        ["startdrumrank"] ->
            mod_drumwar_mgr:gm_startrank(),
            Status;
        ["closedrum"] ->
            mod_drumwar_mgr:gm_closedrum(),
            Status;
        ["1vn1", SignTimeStr, PreTimeStr, RaceTimeStr] ->
            mod_kf_1vn_local:gm_start_1(list_to_integer(SignTimeStr), list_to_integer(PreTimeStr), list_to_integer(RaceTimeStr));
        ["1vnauctionop", TimeStr] ->
            clusters_node:apply_cast(mod_kf_1vn_auction, auction_start, [list_to_integer(TimeStr)]);
        ["1vnauctioned"] ->
            clusters_node:apply_cast(mod_kf_1vn_auction, auction_end, []);
        ["finishlvtask"] ->
            TaskData = lib_task_api:ps2task_args(Status),
            lib_task:finish_lv_task(TaskData),
            Status;
        ["1vnnextstage"] ->
            mod_kf_1vn_local:gm_next_stage();
        ["race2match", TurnStr, AreaStr, CombatPowerStr] ->
            Turn = list_to_integer(TurnStr),
            Area = list_to_integer(AreaStr),
            CombatPower = list_to_integer(CombatPowerStr),
            lib_kf_1vn:test_race2_match(Turn, Area, CombatPower),
            Status;
        ["liveskilllv", _SkillType, _SkillLv, _Exp] ->
            SkillType = list_to_integer(_SkillType),
            SkillLv = list_to_integer(_SkillLv),
            Exp = list_to_integer(_Exp),
            lib_live_skill:gm_set_lv(Status, SkillType, SkillLv, Exp);
        %% 设置过期时间
        ["setexpiredtime", GoodsType, Time] ->
            GoodsTypeId = list_to_integer(GoodsType),
            NewTime = list_to_integer(Time),
            #player_status{id = RoleId} = Status,
            lib_goods_api:set_goods_expired_time([RoleId], [GoodsTypeId], utime:unixtime() + NewTime);
        ["updateguildtime", _Time] ->
            Time = list_to_integer(_Time),
            mod_guild:apply_cast(lib_guild, gm_update_guild_time, [Status#player_status.id, Time]);
        ["stopcharmbeach"] ->
            lib_charm_beach:gm_stop();
        ["fishingmastery", _IncrMastery] ->
            IncrMastery = list_to_integer(_IncrMastery),
            lib_fishing:add_fishing_mastery(Status, IncrMastery);
        ["activegoal", _GoalId] ->
            GoalId = list_to_integer(_GoalId),
            lib_limit_goal_api:gm_active_limit_goal(Status, GoalId);
        ["resetgoal"] ->
            lib_limit_goal_api:gm_reset_limit_goal(Status);
        ["finishgoal", _GoalId] ->
            GoalId = list_to_integer(_GoalId),
            lib_limit_goal_api:gm_finish_limit_goal_task(Status, GoalId);
        ["finishgoal", _GoalId, _TaskId] ->
            GoalId = list_to_integer(_GoalId),
            TaskId = list_to_integer(_TaskId),
            lib_limit_goal_api:gm_finish_limit_goal_task(Status, GoalId, TaskId);
        ["updaterank", _RankType] ->
            RankType = list_to_integer(_RankType),
            mod_common_rank:timer_common_rank(RankType),
            Status;
        ["removekfteam", _Num] ->
            lib_dun_multi_cluster:cast_dun_multi_mgr_cluster({gm_remove_team, [list_to_integer(_Num)]});
        ["endrechargeact", _SubType] ->
            SubType = list_to_integer(_SubType),
            mod_consume_rank_act:clear_recharge_rank_act(?CUSTOM_ACT_STATUS_CLOSE, SubType);
        ["endconsumeact", _SubType] ->
            SubType = list_to_integer(_SubType),
            mod_consume_rank_act:clear_consume_rank_act(?CUSTOM_ACT_STATUS_CLOSE, SubType);
        ["attrgoods", _GoodsTypeId, Attr, _Num] ->
            GoodsTypeId = list_to_integer(_GoodsTypeId),
            Num = list_to_integer(_Num),
            NowTime = utime:unixtime(),
            NewAttr = [{expire, Value + NowTime}||{1, Value}<-util:string_to_term(Attr)],
            lib_goods_api:send_reward(Status, [{?TYPE_ATTR_GOODS, GoodsTypeId, Num, NewAttr}], gm);
        ["costgoodslist", _CostList] ->
            CostList = util:string_to_term(_CostList),
            case lib_goods_api:cost_object_list_with_check(Status, CostList, gm_cost, "") of
                {true, TmpStatus,_} ->
                    lib_server_send:send_to_sid(Status#player_status.sid, pt_110, 11000, [?SUCCESS]);
                {false, ErrCode, TmpStatus} ->
                    lib_server_send:send_to_sid(Status#player_status.sid, pt_110, 11000, [ErrCode])
            end,
            TmpStatus;
        ["synclocalrank"] ->
            mod_common_rank:gm_sync_to_kf_rank();
        ["repairequiprank"] ->
            mod_common_rank:gm_repair_equip_rank();
        ["power1", _Attr] ->
            Attr = util:string_to_term(_Attr),
            Power = lib_player_attr:calc_preview_power(Status, Attr),
            MsgSend = io_lib:format("将有:属性=~p, power=~p", [Attr,Power]),
            #player_status{id = RoleId,server_id = SerId, server_num = ServerNum, figure = Figure, sid = Sid} = Status,
            PackData = [?CHAT_CHANNEL_SYS, SerId, ServerNum, "", RoleId, Figure, MsgSend, util:term_to_string([]), 0, utime:unixtime(), 0, 0],
            {ok, BinData} = pt_110:write(11001, PackData),
            lib_server_send:send_to_sid(Sid, BinData),
            Status;
        ["power2", _Attr] ->
            Attr = util:string_to_term(_Attr),
            Power = lib_player_attr:calc_attr_list_power(Status, Attr),
            MsgSend = io_lib:format("已有:属性=~p, power=~p", [Attr,Power]),
            #player_status{id = RoleId,server_id = SerId, server_num = ServerNum, figure = Figure, sid = Sid} = Status,
            PackData = [?CHAT_CHANNEL_SYS, SerId, ServerNum, "", RoleId, Figure, MsgSend, util:term_to_string([]), 0, utime:unixtime(), 0, 0],
            {ok, BinData} = pt_110:write(11001, PackData),
            lib_server_send:send_to_sid(Sid, BinData);
        ["showattr"] ->
            AttrList = lists:keysort(1, attr_conv:to_attr_tuple_list(Status#player_status.battle_attr#battle_attr.attr)),
            ?INFO("role_id[~p], show_attr:[~p]", [Status#player_status.id, AttrList]),
            MsgSend = io_lib:format("attr:~n~p", [AttrList]),
            #player_status{id = RoleId,server_id = SerId, server_num = ServerNum, figure = Figure, sid = Sid} = Status,
            PackData = [?CHAT_CHANNEL_SYS, SerId, ServerNum, "", RoleId, Figure, MsgSend, util:term_to_string([]), 0, utime:unixtime(), 0, 0],
            {ok, BinData} = pt_110:write(11001, PackData),
            lib_server_send:send_to_sid(Sid, BinData);
        ["showbaseattr"] ->
            #player_status{role_base_attr = {_, Attr}} = Status,
            AttrList = lists:keysort(1, attr_conv:to_attr_tuple_list(Attr)),
            ?INFO("role_id[~p], showbaseattr:[~p]", [Status#player_status.id, AttrList]),
            MsgSend = io_lib:format("base_attr:~n~p", [AttrList]),
            #player_status{id = RoleId,server_id = SerId, server_num = ServerNum, figure = Figure, sid = Sid} = Status,
            PackData = [?CHAT_CHANNEL_SYS, SerId, ServerNum, "", RoleId, Figure, MsgSend, util:term_to_string([]), 0, utime:unixtime(), 0, 0],
            {ok, BinData} = pt_110:write(11001, PackData),
            lib_server_send:send_to_sid(Sid, BinData);
        ["showmonattr", _Mid] ->
            Mid = list_to_integer(_Mid),
            #player_status{scene = Scene, scene_pool_id = ScenePool, copy_id = CopyId, sid = Sid, id = RoleId} = Status,
            #ets_scene{type = SceneType} = data_scene:get(Scene),
            lists:member(SceneType, [?SCENE_TYPE_DUNGEON]) andalso mod_scene_agent:apply_cast(Scene, ScenePool, lib_scene_agent, print_mon_attr, [RoleId, Sid, CopyId, Mid]),
            ok;
        ["guildlabor", _Type] ->
            Type = list_to_integer(_Type),
            lib_guild_labor:task_active(Status,Type);
        ["gmred",_Value]->
            Value = list_to_integer(_Value),
            lib_red_envelopes:gm_red(Status,Value);
        ["petsupportrank", _RefreshType] ->
            RefreshType = list_to_integer(_RefreshType),
            lib_pet_support_mod:gm_imitate_fake_player_login(RefreshType);
        ["enterglamour",_Time]->
            mod_glamour_ctrl:gm_start(list_to_integer(_Time));
        ["changechildlinkheartexp", _Exp] ->
            AddExp = list_to_integer(_Exp),
            TStatus = lib_child:gm_change_link_heart_exp(Status, AddExp),
            TStatus;
        ["getscene"] ->
            #player_status{scene = Scene, scene_pool_id = PoolId, copy_id = CopyId, id = RoleId,
                server_id = SerId, figure = Figure, sid = Sid, x = X, y = Y, dungeon = #status_dungeon{dun_id = DunId}} = Status,
            MsgSend = io_lib:format("scene=~p, scene_pool_id=~p, copy_id=~p, x=~p, y=~p, dun_id=~p", [Scene, PoolId, CopyId, X, Y, DunId]),
            PackData = [?CHAT_CHANNEL_WORLD, SerId, 0, "", RoleId, Figure, MsgSend, util:term_to_string([]), 0, utime:unixtime(), 0, 0],
            {ok, BinData} = pt_110:write(11001, PackData),
            lib_server_send:send_to_sid(Sid, BinData),
            Status;
        ["gboss",_Sec]->
            Sec = list_to_integer(_Sec),
            mod_guild_boss_mgr:gm_start(Sec);
        ["gfire",_Sec]->
            Sec = list_to_integer(_Sec),
            mod_guild_tribe_mgr:activitycalen_start(Sec);
        ["setvehiclestage", _VehicleId, _Stage] ->
            VehicleId = list_to_integer(_VehicleId),
            Stage     = list_to_integer(_Stage),
            lib_child_items:gm_set_child_vehicle_stage(Status, VehicleId, Stage);
        ["resetvip", _Val] ->
            lib_vip_util:gm_reset_vip(list_to_integer(_Val), Status);
        ["resetsupvip"] ->
            lib_sup_vip:gm_reset_supvip(Status);
        ["resettowerdun"] ->
            lib_dungeon_tower:gm_reset_tower_dun(Status);
        ["quickopenslot"] ->
            {ok, Status1} = lib_child_items:gm_quick_open_toy_slot(Status),
            Status1;
        ["trialfashion", Val] ->
            GoodsId = list_to_integer(Val),
            lib_fashion:active_fashion_by_goods(Status#player_status.id, GoodsId),
            Status;
        ["setdevourlv", Lv] ->
            goods_devour:gm_set(Status, list_to_integer(Lv));
		["sendtv", Module, Id, Arg] ->
			List = util:string_to_term(Arg),
			lib_chat:send_TV({all}, list_to_integer(Module), list_to_integer(Id), List),
			Status;
        ["autoequip", Series, Color] ->
            equipment_api:gm_wear_equipment(Status, list_to_integer(Series), list_to_integer(Color));
        ["autofoster"]->
            NStatus = lib_role_foster:gm(Status),
            lib_role_foster_skin:gm(NStatus);
        ["autovisus"]->
            lib_role_visus:gm(Status);
        ["autodsgt"] ->
            lib_designation:active_all_dsgt(Status);
        ["resetvisusdun", DunIdL, WaveL] ->
            lib_dungeon_visus:gm_reset_dun_wave(list_to_integer(WaveL), list_to_integer(DunIdL), Status);
        ["resetlattice"] ->
            lib_lattice:gm_reset(Status);
        ["resetinvest", Type] ->
            lib_investment:gm_reset(Status, list_to_integer(Type));
        ["rrsettlement", ActId1] ->
            ActId = list_to_integer(ActId1),
            MyArgs = [{gm_settlement_act, ActId}],
            Mfa = {race_rank_act, cast, MyArgs},
            clusters_node:apply_cast(Mfa);
        ["gwbegin"] ->
            guild_war_mgr:gm_start(),
            ok;
        ["gwend"] ->
            guild_war_mgr:gm_end(),
            ok;
        ["cmd", _Cmd, _CmdData] ->
            Cmd = list_to_integer(_Cmd),
            CmdData = util:string_to_term(_CmdData),
            io:format("~p[~p] Cmd:~p, Data:~p~n", [?MODULE, ?LINE,  Cmd, CmdData]),
            case protocol_routing:map(Cmd div 100) of
                {role, _ProtoMod, Mod} ->
                    Mod:handle(Cmd, Status, CmdData);
                _ -> ignore
            end;
        ["resetgod"] ->
            god_api:reset_god(Status);
        ["finishelitetask", _Category] ->
            Category = list_to_integer(_Category),
            lib_elite_assessment:gm_finish_category_all_task(Status, Category);
        ["guildrace"] ->
            mod_guild_race_rank:timer_check();
        %% 跨服分区相关GM命令
        ["cz", CZDo] ->
            case CZDo of
                "cl" ->
                    czone:gm_reset_zones();
                "reg" ->
                    center_svr_reg:gm_do_reg();
                _ ->
                    case string:to_integer(CZDo) of
                        {N, []} -> czone:gm_zone_n_times(N);
                        _ ->
                            TimerType = CZDo,
                            czone:gm_timer(TimerType)
                    end
            end,
            ok;
        ["campwar", Type, ClsType] ->
            camp_war_mgr:gm_act(list_to_integer(Type), list_to_integer(ClsType));
        ["sethostvalue", Value] ->
            offline_hosting_api:gm_add_value(Status, list_to_integer(Value));
        ["cgwar",Sec]->
            clusters_node:apply_cast(mod_cgwar_ctrl, gm_start, [list_to_integer(Sec)]);
        ["noticepowerrank"] ->
            clusters_node:apply_cast(god_dun_rank_api, gm_notice_power_rank, []);
        ["wasteland", Option] ->
            TOption = list_to_integer(Option),
            case TOption of
                1 -> wasteland_war_api:gm_start();
                0 -> wasteland_war_api:gm_end();
				_ -> ignore
            end;
        ["madnessbegin"]->
            madness_land:gm_begin(),
            Status;
        ["madnessnext"]->
            madness_land:gm_stage(),
            Status;
        ["goddunrank"] ->
            clusters_node:apply_cast(gen_server, cast, [god_dun_rank_mgr, {daily_reset}]);
        ["singlechargereset"] ->
            custom_act_single_recharge:gm_reset_role_progress(Status);
        ["monopolyreset", Type] ->
            custom_act_mono_poly:gm_reset_monopoly(Status, list_to_integer(Type));
        ["bcbegin"]->
            beauty_contest:gm_begin(),
            Status;
        ["bcnext"]->
            beauty_contest:gm_next(),
            Status;
        ["ctreset"] ->
            custom_act_contract:gm_reset(Status),
            Status;
        ["ctaddscore", SubType, ScoreAdd] ->
            SubType1 = list_to_integer(SubType),
            ScoreAdd1 = list_to_integer(ScoreAdd),
            custom_act_contract:gm_add_score(Status, SubType1, ScoreAdd1),
            Status;
        ["cleardunpetrank"] ->
            mod_dun_pet_rank:midnight_refresh();
        ["montalk", ModId, Id] ->
            {ok, Bin} = pt_110:write(11064, [list_to_integer(ModId), list_to_integer(Id), "绝地武士"]),
            lib_server_send:send_to_sid(Status#player_status.sid, Bin),
            Status;
        ["simupt", _Cmd, _Arg] ->
            Cmd = list_to_integer(_Cmd),
            Arg = util:string_to_term(_Arg),
            case protocol_routing:map(Cmd div 100) of
                {role, ProtoMod, _Mod} ->
                    {ok, Bin} = ProtoMod:write(Cmd, Arg),
                    lib_server_send:send_to_sid(Status#player_status.sid, Bin);
                _ ->
                    ok
            end,
            Status;
        ["resetgalaxydun"] ->
            lib_dungeon_galaxy:gm_reset_galaxy_dun(Status);
        ["addphantomscore", SubType, ScoreAdd] ->
            SubType1 = list_to_integer(SubType),
            ScoreAdd1 = list_to_integer(ScoreAdd),
            custom_act_phantom:gm_add_score(Status, SubType1, ScoreAdd1),
            Status;
        ["phantomreset"] ->
            custom_act_phantom:gm_reset(Status),
            Status;
        ["addscorevalue", SubType, Value] ->
            SubType1 = list_to_integer(SubType),
            AddValue = list_to_integer(Value),
            scratch_card:gm_add_scratch_score(Status, SubType1, AddValue),
            Status;
        ["resetcoupon"] ->
            Status1 = relation_coupon:gm_reset(Status),
            Status1;
        ["vierank",Act0]->
            Act = list_to_integer(Act0),
            clusters_node:apply_cast(mod_vie_rank_center, gm_account, [Act]),
            Status;
        ["autowarsoul"] ->
            warsoul_api:gm_equipment_all(Status);
        ["adventurereset"] ->
            custom_act_adventure:gm_reset(Status),
            Status;
        ["adventurescore", SubType, Score, Progress] ->
            SubType1 = list_to_integer(SubType),
            Score1 = list_to_integer(Score),
            Progress1 = list_to_integer(Progress),
            custom_act_adventure:gm_set_score_and_progress(Status, SubType1, Score1, Progress1),
            Status;
        ["activealldress"] ->
            Status1 = lib_dress_up:gm_active_all_dress_up(Status),
            Status1;
        ["resetroute", SubType, RouteId] ->
            SubType1 = list_to_integer(SubType),
            RouteId1 = list_to_integer(RouteId),
            custom_act_reversi:gm_reset_route(Status, SubType1, RouteId1),
            Status;
        ["checkroute"] ->
           CheckResult = custom_act_reversi:gm_check_route(),
            #player_status{server_id = SerId, server_num = SerNum, server_name = ServerName, id = RoleId, figure = Figure} = Status,
            Msg = io_lib:format("Check Result:~n~p", [CheckResult]),
            PackData = [1, SerId, SerNum, ServerName, RoleId, Figure, Msg, util:term_to_string([]), 0, utime:unixtime(), 0, 0],
            {ok, BinData} = pt_110:write(11001, PackData),
            lib_server_send:send_to_all(BinData);
        ["resetreversi", SubType] ->
            SubType1 = list_to_integer(SubType),
            custom_act_reversi:gm_reset_data(Status, SubType1);
        ["activeallfashion"] ->
            Status1 = lib_fashion:gm_active_all_fashion(Status),
            Status1;
        ["gmauto"] ->
            gm_auto(Status);
        ["actbossinit"] ->
            act_boss_mgr:gm_init_boss(),
            Status;
        ["actbossclean"] ->
            act_boss_mgr:gm_clean_boss(),
            Status;
        ["guardassistacc"] ->
            guard_dun_assist_local:weekly_reset(),
            Status;
        ["permitloginaddday", SubType, Day] ->
            SubType1 = list_to_integer(SubType),
            Day1 = list_to_integer(Day),
            permit_login:gm_add_login_day(Status, SubType1, Day1),
            Status;
        ["sevendaygoal", Day] ->
            Day1 = list_to_integer(Day),
            Status1 = lib_seven_days_goal:gm_add_login_day(Status, Day1),
            Status1;
        ["setstateattr"] ->
            Sql = io_lib:format(<<"update player_state set `attr` = '[{1,10000},{2,10000}]' where `attr` = '[]'">>,[]),
            db:execute(Sql);
        ["sethosting"] ->
            set_hosting(),
            Status;
        ["moninfo"] ->
            #player_status{scene = SceneId} = Status,
            case lib_scene:is_clusters_scene(SceneId) of
                true ->
                    Res = clusters_node:apply_call(mon_mgr, gm_get_mon_info, [SceneId, Status#player_status.scene_pool_id, Status#player_status.copy_id, attr]);
                false ->
                    Res = mon_mgr:gm_get_mon_info(SceneId, Status#player_status.scene_pool_id, Status#player_status.copy_id, attr)
            end,
            MsgSend = io_lib:format("~ts", [util:term_to_bitstring(Res)]),
            PackData = [?CHAT_CHANNEL_WORLD, Status#player_status.server_id, 0, "", Status#player_status.id, Status#player_status.figure, MsgSend, util:term_to_string([]), 0, utime:unixtime(), 0, 0],
            {ok, BinData} = pt_110:write(11001, PackData),
            lib_server_send:send_to_sid(Status#player_status.sid, BinData),
            Status;
        ["cpend"] ->
            clusters_node:apply_cast(cross_point_fight_center, season_switch, [2]),
            Status;
        ["gmcgwsign"]->
            cross_guild_war_api:gm(Status#player_status.id),
            Status;
        ["addlegionscore",Value]->
            {ok,NStatus}=lib_role_legion:add_legion_score(Status,list_to_integer(Value)),
            NStatus;
        ["jumpact", Time] ->
            jump_act_center:gm_begin(list_to_integer(Time)),
            Status;
        ["jumpstart"] ->
            jump_act_center:gm_match_success(),
            Status;
        ["director"] ->
            Zone = czone_api:env_get_zone_id(),
            clusters_node:apply_cast(mod_legion_rank_mgr, issue_reset, [Zone]),
            Status;
        ["expdropreset", Wave] ->
            Status1 = exp_dun_drop_api:gm_reset_role_exp_dun_drop(Status, list_to_integer(Wave)),
            Status1;
        ["addrunassist", TaskType] ->
            guild_run_assist:gm_add_run_assist(Status#player_status.id, list_to_integer(TaskType)),
            Status;
        ["resetgodcd", Pos] ->
            Status1 = god_api:reset_god_cd(Status, list_to_integer(Pos)),
            Status1;
        ["gmreselectegg", SubType] ->
            select_capsule_egg:gm_reset_times(Status, list_to_integer(SubType)),
            Status;
        ["resettowercount"] ->
            lib_dungeon_tower:reset_tower_count(Status#player_status.id),
            Status;
        ["resetexpsea"] ->
            exp_sea_logic:gm_reset_exp_sea_time(Status);
        ["resetwishcount", WishType] ->
            lib_currencywish:gm_reset_wishcount(Status, list_to_integer(WishType));
        _ ->
            ?PRINT("error gm cmd = 11101, data=~p ~n", [Args]),
            Status
    end,
    case NewStatus of
        #player_status{} ->
            lib_player:send_attribute_change_notify(NewStatus, ?NOTIFY_ATTR),
            {ok, battle_attr, NewStatus};
        %% 部分秘籍不需要更新battle_attr, 因为异步消息前后顺序的关系，
        %% PS上的battle_attr不是最新的，更新battle_attr会覆盖原有
        {no_notify_attr, #player_status{} = NewStatus2} ->
            {ok, NewStatus2};
        _ -> NewStatus
    end;

do_handle(_Cmd, _, _Data) ->
    ?PRINT("cmd =~w, data=~p ~n", [_Cmd, _Data]),
    {error, no_match}.

gm_auto(Status) ->
    %% 等级
    Lv = 525,
    F = fun(_, TmpStatus) ->
        Exp = max(0, data_exp:get(TmpStatus#player_status.figure#figure.lv) - TmpStatus#player_status.exp),
        UpExpStatus = lib_player:add_exp(TmpStatus, Exp, gm),
        {ok, UpExpStatus}
        end,
    {ok, Status1} = util:for(Status#player_status.figure#figure.lv, Lv - 1, F, Status),
    %% 转生-2转
    Status2 = turn(Status1),
    Status3 = turn(Status2),
    %% 装备-6套、强化-进化-器灵-宝石-收集
    AllSe = [1, 2, 3, 4, 5, 6],
    Status4 =
    lists:foldl(
        fun(Series, TmpStatus1) ->
            equipment_api:gm_wear_equipment(TmpStatus1, Series, 4)
        end, Status3, AllSe
    ),
    %% 装备其他数据
    equipment_logic:save_equipment_info(Status#player_status.id,
        #equipment{stars = 168, unlock_series = 6, gems_suit = [{Se, 240}||Se <- AllSe]}),
    %% 进阶
    Status5 = lib_role_foster:gm(Status4),
    %% 幻光
    Status6 = lib_role_visus:gm(Status5),
    %% 技能
    Status7 = auto_skill(Status6),
    %% 成就
    Status8 = lib_achievement_api:gm_finish_all_type(Status7),
    %% 战魂
    Status9 = warsoul_api:gm_equipment_all(Status8),
    %% 称号
    Status10 = lib_designation:active_all_dsgt(Status9),
    %% VIP
    Status11 = lib_vip_util:gm_reset_vip(15, Status10),
    %% 任务
    lib_task:gm_finish_lv_task(Status11),
    %% 时装
    Status13 = lib_fashion:gm_active_all_fashion(Status11),
    %% 装扮
    Status14 = lib_dress_up:gm_active_all_dress_up(Status13),
    Status14.

turn(Status) ->
    #player_status{figure = Figure, transform_data = TransformData, id = RoleId} = Status,
    #figure{turn = OldTurn} = Figure,
    NewTurn = OldTurn + 1,
    case NewTurn =< ?MAX_TURN of
        true ->
            TransformData2 = TransformData#transform_info{
                transform_id = NewTurn, stage = 0
            },
            NewTransformData = transform:calc_transform(TransformData2),
            transform:save_transform_data(RoleId, NewTransformData),
            NewPlayer = Status#player_status{figure = Figure#figure{turn = NewTurn, turn_stage = 0}, transform_data = NewTransformData},
            LastPlayer = transform:transform_up(NewPlayer),


            TaskId = case data_transform:get_transform_step_cfg(NewTurn+1, 1) of
                         #transform_step{task_id = TTaskId} -> TTaskId;
                         _ -> -1
                     end,

            TurnTasks = case TaskId>0 of
                true->
                    lists:seq(1,max(1,TaskId-1));
                _->
                    []
            end,
            NowTime = utime:unixtime(),

            [begin
                 case lib_task:find_task_log_list(OTid) of
                    false->
                        Sql = io_lib:format(<<"REPLACE INTO `task_log` set `role_id`=~p, `task_id`=~p, `type`=~p, `trigger_time`=~p, `finish_time`=~p">>, [RoleId, OTid, ?TASK_TYPE_TURN, NowTime, NowTime]),
                        db:execute(Sql);
                    _->
                        skip
                end
            end || OTid <- TurnTasks],

            lib_task:gm_refresh_task(0, lib_task_api:ps2task_args(LastPlayer)),

            case data_task:get(TaskId) of
                null -> skip;
                _ -> lib_task:force_trigger(TaskId, lib_task_api:ps2task_args(Status))
            end,

            LastPlayer;
        false ->
            Status
    end.

auto_skill(Status) ->
    Figure = Status#player_status.figure,
    Skills = lib_skill_api:get_career_all_skill_ids(Figure#figure.career, Figure#figure.sex),
    F = fun({SkillId, SkillLv}, Index) ->
        Sql0 = io_lib:format(<<"replace into skill set id = ~p, skill_id = ~p, lv = ~p ">>, [Status#player_status.id, SkillId, SkillLv]),
        db:execute(Sql0),
        Index + 1
        end,
    lists:foldl(F, 1, Skills),
    SkillStatus = lib_skill:skill_online(Status#player_status.id, Figure#figure.career, Figure#figure.lv, 0, {0, 0, 0}),
    Status1 = lib_player:count_player_attribute(Status#player_status{ skill = SkillStatus}),
    pp_skill:handle(21002, Status1, []),
    Status1.

set_hosting() ->
    Now = utime:unixtime(),
    db:execute(<<"UPDATE offline_hosting_setting SET value=1000,u_time=~p">>, [Now]),
    db:execute(<<"UPDATE player_login set last_logout_time=~p">>, [Now]),
    ets:delete_all_objects(ets_role_show),
    offline_hosting ! load_host_setting.
