187 lines
4.5 KiB
Lua
187 lines
4.5 KiB
Lua
--region *.lua
|
|
--Date
|
|
--此文件由[BabeLua]插件自动生成
|
|
|
|
JSON = (loadfile "JSON.lua")();
|
|
|
|
print("script hava been loaded!");
|
|
|
|
-- 检测数组中是否包含某个值
|
|
function in_table(val, tbl)
|
|
if (not tbl) then
|
|
return false;
|
|
end;
|
|
|
|
for k, v in ipairs(tbl) do
|
|
if (v == val) then
|
|
return true;
|
|
end;
|
|
end;
|
|
|
|
return false;
|
|
end;
|
|
|
|
-- lua 判断一个字符是否存在某个数组
|
|
-- 判断字符b,是否存在于数组list中
|
|
function in_array(b, list)
|
|
if (not list) then
|
|
return false;
|
|
end;
|
|
|
|
for k, v in pairs(list) do
|
|
if (v.tableName == b) then
|
|
return true;
|
|
end;
|
|
end;
|
|
|
|
return false;
|
|
end
|
|
|
|
function LuaMain(CommandLine)
|
|
local command = [[
|
|
select
|
|
idx,
|
|
plgr_agentid,
|
|
plgr_playerid,
|
|
plgr_gameid,
|
|
plgr_roomcode,
|
|
plgr_ownerid,
|
|
plgr_roomtype,
|
|
plgr_createtime,
|
|
plgr_makewartime,
|
|
plgr_overtime,
|
|
plgr_gameinfo1,
|
|
rank
|
|
from
|
|
(
|
|
select
|
|
a.idx,
|
|
a.plgr_agentid,
|
|
a.plgr_playerid,
|
|
a.plgr_gameid,
|
|
a.plgr_roomcode,
|
|
a.plgr_ownerid,
|
|
a.plgr_roomtype,
|
|
a.plgr_createtime,
|
|
a.plgr_makewartime,
|
|
a.plgr_overtime,
|
|
a.plgr_gameinfo1,
|
|
@rn := @rn + 1,
|
|
if (@gp = concat(a.plgr_agentid, a.plgr_gameid, a.plgr_roomcode, a.plgr_ownerid, a.plgr_createtime), @rank := @rank + 1, @rank := 1) rank,
|
|
@gp := concat(a.plgr_agentid, a.plgr_gameid, a.plgr_roomcode, a.plgr_ownerid, a.plgr_createtime)
|
|
from
|
|
(
|
|
select
|
|
idx,
|
|
plgr_agentid,
|
|
plgr_playerid,
|
|
plgr_gameid,
|
|
plgr_roomcode,
|
|
plgr_ownerid,
|
|
plgr_roomtype,
|
|
plgr_createtime,
|
|
plgr_makewartime,
|
|
plgr_overtime,
|
|
plgr_gameinfo1
|
|
from
|
|
player_grade
|
|
where
|
|
# plgr_agentid = '00bA05haB0d9ZC0fwGD09Q2OA30insbQ' and
|
|
#plgr_agentid = 'veRa0qrBf0df2K1G4de2tgfmVxB2jxpv' and
|
|
idx not in (select out_id from ct_grade_core)
|
|
order by
|
|
idx
|
|
limit 1000
|
|
) a,
|
|
(select @rn := 0, @gp := null, @rank := 0) b
|
|
) t
|
|
]];
|
|
|
|
local callable = "callable";
|
|
|
|
return command, callable, 1;
|
|
end;
|
|
|
|
|
|
function callable(...)
|
|
local argv = {...}; -- 参数列表
|
|
local argn = select("#", ...); -- 参数个数
|
|
|
|
local status, result = nil, nil;
|
|
|
|
local id, agent_id, player_id, game_id, room_code, owner_id, room_type, create_time, makewar_time, over_time, game_info1, rank = select("1", ...);
|
|
local nick_name = nil; -- 昵称
|
|
local core = nil; -- 得分
|
|
local avatar = nil; -- 头像
|
|
local player_id = nil; -- 玩家id
|
|
local room_card = nil; -- 房卡数
|
|
local done = "0"; -- 是否成功解析数据包
|
|
|
|
local table_room_type, table_game_info = nil, nil;
|
|
|
|
--print("id="..id.."\nagent_id="..agent_id.."\nplayer_id="..player_id.."\ngame_id="..game_id.."\nroom_code="..room_code.."\nowner_id="..owner_id.."\nroom_type="..room_type.."\ncreate_time="..create_time.."\nmakewar_time="..makewar_time.."\nover_time="..over_time.."\ngame_info1="..game_info1.."\nrank="..rank);
|
|
|
|
status, result = pcall(function() return JSON:decode(room_type); end);
|
|
if (status) then
|
|
table_room_type = result;
|
|
else
|
|
print(result);
|
|
end;
|
|
--print("table_room_type data type is "..type(table_room_type));
|
|
|
|
status, result = pcall(function() return JSON:decode(game_info1); end);
|
|
if (status) then
|
|
table_game_info = result;
|
|
else
|
|
print(result);
|
|
end;
|
|
--print("table_game_info data type is "..type(table_game_info));
|
|
|
|
if (("table" == type(table_room_type)) and (#table_room_type > 0)) then
|
|
room_card = tostring(table_room_type[1]);
|
|
end;
|
|
|
|
if ("table" == type(table_game_info)) then
|
|
local table_player_list = table_game_info["playerlist"];
|
|
|
|
if ("table" == type(table_player_list)) then
|
|
local table_player_item = table_player_list[tonumber(rank)];
|
|
|
|
if (("table" == type(table_player_item)) and (#table_player_item > 0)) then
|
|
nick_name = table_player_item[1];
|
|
core = table_player_item[2];
|
|
avatar = table_player_item[3];
|
|
player_id = table_player_item[4];
|
|
done = "1";
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
local cmd = [[
|
|
insert into ct_grade_core(agent_id, game_id, player_id, nick_name, player_core, room_code, room_type, room_card, owner_id, owner_card, create_time, makewar_time, over_time, is_done, out_id, out_sub_id)
|
|
values(?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?, ?)
|
|
]];
|
|
|
|
local ret = ADOExecute(cmd, agent_id, game_id, player_id, nick_name, core, room_code, room_type, room_card, owner_id, create_time, makewar_time, over_time, done, id, rank);
|
|
return ret;
|
|
-------------------------------------------------------------
|
|
-- print(select("2", ...) .. "\r\n");
|
|
-- -- 遍历参数列表
|
|
-- for idx, val in ipairs(argv) do
|
|
-- print(idx .. ">>>>>>" .. val);
|
|
-- end;
|
|
-------------------------------------------------------------
|
|
end;
|
|
|
|
function lookup_args(...)
|
|
local argv = {...};
|
|
local argn = select("#",...);
|
|
print("参数个数 : ", argn);
|
|
|
|
for n,m in ipairs(argv) do
|
|
print(n..">>>>>>"..m);
|
|
end;
|
|
|
|
return 0;
|
|
end;
|