Lower line length limit to 120

This commit is contained in:
Guangcong Luo 2019-03-15 10:28:58 +09:00
parent 7e27321790
commit 826f7dda62
13 changed files with 194 additions and 97 deletions

View File

@ -30650,7 +30650,10 @@ BattleMoveAnims['flatter'] = {anim: BattleMoveAnims['attract'].anim};
BattleMoveAnims['armthrust'] = {anim: BattleMoveAnims['smellingsalts'].anim}; BattleMoveAnims['armthrust'] = {anim: BattleMoveAnims['smellingsalts'].anim};
BattleMoveAnims['phantomforce'] = {anim: BattleMoveAnims['shadowforce'].anim, prepareAnim: BattleMoveAnims['shadowforce'].prepareAnim}; BattleMoveAnims['phantomforce'] = {
anim: BattleMoveAnims['shadowforce'].anim,
prepareAnim: BattleMoveAnims['shadowforce'].prepareAnim,
};
BattleMoveAnims['shadowstrike'] = {anim: BattleMoveAnims['shadowforce'].anim}; BattleMoveAnims['shadowstrike'] = {anim: BattleMoveAnims['shadowforce'].anim};
BattleMoveAnims['smackdown'] = {anim: BattleMoveAnims['rockblast'].anim}; BattleMoveAnims['smackdown'] = {anim: BattleMoveAnims['rockblast'].anim};

View File

