Commit 94c494dc authored by mercury233's avatar mercury233

update add ai command

parent eed13f3e
......@@ -1294,12 +1294,13 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
msg = _.trim(info.msg)
cancel = _.startsWith(msg, "/")
room.last_active_time = moment() unless cancel or not room.random_type
switch msg
cmd = msg.split(' ')
switch cmd[0]
when '/help'
ygopro.stoc_send_chat(client, "YGOSrv233 指令帮助")
ygopro.stoc_send_chat(client, "/help 显示这个帮助信息")
ygopro.stoc_send_chat(client, "/roomname 显示当前房间的名字")
ygopro.stoc_send_chat(client, "/ai 添加一个AI") if settings.modules.enable_windbot
ygopro.stoc_send_chat(client, "/ai 添加一个AI,/ai 角色名 可指定添加的角色") if settings.modules.enable_windbot
ygopro.stoc_send_chat(client, "/tip 显示一条提示") if settings.modules.tips
when '/tip'
......@@ -1307,7 +1308,14 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
when '/ai'
if settings.modules.enable_windbot
windbot = _.sample settings.modules.windbots
if name = cmd[1]
windbot = _.sample _.filter settings.modules.windbots, (w)->
w.name == name or w.deck == name
if !windbot
ygopro.stoc_send_chat(client, "未找到该AI角色或卡组", ygopro.constants.COLORS.RED)
return
else
windbot = _.sample settings.modules.windbots
room.add_windbot(windbot)
when '/roomname'
......
......@@ -1594,7 +1594,7 @@
});
ygopro.ctos_follow('CHAT', true, function(buffer, info, client, server) {
var cancel, msg, oldmsg, room, struct, windbot;
var cancel, cmd, msg, name, oldmsg, room, struct, windbot;
room = ROOM_all[client.rid];
if (!room) {
return;
......@@ -1604,13 +1604,14 @@
if (!(cancel || !room.random_type)) {
room.last_active_time = moment();
}
switch (msg) {
cmd = msg.split(' ');
switch (cmd[0]) {
case '/help':
ygopro.stoc_send_chat(client, "YGOSrv233 指令帮助");
ygopro.stoc_send_chat(client, "/help 显示这个帮助信息");
ygopro.stoc_send_chat(client, "/roomname 显示当前房间的名字");
if (settings.modules.enable_windbot) {
ygopro.stoc_send_chat(client, "/ai 添加一个AI");
ygopro.stoc_send_chat(client, "/ai 添加一个AI,/ai 角色名 可指定添加的角色");
}
if (settings.modules.tips) {
ygopro.stoc_send_chat(client, "/tip 显示一条提示");
......@@ -1623,7 +1624,17 @@
break;
case '/ai':
if (settings.modules.enable_windbot) {
windbot = _.sample(settings.modules.windbots);
if (name = cmd[1]) {
windbot = _.sample(_.filter(settings.modules.windbots, function(w) {
return w.name === name || w.deck === name;
}));
if (!windbot) {
ygopro.stoc_send_chat(client, "未找到该AI角色或卡组", ygopro.constants.COLORS.RED);
return;
}
} else {
windbot = _.sample(settings.modules.windbots);
}
room.add_windbot(windbot);
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment