Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaD173 committed Sep 7, 2024
2 parents 9ef641a + 5512e76 commit 19b058a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 21 deletions.
26 changes: 24 additions & 2 deletions lib/ntbb-ladder.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,32 @@ function getTop($prefix = null) {
"SELECT * FROM (SELECT * FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ? ORDER BY `elo` DESC LIMIT $overfetch) AS `unusedalias` WHERE `userid` LIKE ? LIMIT $limit",
[$this->formatid, "$prefix%"]
);
$res = $ladderdb->query(
"WITH `max_elo` AS (
SELECT MAX(elo) AS `max_elo` FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ?
),
`rpr_filtered` AS (
SELECT * FROM `{$ladderdb->prefix}ladder` WHERE
((SELECT `max_elo` FROM `max_elo`) <= 1500 OR `rprd` <= 100)
AND `formatid` = ?
)
SELECT * FROM
(SELECT * FROM `rpr_filtered` WHERE `formatid` = ? ORDER BY `elo` DESC LIMIT {$overfetch})
AS `unusedalias` WHERE `userid` LIKE ? LIMIT $limit",
[$this->formatid, $this->formatid, $this->formatid, "$prefix%"]
);
} else {
$res = $ladderdb->query(
"SELECT * FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ? ORDER BY `elo` DESC LIMIT $limit",
[$this->formatid]
"WITH max_elo AS (
SELECT MAX(elo) AS max_elo FROM `{$ladderdb->prefix}ladder` WHERE `formatid` = ?
),
rpr_filtered AS (
SELECT * FROM `{$ladderdb->prefix}ladder` WHERE
((SELECT `max_elo` FROM `max_elo`) <= 1500 OR `rprd` <= 100)
AND `formatid` = ?
)
SELECT * FROM `rpr_filtered` ORDER BY `elo` DESC LIMIT $limit",
[$this->formatid, $this->formatid]
);
}

