Commit ad9a4438 authored by nanahira's avatar nanahira

add death 3

parent 3527332d
......@@ -183,6 +183,14 @@
"unwelcome_tip_part1": "因为您的对手有",
"unwelcome_tip_part2": "行为,现在您可以直接离开游戏或投降,不视为强退。",
"cannot_to_observer": "匹配模式中决斗者不允许观战。",
"death_cancel": "已取消本房间的加时赛状态。",
"death_start": "加时赛开始,从本回合开始计算4回合,基本分高的玩家获得本次决斗的胜利。",
"death_start_siding": "加时赛开始,下次决斗第4回合结束后,基本分高的玩家将获得本次决斗的胜利。",
"death_remain_part1": "本次决斗将在",
"death_remain_part2": "回合后结束,基本分高的玩家将获得本次决斗的胜利。",
"death_remain_final": "若本回合有双方的基本分发生变动,则基本分高的玩家将获得本次决斗的胜利。",
"death_finish_part1": "加时赛决斗结束,恭喜 ",
"death_finish_part2": " 获得本次决斗的胜利。",
"athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。"
},
"ko-kr": {
......
......@@ -313,6 +313,8 @@ class Room
@welcome = ''
@scores = {}
@duel_count = 0
@death = 0
@dueling = false
ROOM_all.push this
@hostinfo ||= JSON.parse(JSON.stringify(settings.hostinfo))
......@@ -1248,6 +1250,11 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
client.lp = room.hostinfo.start_lp
if client.pos == 0
room.turn = 0
room.dueling = true
if room.death == -1
room.death = 5
else
room.death = 0
room.duel_count = room.duel_count + 1
#ygopro.stoc_send_chat_to_room(room, "LP跟踪调试信息: #{client.name} 初始LP #{client.lp}")
......@@ -1255,6 +1262,15 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
if ygopro.constants.MSG[msg] == 'NEW_TURN'
if client.pos == 0
room.turn = room.turn + 1
if room.death > 0
if room.turn >= room.death
if room.dueling_players[0].lp != room.dueling_players[1].lp
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')
else
ygopro.stoc_send_chat_to_room(room, "${death_remain_final}", ygopro.constants.COLORS.BABYBLUE)
else
ygopro.stoc_send_chat_to_room(room, "${death_remain_part1}" + (room.death - room.turn) + "${death_remain_part2}", ygopro.constants.COLORS.BABYBLUE)
if client.surrend_confirm
client.surrend_confirm = false
ygopro.stoc_send_chat(client, "${surrender_canceled}", ygopro.constants.COLORS.BABYBLUE)
......@@ -1263,6 +1279,9 @@ ygopro.stoc_follow 'GAME_MSG', false, (buffer, info, client, server)->
pos = buffer.readUInt8(1)
pos = 1 - pos unless client.is_first or pos == 2
reason = buffer.readUInt8(2)
room.dueling = false
if room.death
room.death = -1
#log.info {winner: pos, reason: reason}
#room.duels.push {winner: pos, reason: reason}
room.winner = pos
......@@ -1891,7 +1910,7 @@ if settings.modules.http
name: player.name + (if settings.modules.http.show_ip and pass_validated and player.ip != '::ffff:127.0.0.1' 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 ""),
pos: player.pos
),
istart: if room.started then (if settings.modules.http.show_info then ("Duel:" + room.duel_count + " Turn:" + (if room.turn? then room.turn else 0)) else 'start') else 'wait'
istart: if room.started then (if settings.modules.http.show_info then ("Duel:" + room.duel_count + " Turn:" + (if room.turn? then room.turn else 0) + (if room.death > 0 then "/" + (room.death - 1) else "")) else 'start') else 'wait'
), null, 2
response.end(addCallback(u.query.callback, roomsjson))
......@@ -2017,6 +2036,34 @@ if settings.modules.http
response.writeHead(200)
response.end(addCallback(u.query.callback, "['ban ok', '" + u.query.ban + "']"))
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())
death_room_found = true
if room.dueling
room.death = (if room.turn then room.turn + 4 else 5)
ygopro.stoc_send_chat_to_room(room, "${death_start}", ygopro.constants.COLORS.BABYBLUE)
else
room.death = -1
ygopro.stoc_send_chat_to_room(room, "${death_start_siding}", ygopro.constants.COLORS.BABYBLUE)
response.writeHead(200)
if death_room_found
response.end(addCallback(u.query.callback, "['death ok', '" + u.query.death + "']"))
else
response.end(addCallback(u.query.callback, "['room not found', '" + u.query.death + "']"))
else if u.query.deathcancel
death_room_found = false
for room in ROOM_all when room and room.established and room.started and room.death and (u.query.deathcancel == "all" or u.query.deathcancel == room.port.toString())
death_room_found = true
room.death = 0
ygopro.stoc_send_chat_to_room(room, "${death_cancel}", ygopro.constants.COLORS.BABYBLUE)
response.writeHead(200)
if death_room_found
response.end(addCallback(u.query.callback, "['death cancel ok', '" + u.query.deathcancel + "']"))
else
response.end(addCallback(u.query.callback, "['room not found', '" + u.query.deathcancel + "']"))
else
response.writeHead(400)
response.end()
......
......@@ -433,6 +433,8 @@
this.welcome = '';
this.scores = {};
this.duel_count = 0;
this.death = 0;
this.dueling = false;
ROOM_all.push(this);
this.hostinfo || (this.hostinfo = JSON.parse(JSON.stringify(settings.hostinfo)));
if (settings.lflist.length) {
......@@ -1493,12 +1495,30 @@
client.lp = room.hostinfo.start_lp;
if (client.pos === 0) {
room.turn = 0;
room.dueling = true;
if (room.death === -1) {
room.death = 5;
} else {
room.death = 0;
}
room.duel_count = room.duel_count + 1;
}
}
if (ygopro.constants.MSG[msg] === 'NEW_TURN') {
if (client.pos === 0) {
room.turn = room.turn + 1;
if (room.death > 0) {
if (room.turn >= room.death) {
if (room.dueling_players[0].lp !== room.dueling_players[1].lp) {
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');
} else {
ygopro.stoc_send_chat_to_room(room, "${death_remain_final}", ygopro.constants.COLORS.BABYBLUE);
}
} else {
ygopro.stoc_send_chat_to_room(room, "${death_remain_part1}" + (room.death - room.turn) + "${death_remain_part2}", ygopro.constants.COLORS.BABYBLUE);
}
}
}
if (client.surrend_confirm) {
client.surrend_confirm = false;
......@@ -1511,6 +1531,10 @@
pos = 1 - pos;
}
reason = buffer.readUInt8(2);
room.dueling = false;
if (room.death) {
room.death = -1;
}
room.winner = pos;
if (room && !room.finished && room.dueling_players[pos]) {
room.winner_name = room.dueling_players[pos].name;
......@@ -2351,7 +2375,7 @@
return callback + "( " + text + " );";
};
requestListener = function(request, response) {
var archive_args, archive_name, archive_process, duellog, error, filename, getpath, j, k, len, len1, parseQueryString, pass_validated, player, ref, replay, room, roomsjson, u;
var archive_args, archive_name, archive_process, death_room_found, duellog, error, filename, getpath, j, k, l, len, len1, len2, len3, m, parseQueryString, pass_validated, player, ref, replay, room, roomsjson, u;
parseQueryString = true;
u = url.parse(request.url, parseQueryString);
pass_validated = u.query.pass === settings.modules.http.password;
......@@ -2389,7 +2413,7 @@
}
return results1;
})(),
istart: room.started ? (settings.modules.http.show_info ? "Duel:" + room.duel_count + " Turn:" + (room.turn != null ? room.turn : 0) : 'start') : 'wait'
istart: room.started ? (settings.modules.http.show_info ? "Duel:" + room.duel_count + " Turn:" + (room.turn != null ? room.turn : 0) + (room.death > 0 ? "/" + (room.death - 1) : "") : 'start') : 'wait'
});
}
}
......@@ -2542,6 +2566,45 @@
ban_user(u.query.ban);
response.writeHead(200);
response.end(addCallback(u.query.callback, "['ban ok', '" + u.query.ban + "']"));
} else if (u.query.death) {
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()))) {
continue;
}
death_room_found = true;
if (room.dueling) {
room.death = (room.turn ? room.turn + 4 : 5);
ygopro.stoc_send_chat_to_room(room, "${death_start}", ygopro.constants.COLORS.BABYBLUE);
} else {
room.death = -1;
ygopro.stoc_send_chat_to_room(room, "${death_start_siding}", ygopro.constants.COLORS.BABYBLUE);
}
}
response.writeHead(200);
if (death_room_found) {
response.end(addCallback(u.query.callback, "['death ok', '" + u.query.death + "']"));
} else {
response.end(addCallback(u.query.callback, "['room not found', '" + u.query.death + "']"));
}
} else if (u.query.deathcancel) {
death_room_found = false;
for (m = 0, len3 = ROOM_all.length; m < len3; m++) {
room = ROOM_all[m];
if (!(room && room.established && room.started && room.death && (u.query.deathcancel === "all" || u.query.deathcancel === room.port.toString()))) {
continue;
}
death_room_found = true;
room.death = 0;
ygopro.stoc_send_chat_to_room(room, "${death_cancel}", ygopro.constants.COLORS.BABYBLUE);
}
response.writeHead(200);
if (death_room_found) {
response.end(addCallback(u.query.callback, "['death cancel ok', '" + u.query.deathcancel + "']"));
} else {
response.end(addCallback(u.query.callback, "['room not found', '" + u.query.deathcancel + "']"));
}
} else {
response.writeHead(400);
response.end();
......
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