mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-26 02:39:38 -05:00
Remove restrictions on concurrent battle searches (#6462)
https://www.smogon.com/forums/threads/improve-searching-for-concurrent-ladder-battles.3660989/
This commit is contained in:
parent
f4ae5b435f
commit
17501fc001
|
|
@ -406,17 +406,6 @@ class Ladder extends LadderStore {
|
|||
return;
|
||||
}
|
||||
|
||||
const roomid = this.needsToMove(user);
|
||||
if (roomid) {
|
||||
connection.popup(`Error: You need to make a move in <<${roomid}>> before you can look for another battle.\n\n(This restriction doesn't apply in the first five turns of a battle.)`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (roomid === null && Date.now() < user.lastDecision + 3 * SECONDS) {
|
||||
connection.popup(`Error: You need to wait until after making a move before you can look for another battle.\n\n(This restriction doesn't apply in the first five turns of a battle.)`);
|
||||
return;
|
||||
}
|
||||
|
||||
const oldUserid = user.id;
|
||||
const search = await this.prepBattle(connection, format.rated ? 'rated' : 'unrated', null, format.rated !== false);
|
||||
|
||||
|
|
@ -426,31 +415,6 @@ class Ladder extends LadderStore {
|
|||
this.addSearch(search, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* null = all battles ok
|
||||
* undefined = not in any battle
|
||||
*/
|
||||
needsToMove(user: User) {
|
||||
let out;
|
||||
for (const roomid of user.games) {
|
||||
const room = Rooms.get(roomid);
|
||||
if (!room || !room.battle || !room.battle.playerTable[user.id]) continue;
|
||||
const battle: RoomBattle = room.battle;
|
||||
if (battle.requestCount <= 16) {
|
||||
// it's fine as long as it's before turn 5
|
||||
// to be safe, we count off 8 requests for Team Preview, U-turn, and faints
|
||||
continue;
|
||||
}
|
||||
if (Dex.getFormat(battle.format).allowMultisearch) {
|
||||
continue;
|
||||
}
|
||||
const player = battle.playerTable[user.id];
|
||||
if (!player.request.isWait) return roomid;
|
||||
out = null;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies whether or not a match made between two users is valid. Returns
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -606,7 +606,6 @@ export class RoomBattle extends RoomGames.RoomGame {
|
|||
player.sendRoom(`|error|[Invalid choice] Sorry, too late to make a different move; the next turn has already started`);
|
||||
return;
|
||||
}
|
||||
user.lastDecision = Date.now();
|
||||
request.isWait = true;
|
||||
request.choice = choice;
|
||||
|
||||
|
|
|
|||
|
|
@ -448,8 +448,6 @@ export class User extends Chat.MessageContext {
|
|||
permalocked: string | ID | null;
|
||||
prevNames: {[id: /** ID */ string]: string};
|
||||
|
||||
/** Millisecond timestamp for last battle decision */
|
||||
lastDecision: number;
|
||||
lastChallenge: number;
|
||||
lastPM: string;
|
||||
team: string;
|
||||
|
|
@ -522,8 +520,6 @@ export class User extends Chat.MessageContext {
|
|||
this.permalocked = null;
|
||||
this.prevNames = Object.create(null);
|
||||
|
||||
this.lastDecision = 0;
|
||||
|
||||
// misc state
|
||||
this.lastChallenge = 0;
|
||||
this.lastPM = '';
|
||||
|
|
|
|||
|
|
@ -1157,7 +1157,6 @@ interface FormatsData extends EventMethods {
|
|||
restricted?: string[];
|
||||
ruleset?: string[];
|
||||
searchShow?: boolean;
|
||||
allowMultisearch?: boolean;
|
||||
team?: string;
|
||||
teamLength?: {validate?: [number, number], battle?: number};
|
||||
threads?: string[];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user