forked from smogon/pokemon-showdown-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient-ladder.js
99 lines (97 loc) · 4.4 KB
/
client-ladder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
(function ($) {
var LadderRoom = this.LadderRoom = this.Room.extend({
type: 'ladder',
title: 'Ladder',
initialize: function () {
this.$el.addClass('ps-room-light').addClass('scrollable');
app.on('init:formats', this.update, this);
this.update();
app.on('response:laddertop', function (data) {
var buf = '<div class="ladder pad"><p><button name="selectFormat"><i class="fa fa-chevron-left"></i> Format List</button></p>';
if (!data) {
this.$el.html(buf + '<p>error</p></div>');
return;
}
if (this.curFormat !== data[0]) return;
buf += Tools.sanitizeHTML(data[1]) + '</div>';
this.$el.html(buf);
}, this);
},
curFormat: '',
update: function () {
if (!this.curFormat) {
var buf = '<div class="ladder pad"><p>See a user\'s ranking with <code>/ranking <em>username</em></code></p>' +
//'<p><strong style="color:red">I\'m really really sorry, but as a warning: we\'re going to reset the ladder again soon to fix some more ladder bugs.</strong></p>' +
'<p>(btw if you couldn\'t tell the ladder screens aren\'t done yet; they\'ll look nicer than this once I\'m done.)</p>' +
'<p><button name="selectFormat" value="help" class="button"><i class="fa fa-info-circle"></i> How the ladder works</button></p><ul>';
if (!window.BattleFormats) {
this.$el.html('<div class="pad"><em>Loading...</em></div>');
return;
}
var curSection = '';
for (var i in BattleFormats) {
var format = BattleFormats[i];
if (format.section && format.section !== curSection) {
curSection = format.section;
buf += '</ul><h3>' + Tools.escapeHTML(curSection) + '</h3><ul style="list-style:none;margin:0;padding:0">';
}
if (!format.searchShow || !format.rated) continue;
buf += '<li style="margin:5px"><button name="selectFormat" value="' + i + '" class="button" style="width:320px;height:30px;text-align:left;font:12pt Verdana">' + Tools.escapeFormat(format.id) + '</button></li>';
}
buf += '</ul></div>';
this.$el.html(buf);
} else if (this.curFormat === 'help') {
this.showHelp();
} else {
var format = this.curFormat;
var self = this;
this.$el.html('<div class="ladder pad"><p><button name="selectFormat"><i class="fa fa-chevron-left"></i> Format List</button></p><p><em>Loading...</em></p></div>');
if (app.localLadder) {
app.send('/cmd laddertop ' + format);
} else {
$.get('/ladder.php', {
format: format,
server: Config.server.id.split(':')[0],
output: 'html'
}, function (data) {
if (self.curFormat !== format) return;
var buf = '<div class="ladder pad"><p><button name="selectFormat"><i class="fa fa-chevron-left"></i> Format List</button></p>';
buf += '<h3>' + Tools.escapeFormat(format) + ' Top 500</h3>';
buf += data + '</div>';
self.$el.html(buf);
}, 'html');
}
}
},
showHelp: function () {
var buf = '<div class="ladder pad"><p><button name="selectFormat"><i class="fa fa-chevron-left"></i> Format List</button></p>';
buf += '<h3>How the ladder works</h3>';
buf += '<p>Our ladder displays four ratings: Elo, GXE, Glicko-1, and COIL.</p>';
buf += '<p><strong>Elo</strong> is the main ladder rating. It\'s a pretty normal ladder rating: goes up when you win and down when you lose.</p>';
buf += '<p><strong>GXE</strong> (Glicko X-Act Estimate) is an estimate of your win chance against an average ladder player.</p>';
buf += '<p><strong>Glicko-1</strong> is a different rating system. It has rating and deviation values.</p>';
buf += '<p><strong>COIL</strong> (Converging Order Invariant Ladder) is mainly used for suspect tests. It goes up as you play games, but not too many games.</p>';
buf += '<p>Note that win/loss should not be used to estimate skill, since who you play against is much more important than how many times you win or lose. Our other stats like Elo and GXE are much better for estimating skill.</p>';
buf += '</div>';
this.$el.html(buf);
},
selectFormat: function (format) {
this.curFormat = format;
this.update();
}
}, {
COIL_B: {
'gen7oususpecttest': 17,
'uususpecttest': 20,
'rususpecttest': 11,
'nususpecttest': 9,
'pususpecttest': 9,
'lcsuspecttest': 9,
'doublesoususpecttest': 14.5,
'gen7balancedhackmonssuspecttest': 7.6,
'gen7mixandmegasuspecttest': 6,
'gen7almostanyabilitysuspecttest': 6,
'gen7sketchmonssuspecttest': 6
}
});
}).call(this, jQuery);