Commit f749edac authored by nanahira's avatar nanahira

-5

parent 0d88f88d
...@@ -838,30 +838,37 @@ class Room ...@@ -838,30 +838,37 @@ class Room
score_array=[] score_array=[]
for name, score of @scores for name, score of @scores
score_array.push { name: name, score: score } score_array.push { name: name, score: score }
if score_array.length > 0 and settings.modules.arena_mode.enabled and @arena if settings.modules.arena_mode.enabled and @arena
#log.info 'SCORE', score_array, @start_time #log.info 'SCORE', score_array, @start_time
if score_array.length == 2 end_time = moment().format()
end_time = moment().format() if !@start_time
if !@start_time @start_time = end_time
@start_time = end_time if score_array.length != 2
request.post { url : settings.modules.arena_mode.post_score , form : { if !score_array[0]
accesskey: settings.modules.arena_mode.accesskey, score_array[0] = { name: "unknown_player1", score: -5 }
usernameA: score_array[0].name, if !score_array[1]
usernameB: score_array[1].name, score_array[1] = { name: "unknown_player2", score: -5 }
userscoreA: score_array[0].score, score_array[0].score = -5
userscoreB: score_array[1].score, score_array[1].score = -5
start: @start_time, request.post { url : settings.modules.arena_mode.post_score , form : {
end: end_time, accesskey: settings.modules.arena_mode.accesskey,
arena: @arena usernameA: score_array[0].name,
}}, (error, response, body)=> usernameB: score_array[1].name,
if error userscoreA: score_array[0].score,
log.warn 'SCORE POST ERROR', error userscoreB: score_array[1].score,
else start: @start_time,
if response.statusCode != 204 and response.statusCode != 200 end: end_time,
log.warn 'SCORE POST FAIL', response.statusCode, response.statusMessage, @name, body arena: @arena
#else }}, (error, response, body)=>
# log.info 'SCORE POST OK', response.statusCode, response.statusMessage, @name, body if error
return log.warn 'SCORE POST ERROR', error
else
if response.statusCode != 204 and response.statusCode != 200
log.warn 'SCORE POST FAIL', response.statusCode, response.statusMessage, @name, body
#else
# log.info 'SCORE POST OK', response.statusCode, response.statusMessage, @name, body
return
if settings.modules.challonge.enabled and @started and !@kicked if settings.modules.challonge.enabled and @started and !@kicked
challonge.matches.update({ challonge.matches.update({
id: encodeURIComponent(settings.modules.challonge.tournament_id), id: encodeURIComponent(settings.modules.challonge.tournament_id),
...@@ -980,10 +987,11 @@ class Room ...@@ -980,10 +987,11 @@ class Room
client.server.destroy() client.server.destroy()
else else
#log.info(client.name, @started, @disconnector, @random_type, @players.length) #log.info(client.name, @started, @disconnector, @random_type, @players.length)
if @arena == "athletic" and !@started and @players.length == 2 if @arena and !@started
for player in @players when player.pos != 7 for player in @players when player.pos != 7
@scores[player.name] = 0 @scores[player.name] = 0
@scores[client.name] = -9 if @players.length == 2
@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
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)
...@@ -991,7 +999,7 @@ class Room ...@@ -991,7 +999,7 @@ class Room
@scores[client.name] = -9 @scores[client.name] = -9
if @random_type and not client.flee_free if @random_type and not client.flee_free
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}") ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}")
if @players.length and !(@windbot and client.is_host) if @players.length and !(@windbot and client.is_host) and !(@arena and !@started and client.pos <= 3)
ygopro.stoc_send_chat_to_room this, "#{client.name} ${left_game}" + if error then ": #{error}" else '' ygopro.stoc_send_chat_to_room this, "#{client.name} ${left_game}" + if error then ": #{error}" else ''
roomlist.update(this) if !@windbot and !@started and settings.modules.http.websocket_roomlist roomlist.update(this) if !@windbot and !@started and settings.modules.http.websocket_roomlist
#client.room = null #client.room = null
......
...@@ -1076,36 +1076,50 @@ ...@@ -1076,36 +1076,50 @@
score: score score: score
}); });
} }
if (score_array.length > 0 && settings.modules.arena_mode.enabled && this.arena) { if (settings.modules.arena_mode.enabled && this.arena) {
if (score_array.length === 2) { end_time = moment().format();
end_time = moment().format(); if (!this.start_time) {
if (!this.start_time) { this.start_time = end_time;
this.start_time = end_time; }
} if (score_array.length !== 2) {
request.post({ if (!score_array[0]) {
url: settings.modules.arena_mode.post_score, score_array[0] = {
form: { name: "unknown_player1",
accesskey: settings.modules.arena_mode.accesskey, score: -5
usernameA: score_array[0].name,
usernameB: score_array[1].name,
userscoreA: score_array[0].score,
userscoreB: score_array[1].score,
start: this.start_time,
end: end_time,
arena: this.arena
}
}, (function(_this) {
return function(error, response, body) {
if (error) {
log.warn('SCORE POST ERROR', error);
} else {
if (response.statusCode !== 204 && response.statusCode !== 200) {
log.warn('SCORE POST FAIL', response.statusCode, response.statusMessage, _this.name, body);
}
}
}; };
})(this)); }
if (!score_array[1]) {
score_array[1] = {
name: "unknown_player2",
score: -5
};
}
score_array[0].score = -5;
score_array[1].score = -5;
} }
request.post({
url: settings.modules.arena_mode.post_score,
form: {
accesskey: settings.modules.arena_mode.accesskey,
usernameA: score_array[0].name,
usernameB: score_array[1].name,
userscoreA: score_array[0].score,
userscoreB: score_array[1].score,
start: this.start_time,
end: end_time,
arena: this.arena
}
}, (function(_this) {
return function(error, response, body) {
if (error) {
log.warn('SCORE POST ERROR', error);
} else {
if (response.statusCode !== 204 && response.statusCode !== 200) {
log.warn('SCORE POST FAIL', response.statusCode, response.statusMessage, _this.name, body);
}
}
};
})(this));
} }
if (settings.modules.challonge.enabled && this.started && !this.kicked) { if (settings.modules.challonge.enabled && this.started && !this.kicked) {
challonge.matches.update({ challonge.matches.update({
...@@ -1252,7 +1266,7 @@ ...@@ -1252,7 +1266,7 @@
} }
client.server.destroy(); client.server.destroy();
} else { } else {
if (this.arena === "athletic" && !this.started && this.players.length === 2) { if (this.arena && !this.started) {
ref2 = this.players; ref2 = this.players;
for (m = 0, len2 = ref2.length; m < len2; m++) { for (m = 0, len2 = ref2.length; m < len2; m++) {
player = ref2[m]; player = ref2[m];
...@@ -1260,7 +1274,9 @@ ...@@ -1260,7 +1274,9 @@
this.scores[player.name] = 0; this.scores[player.name] = 0;
} }
} }
this.scores[client.name] = -9; if (this.players.length === 2) {
this.scores[client.name] = -9;
}
} }
index = _.indexOf(this.players, client); index = _.indexOf(this.players, client);
if (index !== -1) { if (index !== -1) {
...@@ -1273,7 +1289,7 @@ ...@@ -1273,7 +1289,7 @@
ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}"); ROOM_ban_player(client.name, client.ip, "${random_ban_reason_flee}");
} }
} }
if (this.players.length && !(this.windbot && client.is_host)) { if (this.players.length && !(this.windbot && client.is_host) && !(this.arena && !this.started && client.pos <= 3)) {
ygopro.stoc_send_chat_to_room(this, (client.name + " ${left_game}") + (error ? ": " + error : '')); ygopro.stoc_send_chat_to_room(this, (client.name + " ${left_game}") + (error ? ": " + error : ''));
if (!this.windbot && !this.started && settings.modules.http.websocket_roomlist) { if (!this.windbot && !this.started && settings.modules.http.websocket_roomlist) {
roomlist.update(this); roomlist.update(this);
......
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