mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-05-06 05:26:21 -05:00
Parse formats without needing lobby open
This commit is contained in:
parent
a572e22997
commit
019a4fbbdb
|
|
@ -225,10 +225,6 @@
|
|||
this.parseUserList(row[1]);
|
||||
break;
|
||||
|
||||
case 'formats':
|
||||
this.parseFormats(row);
|
||||
break;
|
||||
|
||||
case 'raw':
|
||||
this.$chat.append('<div class="message">' + Tools.sanitizeHTML(row.slice(1).join('|')) + '</div>');
|
||||
break;
|
||||
|
|
@ -256,47 +252,6 @@
|
|||
}
|
||||
this.userList.construct();
|
||||
},
|
||||
parseFormats: function(formatsList) {
|
||||
var isSection = false;
|
||||
var section = '';
|
||||
BattleFormats = {};
|
||||
for (var j=1; j<formatsList.length; j++) {
|
||||
if (isSection) {
|
||||
section = formatsList[j];
|
||||
isSection = false;
|
||||
} else if (formatsList[j] === '') {
|
||||
isSection = true;
|
||||
} else {
|
||||
var searchShow = true;
|
||||
var challengeShow = true;
|
||||
var team = null;
|
||||
var name = formatsList[j];
|
||||
if (name.substr(name.length-2) === ',#') { // preset teams
|
||||
team = 'preset';
|
||||
name = name.substr(0,name.length-2);
|
||||
}
|
||||
if (name.substr(name.length-2) === ',,') { // search-only
|
||||
challengeShow = false;
|
||||
name = name.substr(0,name.length-2);
|
||||
} else if (name.substr(name.length-1) === ',') { // challenge-only
|
||||
searchShow = false;
|
||||
name = name.substr(0,name.length-1);
|
||||
}
|
||||
BattleFormats[toId(name)] = {
|
||||
id: toId(name),
|
||||
name: name,
|
||||
team: team,
|
||||
section: section,
|
||||
searchShow: searchShow,
|
||||
challengeShow: challengeShow,
|
||||
rated: challengeShow && searchShow,
|
||||
isTeambuilderFormat: challengeShow && searchShow && !team,
|
||||
effectType: 'Format'
|
||||
};
|
||||
}
|
||||
}
|
||||
app.trigger('init:formats');
|
||||
},
|
||||
addJoinLeave: function(action, name, oldid, silent) {
|
||||
var userid = toUserid(name);
|
||||
if (!action) {
|
||||
|
|
|
|||
54
js/client.js
54
js/client.js
|
|
@ -482,12 +482,62 @@
|
|||
challenge: parts[2]
|
||||
});
|
||||
break;
|
||||
|
||||
case 'formats':
|
||||
this.parseFormats(parts);
|
||||
break;
|
||||
|
||||
default:
|
||||
this.joinRoom('lobby');
|
||||
this.rooms['lobby'].receive(data);
|
||||
if (data.substr(0,6) === '|init|') {
|
||||
this.joinRoom('lobby');
|
||||
}
|
||||
if (this.rooms['lobby']) {
|
||||
this.rooms['lobby'].receive(data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
parseFormats: function(formatsList) {
|
||||
var isSection = false;
|
||||
var section = '';
|
||||
BattleFormats = {};
|
||||
for (var j=1; j<formatsList.length; j++) {
|
||||
if (isSection) {
|
||||
section = formatsList[j];
|
||||
isSection = false;
|
||||
} else if (formatsList[j] === '') {
|
||||
isSection = true;
|
||||
} else {
|
||||
var searchShow = true;
|
||||
var challengeShow = true;
|
||||
var team = null;
|
||||
var name = formatsList[j];
|
||||
if (name.substr(name.length-2) === ',#') { // preset teams
|
||||
team = 'preset';
|
||||
name = name.substr(0,name.length-2);
|
||||
}
|
||||
if (name.substr(name.length-2) === ',,') { // search-only
|
||||
challengeShow = false;
|
||||
name = name.substr(0,name.length-2);
|
||||
} else if (name.substr(name.length-1) === ',') { // challenge-only
|
||||
searchShow = false;
|
||||
name = name.substr(0,name.length-1);
|
||||
}
|
||||
BattleFormats[toId(name)] = {
|
||||
id: toId(name),
|
||||
name: name,
|
||||
team: team,
|
||||
section: section,
|
||||
searchShow: searchShow,
|
||||
challengeShow: challengeShow,
|
||||
rated: challengeShow && searchShow,
|
||||
isTeambuilderFormat: challengeShow && searchShow && !team,
|
||||
effectType: 'Format'
|
||||
};
|
||||
}
|
||||
}
|
||||
this.trigger('init:formats');
|
||||
},
|
||||
|
||||
/*********************************************************
|
||||
* Rooms
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user