Commit f0590f82 authored by nanahira's avatar nanahira

support tag duel surrender

parent 1774e230
Pipeline #27236 failed with stages
in 3 minutes and 4 seconds
......@@ -54,6 +54,7 @@
"32": "HS_PLAYER_ENTER",
"33": "HS_PLAYER_CHANGE",
"34": "HS_WATCH_CHANGE",
"35": "TEAMMATE_SURRENDER",
"48": "FIELD_FINISH"
},
"PLAYERCHANGE":{
......
......@@ -108,6 +108,8 @@
"afk_warn_part1": "no opreation too long, will be disconnected after ",
"afk_warn_part2": " seconds",
"surrender_confirm": "Are you sure? Enter /surrender again to confirm.",
"surrender_confirm_tag": "Your partner started a surrender request, click Surrender Button or type /surrender to confirm.",
"surrender_confirm_sent": "Surrender request sent, waiting for partner to confirm.",
"surrender_canceled": "Surrender canceled.",
"surrender_denied": "Please don't surrender in the first 2 turns.",
"unwelcome_warn_part1": "If you keep doing ",
......@@ -433,6 +435,8 @@
"afk_warn_part1": "已经很久没有操作了,若继续挂机,将于",
"afk_warn_part2": "秒后被请出房间",
"surrender_confirm": "确实要投降吗?再次输入 /投降 以确认。",
"surrender_confirm_tag": "您的队友发起了投降请求,点击投降按钮或输入 /投降 以确认。",
"surrender_confirm_sent": "已发起投降请求,请等待队友确认。",
"surrender_canceled": "已取消投降,加油!",
"surrender_denied": "为保证双方玩家的游戏体验,随机对战中3回合后才能投降。",
"unwelcome_warn_part1": "如果您经常",
......
......@@ -1148,6 +1148,24 @@ CLIENT_heartbeat_register = global.CLIENT_heartbeat_register = (client, send) ->
CLIENT_is_banned_by_mc = global.CLIENT_is_banned_by_mc = (client) ->
return client.ban_mc and client.ban_mc.banned and moment_now.isBefore(client.ban_mc.until)
CLIENT_get_absolute_pos = global.CLIENT_get_absolute_pos = (client) ->
room = ROOM_all[client.rid]
if room.hostinfo.mode != 2 or client.pos > 3
return client.pos
else if client.pos < 2
return 0
else
return 1
CLIENT_get_partner = global.CLIENT_get_partner = (client) ->
room = ROOM_all[client.rid]
if room.hostinfo.mode != 2 or client.pos > 3
return client
if client.pos < 2
return room.dueling_players[1 - client.pos]
else
return room.dueling_players[5 - client.pos]
CLIENT_send_replays = global.CLIENT_send_replays = (client, room) ->
return false unless settings.modules.replay_delay and not (settings.modules.tournament_mode.enabled and settings.modules.tournament_mode.block_replay_to_player) and room.replays.length and room.hostinfo.mode == 1 and !client.replays_sent and !client.isClosed
client.replays_sent = true
......@@ -2558,15 +2576,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
if room.dueling_players[0].lp != room.dueling_players[oppo_pos].lp and room.turn > 1
win_pos = if room.dueling_players[0].lp > room.dueling_players[oppo_pos].lp then 0 else oppo_pos
ygopro.stoc_send_chat_to_room(room, "${death_finish_part1}" + room.dueling_players[win_pos].name + "${death_finish_part2}", ygopro.constants.COLORS.BABYBLUE)
if room.hostinfo.mode == 2
room.finished_by_death = true
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos], 'DUEL_END')
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END')
room.scores[room.dueling_players[oppo_pos - win_pos].name_vpass] = -1
CLIENT_kick(room.dueling_players[oppo_pos - win_pos])
CLIENT_kick(room.dueling_players[oppo_pos - win_pos + 1])
else
ygopro.ctos_send(room.dueling_players[oppo_pos - win_pos].server, 'SURRENDER')
ygopro.ctos_send(room.dueling_players[oppo_pos - win_pos].server, 'SURRENDER')
else
room.death = -1
ygopro.stoc_send_chat_to_room(room, "${death_remain_final}", ygopro.constants.COLORS.BABYBLUE)
......@@ -2583,15 +2593,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
if room.dueling_players[0].lp != room.dueling_players[oppo_pos].lp
win_pos = if room.dueling_players[0].lp > room.dueling_players[oppo_pos].lp then 0 else oppo_pos
ygopro.stoc_send_chat_to_room(room, "${death_finish_part1}" + room.dueling_players[win_pos].name + "${death_finish_part2}", ygopro.constants.COLORS.BABYBLUE)
if room.hostinfo.mode == 2
room.finished_by_death = true
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos], 'DUEL_END')
ygopro.stoc_send(room.dueling_players[oppo_pos - win_pos + 1], 'DUEL_END')
room.scores[room.dueling_players[oppo_pos - win_pos].name_vpass] = -1
CLIENT_kick(room.dueling_players[oppo_pos - win_pos])
CLIENT_kick(room.dueling_players[oppo_pos - win_pos + 1])
else
ygopro.ctos_send(room.dueling_players[oppo_pos - win_pos].server, 'SURRENDER')
ygopro.ctos_send(room.dueling_players[oppo_pos - win_pos].server, 'SURRENDER')
else
room.death = -1
ygopro.stoc_send_chat_to_room(room, "${death_remain_final}", ygopro.constants.COLORS.BABYBLUE)
......@@ -3038,11 +3040,20 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)->
ygopro.ctos_follow 'SURRENDER', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid]
return unless room
if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN or room.hostinfo.mode == 2
if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN
return true
if room.random_type and room.turn < 3 and not client.flee_free and not settings.modules.test_mode.surrender_anytime and not (room.random_type=='M' and settings.modules.random_duel.record_match_scores)
ygopro.stoc_send_chat(client, "${surrender_denied}", ygopro.constants.COLORS.BABYBLUE)
return true
if room.hostinfo.mode == 2
if !client.surrend_confirm and !CLIENT_get_partner(client).closed and !CLIENT_get_partner(client).is_local
sur_player = CLIENT_get_partner(client)
ygopro.stoc_send_chat(sur_player, "${surrender_confirm_tag}", ygopro.constants.COLORS.BABYBLUE)
ygopro.stoc_send_chat(client, "${surrender_confirm_sent}", ygopro.constants.COLORS.BABYBLUE)
sur_player.surrend_confirm = true
for player in [client, sur_player]
ygopro.stoc_send(client, 'TEAMMATE_SURRENDER')
return true
await return false
report_to_big_brother = global.report_to_big_brother = (roomname, sender, ip, level, content, match) ->
......@@ -3075,16 +3086,25 @@ ygopro.ctos_follow 'CHAT', true, (buffer, info, client, server, datas)->
cmd = msg.split(' ')
switch cmd[0]
when '/投降', '/surrender'
if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN or room.hostinfo.mode == 2
if room.duel_stage == ygopro.constants.DUEL_STAGE.BEGIN
return cancel
if room.random_type and room.turn < 3
if room.random_type and room.turn < 3 and !client.flee_free
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
sur_player = CLIENT_get_partner(client)
if !sur_player or sur_player.closed or sur_player.is_local
sur_player = client
if room.hostinfo.mode==2 and sur_player != client
ygopro.stoc_send_chat(sur_player, "${surrender_confirm_tag}", ygopro.constants.COLORS.BABYBLUE)
ygopro.stoc_send_chat(client, "${surrender_confirm_sent}", ygopro.constants.COLORS.BABYBLUE)
for player in [client, sur_player]
ygopro.stoc_send(client, 'TEAMMATE_SURRENDER')
else
ygopro.stoc_send_chat(client, "${surrender_confirm}", ygopro.constants.COLORS.BABYBLUE)
sur_player.surrend_confirm = true
when '/help'
ygopro.stoc_send_chat(client, "${chat_order_main}")
......
This diff is collapsed.
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