Commit 46853f49 authored by mercury233's avatar mercury233

add surrender

parent 611eac0e
......@@ -165,6 +165,9 @@
"cloud_replay_delay_part1": "本场比赛云录像:",
"cloud_replay_delay_part2": "。将于本局结束后可播放。",
"afk_warn_part1": "已经很久没有操作了,若继续挂机,将于",
"afk_warn_part2": "秒后被请出房间"
"afk_warn_part2": "秒后被请出房间",
"surrender_confirm": "确实要投降吗?再次输入 /投降 以确认。",
"surrender_canceled": "已取消投降,加油!",
"surrender_denied": "为保证双方玩家的游戏体验,随机对战中3回合后才能投降。"
}
}
\ No newline at end of file
......@@ -1191,6 +1191,10 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
client.lp = room.hostinfo.start_lp
#ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}")
if ygopro.constants.MSG[msg] == 'NEW_TURN' and client.surrend_confirm
client.surrend_confirm = false
ygopro.stoc_send_chat(client, "${surrender_canceled}", ygopro.constants.COLORS.BABYBLUE)
if ygopro.constants.MSG[msg] == 'WIN' and client.is_host
pos = buffer.readUInt8(1)
......@@ -1378,6 +1382,18 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server)->
room.last_active_time = moment() unless cancel or not room.random_type
cmd = msg.split(' ')
switch cmd[0]
when '/投降', '/surrender'
if !room.started or room.hostinfo.mode==2
return cancel
if room.random_type
ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE)
return cancel
if client.surrend_confirm
ygopro.ctos_send(client.server, 'SURRENDER')
else
ygopro.stoc_send_chat(client, "${surrender_confirm}", ygopro.constants.COLORS.BABYBLUE)
client.surrend_confirm = true
when '/help'
ygopro.stoc_send_chat(client, "${chat_order_main}")
ygopro.stoc_send_chat(client, "${chat_order_help}")
......
......@@ -1429,6 +1429,10 @@
client.is_first = !(playertype & 0xf);
client.lp = room.hostinfo.start_lp;
}
if (ygopro.constants.MSG[msg] === 'NEW_TURN' && client.surrend_confirm) {
client.surrend_confirm = false;
ygopro.stoc_send_chat(client, "${surrender_canceled}", ygopro.constants.COLORS.BABYBLUE);
}
if (ygopro.constants.MSG[msg] === 'WIN' && client.is_host) {
pos = buffer.readUInt8(1);
if (!(client.is_first || pos === 2)) {
......@@ -1696,6 +1700,22 @@
}
cmd = msg.split(' ');
switch (cmd[0]) {
case '/投降':
case '/surrender':
if (!room.started || room.hostinfo.mode === 2) {
return cancel;
}
if (room.random_type) {
ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE);
return cancel;
}
if (client.surrend_confirm) {
ygopro.ctos_send(client.server, 'SURRENDER');
} else {
ygopro.stoc_send_chat(client, "${surrender_confirm}", ygopro.constants.COLORS.BABYBLUE);
client.surrend_confirm = true;
}
break;
case '/help':
ygopro.stoc_send_chat(client, "${chat_order_main}");
ygopro.stoc_send_chat(client, "${chat_order_help}");
......
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