Commit d7c5a50c authored by mercury233's avatar mercury233

make athletic arena post score if player escape before match starts

parent c12e2ad3
...@@ -179,7 +179,8 @@ ...@@ -179,7 +179,8 @@
"unwelcome_warn_part1": "如果您经常", "unwelcome_warn_part1": "如果您经常",
"unwelcome_warn_part2": ",您的对手可能会离你而去。", "unwelcome_warn_part2": ",您的对手可能会离你而去。",
"unwelcome_tip_part1": "因为您的对手有", "unwelcome_tip_part1": "因为您的对手有",
"unwelcome_tip_part2": "行为,现在您可以直接离开游戏或投降,不视为强退。" "unwelcome_tip_part2": "行为,现在您可以直接离开游戏或投降,不视为强退。",
"athletic_arena_tip": "在竞技匹配中,比赛开始前退出游戏也会视为投降。"
}, },
"ko-kr": { "ko-kr": {
"random_duel_enter_room_waiting": "땅콩: 게임을 진행하게 준비 또는 시작을 하십시오.", "random_duel_enter_room_waiting": "땅콩: 게임을 진행하게 준비 또는 시작을 하십시오.",
......
...@@ -448,13 +448,15 @@ class Room ...@@ -448,13 +448,15 @@ class Room
delete: -> delete: ->
return if @deleted return if @deleted
#log.info 'room-delete', this.name, ROOM_all.length #log.info 'room-delete', this.name, ROOM_all.length
if @started and settings.modules.arena_mode.enabled and @arena score_array=[]
#log.info @scores for name, score of @scores
score_array=[] score_array.push { name: name, score: score }
for name, score of @scores if score_array.length > 0 and settings.modules.arena_mode.enabled and @arena
score_array.push { name: name, score: score }
#log.info 'SCORE', score_array, @start_time #log.info 'SCORE', score_array, @start_time
if score_array.length == 2 if score_array.length == 2
end_time = moment().format()
if !@start_time
@start_time = end_time
request.post { url : settings.modules.arena_mode.post_score , form : { request.post { url : settings.modules.arena_mode.post_score , form : {
accesskey: settings.modules.arena_mode.accesskey, accesskey: settings.modules.arena_mode.accesskey,
usernameA: score_array[0].name, usernameA: score_array[0].name,
...@@ -462,7 +464,7 @@ class Room ...@@ -462,7 +464,7 @@ class Room
userscoreA: score_array[0].score, userscoreA: score_array[0].score,
userscoreB: score_array[1].score, userscoreB: score_array[1].score,
start: @start_time, start: @start_time,
end: moment().format(), end: end_time,
arena: @arena arena: @arena
}}, (error, response, body)=> }}, (error, response, body)=>
if error if error
...@@ -575,9 +577,13 @@ class Room ...@@ -575,9 +577,13 @@ class Room
@watchers.splice(index, 1) unless index == -1 @watchers.splice(index, 1) unless index == -1
#client.room = null #client.room = null
else else
#log.info(client.name, @started, @disconnector, @random_type, @players.length)
if @arena == "athletic" and !@started and @players.length == 2
for player in @players when player.pos != 7
@scores[player.name] = 0
@scores[client.name] = -9
index = _.indexOf(@players, client) index = _.indexOf(@players, client)
@players.splice(index, 1) unless index == -1 @players.splice(index, 1) unless index == -1
#log.info(@started,@disconnector,@random_type)
if @started and @disconnector != 'server' and (client.pos < 4 or client.is_host) if @started and @disconnector != 'server' and (client.pos < 4 or client.is_host)
@finished = true @finished = true
@scores[client.name] = -9 @scores[client.name] = -9
...@@ -991,6 +997,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)-> ...@@ -991,6 +997,9 @@ ygopro.ctos_follow 'JOIN_GAME', false, (buffer, info, client, server)->
room = ROOM_find_or_create_by_name('M#' + info.pass.slice(8)) room = ROOM_find_or_create_by_name('M#' + info.pass.slice(8))
room.private = true room.private = true
room.arena = settings.modules.arena_mode.mode room.arena = settings.modules.arena_mode.mode
if room.arena == "athletic"
room.max_player = 2
room.welcome = "${athletic_arena_tip}"
when 5 when 5
title = info.pass.slice(8).replace(String.fromCharCode(0xFEFF), ' ') title = info.pass.slice(8).replace(String.fromCharCode(0xFEFF), ' ')
room = ROOM_find_by_title(title) room = ROOM_find_by_title(title)
...@@ -1304,6 +1313,10 @@ ygopro.ctos_follow 'HS_KICK', true, (buffer, info, client, server)-> ...@@ -1304,6 +1313,10 @@ ygopro.ctos_follow 'HS_KICK', true, (buffer, info, client, server)->
return unless room return unless room
for player in room.players for player in room.players
if player and player.pos == info.pos and player != client if player and player.pos == info.pos and player != client
if room.arena == "athletic"
ygopro.stoc_send_chat_to_room(room, "#{client.name} ${kicked_by_system}", ygopro.constants.COLORS.RED)
client.destroy()
return true
client.kick_count = if client.kick_count then client.kick_count+1 else 1 client.kick_count = if client.kick_count then client.kick_count+1 else 1
if client.kick_count>=5 and room.random_type if client.kick_count>=5 and room.random_type
ygopro.stoc_send_chat_to_room(room, "#{client.name} ${kicked_by_system}", ygopro.constants.COLORS.RED) ygopro.stoc_send_chat_to_room(room, "#{client.name} ${kicked_by_system}", ygopro.constants.COLORS.RED)
......
...@@ -605,21 +605,25 @@ ...@@ -605,21 +605,25 @@
} }
Room.prototype["delete"] = function() { Room.prototype["delete"] = function() {
var index, log_rep_id, name, player_ips, player_names, recorder_buffer, ref, replay_id, score, score_array; var end_time, index, log_rep_id, name, player_ips, player_names, recorder_buffer, ref, replay_id, score, score_array;
if (this.deleted) { if (this.deleted) {
return; return;
} }
if (this.started && settings.modules.arena_mode.enabled && this.arena) { score_array = [];
score_array = []; ref = this.scores;
ref = this.scores; for (name in ref) {
for (name in ref) { score = ref[name];
score = ref[name]; score_array.push({
score_array.push({ name: name,
name: name, score: score
score: score });
}); }
} if (score_array.length > 0 && settings.modules.arena_mode.enabled && this.arena) {
if (score_array.length === 2) { if (score_array.length === 2) {
end_time = moment().format();
if (!this.start_time) {
this.start_time = end_time;
}
request.post({ request.post({
url: settings.modules.arena_mode.post_score, url: settings.modules.arena_mode.post_score,
form: { form: {
...@@ -629,7 +633,7 @@ ...@@ -629,7 +633,7 @@
userscoreA: score_array[0].score, userscoreA: score_array[0].score,
userscoreB: score_array[1].score, userscoreB: score_array[1].score,
start: this.start_time, start: this.start_time,
end: moment().format(), end: end_time,
arena: this.arena arena: this.arena
} }
}, (function(_this) { }, (function(_this) {
...@@ -763,7 +767,7 @@ ...@@ -763,7 +767,7 @@
}; };
Room.prototype.disconnect = function(client, error) { Room.prototype.disconnect = function(client, error) {
var index; var index, j, len, player, ref;
if (client.is_post_watcher) { if (client.is_post_watcher) {
ygopro.stoc_send_chat_to_room(this, (client.name + " ${quit_watch}") + (error ? ": " + error : '')); ygopro.stoc_send_chat_to_room(this, (client.name + " ${quit_watch}") + (error ? ": " + error : ''));
index = _.indexOf(this.watchers, client); index = _.indexOf(this.watchers, client);
...@@ -771,6 +775,16 @@ ...@@ -771,6 +775,16 @@
this.watchers.splice(index, 1); this.watchers.splice(index, 1);
} }
} else { } else {
if (this.arena === "athletic" && !this.started && this.players.length === 2) {
ref = this.players;
for (j = 0, len = ref.length; j < len; j++) {
player = ref[j];
if (player.pos !== 7) {
this.scores[player.name] = 0;
}
}
this.scores[client.name] = -9;
}
index = _.indexOf(this.players, client); index = _.indexOf(this.players, client);
if (index !== -1) { if (index !== -1) {
this.players.splice(index, 1); this.players.splice(index, 1);
...@@ -1213,6 +1227,10 @@ ...@@ -1213,6 +1227,10 @@
room = ROOM_find_or_create_by_name('M#' + info.pass.slice(8)); room = ROOM_find_or_create_by_name('M#' + info.pass.slice(8));
room["private"] = true; room["private"] = true;
room.arena = settings.modules.arena_mode.mode; room.arena = settings.modules.arena_mode.mode;
if (room.arena === "athletic") {
room.max_player = 2;
room.welcome = "${athletic_arena_tip}";
}
break; break;
case 5: case 5:
title = info.pass.slice(8).replace(String.fromCharCode(0xFEFF), ' '); title = info.pass.slice(8).replace(String.fromCharCode(0xFEFF), ' ');
...@@ -1559,6 +1577,11 @@ ...@@ -1559,6 +1577,11 @@
for (j = 0, len = ref.length; j < len; j++) { for (j = 0, len = ref.length; j < len; j++) {
player = ref[j]; player = ref[j];
if (player && player.pos === info.pos && player !== client) { if (player && player.pos === info.pos && player !== client) {
if (room.arena === "athletic") {
ygopro.stoc_send_chat_to_room(room, client.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED);
client.destroy();
return true;
}
client.kick_count = client.kick_count ? client.kick_count + 1 : 1; client.kick_count = client.kick_count ? client.kick_count + 1 : 1;
if (client.kick_count >= 5 && room.random_type) { if (client.kick_count >= 5 && room.random_type) {
ygopro.stoc_send_chat_to_room(room, client.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED); ygopro.stoc_send_chat_to_room(room, client.name + " ${kicked_by_system}", ygopro.constants.COLORS.RED);
......
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