Commit 55afc8da authored by nanahira's avatar nanahira

Merge branch 'patch-5' of github.com:moecube/srvpro into mc

parents dc57bdcf cc17daf7
Pipeline #4749 passed with stages
in 10 minutes and 20 seconds
...@@ -2510,12 +2510,13 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2510,12 +2510,13 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
room=ROOM_all[client.rid] room=ROOM_all[client.rid]
return unless room and !client.reconnecting return unless room and !client.reconnecting
msg = buffer.readInt8(0) msg = buffer.readInt8(0)
#console.log client.pos, "MSG", ygopro.constants.MSG[msg] msg_name = ygopro.constants.MSG[msg]
if ygopro.constants.MSG[msg] == 'RETRY' and room.recovering #console.log client.pos, "MSG", msg_name
if msg_name == 'RETRY' and room.recovering
room.finish_recover(true) room.finish_recover(true)
return true return true
if settings.modules.retry_handle.enabled if settings.modules.retry_handle.enabled
if ygopro.constants.MSG[msg] == 'RETRY' if msg_name == 'RETRY'
if !client.retry_count? if !client.retry_count?
client.retry_count = 0 client.retry_count = 0
client.retry_count++ client.retry_count++
...@@ -2537,11 +2538,11 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2537,11 +2538,11 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
return true return true
else else
client.last_game_msg = buffer client.last_game_msg = buffer
client.last_game_msg_title = ygopro.constants.MSG[msg] client.last_game_msg_title = msg_name
# log.info(client.name, client.last_game_msg_title) # log.info(client.name, client.last_game_msg_title)
else if ygopro.constants.MSG[msg] != 'RETRY' else if msg_name != 'RETRY'
client.last_game_msg = buffer client.last_game_msg = buffer
client.last_game_msg_title = ygopro.constants.MSG[msg] client.last_game_msg_title = msg_name
# log.info(client.name, client.last_game_msg_title) # log.info(client.name, client.last_game_msg_title)
if (msg >= 10 and msg < 30) or msg == 132 or (msg >= 140 and msg <= 144) #SELECT和ANNOUNCE开头的消息 if (msg >= 10 and msg < 30) or msg == 132 or (msg >= 140 and msg <= 144) #SELECT和ANNOUNCE开头的消息
...@@ -2553,10 +2554,10 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2553,10 +2554,10 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
else else
room.waiting_for_player = client room.waiting_for_player = client
room.last_active_time = moment_now_string room.last_active_time = moment_now_string
#log.info("#{ygopro.constants.MSG[msg]}等待#{room.waiting_for_player.name}") #log.info("#{msg_name}等待#{room.waiting_for_player.name}")
#log.info 'MSG', ygopro.constants.MSG[msg] #log.info 'MSG', msg_name
if ygopro.constants.MSG[msg] == 'START' if msg_name == 'START'
playertype = buffer.readUInt8(1) playertype = buffer.readUInt8(1)
client.is_first = !(playertype & 0xf) client.is_first = !(playertype & 0xf)
client.lp = room.hostinfo.start_lp client.lp = room.hostinfo.start_lp
...@@ -2580,12 +2581,12 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2580,12 +2581,12 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
#ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}") #ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}")
if ygopro.constants.MSG[msg] == 'HINT' if msg_name == 'HINT'
hint_type = buffer.readUInt8(1) hint_type = buffer.readUInt8(1)
if hint_type == 3 if hint_type == 3
client.last_hint_msg = buffer client.last_hint_msg = buffer
if ygopro.constants.MSG[msg] == 'NEW_TURN' if msg_name == 'NEW_TURN'
if client.pos == 0 if client.pos == 0
room.turn++ room.turn++
if room.recovering and room.recover_from_turn <= room.turn if room.recovering and room.recover_from_turn <= room.turn
...@@ -2614,7 +2615,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2614,7 +2615,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
client.surrend_confirm = false client.surrend_confirm = false
ygopro.stoc_send_chat(client, "${surrender_canceled}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat(client, "${surrender_canceled}", ygopro.constants.COLORS.BABYBLUE)
if ygopro.constants.MSG[msg] == 'NEW_PHASE' if msg_name == 'NEW_PHASE'
phase = buffer.readInt16LE(1) phase = buffer.readInt16LE(1)
oppo_pos = if room.hostinfo.mode == 2 then 2 else 1 oppo_pos = if room.hostinfo.mode == 2 then 2 else 1
if client.pos == 0 and room.death == -2 and not (phase == 0x1 and room.turn < 2) if client.pos == 0 and room.death == -2 and not (phase == 0x1 and room.turn < 2)
...@@ -2634,7 +2635,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2634,7 +2635,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
room.death = -1 room.death = -1
ygopro.stoc_send_chat_to_room(room, "${death_remain_final}", ygopro.constants.COLORS.BABYBLUE) ygopro.stoc_send_chat_to_room(room, "${death_remain_final}", ygopro.constants.COLORS.BABYBLUE)
if ygopro.constants.MSG[msg] == 'WIN' and client.pos == 0 if msg_name == 'WIN' and client.pos == 0
if room.recovering if room.recovering
room.finish_recover(true) room.finish_recover(true)
return true return true
...@@ -2665,11 +2666,11 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2665,11 +2666,11 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
else else
room.death = 5 room.death = 5
if ygopro.constants.MSG[msg] == 'MATCH_KILL' and client.pos == 0 if msg_name == 'MATCH_KILL' and client.pos == 0
room.match_kill = true room.match_kill = true
#lp跟踪 #lp跟踪
if ygopro.constants.MSG[msg] == 'DAMAGE' and client.pos == 0 if msg_name == 'DAMAGE' and client.pos == 0
pos = buffer.readUInt8(1) pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2 pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
...@@ -2679,21 +2680,21 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2679,21 +2680,21 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
if 0 < room.dueling_players[pos].lp <= 100 if 0 < room.dueling_players[pos].lp <= 100
ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK) ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK)
if ygopro.constants.MSG[msg] == 'RECOVER' and client.pos == 0 if msg_name == 'RECOVER' and client.pos == 0
pos = buffer.readUInt8(1) pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2 pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
val = buffer.readInt32LE(2) val = buffer.readInt32LE(2)
room.dueling_players[pos].lp += val room.dueling_players[pos].lp += val
if ygopro.constants.MSG[msg] == 'LPUPDATE' and client.pos == 0 if msg_name == 'LPUPDATE' and client.pos == 0
pos = buffer.readUInt8(1) pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2 pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
val = buffer.readInt32LE(2) val = buffer.readInt32LE(2)
room.dueling_players[pos].lp = val room.dueling_players[pos].lp = val
if ygopro.constants.MSG[msg] == 'PAY_LPCOST' and client.pos == 0 if msg_name == 'PAY_LPCOST' and client.pos == 0
pos = buffer.readUInt8(1) pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2 pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
...@@ -2705,7 +2706,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2705,7 +2706,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
#track card count #track card count
#todo: track card count in tag mode #todo: track card count in tag mode
if ygopro.constants.MSG[msg] == 'MOVE' and room.hostinfo.mode != 2 if msg_name == 'MOVE' and room.hostinfo.mode != 2
pos = buffer.readUInt8(5) pos = buffer.readUInt8(5)
pos = 1 - pos unless client.is_first pos = 1 - pos unless client.is_first
loc = buffer.readUInt8(6) loc = buffer.readUInt8(6)
...@@ -2715,7 +2716,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2715,7 +2716,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
loc = buffer.readUInt8(10) loc = buffer.readUInt8(10)
client.card_count++ if (loc & 0xe) and pos == 0 client.card_count++ if (loc & 0xe) and pos == 0
if ygopro.constants.MSG[msg] == 'DRAW' and room.hostinfo.mode != 2 if msg_name == 'DRAW' and room.hostinfo.mode != 2
pos = buffer.readUInt8(1) pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first pos = 1 - pos unless client.is_first
if pos == 0 if pos == 0
...@@ -2723,7 +2724,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2723,7 +2724,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
client.card_count += count client.card_count += count
# check panel confirming cards in heartbeat # check panel confirming cards in heartbeat
if settings.modules.heartbeat_detection.enabled and ygopro.constants.MSG[msg] == 'CONFIRM_CARDS' if settings.modules.heartbeat_detection.enabled and msg_name == 'CONFIRM_CARDS'
check = false check = false
count = buffer.readInt8(2) count = buffer.readInt8(2)
max_loop = 3 + (count - 1) * 7 max_loop = 3 + (count - 1) * 7
...@@ -2744,7 +2745,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2744,7 +2745,7 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
# chain detection # chain detection
if settings.modules.heartbeat_detection.enabled and client.pos == 0 if settings.modules.heartbeat_detection.enabled and client.pos == 0
if ygopro.constants.MSG[msg] == 'CHAINING' if msg_name == 'CHAINING'
card = buffer.readUInt32LE(1) card = buffer.readUInt32LE(1)
found = false found = false
for id in long_resolve_cards when id == card for id in long_resolve_cards when id == card
...@@ -2755,46 +2756,46 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)-> ...@@ -2755,46 +2756,46 @@ ygopro.stoc_follow 'GAME_MSG', true, (buffer, info, client, server, datas)->
# console.log(0,card) # console.log(0,card)
else else
delete room.long_resolve_card delete room.long_resolve_card
else if ygopro.constants.MSG[msg] == 'CHAINED' and room.long_resolve_card else if msg_name == 'CHAINED' and room.long_resolve_card
chain = buffer.readInt8(1) chain = buffer.readInt8(1)
if !room.long_resolve_chain if !room.long_resolve_chain
room.long_resolve_chain = [] room.long_resolve_chain = []
room.long_resolve_chain[chain] = true room.long_resolve_chain[chain] = true
# console.log(1,chain) # console.log(1,chain)
delete room.long_resolve_card delete room.long_resolve_card
else if ygopro.constants.MSG[msg] == 'CHAIN_SOLVING' and room.long_resolve_chain else if msg_name == 'CHAIN_SOLVING' and room.long_resolve_chain
chain = buffer.readInt8(1) chain = buffer.readInt8(1)
# console.log(2,chain) # console.log(2,chain)
if room.long_resolve_chain[chain] if room.long_resolve_chain[chain]
for player in room.get_playing_player() for player in room.get_playing_player()
player.heartbeat_protected = true player.heartbeat_protected = true
else if (ygopro.constants.MSG[msg] == 'CHAIN_NEGATED' or ygopro.constants.MSG[msg] == 'CHAIN_DISABLED') and room.long_resolve_chain else if (msg_name == 'CHAIN_NEGATED' or msg_name == 'CHAIN_DISABLED') and room.long_resolve_chain
chain = buffer.readInt8(1) chain = buffer.readInt8(1)
# console.log(3,chain) # console.log(3,chain)
delete room.long_resolve_chain[chain] delete room.long_resolve_chain[chain]
else if ygopro.constants.MSG[msg] == 'CHAIN_END' else if msg_name == 'CHAIN_END'
# console.log(4,chain) # console.log(4,chain)
delete room.long_resolve_card delete room.long_resolve_card
delete room.long_resolve_chain delete room.long_resolve_chain
#登场台词 #登场台词
if settings.modules.dialogues.enabled and !room.recovering if settings.modules.dialogues.enabled and !room.recovering
if ygopro.constants.MSG[msg] == 'SUMMONING' or ygopro.constants.MSG[msg] == 'SPSUMMONING' or ygopro.constants.MSG[msg] == 'CHAINING' if msg_name == 'SUMMONING' or msg_name == 'SPSUMMONING' or msg_name == 'CHAINING'
card = buffer.readUInt32LE(1) card = buffer.readUInt32LE(1)
trigger_location = buffer.readUInt8(6) trigger_location = buffer.readUInt8(6)
if dialogues.dialogues[card] and (ygopro.constants.MSG[msg] != 'CHAINING' or (trigger_location & 0x8) and client.ready_trap) if dialogues.dialogues[card] and (msg_name != 'CHAINING' or (trigger_location & 0x8) and client.ready_trap)
for line in _.lines dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)] for line in _.lines dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]
ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK) ygopro.stoc_send_chat(client, line, ygopro.constants.COLORS.PINK)
if ygopro.constants.MSG[msg] == 'POS_CHANGE' if msg_name == 'POS_CHANGE'
loc = buffer.readUInt8(6) loc = buffer.readUInt8(6)
ppos = buffer.readUInt8(8) ppos = buffer.readUInt8(8)
cpos = buffer.readUInt8(9) cpos = buffer.readUInt8(9)
client.ready_trap = !!(loc & 0x8) and !!(ppos & 0xa) and !!(cpos & 0x5) client.ready_trap = !!(loc & 0x8) and !!(ppos & 0xa) and !!(cpos & 0x5)
else if ygopro.constants.MSG[msg] != 'UPDATE_CARD' and ygopro.constants.MSG[msg] != 'WAITING' else if msg_name != 'UPDATE_CARD' and msg_name != 'WAITING'
client.ready_trap = false client.ready_trap = false
if room.recovering and client.pos < 4 if room.recovering and client.pos < 4
if ygopro.constants.MSG[msg] != 'WAITING' if msg_name != 'WAITING'
room.recover_buffers[client.pos].push(buffer) room.recover_buffers[client.pos].push(buffer)
return true return true
......
...@@ -3267,19 +3267,20 @@ ...@@ -3267,19 +3267,20 @@
}; };
ygopro.stoc_follow('GAME_MSG', true, async function(buffer, info, client, server, datas) { ygopro.stoc_follow('GAME_MSG', true, async function(buffer, info, client, server, datas) {
var card, chain, check, count, cpos, deck_found, found, hint_type, i, id, j, l, len, len1, len2, len3, limbo_found, line, loc, m, max_loop, msg, n, o, oppo_pos, phase, player, playertype, pos, ppos, reason, ref, ref1, ref2, ref3, ref4, ref5, room, trigger_location, val, win_pos; var card, chain, check, count, cpos, deck_found, found, hint_type, i, id, j, l, len, len1, len2, len3, limbo_found, line, loc, m, max_loop, msg, msg_name, n, o, oppo_pos, phase, player, playertype, pos, ppos, reason, ref, ref1, ref2, ref3, ref4, ref5, room, trigger_location, val, win_pos;
room = ROOM_all[client.rid]; room = ROOM_all[client.rid];
if (!(room && !client.reconnecting)) { if (!(room && !client.reconnecting)) {
return; return;
} }
msg = buffer.readInt8(0); msg = buffer.readInt8(0);
//console.log client.pos, "MSG", ygopro.constants.MSG[msg] msg_name = ygopro.constants.MSG[msg];
if (ygopro.constants.MSG[msg] === 'RETRY' && room.recovering) { //console.log client.pos, "MSG", msg_name
if (msg_name === 'RETRY' && room.recovering) {
room.finish_recover(true); room.finish_recover(true);
return true; return true;
} }
if (settings.modules.retry_handle.enabled) { if (settings.modules.retry_handle.enabled) {
if (ygopro.constants.MSG[msg] === 'RETRY') { if (msg_name === 'RETRY') {
if (client.retry_count == null) { if (client.retry_count == null) {
client.retry_count = 0; client.retry_count = 0;
} }
...@@ -3306,12 +3307,12 @@ ...@@ -3306,12 +3307,12 @@
} }
} else { } else {
client.last_game_msg = buffer; client.last_game_msg = buffer;
client.last_game_msg_title = ygopro.constants.MSG[msg]; client.last_game_msg_title = msg_name;
} }
// log.info(client.name, client.last_game_msg_title) // log.info(client.name, client.last_game_msg_title)
} else if (ygopro.constants.MSG[msg] !== 'RETRY') { } else if (msg_name !== 'RETRY') {
client.last_game_msg = buffer; client.last_game_msg = buffer;
client.last_game_msg_title = ygopro.constants.MSG[msg]; client.last_game_msg_title = msg_name;
} }
// log.info(client.name, client.last_game_msg_title) // log.info(client.name, client.last_game_msg_title)
if ((msg >= 10 && msg < 30) || msg === 132 || (msg >= 140 && msg <= 144)) { //SELECT和ANNOUNCE开头的消息 if ((msg >= 10 && msg < 30) || msg === 132 || (msg >= 140 && msg <= 144)) { //SELECT和ANNOUNCE开头的消息
...@@ -3326,10 +3327,10 @@ ...@@ -3326,10 +3327,10 @@
room.last_active_time = moment_now_string; room.last_active_time = moment_now_string;
} }
} }
//log.info("#{ygopro.constants.MSG[msg]}等待#{room.waiting_for_player.name}") //log.info("#{msg_name}等待#{room.waiting_for_player.name}")
//log.info 'MSG', ygopro.constants.MSG[msg] //log.info 'MSG', msg_name
if (ygopro.constants.MSG[msg] === 'START') { if (msg_name === 'START') {
playertype = buffer.readUInt8(1); playertype = buffer.readUInt8(1);
client.is_first = !(playertype & 0xf); client.is_first = !(playertype & 0xf);
client.lp = room.hostinfo.start_lp; client.lp = room.hostinfo.start_lp;
...@@ -3360,13 +3361,13 @@ ...@@ -3360,13 +3361,13 @@
} }
} }
//ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}") //ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}")
if (ygopro.constants.MSG[msg] === 'HINT') { if (msg_name === 'HINT') {
hint_type = buffer.readUInt8(1); hint_type = buffer.readUInt8(1);
if (hint_type === 3) { if (hint_type === 3) {
client.last_hint_msg = buffer; client.last_hint_msg = buffer;
} }
} }
if (ygopro.constants.MSG[msg] === 'NEW_TURN') { if (msg_name === 'NEW_TURN') {
if (client.pos === 0) { if (client.pos === 0) {
room.turn++; room.turn++;
if (room.recovering && room.recover_from_turn <= room.turn) { if (room.recovering && room.recover_from_turn <= room.turn) {
...@@ -3402,7 +3403,7 @@ ...@@ -3402,7 +3403,7 @@
ygopro.stoc_send_chat(client, "${surrender_canceled}", ygopro.constants.COLORS.BABYBLUE); ygopro.stoc_send_chat(client, "${surrender_canceled}", ygopro.constants.COLORS.BABYBLUE);
} }
} }
if (ygopro.constants.MSG[msg] === 'NEW_PHASE') { if (msg_name === 'NEW_PHASE') {
phase = buffer.readInt16LE(1); phase = buffer.readInt16LE(1);
oppo_pos = room.hostinfo.mode === 2 ? 2 : 1; oppo_pos = room.hostinfo.mode === 2 ? 2 : 1;
if (client.pos === 0 && room.death === -2 && !(phase === 0x1 && room.turn < 2)) { if (client.pos === 0 && room.death === -2 && !(phase === 0x1 && room.turn < 2)) {
...@@ -3425,7 +3426,7 @@ ...@@ -3425,7 +3426,7 @@
} }
} }
} }
if (ygopro.constants.MSG[msg] === 'WIN' && client.pos === 0) { if (msg_name === 'WIN' && client.pos === 0) {
if (room.recovering) { if (room.recovering) {
room.finish_recover(true); room.finish_recover(true);
return true; return true;
...@@ -3469,11 +3470,11 @@ ...@@ -3469,11 +3470,11 @@
} }
} }
} }
if (ygopro.constants.MSG[msg] === 'MATCH_KILL' && client.pos === 0) { if (msg_name === 'MATCH_KILL' && client.pos === 0) {
room.match_kill = true; room.match_kill = true;
} }
//lp跟踪 //lp跟踪
if (ygopro.constants.MSG[msg] === 'DAMAGE' && client.pos === 0) { if (msg_name === 'DAMAGE' && client.pos === 0) {
pos = buffer.readUInt8(1); pos = buffer.readUInt8(1);
if (!client.is_first) { if (!client.is_first) {
pos = 1 - pos; pos = 1 - pos;
...@@ -3490,7 +3491,7 @@ ...@@ -3490,7 +3491,7 @@
ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK); ygopro.stoc_send_chat_to_room(room, "${lp_low_opponent}", ygopro.constants.COLORS.PINK);
} }
} }
if (ygopro.constants.MSG[msg] === 'RECOVER' && client.pos === 0) { if (msg_name === 'RECOVER' && client.pos === 0) {
pos = buffer.readUInt8(1); pos = buffer.readUInt8(1);
if (!client.is_first) { if (!client.is_first) {
pos = 1 - pos; pos = 1 - pos;
...@@ -3501,7 +3502,7 @@ ...@@ -3501,7 +3502,7 @@
val = buffer.readInt32LE(2); val = buffer.readInt32LE(2);
room.dueling_players[pos].lp += val; room.dueling_players[pos].lp += val;
} }
if (ygopro.constants.MSG[msg] === 'LPUPDATE' && client.pos === 0) { if (msg_name === 'LPUPDATE' && client.pos === 0) {
pos = buffer.readUInt8(1); pos = buffer.readUInt8(1);
if (!client.is_first) { if (!client.is_first) {
pos = 1 - pos; pos = 1 - pos;
...@@ -3512,7 +3513,7 @@ ...@@ -3512,7 +3513,7 @@
val = buffer.readInt32LE(2); val = buffer.readInt32LE(2);
room.dueling_players[pos].lp = val; room.dueling_players[pos].lp = val;
} }
if (ygopro.constants.MSG[msg] === 'PAY_LPCOST' && client.pos === 0) { if (msg_name === 'PAY_LPCOST' && client.pos === 0) {
pos = buffer.readUInt8(1); pos = buffer.readUInt8(1);
if (!client.is_first) { if (!client.is_first) {
pos = 1 - pos; pos = 1 - pos;
...@@ -3531,7 +3532,7 @@ ...@@ -3531,7 +3532,7 @@
} }
//track card count //track card count
//todo: track card count in tag mode //todo: track card count in tag mode
if (ygopro.constants.MSG[msg] === 'MOVE' && room.hostinfo.mode !== 2) { if (msg_name === 'MOVE' && room.hostinfo.mode !== 2) {
pos = buffer.readUInt8(5); pos = buffer.readUInt8(5);
if (!client.is_first) { if (!client.is_first) {
pos = 1 - pos; pos = 1 - pos;
...@@ -3549,7 +3550,7 @@ ...@@ -3549,7 +3550,7 @@
client.card_count++; client.card_count++;
} }
} }
if (ygopro.constants.MSG[msg] === 'DRAW' && room.hostinfo.mode !== 2) { if (msg_name === 'DRAW' && room.hostinfo.mode !== 2) {
pos = buffer.readUInt8(1); pos = buffer.readUInt8(1);
if (!client.is_first) { if (!client.is_first) {
pos = 1 - pos; pos = 1 - pos;
...@@ -3560,7 +3561,7 @@ ...@@ -3560,7 +3561,7 @@
} }
} }
// check panel confirming cards in heartbeat // check panel confirming cards in heartbeat
if (settings.modules.heartbeat_detection.enabled && ygopro.constants.MSG[msg] === 'CONFIRM_CARDS') { if (settings.modules.heartbeat_detection.enabled && msg_name === 'CONFIRM_CARDS') {
check = false; check = false;
count = buffer.readInt8(2); count = buffer.readInt8(2);
max_loop = 3 + (count - 1) * 7; max_loop = 3 + (count - 1) * 7;
...@@ -3585,7 +3586,7 @@ ...@@ -3585,7 +3586,7 @@
} }
// chain detection // chain detection
if (settings.modules.heartbeat_detection.enabled && client.pos === 0) { if (settings.modules.heartbeat_detection.enabled && client.pos === 0) {
if (ygopro.constants.MSG[msg] === 'CHAINING') { if (msg_name === 'CHAINING') {
card = buffer.readUInt32LE(1); card = buffer.readUInt32LE(1);
found = false; found = false;
for (m = 0, len1 = long_resolve_cards.length; m < len1; m++) { for (m = 0, len1 = long_resolve_cards.length; m < len1; m++) {
...@@ -3602,7 +3603,7 @@ ...@@ -3602,7 +3603,7 @@
// console.log(0,card) // console.log(0,card)
delete room.long_resolve_card; delete room.long_resolve_card;
} }
} else if (ygopro.constants.MSG[msg] === 'CHAINED' && room.long_resolve_card) { } else if (msg_name === 'CHAINED' && room.long_resolve_card) {
chain = buffer.readInt8(1); chain = buffer.readInt8(1);
if (!room.long_resolve_chain) { if (!room.long_resolve_chain) {
room.long_resolve_chain = []; room.long_resolve_chain = [];
...@@ -3610,7 +3611,7 @@ ...@@ -3610,7 +3611,7 @@
room.long_resolve_chain[chain] = true; room.long_resolve_chain[chain] = true;
// console.log(1,chain) // console.log(1,chain)
delete room.long_resolve_card; delete room.long_resolve_card;
} else if (ygopro.constants.MSG[msg] === 'CHAIN_SOLVING' && room.long_resolve_chain) { } else if (msg_name === 'CHAIN_SOLVING' && room.long_resolve_chain) {
chain = buffer.readInt8(1); chain = buffer.readInt8(1);
// console.log(2,chain) // console.log(2,chain)
if (room.long_resolve_chain[chain]) { if (room.long_resolve_chain[chain]) {
...@@ -3620,11 +3621,11 @@ ...@@ -3620,11 +3621,11 @@
player.heartbeat_protected = true; player.heartbeat_protected = true;
} }
} }
} else if ((ygopro.constants.MSG[msg] === 'CHAIN_NEGATED' || ygopro.constants.MSG[msg] === 'CHAIN_DISABLED') && room.long_resolve_chain) { } else if ((msg_name === 'CHAIN_NEGATED' || msg_name === 'CHAIN_DISABLED') && room.long_resolve_chain) {
chain = buffer.readInt8(1); chain = buffer.readInt8(1);
// console.log(3,chain) // console.log(3,chain)
delete room.long_resolve_chain[chain]; delete room.long_resolve_chain[chain];
} else if (ygopro.constants.MSG[msg] === 'CHAIN_END') { } else if (msg_name === 'CHAIN_END') {
// console.log(4,chain) // console.log(4,chain)
delete room.long_resolve_card; delete room.long_resolve_card;
delete room.long_resolve_chain; delete room.long_resolve_chain;
...@@ -3632,10 +3633,10 @@ ...@@ -3632,10 +3633,10 @@
} }
//登场台词 //登场台词
if (settings.modules.dialogues.enabled && !room.recovering) { if (settings.modules.dialogues.enabled && !room.recovering) {
if (ygopro.constants.MSG[msg] === 'SUMMONING' || ygopro.constants.MSG[msg] === 'SPSUMMONING' || ygopro.constants.MSG[msg] === 'CHAINING') { if (msg_name === 'SUMMONING' || msg_name === 'SPSUMMONING' || msg_name === 'CHAINING') {
card = buffer.readUInt32LE(1); card = buffer.readUInt32LE(1);
trigger_location = buffer.readUInt8(6); trigger_location = buffer.readUInt8(6);
if (dialogues.dialogues[card] && (ygopro.constants.MSG[msg] !== 'CHAINING' || (trigger_location & 0x8) && client.ready_trap)) { if (dialogues.dialogues[card] && (msg_name !== 'CHAINING' || (trigger_location & 0x8) && client.ready_trap)) {
ref5 = _.lines(dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]); ref5 = _.lines(dialogues.dialogues[card][Math.floor(Math.random() * dialogues.dialogues[card].length)]);
for (o = 0, len3 = ref5.length; o < len3; o++) { for (o = 0, len3 = ref5.length; o < len3; o++) {
line = ref5[o]; line = ref5[o];
...@@ -3643,17 +3644,17 @@ ...@@ -3643,17 +3644,17 @@
} }
} }
} }
if (ygopro.constants.MSG[msg] === 'POS_CHANGE') { if (msg_name === 'POS_CHANGE') {
loc = buffer.readUInt8(6); loc = buffer.readUInt8(6);
ppos = buffer.readUInt8(8); ppos = buffer.readUInt8(8);
cpos = buffer.readUInt8(9); cpos = buffer.readUInt8(9);
client.ready_trap = !!(loc & 0x8) && !!(ppos & 0xa) && !!(cpos & 0x5); client.ready_trap = !!(loc & 0x8) && !!(ppos & 0xa) && !!(cpos & 0x5);
} else if (ygopro.constants.MSG[msg] !== 'UPDATE_CARD' && ygopro.constants.MSG[msg] !== 'WAITING') { } else if (msg_name !== 'UPDATE_CARD' && msg_name !== 'WAITING') {
client.ready_trap = false; client.ready_trap = false;
} }
} }
if (room.recovering && client.pos < 4) { if (room.recovering && client.pos < 4) {
if (ygopro.constants.MSG[msg] !== 'WAITING') { if (msg_name !== 'WAITING') {
room.recover_buffers[client.pos].push(buffer); room.recover_buffers[client.pos].push(buffer);
} }
return true; return true;
......
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