@ -569,7 +569,8 @@ class BattleScene {
} }
getDetailsText(pokemon: Pokemon) { getDetailsText(pokemon: Pokemon) {
let name = pokemon.side && pokemon.side.n && (this.battle.ignoreOpponent || this.battle.ignoreNicks) ? pokemon.species : pokemon.name; let name = pokemon.side && pokemon.side.n &&
(this.battle.ignoreOpponent || this.battle.ignoreNicks) ? pokemon.species : pokemon.name;
if (name !== pokemon.species) { if (name !== pokemon.species) {
name += ' (' + pokemon.species + ')'; name += ' (' + pokemon.species + ')';
} }
@ -759,15 +760,15 @@ class BattleScene {
weatherLeft() { weatherLeft() {
if (this.battle.gen < 7 && this.battle.hardcoreMode) return ''; if (this.battle.gen < 7 && this.battle.hardcoreMode) return '';
if (this.battle.weatherMinTimeLeft !== 0) { if (this.battle.weatherMinTimeLeft !== 0) {
return ' <small>(' + this.battle.weatherMinTimeLeft + ' or ' + this.battle.weatherTimeLeft + ' turns)</small>'; return ` <small>(${this.battle.weatherMinTimeLeft} or ${this.battle.weatherTimeLeft} turns)</small>`;
} }
if (this.battle.weatherTimeLeft !== 0) { if (this.battle.weatherTimeLeft !== 0) {
return ' <small>(' + this.battle.weatherTimeLeft + ' turn' + (this.battle.weatherTimeLeft === 1 ? '' : 's') + ')</small>'; return ` <small>(${this.battle.weatherTimeLeft} turn${this.battle.weatherTimeLeft === 1 ? '' : 's'})</small>`;
} }
return ''; return '';
} }
upkeepWeather() { upkeepWeather() {
const isIntense = (this.curWeather === 'desolateland' || this.curWeather === 'primordialsea' || this.curWeather === 'deltastream'); const isIntense = ['desolateland', 'primordialsea', 'deltastream'].includes(this.curWeather);
this.$weather.animate({ this.$weather.animate({
opacity: 1.0, opacity: 1.0,
}, 300).animate({ }, 300).animate({
@ -2326,21 +2327,24 @@ class PokemonSprite extends Sprite {
getStatbarHTML(pokemon: Pokemon) { getStatbarHTML(pokemon: Pokemon) {
let buf = '<div class="statbar' + (this.siden ? ' lstatbar' : ' rstatbar') + '" style="display: none">'; let buf = '<div class="statbar' + (this.siden ? ' lstatbar' : ' rstatbar') + '" style="display: none">';
buf += '<strong>' + (this.siden && (this.scene.battle.ignoreOpponent || this.scene.battle.ignoreNicks) ? pokemon.species : BattleLog.escapeHTML(pokemon.name)); const ignoreNick = this.siden && (this.scene.battle.ignoreOpponent || this.scene.battle.ignoreNicks);
buf += `<strong>${BattleLog.escapeHTML(ignoreNick ? pokemon.species : pokemon.name)}`;
let gender = pokemon.gender; let gender = pokemon.gender;
if (gender) buf += ' <img src="' + Dex.resourcePrefix + 'fx/gender-' + gender.toLowerCase() + '.png" alt="' + gender + '" />'; if (gender) {
buf += (pokemon.level === 100 ? '' : ' <small>L' + pokemon.level + '</small>'); buf += ` <img src="${Dex.resourcePrefix}fx/gender-${gender.toLowerCase()}.png" alt="${gender}" />`;
}
buf += (pokemon.level === 100 ? `` : ` <small>L${pokemon.level}</small>`);
let symbol = ''; let symbol = '';
if (pokemon.species.indexOf('-Mega') >= 0) symbol = 'mega'; if (pokemon.species.indexOf('-Mega') >= 0) symbol = 'mega';
else if (pokemon.species === 'Kyogre-Primal') symbol = 'alpha'; else if (pokemon.species === 'Kyogre-Primal') symbol = 'alpha';
else if (pokemon.species === 'Groudon-Primal') symbol = 'omega'; else if (pokemon.species === 'Groudon-Primal') symbol = 'omega';
if (symbol) { if (symbol) {
buf += ' <img src="' + Dex.resourcePrefix + 'sprites/misc/' + symbol + '.png" alt="' + symbol + '" style="vertical-align:text-bottom;" />'; buf += ` <img src="${Dex.resourcePrefix}sprites/misc/${symbol}.png" alt="${symbol}" style="vertical-align:text-bottom;" />`;
} }
buf += '</strong><div class="hpbar"><div class="hptext"></div><div class="hptextborder"></div><div class="prevhp"><div class="hp"></div></div><div class="status"></div>'; buf += `</strong><div class="hpbar"><div class="hptext"></div><div class="hptextborder"></div><div class="prevhp"><div class="hp"></div></div><div class="status"></div>`;
buf += '</div>'; buf += `</div>`;
return buf; return buf;
} }

View File

@ -142,7 +142,10 @@ function toName(name: any) {
if (name.length > 18) name = name.substr(0, 18).trim(); if (name.length > 18) name = name.substr(0, 18).trim();
// remove zalgo // remove zalgo
name = name.replace(/[\u0300-\u036f\u0483-\u0489\u0610-\u0615\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06ED\u0E31\u0E34-\u0E3A\u0E47-\u0E4E]{3,}/g, ''); name = name.replace(
/[\u0300-\u036f\u0483-\u0489\u0610-\u0615\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06ED\u0E31\u0E34-\u0E3A\u0E47-\u0E4E]{3,}/g,
''
);
name = name.replace(/[\u239b-\u23b9]/g, ''); name = name.replace(/[\u239b-\u23b9]/g, '');
return name; return name;
@ -224,7 +227,9 @@ const Dex = new class implements ModdedDex {
*/ */
sanitizeName(name: any) { sanitizeName(name: any) {
if (!name) return ''; if (!name) return '';
return ('' + name).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').slice(0, 50); return ('' + name)
.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
.slice(0, 50);
} }
prefs(prop: string, value?: any, save?: boolean) { prefs(prop: string, value?: any, save?: boolean) {
@ -590,9 +595,13 @@ const Dex = new class implements ModdedDex {
if (pokemon && pokemon.volatiles && pokemon.volatiles.formechange && !pokemon.volatiles.transform) { if (pokemon && pokemon.volatiles && pokemon.volatiles.formechange && !pokemon.volatiles.transform) {
id = toId(pokemon.volatiles.formechange[1]); id = toId(pokemon.volatiles.formechange[1]);
} }
if (pokemon && pokemon.num) num = pokemon.num; if (pokemon && pokemon.num) {
else if (window.BattlePokemonSprites && BattlePokemonSprites[id] && BattlePokemonSprites[id].num) num = BattlePokemonSprites[id].num; num = pokemon.num;
else if (window.BattlePokedex && window.BattlePokedex[id] && BattlePokedex[id].num) num = BattlePokedex[id].num; } else if (window.BattlePokemonSprites && BattlePokemonSprites[id] && BattlePokemonSprites[id].num) {
num = BattlePokemonSprites[id].num;
} else if (window.BattlePokedex && window.BattlePokedex[id] && BattlePokedex[id].num) {
num = BattlePokedex[id].num;
}
if (num < 0) num = 0; if (num < 0) num = 0;
if (num > 809) num = 0; if (num > 809) num = 0;

View File

@ -78,7 +78,9 @@ class BattleLog {
} }
let rank = name.charAt(0); let rank = name.charAt(0);
if (battle && battle.ignoreSpects && ' +'.includes(rank)) return; if (battle && battle.ignoreSpects && ' +'.includes(rank)) return;
if (battle && battle.ignoreOpponent && '\u2605\u2606'.includes(rank) && toUserid(name) !== app.user.get('userid')) return; if (battle && battle.ignoreOpponent) {
if ('\u2605\u2606'.includes(rank) && toUserid(name) !== app.user.get('userid')) return;
}
if (window.app && app.ignore && app.ignore[toUserid(name)] && ' +\u2605\u2606'.includes(rank)) return; if (window.app && app.ignore && app.ignore[toUserid(name)] && ' +\u2605\u2606'.includes(rank)) return;
let isHighlighted = window.app && app.rooms && app.rooms[battle!.roomid].getHighlight(message); let isHighlighted = window.app && app.rooms && app.rooms[battle!.roomid].getHighlight(message);
[divClass, divHTML] = this.parseChatMessage(message, name, '', isHighlighted); [divClass, divHTML] = this.parseChatMessage(message, name, '', isHighlighted);
@ -339,7 +341,8 @@ class BattleLog {
static escapeFormat(formatid: string): string { static escapeFormat(formatid: string): string {
let atIndex = formatid.indexOf('@@@'); let atIndex = formatid.indexOf('@@@');
if (atIndex >= 0) { if (atIndex >= 0) {
return this.escapeFormat(formatid.slice(0, atIndex)) + '<br />Custom rules: ' + this.escapeHTML(formatid.slice(atIndex + 3)); return this.escapeFormat(formatid.slice(0, atIndex)) +
'<br />Custom rules: ' + this.escapeHTML(formatid.slice(atIndex + 3));
} }
if (window.BattleFormats && BattleFormats[formatid]) { if (window.BattleFormats && BattleFormats[formatid]) {
return this.escapeHTML(BattleFormats[formatid].name); return this.escapeHTML(BattleFormats[formatid].name);

View File

@ -27,7 +27,9 @@ class BattleSceneStub {
preemptCatchup(): void { } preemptCatchup(): void { }
removeSideCondition(siden: number, id: ID): void { } removeSideCondition(siden: number, id: ID): void { }
reset(): void { } reset(): void { }
resultAnim(pokemon: Pokemon, result: string, type: "bad" | "good" | "neutral" | "par" | "psn" | "frz" | "slp" | "brn"): void { } resultAnim(
pokemon: Pokemon, result: string, type: "bad" | "good" | "neutral" | "par" | "psn" | "frz" | "slp" | "brn"
): void { }
typeAnim(pokemon: Pokemon, types: string): void { } typeAnim(pokemon: Pokemon, types: string): void { }
resume(): void { } resume(): void { }
runMoveAnim(moveid: ID, participants: Pokemon[]): void { } runMoveAnim(moveid: ID, participants: Pokemon[]): void { }

View File

@ -566,7 +566,8 @@ class BattleTextParser {
return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[ITEM]', this.effect(item)).replace('[SOURCE]', this.pokemon(target || kwArgs.of)); return line1 + template.replace('[POKEMON]', this.pokemon(pokemon)).replace('[ITEM]', this.effect(item)).replace('[SOURCE]', this.pokemon(target || kwArgs.of));
} }
if (id === 'frisk') { if (id === 'frisk') {
const template = this.template(kwArgs.of && pokemon && kwArgs.of !== pokemon ? 'activate' : 'activateNoTarget', "Frisk"); const hasTarget = kwArgs.of && pokemon && kwArgs.of !== pokemon;
const template = this.template(hasTarget ? 'activate' : 'activateNoTarget', "Frisk");
return line1 + template.replace('[POKEMON]', this.pokemon(kwArgs.of)).replace('[ITEM]', this.effect(item)).replace('[TARGET]', this.pokemon(pokemon)); return line1 + template.replace('[POKEMON]', this.pokemon(kwArgs.of)).replace('[ITEM]', this.effect(item)).replace('[TARGET]', this.pokemon(pokemon));
} }
if (kwArgs.from) { if (kwArgs.from) {
@ -643,7 +644,8 @@ class BattleTextParser {
case '-singleturn': case '-singlemove': { case '-singleturn': case '-singlemove': {
const [, pokemon, effect] = args; const [, pokemon, effect] = args;
const line1 = this.maybeAbility(effect, kwArgs.of || pokemon) || this.maybeAbility(kwArgs.from, kwArgs.of || pokemon); const line1 = this.maybeAbility(effect, kwArgs.of || pokemon) ||
this.maybeAbility(kwArgs.from, kwArgs.of || pokemon);
let id = BattleTextParser.effectId(effect); let id = BattleTextParser.effectId(effect);
if (id === 'instruct') { if (id === 'instruct') {
const template = this.template('activate', effect); const template = this.template('activate', effect);

View File

@ -26,7 +26,8 @@ class ModifiableValue {
this.serverPokemon = serverPokemon; this.serverPokemon = serverPokemon;
this.itemName = Dex.getItem(serverPokemon.item).name; this.itemName = Dex.getItem(serverPokemon.item).name;
this.abilityName = Dex.getAbility(serverPokemon.ability || (pokemon && pokemon.ability) || serverPokemon.baseAbility).name; const ability = serverPokemon.ability || (pokemon && pokemon.ability) || serverPokemon.baseAbility;
this.abilityName = Dex.getAbility(ability).name;
this.weatherName = Dex.getMove(battle.weather).name; this.weatherName = Dex.getMove(battle.weather).name;
} }
reset(value = 0, isAccuracy?: boolean) { reset(value = 0, isAccuracy?: boolean) {
@ -45,7 +46,9 @@ class ModifiableValue {
this.comment.push(` (${itemName} suppressed by Embargo)`); this.comment.push(` (${itemName} suppressed by Embargo)`);
return false; return false;
} }
const ignoreKlutz = ["Macho Brace", "Power Anklet", "Power Band", "Power Belt", "Power Bracer", "Power Lens", "Power Weight"]; const ignoreKlutz = [
"Macho Brace", "Power Anklet", "Power Band", "Power Belt", "Power Bracer", "Power Lens", "Power Weight",
];
if (this.tryAbility('Klutz') && !ignoreKlutz.includes(itemName)) { if (this.tryAbility('Klutz') && !ignoreKlutz.includes(itemName)) {
this.comment.push(` (${itemName} suppressed by Klutz)`); this.comment.push(` (${itemName} suppressed by Klutz)`);
return false; return false;
@ -544,42 +547,42 @@ class BattleTooltips {
} }
} }
if ('defrost' in move.flags) { if (move.flags.defrost) {
text += '<p class="movetag">The user thaws out if it is frozen.</p>'; text += `<p class="movetag">The user thaws out if it is frozen.</p>`;
} }
if (!('protect' in move.flags) && move.target !== 'self' && move.target !== 'allySide') { if (!move.flags.protect && !['self', 'allySide'].includes(move.target)) {
text += '<p class="movetag">Not blocked by Protect <small>(and Detect, King\'s Shield, Spiky Shield)</small></p>'; text += `<p class="movetag">Not blocked by Protect <small>(and Detect, King's Shield, Spiky Shield)</small></p>`;
} }
if ('authentic' in move.flags) { if (move.flags.authentic) {
text += '<p class="movetag">Bypasses Substitute <small>(but does not break it)</small></p>'; text += `<p class="movetag">Bypasses Substitute <small>(but does not break it)</small></p>`;
} }
if (!('reflectable' in move.flags) && move.target !== 'self' && move.target !== 'allySide' && move.category === 'Status') { if (!move.flags.reflectable && !['self', 'allySide'].includes(move.target) && move.category === 'Status') {
text += '<p class="movetag">&#x2713; Not bounceable <small>(can\'t be bounced by Magic Coat/Bounce)</small></p>'; text += `<p class="movetag">&#x2713; Not bounceable <small>(can't be bounced by Magic Coat/Bounce)</small></p>`;
} }
if ('contact' in move.flags) { if (move.flags.contact) {
text += '<p class="movetag">&#x2713; Contact <small>(triggers Iron Barbs, Spiky Shield, etc)</small></p>'; text += `<p class="movetag">&#x2713; Contact <small>(triggers Iron Barbs, Spiky Shield, etc)</small></p>`;
} }
if ('sound' in move.flags) { if (move.flags.sound) {
text += '<p class="movetag">&#x2713; Sound <small>(doesn\'t affect Soundproof pokemon)</small></p>'; text += `<p class="movetag">&#x2713; Sound <small>(doesn't affect Soundproof pokemon)</small></p>`;
} }
if ('powder' in move.flags) { if (move.flags.powder) {
text += '<p class="movetag">&#x2713; Powder <small>(doesn\'t affect Grass, Overcoat, Safety Goggles)</small></p>'; text += `<p class="movetag">&#x2713; Powder <small>(doesn't affect Grass, Overcoat, Safety Goggles)</small></p>`;
} }
if ('punch' in move.flags && ability === 'ironfist') { if (move.flags.punch && ability === 'ironfist') {
text += '<p class="movetag">&#x2713; Fist <small>(boosted by Iron Fist)</small></p>'; text += `<p class="movetag">&#x2713; Fist <small>(boosted by Iron Fist)</small></p>`;
} }
if ('pulse' in move.flags && ability === 'megalauncher') { if (move.flags.pulse && ability === 'megalauncher') {
text += '<p class="movetag">&#x2713; Pulse <small>(boosted by Mega Launcher)</small></p>'; text += `<p class="movetag">&#x2713; Pulse <small>(boosted by Mega Launcher)</small></p>`;
} }
if ('bite' in move.flags && ability === 'strongjaw') { if (move.flags.bite && ability === 'strongjaw') {
text += '<p class="movetag">&#x2713; Bite <small>(boosted by Strong Jaw)</small></p>'; text += `<p class="movetag">&#x2713; Bite <small>(boosted by Strong Jaw)</small></p>`;
} }
if ((move.recoil || move.hasCustomRecoil) && ability === 'reckless') { if ((move.recoil || move.hasCustomRecoil) && ability === 'reckless') {
text += '<p class="movetag">&#x2713; Recoil <small>(boosted by Reckless)</small></p>'; text += `<p class="movetag">&#x2713; Recoil <small>(boosted by Reckless)</small></p>`;
} }
if ('bullet' in move.flags) { if (move.flags.bullet) {
text += '<p class="movetag">&#x2713; Bullet-like <small>(doesn\'t affect Bulletproof pokemon)</small></p>'; text += `<p class="movetag">&#x2713; Bullet-like <small>(doesn't affect Bulletproof pokemon)</small></p>`;
} }
} }
return text; return text;
@ -1039,7 +1042,8 @@ class BattleTooltips {
let baseSpe = pokemon.getTemplate().baseStats['spe']; let baseSpe = pokemon.getTemplate().baseStats['spe'];
let tier = this.battle.tier; let tier = this.battle.tier;
let gen = this.battle.gen; let gen = this.battle.gen;
let isRandomBattle = tier.includes('Random Battle') || (tier.includes('Random') && tier.includes('Battle') && gen >= 6); let isRandomBattle = tier.includes('Random Battle') ||
(tier.includes('Random') && tier.includes('Battle') && gen >= 6);
let minNature = (isRandomBattle || gen < 3) ? 1 : 0.9; let minNature = (isRandomBattle || gen < 3) ? 1 : 0.9;
let maxNature = (isRandomBattle || gen < 3) ? 1 : 1.1; let maxNature = (isRandomBattle || gen < 3) ? 1 : 1.1;
@ -1099,7 +1103,9 @@ class BattleTooltips {
} }
} }
// Other abilities that change the move type. // Other abilities that change the move type.
const noTypeOverride = ['judgment', 'multiattack', 'naturalgift', 'revelationdance', 'struggle', 'technoblast', 'weatherball']; const noTypeOverride = [
'judgment', 'multiattack', 'naturalgift', 'revelationdance', 'struggle', 'technoblast', 'weatherball',
];
const allowTypeOverride = !noTypeOverride.includes(move.id); const allowTypeOverride = !noTypeOverride.includes(move.id);
if (allowTypeOverride && move.flags['sound'] && value.abilityModify(0, 'Liquid Voice')) { if (allowTypeOverride && move.flags['sound'] && value.abilityModify(0, 'Liquid Voice')) {
@ -1382,7 +1388,9 @@ class BattleTooltips {
value.abilityModify(1.25, "Rivalry"); value.abilityModify(1.25, "Rivalry");
} }
} }
const noTypeOverride = ['judgment', 'multiattack', 'naturalgift', 'revelationdance', 'struggle', 'technoblast', 'weatherball']; const noTypeOverride = [
'judgment', 'multiattack', 'naturalgift', 'revelationdance', 'struggle', 'technoblast', 'weatherball',
];
if (move.category !== 'Status' && !noTypeOverride.includes(move.id)) { if (move.category !== 'Status' && !noTypeOverride.includes(move.id)) {
if (move.type === 'Normal') { if (move.type === 'Normal') {
value.abilityModify(this.battle.gen > 6 ? 1.2 : 1.3, "Aerilate"); value.abilityModify(this.battle.gen > 6 ? 1.2 : 1.3, "Aerilate");
@ -1839,7 +1847,9 @@ class BattleStatGuesser {
} else if (itemid === 'salacberry') { } else if (itemid === 'salacberry') {
isFast = true; isFast = true;
} }
if (hasMove['agility'] || hasMove['shellsmash'] || hasMove['autotomize'] || hasMove['shiftgear'] || hasMove['rockpolish']) { const ultrafast = hasMove['agility'] || hasMove['shellsmash'] ||
hasMove['autotomize'] || hasMove['shiftgear'] || hasMove['rockpolish'];
if (ultrafast) {
moveCount['Ultrafast'] = 2; moveCount['Ultrafast'] = 2;
} }
moveCount['Fast'] = isFast ? 1 : 0; moveCount['Fast'] = isFast ? 1 : 0;
@ -1943,7 +1953,9 @@ class BattleStatGuesser {
let hasMove = this.hasMove; let hasMove = this.hasMove;
let moveCount = this.moveCount; let moveCount = this.moveCount;
let evs: StatsTable & {plusStat?: StatName | '', minusStat?: StatName | ''} = {hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0}; let evs: StatsTable & {plusStat?: StatName | '', minusStat?: StatName | ''} = {
hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0,
};
let plusStat: StatName | '' = ''; let plusStat: StatName | '' = '';
let minusStat: StatName | '' = ''; let minusStat: StatName | '' = '';
@ -2161,12 +2173,12 @@ class BattleStatGuesser {
if (stat === 'hp') { if (stat === 'hp') {
if (baseStat === 1) return 1; if (baseStat === 1) return 1;
if (!this.supportsEVs) return Math.floor(Math.floor(2 * baseStat + iv + 100) * level / 100 + 10) + (this.supportsAVs ? ev : 0); if (!this.supportsEVs) return ~~(~~(2 * baseStat + iv + 100) * level / 100 + 10) + (this.supportsAVs ? ev : 0);
return Math.floor(Math.floor(2 * baseStat + iv + Math.floor(ev / 4) + 100) * level / 100 + 10); return ~~(~~(2 * baseStat + iv + ~~(ev / 4) + 100) * level / 100 + 10);
} }
let val = Math.floor(Math.floor(2 * baseStat + iv + Math.floor(ev / 4)) * level / 100 + 5); let val = ~~(~~(2 * baseStat + iv + ~~(ev / 4)) * level / 100 + 5);
if (!this.supportsEVs) { if (!this.supportsEVs) {
val = Math.floor(Math.floor(2 * baseStat + iv) * level / 100 + 5); val = ~~(~~(2 * baseStat + iv) * level / 100 + 5);
} }
if (natureOverride) { if (natureOverride) {
val *= natureOverride; val *= natureOverride;
@ -2176,10 +2188,10 @@ class BattleStatGuesser {
val *= 0.9; val *= 0.9;
} }
if (!this.supportsEVs) { if (!this.supportsEVs) {
let friendshipValue = Math.floor((70 / 255 / 10 + 1) * 100); let friendshipValue = ~~((70 / 255 / 10 + 1) * 100);
val = Math.floor(val) * friendshipValue / 100 + (this.supportsAVs ? ev : 0); val = ~~(val) * friendshipValue / 100 + (this.supportsAVs ? ev : 0);
} }
return Math.floor(val); return ~~(val);
} }
} }

View File

@ -366,20 +366,28 @@ class Pokemon implements PokemonDetails, PokemonHealth {
if (this.boosts[boostStat] < -6) this.boosts[boostStat] = -6; if (this.boosts[boostStat] < -6) this.boosts[boostStat] = -6;
if (boostStat === 'accuracy' || boostStat === 'evasion') { if (boostStat === 'accuracy' || boostStat === 'evasion') {
if (this.boosts[boostStat] > 0) { if (this.boosts[boostStat] > 0) {
let goodBoostTable = ['1&times;', '1.33&times;', '1.67&times;', '2&times;', '2.33&times;', '2.67&times;', '3&times;']; let goodBoostTable = [
'1&times;', '1.33&times;', '1.67&times;', '2&times;', '2.33&times;', '2.67&times;', '3&times;',
];
// let goodBoostTable = ['Normal', '+1', '+2', '+3', '+4', '+5', '+6']; // let goodBoostTable = ['Normal', '+1', '+2', '+3', '+4', '+5', '+6'];
return '' + goodBoostTable[this.boosts[boostStat]] + '&nbsp;' + boostStatTable[boostStat]; return '' + goodBoostTable[this.boosts[boostStat]] + '&nbsp;' + boostStatTable[boostStat];
} }
let badBoostTable = ['1&times;', '0.75&times;', '0.6&times;', '0.5&times;', '0.43&times;', '0.38&times;', '0.33&times;']; let badBoostTable = [
'1&times;', '0.75&times;', '0.6&times;', '0.5&times;', '0.43&times;', '0.38&times;', '0.33&times;',
];
// let badBoostTable = ['Normal', '&minus;1', '&minus;2', '&minus;3', '&minus;4', '&minus;5', '&minus;6']; // let badBoostTable = ['Normal', '&minus;1', '&minus;2', '&minus;3', '&minus;4', '&minus;5', '&minus;6'];
return '' + badBoostTable[-this.boosts[boostStat]] + '&nbsp;' + boostStatTable[boostStat]; return '' + badBoostTable[-this.boosts[boostStat]] + '&nbsp;' + boostStatTable[boostStat];
} }
if (this.boosts[boostStat] > 0) { if (this.boosts[boostStat] > 0) {
let goodBoostTable = ['1&times;', '1.5&times;', '2&times;', '2.5&times;', '3&times;', '3.5&times;', '4&times;']; let goodBoostTable = [
'1&times;', '1.5&times;', '2&times;', '2.5&times;', '3&times;', '3.5&times;', '4&times;',
];
// let goodBoostTable = ['Normal', '+1', '+2', '+3', '+4', '+5', '+6']; // let goodBoostTable = ['Normal', '+1', '+2', '+3', '+4', '+5', '+6'];
return '' + goodBoostTable[this.boosts[boostStat]] + '&nbsp;' + boostStatTable[boostStat]; return '' + goodBoostTable[this.boosts[boostStat]] + '&nbsp;' + boostStatTable[boostStat];
} }
let badBoostTable = ['1&times;', '0.67&times;', '0.5&times;', '0.4&times;', '0.33&times;', '0.29&times;', '0.25&times;']; let badBoostTable = [
'1&times;', '0.67&times;', '0.5&times;', '0.4&times;', '0.33&times;', '0.29&times;', '0.25&times;',
];
// let badBoostTable = ['Normal', '&minus;1', '&minus;2', '&minus;3', '&minus;4', '&minus;5', '&minus;6']; // let badBoostTable = ['Normal', '&minus;1', '&minus;2', '&minus;3', '&minus;4', '&minus;5', '&minus;6'];
return '' + badBoostTable[-this.boosts[boostStat]] + '&nbsp;' + boostStatTable[boostStat]; return '' + badBoostTable[-this.boosts[boostStat]] + '&nbsp;' + boostStatTable[boostStat];
} }
@ -1411,19 +1419,33 @@ class Battle {
runMinor(args: Args, kwArgs: KWArgs, nextArgs?: Args, nextKwargs?: KWArgs) { runMinor(args: Args, kwArgs: KWArgs, nextArgs?: Args, nextKwargs?: KWArgs) {
if (nextArgs && nextKwargs) { if (nextArgs && nextKwargs) {
if (args[2] === 'Sturdy' && args[0] === '-activate') args[2] = 'ability: Sturdy'; if (args[2] === 'Sturdy' && args[0] === '-activate') {
if (args[0] === '-crit' || args[0] === '-supereffective' || args[0] === '-resisted' || args[2] === 'ability: Sturdy') kwArgs.then = '.'; args[2] = 'ability: Sturdy';
}
if (['-crit', '-supereffective', '-resisted'].includes(args[0]) || args[2] === 'ability: Sturdy') {
kwArgs.then = '.';
}
if (args[0] === '-damage' && !kwArgs.from && args[1] !== nextArgs[1] && ( if (args[0] === '-damage' && !kwArgs.from && args[1] !== nextArgs[1] && (
nextArgs[0] === '-crit' || ['-crit', '-supereffective', '-resisted'].includes(nextArgs[0]) ||
nextArgs[0] === '-supereffective' ||
nextArgs[0] === '-resisted' ||
(nextArgs[0] === '-damage' && !nextKwargs.from) (nextArgs[0] === '-damage' && !nextKwargs.from)
)) kwArgs.then = '.'; )) {
if (args[0] === '-damage' && nextArgs[0] === '-damage' && kwArgs.from && kwArgs.from === nextKwargs.from) kwArgs.then = '.'; kwArgs.then = '.';
if (args[0] === '-ability' && (args[2] === 'Intimidate' || args[3] === 'boost')) kwArgs.then = '.'; }
if (args[0] === '-unboost' && nextArgs[0] === '-unboost') kwArgs.then = '.'; if (args[0] === '-damage' && nextArgs[0] === '-damage' && kwArgs.from && kwArgs.from === nextKwargs.from) {
if (args[0] === '-boost' && nextArgs[0] === '-boost') kwArgs.then = '.'; kwArgs.then = '.';
if (args[0] === '-damage' && kwArgs.from === 'Leech Seed' && nextArgs[0] === '-heal' && nextKwargs.silent) kwArgs.then = '.'; }
if (args[0] === '-ability' && (args[2] === 'Intimidate' || args[3] === 'boost')) {
kwArgs.then = '.';
}
if (args[0] === '-unboost' && nextArgs[0] === '-unboost') {
kwArgs.then = '.';
}
if (args[0] === '-boost' && nextArgs[0] === '-boost') {
kwArgs.then = '.';
}
if (args[0] === '-damage' && kwArgs.from === 'Leech Seed' && nextArgs[0] === '-heal' && nextKwargs.silent) {
kwArgs.then = '.';
}
if (args[0] === 'detailschange' && nextArgs[0] === '-mega') { if (args[0] === 'detailschange' && nextArgs[0] === '-mega') {
if (this.scene.closeMessagebar()) { if (this.scene.closeMessagebar()) {
this.activityStep--; this.activityStep--;
@ -2678,7 +2700,7 @@ class Battle {
if (['electricterrain', 'grassyterrain', 'mistyterrain', 'psychicterrain'].includes(effect.id)) { if (['electricterrain', 'grassyterrain', 'mistyterrain', 'psychicterrain'].includes(effect.id)) {
for (let i = this.pseudoWeather.length - 1; i >= 0; i--) { for (let i = this.pseudoWeather.length - 1; i >= 0; i--) {
let pwName = this.pseudoWeather[i][0]; let pwName = this.pseudoWeather[i][0];
if (pwName === 'Electric Terrain' || pwName === 'Grassy Terrain' || pwName === 'Misty Terrain' || pwName === 'Psychic Terrain') { if (['Electric Terrain', 'Grassy Terrain', 'Misty Terrain', 'Psychic Terrain'].includes(pwName)) {
this.pseudoWeather.splice(i, 1); this.pseudoWeather.splice(i, 1);
continue; continue;
} }

View File

@ -63,12 +63,17 @@ class MainMenuPanel extends PSRoomPanel {
<p class="error"><strong>Pok&eacute;mon Showdown is offline due to a DDoS attack!</strong></p> : <p class="error"><strong>Pok&eacute;mon Showdown is offline due to a DDoS attack!</strong></p> :
<p class="error"><strong>Pok&eacute;mon Showdown is offline due to technical difficulties!</strong></p>} <p class="error"><strong>Pok&eacute;mon Showdown is offline due to technical difficulties!</strong></p>}
<p> <p>
<div style={{textAlign: 'center'}}><img width="96" height="96" src="//play.pokemonshowdown.com/sprites/bw/teddiursa.png" alt="" /></div> <div style={{textAlign: 'center'}}>
<img width="96" height="96" src="//play.pokemonshowdown.com/sprites/bw/teddiursa.png" alt="" />
</div>
Bear with us as we freak out. Bear with us as we freak out.
</p> </p>
<p>(We'll be back up in a few hours.)</p> <p>(We'll be back up in a few hours.)</p>
</div> : <div class="menugroup"> </div> : <div class="menugroup">
<p><button class="button mainmenu1 big" name="search"><strong>Battle!</strong><br /><small>Find a random opponent</small></button></p> <p><button class="button mainmenu1 big" name="search">
<strong>Battle!</strong><br />
<small>Find a random opponent</small>
</button></p>
</div>); </div>);
const onlineButton = ' button' + (PS.connected ? '' : ' disabled'); const onlineButton = ' button' + (PS.connected ? '' : ' disabled');
return <PSPanelWrapper room={this.props.room}> return <PSPanelWrapper room={this.props.room}>
@ -77,9 +82,17 @@ class MainMenuPanel extends PSRoomPanel {
<div class="activitymenu"> <div class="activitymenu">
<div class="pmbox"> <div class="pmbox">
<div class="pm-window news-embed" data-newsid="<!-- newsid -->"> <div class="pm-window news-embed" data-newsid="<!-- newsid -->">
<h3><button class="closebutton" tabIndex={-1}><i class="fa fa-times-circle"></i></button><button class="minimizebutton" tabIndex={-1}><i class="fa fa-minus-circle"></i></button>News</h3> <h3>
<button class="closebutton" tabIndex={-1}><i class="fa fa-times-circle"></i></button>
<button class="minimizebutton" tabIndex={-1}><i class="fa fa-minus-circle"></i></button>
News
</h3>
<div class="pm-log" style="max-height:none"> <div class="pm-log" style="max-height:none">
<div class="newsentry"><h4>Test client</h4><p>Welcome to the test client! You can test client changes here!</p><p>&mdash;<strong>Zarel</strong> <small class="date">on Sep 25, 2015</small></p></div> <div class="newsentry">
<h4>Test client</h4>
<p>Welcome to the test client! You can test client changes here!</p>
<p>&mdash;<strong>Zarel</strong> <small class="date">on Sep 25, 2015</small></p>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -99,13 +112,23 @@ class MainMenuPanel extends PSRoomPanel {
</div> </div>
</div> </div>
<div class="rightmenu" style={{display: PS.leftRoomWidth ? 'none' : 'block'}}> <div class="rightmenu" style={{display: PS.leftRoomWidth ? 'none' : 'block'}}>
<div class="menugroup">
{PS.server.id === 'showdown' ? {PS.server.id === 'showdown' ?
<div class="menugroup"><p><button class={"mainmenu1" + onlineButton} name="joinRoom" value="rooms">Join chat</button></p></div> : <p><button class={"mainmenu1" + onlineButton} name="joinRoom" value="rooms">Join chat</button></p>
<div class="menugroup"><p><button class={"mainmenu1" + onlineButton} name="joinRoom" value="lobby">Join lobby chat</button></p></div>} :
<p><button class={"mainmenu1" + onlineButton} name="joinRoom" value="lobby">Join lobby chat</button></p>
}
</div>
</div> </div>
<div class="mainmenufooter"> <div class="mainmenufooter">
<div class="bgcredit"></div> <div class="bgcredit"></div>
<small><a href="//dex.pokemonshowdown.com/" target="_blank">Pok&eacute;dex</a> | <a href="//replay.pokemonshowdown.com/" target="_blank">Replays</a> | <a href="//pokemonshowdown.com/rules" target="_blank">Rules</a> | <a href="//pokemonshowdown.com/credits" target="_blank">Credits</a> | <a href="http://smogon.com/forums/" target="_blank">Forum</a></small> <small>
<a href="//dex.pokemonshowdown.com/" target="_blank">Pok&eacute;dex</a> | {}
<a href="//replay.pokemonshowdown.com/" target="_blank">Replays</a> | {}
<a href="//pokemonshowdown.com/rules" target="_blank">Rules</a> | {}
<a href="//pokemonshowdown.com/credits" target="_blank">Credits</a> | {}
<a href="http://smogon.com/forums/" target="_blank">Forum</a>
</small>
</div> </div>
</div> </div>
</PSPanelWrapper>; </PSPanelWrapper>;

View File

@ -532,8 +532,12 @@ class TeambuilderPanel extends PSRoomPanel {
{filterFolder ? {filterFolder ?
<h2> <h2>
<i class="fa fa-folder-open"></i> {filterFolder} {} <i class="fa fa-folder-open"></i> {filterFolder} {}
<button class="button small" style="margin-left:5px" name="renameFolder"><i class="fa fa-pencil"></i> Rename</button> {} <button class="button small" style="margin-left:5px" name="renameFolder">
<button class="button small" style="margin-left:5px" name="promptDeleteFolder"><i class="fa fa-times"></i> Remove</button> <i class="fa fa-pencil"></i> Rename
</button> {}
<button class="button small" style="margin-left:5px" name="promptDeleteFolder">
<i class="fa fa-times"></i> Remove
</button>
</h2> </h2>
: filterFolder === '' ? : filterFolder === '' ?
<h2><i class="fa fa-folder-open-o"></i> Teams not in any folders</h2> <h2><i class="fa fa-folder-open-o"></i> Teams not in any folders</h2>

View File

@ -76,13 +76,21 @@ class PSHeader extends preact.Component<{style: {}}> {
break; break;
} }
if (closable) { if (closable) {
closeButton = <button class="closebutton" name="closeRoom" value={id} aria-label="Close"><i class="fa fa-times-circle"></i></button>; closeButton = <button class="closebutton" name="closeRoom" value={id} aria-label="Close">
<i class="fa fa-times-circle"></i>
</button>;
} }
return <li><a class={className} href={`/${id}`} draggable={true}>{icon} <span>{title}</span></a>{closeButton}</li>; return <li><a class={className} href={`/${id}`} draggable={true}>{icon} <span>{title}</span></a>{closeButton}</li>;
} }
render() { render() {
return <div id="header" class="header" style={this.props.style}> return <div id="header" class="header" style={this.props.style}>
<img class="logo" src="https://play.pokemonshowdown.com/pokemonshowdownbeta.png" srcset="https://play.pokemonshowdown.com/pokemonshowdownbeta@2x.png 2x" alt="Pokémon Showdown! (beta)" width="146" height="44" /> <img
class="logo"
src="https://play.pokemonshowdown.com/pokemonshowdownbeta.png"
srcset="https://play.pokemonshowdown.com/pokemonshowdownbeta@2x.png 2x"
alt="Pokémon Showdown! (beta)"
width="146" height="44"
/>
<div class="maintabbarbottom"></div> <div class="maintabbarbottom"></div>
<div class="tabbar maintabbar"><div class="inner"> <div class="tabbar maintabbar"><div class="inner">
<ul> <ul>
@ -98,10 +106,10 @@ class PSHeader extends preact.Component<{style: {}}> {
<div class="userbar"> <div class="userbar">
<span class="username" data-name={PS.user.name} style="color:hsl(96,67%,36%);"> <span class="username" data-name={PS.user.name} style="color:hsl(96,67%,36%);">
<i class="fa fa-user" style="color:#779EC5"></i> {PS.user.name} <i class="fa fa-user" style="color:#779EC5"></i> {PS.user.name}
</span>{' '} </span> {}
<button class="icon button" name="joinRoom" value="volume" title="Sound" aria-label="Sound"> <button class="icon button" name="joinRoom" value="volume" title="Sound" aria-label="Sound">
<i class="fa fa-volume-up"></i> <i class="fa fa-volume-up"></i>
</button>{' '} </button> {}
<button class="icon button" name="joinRoom" value="options" title="Options" aria-label="Options"> <button class="icon button" name="joinRoom" value="options" title="Options" aria-label="Options">
<i class="fa fa-cog"></i> <i class="fa fa-cog"></i>
</button> </button>
@ -179,7 +187,9 @@ class UserPanel extends PSRoomPanel<UserRoom> {
battlebuf.push(roomLink); battlebuf.push(roomLink);
} }
} else { } else {
const roomLink = <a href={`/${roomid}`} class={'ilink' + (roomid in PS.rooms ? ' yours' : '')}>{roomrank}{roomid}</a>; const roomLink = <a href={`/${roomid}`} class={'ilink' + (roomid in PS.rooms ? ' yours' : '')}>
{roomrank}{roomid}
</a>;
if (curRoom.isPrivate) { if (curRoom.isPrivate) {
if (privatebuf.length) privatebuf.push(", "); if (privatebuf.length) privatebuf.push(", ");
privatebuf.push(roomLink); privatebuf.push(roomLink);
@ -204,7 +214,10 @@ class UserPanel extends PSRoomPanel<UserRoom> {
return <PSPanelWrapper room={room}> return <PSPanelWrapper room={room}>
<div class="userdetails"> <div class="userdetails">
{user.avatar !== '[loading]' && {user.avatar !== '[loading]' &&
<img class={'trainersprite' + (room.isSelf ? ' yours' : '')} src={Dex.resolveAvatar('' + (user.avatar || 'unknown'))} /> <img
class={'trainersprite' + (room.isSelf ? ' yours' : '')}
src={Dex.resolveAvatar('' + (user.avatar || 'unknown'))}
/>
} }
<strong><a href={`//pokemonshowdown.com/users/${user.userid}`} target="_blank">{name}</a></strong><br /> <strong><a href={`//pokemonshowdown.com/users/${user.userid}`} target="_blank">{name}</a></strong><br />
{groupName && <small>{groupName}</small>} {groupName && <small>{groupName}</small>}
@ -214,19 +227,19 @@ class UserPanel extends PSRoomPanel<UserRoom> {
</div> </div>
{isSelf || !PS.user.named ? {isSelf || !PS.user.named ?
<p class="buttonbar"> <p class="buttonbar">
<button class="button disabled" disabled>Challenge</button>{' '} <button class="button disabled" disabled>Challenge</button> {}
<button class="button disabled" disabled>Chat</button> <button class="button disabled" disabled>Chat</button>
</p> </p>
: :
<p class="buttonbar"> <p class="buttonbar">
<button class="button" name="challenge">Challenge</button>{' '} <button class="button" name="challenge">Challenge</button> {}
<button class="button" name="pm">Chat</button>{' '} <button class="button" name="pm">Chat</button> {}
<button class="button" name="userOptions">{'\u2026'}</button> <button class="button" name="userOptions">{'\u2026'}</button>
</p> </p>
} }
{isSelf && <hr />} {isSelf && <hr />}
{isSelf && <p class="buttonbar" style="text-align: right"> {isSelf && <p class="buttonbar" style="text-align: right">
<button class="button" name="login"><i class="fa fa-pencil"></i> Change name</button>{' '} <button class="button" name="login"><i class="fa fa-pencil"></i> Change name</button> {}
<button class="button" name="logout"><i class="fa fa-power-off"></i> Log out</button> <button class="button" name="logout"><i class="fa fa-power-off"></i> Log out</button>
</p>} </p>}
</PSPanelWrapper>; </PSPanelWrapper>;

View File

@ -209,7 +209,7 @@ class PSMain extends preact.Component {
let elem = e.target as HTMLInputElement | null; let elem = e.target as HTMLInputElement | null;
if (elem) { if (elem) {
let isTextInput = (elem.tagName === 'INPUT' || elem.tagName === 'TEXTAREA'); let isTextInput = (elem.tagName === 'INPUT' || elem.tagName === 'TEXTAREA');
if (isTextInput && (elem.type === 'button' || elem.type === 'radio' || elem.type === 'checkbox' || elem.type === 'file')) { if (isTextInput && ['button', 'radio', 'checkbox', 'file'].includes(elem.type)) {
isTextInput = false; isTextInput = false;
} }
if (isTextInput && elem.value) { if (isTextInput && elem.value) {

View File

@ -18,8 +18,8 @@
"max-line-length": { "max-line-length": {
"severity": "warning", "severity": "warning",
"options": { "options": {
"limit": 140, "limit": 120,
"ignore-pattern": "\\.replace\\(('\\[|/)|^\\s*(// \\s*)?(return |(let |const )?[a-zA-Z0-9$.]+ \\+?= (\\$\\()?|[a-zA-Z0-9$.]+\\()?['\"`]" "ignore-pattern": "template\\.replace\\(('\\[|/)|^\\s*(// \\s*)?((let |const )?[a-zA-Z0-9$.]+ \\+?= (\\$\\()?|(return |throw )?(new )?([a-zA-Z0-9$.]+\\()?)?['\"`/]"
} }
}, },
"interface-name": false, "interface-name": false,