Expand Down
10 changes: 6 additions & 4 deletions play.pokemonshowdown.com/js/client-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,11 @@
var m2 = /^([\s\S!/]*?)([A-Za-z0-9][^, \n]* [^, ]*)$/.exec(prefix);
if (!m1 && !m2) return true;
var cmds = this.tabComplete.commands;
var currentLine = prefix.substr(prefix.lastIndexOf('\n') + 1);
var shouldSearchCommands = !cmds || (cmds.length ? !!cmds.length && !cmds.filter(function (x) {
return x.startsWith(prefix);
return x.startsWith(currentLine);
}).length : prefix != this.tabComplete.prefix);
var isCommandSearch = (text.startsWith('/') && !text.startsWith('//')) || text.startsWith('!');
var isCommandSearch = (currentLine.startsWith('/') && !currentLine.startsWith('//')) || currentLine.startsWith('!');
var resultsExist = this.tabComplete.lastSearch === text && this.tabComplete.commands;
if (isCommandSearch && shouldSearchCommands && !resultsExist) {
if (this.tabComplete.searchPending) return true; // wait
Expand All @@ -378,7 +379,7 @@
self.handleTabComplete($textbox, reverse);
}
});
this.send('/crq cmdsearch ' + text);
this.send('/crq cmdsearch ' + currentLine);
return true;
} else if (!isCommandSearch) {
delete this.tabComplete.isCommand;
Expand Down Expand Up @@ -447,7 +448,8 @@
if (!substituteUser) return true;
var name = typeof substituteUser === 'object' ? substituteUser.name : substituteUser;
name = Dex.getShortName(name);
var fullPrefix = this.tabComplete.prefix.substr(0, candidate[1]) + name;
var prefixIndex = candidate[1].toString().charAt(0) === '/' ? prefix.lastIndexOf('\n') + 1 : candidate[1];
var fullPrefix = this.tabComplete.prefix.substr(0, prefixIndex) + name;
$textbox.val(fullPrefix + text.substr(idx));
var pos = fullPrefix.length;
$textbox[0].setSelectionRange(pos, pos);
Expand Down
10 changes: 5 additions & 5 deletions play.pokemonshowdown.com/js/client-teambuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3232,21 +3232,21 @@
},
searchChange: function (e) {
var DEBOUNCE_THRESHOLD_TEAMS = 500;
var searchVal = e.currentTarget.value;
var self = this;
function updateTeamList() {
// 91 for right CMD / 93 for left CMD / 17 for CTL
if (e.keyCode !== 91 && e.keyCode !== 93 && e.keyCode !== 17) {
this.curSearchVal = searchVal;
self.curSearchVal = searchVal;
}
this.updateTeamList();
self.updateTeamList();
}

// If the user has a lot of teams, search is debounced to
// ensure this isn't called too frequently while typing
if (Storage.teams.length > DEBOUNCE_THRESHOLD_TEAMS) {
if (this.searchTimeout) clearTimeout(this.searchTimeout);

var searchVal = e.currentTarget.value;
this.searchTimeout = setTimeout(updateTeamList.bind(this), 400);
this.searchTimeout = setTimeout(updateTeamList, 400);
} else updateTeamList();

},
Expand Down
19 changes: 14 additions & 5 deletions play.pokemonshowdown.com/src/battle-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1516,8 +1516,8 @@ export class BattleScene implements BattleSceneStub {
updateStatbarIfExists(pokemon: Pokemon, updatePrevhp?: boolean, updateHp?: boolean) {
return pokemon.sprite.updateStatbarIfExists(pokemon, updatePrevhp, updateHp);
}
animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean) {
return pokemon.sprite.animTransform(pokemon, isCustomAnim, isPermanent);
animTransform(pokemon: Pokemon, useSpeciesAnim?: boolean, isPermanent?: boolean) {
return pokemon.sprite.animTransform(pokemon, useSpeciesAnim, isPermanent);
}
clearEffects(pokemon: Pokemon) {
return pokemon.sprite.clearEffects();
Expand Down Expand Up @@ -2503,7 +2503,12 @@ export class PokemonSprite extends Sprite {
});
}
}
animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean) {
/**
* @param pokemon
* @param useSpeciesAnim false = Transform the move or Imposter the ability
* @param isPermanent false = reverts on switch-out
*/
animTransform(pokemon: Pokemon, useSpeciesAnim?: boolean, isPermanent?: boolean) {
if (!this.scene.animating && !isPermanent) return;
let sp = Dex.getSpriteData(pokemon, this.isFrontSprite, {
gen: this.scene.gen,
Expand All @@ -2530,8 +2535,9 @@ export class PokemonSprite extends Sprite {
if (!this.scene.animating) return;
let speciesid = toID(pokemon.getSpeciesForme());
let doCry = false;
let skipAnim = false;
const scene = this.scene;
if (isCustomAnim) {
if (useSpeciesAnim) {
if (speciesid === 'kyogreprimal') {
BattleOtherAnims.primalalpha.anim(scene, [this]);
doCry = true;
Expand All @@ -2549,6 +2555,8 @@ export class PokemonSprite extends Sprite {
BattleOtherAnims.schoolingout.anim(scene, [this]);
} else if (speciesid === 'mimikyubusted' || speciesid === 'mimikyubustedtotem') {
// standard animation
} else if (speciesid === 'palafinhero') {
skipAnim = true;
} else {
BattleOtherAnims.megaevo.anim(scene, [this]);
doCry = true;
Expand All @@ -2564,9 +2572,10 @@ export class PokemonSprite extends Sprite {
xscale: 0,
opacity: 0,
}, sp));
if (speciesid === 'palafinhero') {
if (skipAnim) {
this.$el.replaceWith($newEl);
this.$el = $newEl;
this.animReset();
} else {
this.$el.animate(this.scene.pos({
x: this.x,
Expand Down
2 changes: 1 addition & 1 deletion play.pokemonshowdown.com/src/battle-scene-stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class BattleSceneStub {
resetStatbar(pokemon: Pokemon, startHidden?: boolean) { }
updateStatbar(pokemon: Pokemon, updatePrevhp?: boolean, updateHp?: boolean) { }
updateStatbarIfExists(pokemon: Pokemon, updatePrevhp?: boolean, updateHp?: boolean) { }
animTransform(pokemon: Pokemon, isCustomAnim?: boolean, isPermanent?: boolean) { }
animTransform(pokemon: Pokemon, useSpeciesAnim?: boolean, isPermanent?: boolean) { }
clearEffects(pokemon: Pokemon) { }
removeTransform(pokemon: Pokemon) { }
animFaint(pokemon: Pokemon) { }
Expand Down
6 changes: 2 additions & 4 deletions play.pokemonshowdown.com/src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2459,8 +2459,7 @@ export class Battle {
poke.details = args[2];
poke.searchid = args[1].substr(0, 2) + args[1].substr(3) + '|' + args[2];

let isCustomAnim = species.id !== 'palafinhero';
this.scene.animTransform(poke, isCustomAnim, true);
this.scene.animTransform(poke, true, true);
this.log(args, kwArgs);
break;
}
Expand Down Expand Up @@ -2498,7 +2497,6 @@ export class Battle {
let poke = this.getPokemon(args[1])!;
let species = Dex.species.get(args[2]);
let fromeffect = Dex.getEffect(kwArgs.from);
let isCustomAnim = species.name.startsWith('Wishiwashi');
if (!poke.getSpeciesForme().endsWith('-Gmax') && !species.name.endsWith('-Gmax')) {
poke.removeVolatile('typeadd' as ID);
poke.removeVolatile('typechange' as ID);
Expand All @@ -2509,7 +2507,7 @@ export class Battle {
this.activateAbility(poke, fromeffect);
}
poke.addVolatile('formechange' as ID, species.name); // the formechange volatile reminds us to revert the sprite change on switch-out
this.scene.animTransform(poke, isCustomAnim);
this.scene.animTransform(poke, true);
this.log(args, kwArgs);
break;
}
Expand Down

0 comments on commit 19b058a

Please sign in to comment.