Commit 12496bcd authored by nanahira's avatar nanahira

Merge branch 'mc'

parents 97ed876f e13291c3
......@@ -1364,9 +1364,10 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
room.turn = room.turn + 1
if room.death
if room.turn >= room.death
if room.dueling_players[0].lp != room.dueling_players[1].lp and room.turn > 1
ygopro.stoc_send_chat_to_room(room, "${death_finish_part1}" + (if room.dueling_players[0].lp > room.dueling_players[1].lp then room.dueling_players[0] else room.dueling_players[1]).name + "${death_finish_part2}", ygopro.constants.COLORS.BABYBLUE)
ygopro.ctos_send((if room.dueling_players[0].lp > room.dueling_players[1].lp then room.dueling_players[1] else room.dueling_players[0]).server, 'SURRENDER')
oppo_pos = if room.hostinfo.mode == 2 then 2 else 1
if room.dueling_players[0].lp != room.dueling_players[oppo_pos].lp and room.turn > 1
ygopro.stoc_send_chat_to_room(room, "${death_finish_part1}" + (if room.dueling_players[0].lp > room.dueling_players[oppo_pos].lp then room.dueling_players[0] else room.dueling_players[oppo_pos]).name + "${death_finish_part2}", ygopro.constants.COLORS.BABYBLUE)
ygopro.ctos_send((if room.dueling_players[0].lp > room.dueling_players[oppo_pos].lp then room.dueling_players[oppo_pos] else room.dueling_players[0]).server, 'SURRENDER')
else
room.death = -1
ygopro.stoc_send_chat_to_room(room, "${death_remain_final}", ygopro.constants.COLORS.BABYBLUE)
......@@ -1379,6 +1380,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
if ygopro.constants.MSG[msg] == 'WIN' and client.pos == 0
pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first or pos == 2
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
reason = buffer.readUInt8(2)
#log.info {winner: pos, reason: reason}
#room.duels.push {winner: pos, reason: reason}
......@@ -1398,6 +1400,7 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
if ygopro.constants.MSG[msg] == 'DAMAGE' and client.pos == 0
pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
val = buffer.readInt32LE(2)
room.dueling_players[pos].lp -= val
room.dueling_players[pos].lp = 0 if room.dueling_players[pos].lp < 0
......@@ -1407,18 +1410,21 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
if ygopro.constants.MSG[msg] == 'RECOVER' and client.pos == 0
pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
val = buffer.readInt32LE(2)
room.dueling_players[pos].lp += val
if ygopro.constants.MSG[msg] == 'LPUPDATE' and client.pos == 0
pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
val = buffer.readInt32LE(2)
room.dueling_players[pos].lp = val
if ygopro.constants.MSG[msg] == 'PAY_LPCOST' and client.pos == 0
pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first
pos = pos * 2 if pos >= 0 and room.hostinfo.mode == 2
val = buffer.readInt32LE(2)
room.dueling_players[pos].lp -= val
room.dueling_players[pos].lp = 0 if room.dueling_players[pos].lp < 0
......@@ -1979,8 +1985,12 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
if client.pos == 0
dueltime=moment().format('YYYY-MM-DD HH:mm:ss')
replay_filename=dueltime
for player,i in room.dueling_players
replay_filename=replay_filename + (if i > 0 then " VS " else " ") + player.name
if room.hostinfo.mode != 2
for player,i in room.dueling_players
replay_filename=replay_filename + (if i > 0 then " VS " else " ") + player.name
else
for player,i in room.dueling_players
replay_filename=replay_filename + (if i > 0 then (if i == 2 then " VS " else " & ") else " ") + player.name
replay_filename=replay_filename.replace(/[\/\\\?\*]/g, '_')+".yrp"
duellog = {
time: dueltime,
......@@ -1988,8 +1998,9 @@ ygopro.stoc_follow 'REPLAY', true, (buffer, info, client, server)->
roomid: room.port.toString(),
cloud_replay_id: "R#"+room.cloud_replay_id,
replay_filename: replay_filename,
roommode: room.hostinfo.mode,
players: (for player in room.dueling_players
name: player.name + (if settings.modules.tournament_mode.show_ip and !player.is_local then (" (IP: " + player.ip.slice(7) + ")") else "") + (if settings.modules.tournament_mode.show_info and not (room.hostinfo.mode == 2 and player.pos > 1) then (" (Score:" + room.scores[player.name] + " LP:" + (if player.lp? then player.lp else room.hostinfo.start_lp) + ")") else ""),
name: player.name + (if settings.modules.tournament_mode.show_ip and !player.is_local then (" (IP: " + player.ip.slice(7) + ")") else "") + (if settings.modules.tournament_mode.show_info and not (room.hostinfo.mode == 2 and player.pos % 2 > 0) then (" (Score:" + room.scores[player.name] + " LP:" + (if player.lp? then player.lp else room.hostinfo.start_lp) + ")") else ""),
winner: player.pos == room.winner
)
}
......@@ -2084,10 +2095,11 @@ if settings.modules.http
pid: room.process.pid.toString(),
roomid: room.port.toString(),
roomname: if pass_validated then room.name else room.name.split('$', 2)[0],
roommode: room.hostinfo.mode,
needpass: (room.name.indexOf('$') != -1).toString(),
users: (for player in room.players when player.pos?
id: (-1).toString(),
name: player.name + (if settings.modules.http.show_ip and pass_validated and !player.is_local then (" (IP: " + player.ip.slice(7) + ")") else "") + (if settings.modules.http.show_info and room.started and not (room.hostinfo.mode == 2 and player.pos > 1) then (" (Score:" + room.scores[player.name] + " LP:" + (if player.lp? then player.lp else room.hostinfo.start_lp) + ")") else ""),
name: player.name + (if settings.modules.http.show_ip and pass_validated and !player.is_local then (" (IP: " + player.ip.slice(7) + ")") else "") + (if settings.modules.http.show_info and room.started and not (room.hostinfo.mode == 2 and player.pos % 2 > 0) then (" (Score:" + room.scores[player.name] + " LP:" + (if player.lp? then player.lp else room.hostinfo.start_lp) + ")") else ""),
pos: player.pos
),
istart: if room.started then (if settings.modules.http.show_info then ("Duel:" + room.duel_count + " " + (if room.changing_side then "Siding" else "Turn:" + (if room.turn? then room.turn else 0) + (if room.death then "/" + (if room.death > 0 then room.death - 1 else "Death") else ""))) else 'start') else 'wait'
......@@ -2226,7 +2238,7 @@ if settings.modules.http
else if u.query.death
death_room_found = false
for room in ROOM_all when room and room.established and room.started and !room.death and (u.query.death == "all" or u.query.death == room.port.toString())
for room in ROOM_all when room and room.established and room.started and !room.death and (u.query.death == "all" or u.query.death == room.port.toString()) and room.hostinfo.mode != 2
death_room_found = true
if !room.changing_side and (!room.duel_count or room.turn)
room.death = (if room.turn then room.turn + 4 else 5)
......
......@@ -1670,7 +1670,7 @@
}
ygopro.stoc_follow('GAME_MSG', false, function(buffer, info, client, server) {
var card, j, len, line, msg, playertype, pos, reason, ref, ref1, ref2, room, val;
var card, j, len, line, msg, oppo_pos, playertype, pos, reason, ref, ref1, ref2, room, val;
room = ROOM_all[client.rid];
if (!room) {
return;
......@@ -1701,9 +1701,10 @@
room.turn = room.turn + 1;
if (room.death) {
if (room.turn >= room.death) {
if (room.dueling_players[0].lp !== room.dueling_players[1].lp && room.turn > 1) {
ygopro.stoc_send_chat_to_room(room, "${death_finish_part1}" + (room.dueling_players[0].lp > room.dueling_players[1].lp ? room.dueling_players[0] : room.dueling_players[1]).name + "${death_finish_part2}", ygopro.constants.COLORS.BABYBLUE);
ygopro.ctos_send((room.dueling_players[0].lp > room.dueling_players[1].lp ? room.dueling_players[1] : room.dueling_players[0]).server, 'SURRENDER');
oppo_pos = room.hostinfo.mode === 2 ? 2 : 1;
if (room.dueling_players[0].lp !== room.dueling_players[oppo_pos].lp && room.turn > 1) {
ygopro.stoc_send_chat_to_room(room, "${death_finish_part1}" + (room.dueling_players[0].lp > room.dueling_players[oppo_pos].lp ? room.dueling_players[0] : room.dueling_players[oppo_pos]).name + "${death_finish_part2}", ygopro.constants.COLORS.BABYBLUE);
ygopro.ctos_send((room.dueling_players[0].lp > room.dueling_players[oppo_pos].lp ? room.dueling_players[oppo_pos] : room.dueling_players[0]).server, 'SURRENDER');
} else {
room.death = -1;
ygopro.stoc_send_chat_to_room(room, "${death_remain_final}", ygopro.constants.COLORS.BABYBLUE);
......@@ -1723,6 +1724,9 @@
if (!(client.is_first || pos === 2)) {
pos = 1 - pos;
}
if (pos >= 0 && room.hostinfo.mode === 2) {
pos = pos * 2;
}
reason = buffer.readUInt8(2);
room.winner = pos;
room.turn = 0;
......@@ -1743,6 +1747,9 @@
if (!client.is_first) {
pos = 1 - pos;
}
if (pos >= 0 && room.hostinfo.mode === 2) {
pos = pos * 2;
}
val = buffer.readInt32LE(2);
room.dueling_players[pos].lp -= val;
if (room.dueling_players[pos].lp < 0) {
......@@ -1757,6 +1764,9 @@
if (!client.is_first) {
pos = 1 - pos;
}
if (pos >= 0 && room.hostinfo.mode === 2) {
pos = pos * 2;
}
val = buffer.readInt32LE(2);
room.dueling_players[pos].lp += val;
}
......@@ -1765,6 +1775,9 @@
if (!client.is_first) {
pos = 1 - pos;
}
if (pos >= 0 && room.hostinfo.mode === 2) {
pos = pos * 2;
}
val = buffer.readInt32LE(2);
room.dueling_players[pos].lp = val;
}
......@@ -1773,6 +1786,9 @@
if (!client.is_first) {
pos = 1 - pos;
}
if (pos >= 0 && room.hostinfo.mode === 2) {
pos = pos * 2;
}
val = buffer.readInt32LE(2);
room.dueling_players[pos].lp -= val;
if (room.dueling_players[pos].lp < 0) {
......@@ -2637,7 +2653,7 @@
});
ygopro.stoc_follow('REPLAY', true, function(buffer, info, client, server) {
var duellog, dueltime, i, j, len, player, ref, replay_filename, room;
var duellog, dueltime, i, j, k, len, len1, player, ref, ref1, replay_filename, room;
room = ROOM_all[client.rid];
if (!room) {
return settings.modules.tournament_mode.enabled && settings.modules.tournament_mode.replay_safe;
......@@ -2649,10 +2665,18 @@
if (client.pos === 0) {
dueltime = moment().format('YYYY-MM-DD HH:mm:ss');
replay_filename = dueltime;
ref = room.dueling_players;
for (i = j = 0, len = ref.length; j < len; i = ++j) {
player = ref[i];
replay_filename = replay_filename + (i > 0 ? " VS " : " ") + player.name;
if (room.hostinfo.mode !== 2) {
ref = room.dueling_players;
for (i = j = 0, len = ref.length; j < len; i = ++j) {
player = ref[i];
replay_filename = replay_filename + (i > 0 ? " VS " : " ") + player.name;
}
} else {
ref1 = room.dueling_players;
for (i = k = 0, len1 = ref1.length; k < len1; i = ++k) {
player = ref1[i];
replay_filename = replay_filename + (i > 0 ? (i === 2 ? " VS " : " & ") : " ") + player.name;
}
}
replay_filename = replay_filename.replace(/[\/\\\?\*]/g, '_') + ".yrp";
duellog = {
......@@ -2661,14 +2685,15 @@
roomid: room.port.toString(),
cloud_replay_id: "R#" + room.cloud_replay_id,
replay_filename: replay_filename,
roommode: room.hostinfo.mode,
players: (function() {
var k, len1, ref1, results;
ref1 = room.dueling_players;
var l, len2, ref2, results;
ref2 = room.dueling_players;
results = [];
for (k = 0, len1 = ref1.length; k < len1; k++) {
player = ref1[k];
for (l = 0, len2 = ref2.length; l < len2; l++) {
player = ref2[l];
results.push({
name: player.name + (settings.modules.tournament_mode.show_ip && !player.is_local ? " (IP: " + player.ip.slice(7) + ")" : "") + (settings.modules.tournament_mode.show_info && !(room.hostinfo.mode === 2 && player.pos > 1) ? " (Score:" + room.scores[player.name] + " LP:" + (player.lp != null ? player.lp : room.hostinfo.start_lp) + ")" : ""),
name: player.name + (settings.modules.tournament_mode.show_ip && !player.is_local ? " (IP: " + player.ip.slice(7) + ")" : "") + (settings.modules.tournament_mode.show_info && !(room.hostinfo.mode === 2 && player.pos % 2 > 0) ? " (Score:" + room.scores[player.name] + " LP:" + (player.lp != null ? player.lp : room.hostinfo.start_lp) + ")" : ""),
winner: player.pos === room.winner
});
}
......@@ -2793,6 +2818,7 @@
pid: room.process.pid.toString(),
roomid: room.port.toString(),
roomname: pass_validated ? room.name : room.name.split('$', 2)[0],
roommode: room.hostinfo.mode,
needpass: (room.name.indexOf('$') !== -1).toString(),
users: (function() {
var k, len1, ref, results1;
......@@ -2803,7 +2829,7 @@
if (player.pos != null) {
results1.push({
id: (-1).toString(),
name: player.name + (settings.modules.http.show_ip && pass_validated && !player.is_local ? " (IP: " + player.ip.slice(7) + ")" : "") + (settings.modules.http.show_info && room.started && !(room.hostinfo.mode === 2 && player.pos > 1) ? " (Score:" + room.scores[player.name] + " LP:" + (player.lp != null ? player.lp : room.hostinfo.start_lp) + ")" : ""),
name: player.name + (settings.modules.http.show_ip && pass_validated && !player.is_local ? " (IP: " + player.ip.slice(7) + ")" : "") + (settings.modules.http.show_info && room.started && !(room.hostinfo.mode === 2 && player.pos % 2 > 0) ? " (Score:" + room.scores[player.name] + " LP:" + (player.lp != null ? player.lp : room.hostinfo.start_lp) + ")" : ""),
pos: player.pos
});
}
......@@ -3003,7 +3029,7 @@
death_room_found = false;
for (l = 0, len2 = ROOM_all.length; l < len2; l++) {
room = ROOM_all[l];
if (!(room && room.established && room.started && !room.death && (u.query.death === "all" || u.query.death === room.port.toString()))) {
if (!(room && room.established && room.started && !room.death && (u.query.death === "all" || u.query.death === room.port.toString()) && room.hostinfo.mode !== 2)) {
continue;
}
death_room_found = 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