Skip to content

Commit

Permalink
Rename Max Chosen Total Level -> Max Total Level
Browse files Browse the repository at this point in the history
In hindsight, the "Chosen" isn't adding that much, and unlike
Chosen Team Size, it _is_ usable outside of Team Preview. Losing a
word makes it noticeably easy to read, I think.
  • Loading branch information
Zarel committed May 4, 2021
1 parent 1309a1e commit ecb5ffa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions config/formats.ts
Expand Up @@ -3092,7 +3092,7 @@ export const Formats: FormatList = [
mod: 'gen2',
searchShow: false,
ruleset: [
'Chosen Team Size = 3', 'Min Level = 50', 'Max Level = 55', 'Max Chosen Total Level = 155',
'Chosen Team Size = 3', 'Min Level = 50', 'Max Level = 55', 'Max Total Level = 155',
'Obtainable', 'Stadium Sleep Clause', 'Freeze Clause Mod', 'Species Clause', 'Item Clause', 'Endless Battle Clause', 'Cancel Mod', 'Event Moves Clause', 'Nickname Clause', 'Team Preview', 'Nintendo Cup 2000 Move Legality',
],
banlist: ['Uber'],
Expand Down Expand Up @@ -3180,7 +3180,7 @@ export const Formats: FormatList = [
mod: 'gen1jpn',
searchShow: false,
ruleset: [
'Chosen Team Size = 3', 'Min Level = 50', 'Max Level = 55', 'Max Chosen Total Level = 155',
'Chosen Team Size = 3', 'Min Level = 50', 'Max Level = 55', 'Max Total Level = 155',
'Obtainable', 'Team Preview', 'Sleep Clause Mod', 'Species Clause', 'Nickname Clause', 'HP Percentage Mod', 'Cancel Mod', 'Nintendo Cup 1997 Move Legality',
],
banlist: ['Uber'],
Expand Down
23 changes: 12 additions & 11 deletions data/rulesets.ts
Expand Up @@ -1317,15 +1317,15 @@ export const Rulesets: {[k: string]: FormatData} = {
hasValue: 'positive-integer',
// hardcoded in sim/team-validator
},
maxchosentotallevel: {
maxtotallevel: {
effectType: 'Rule',
name: 'Max Chosen Total Level',
name: 'Max Total Level',
desc: "Teams are restricted to a total maximum Level limit and Pokemon are restricted to a set range of Levels",
hasValue: 'positive-integer',
onValidateTeam(team) {
const chosenTeamSize = this.ruleTable.chosenTeamSize || team.length;
const maxChosenTotalLevel = this.ruleTable.maxChosenTotalLevel;
if (maxChosenTotalLevel === null) throw new Error("No maxChosenTotalLevel specified.");
const maxTotalLevel = this.ruleTable.maxTotalLevel;
if (maxTotalLevel === null) throw new Error("No maxChosenTotalLevel specified.");

const teamLevels = [];
for (const set of team) {
Expand All @@ -1337,32 +1337,33 @@ export const Rulesets: {[k: string]: FormatData} = {
for (let i = 0; i < chosenTeamSize; i++) {
totalLowestLevels += teamLevels[i];
}
if (totalLowestLevels > maxChosenTotalLevel) {
if (totalLowestLevels > maxTotalLevel) {
const thePokemon = chosenTeamSize === team.length ? `all ${team.length} Pokémon` : `the ${chosenTeamSize} lowest-leveled Pokémon`;
return [
`The combined levels of the ${chosenTeamSize} lowest-leveled Pokémon of your team is ${totalLowestLevels}, above the format's total level limit of ${maxChosenTotalLevel}.`,
`The combined levels of ${thePokemon} of your team is ${totalLowestLevels}, above the format's total level limit of ${maxTotalLevel}${this.ruleTable.blame('maxtotallevel')}.`,
];
}

let minTotalWithHighestLevel = teamLevels[teamLevels.length - 1];
for (let i = 0; i < chosenTeamSize - 1; i++) {
minTotalWithHighestLevel += teamLevels[i];
}
if (minTotalWithHighestLevel > maxChosenTotalLevel) {
if (minTotalWithHighestLevel > maxTotalLevel) {
return [
`Your highest level Pokémon is unusable, because there's no way to create a team with it whose total level is less than the format's total level limit of ${maxChosenTotalLevel}.`,
`Your highest level Pokémon is unusable, because there's no way to create a team with it whose total level is less than the format's total level limit of ${maxTotalLevel}${this.ruleTable.blame('maxtotallevel')}.`,
];
}
},
onValidateRule(value) {
const ruleTable = this.ruleTable;
const maxChosenTotalLevel = ruleTable.maxChosenTotalLevel!;
const maxChosenTotalLevel = ruleTable.maxTotalLevel!;
const maxTeamSize = ruleTable.chosenTeamSize || ruleTable.maxTeamSize;
const maxTeamSizeBlame = ruleTable.chosenTeamSize ? ruleTable.blame('chosenteamsize') : ruleTable.blame('maxteamsize');
if (maxChosenTotalLevel >= ruleTable.maxLevel * maxTeamSize) {
throw new Error(`A Max Chosen Total Level of ${maxChosenTotalLevel}${ruleTable.blame('maxchosentotallevel')} is too high (and will have no effect) with ${maxTeamSize}${maxTeamSizeBlame} Pokémon at max level ${ruleTable.maxLevel}${ruleTable.blame('maxlevel')}`);
throw new Error(`A Max Total Level of ${maxChosenTotalLevel}${ruleTable.blame('maxtotallevel')} is too high (and will have no effect) with ${maxTeamSize}${maxTeamSizeBlame} Pokémon at max level ${ruleTable.maxLevel}${ruleTable.blame('maxlevel')}`);
}
if (maxChosenTotalLevel <= ruleTable.minLevel * maxTeamSize) {
throw new Error(`A Max Chosen Total Level of ${maxChosenTotalLevel}${ruleTable.blame('maxchosentotallevel')} is too low with ${maxTeamSize}${maxTeamSizeBlame} Pokémon at min level ${ruleTable.minLevel}${ruleTable.blame('minlevel')}`);
throw new Error(`A Max Total Level of ${maxChosenTotalLevel}${ruleTable.blame('maxtotallevel')} is too low with ${maxTeamSize}${maxTeamSizeBlame} Pokémon at min level ${ruleTable.minLevel}${ruleTable.blame('minlevel')}`);
}
},
// hardcoded in sim/side
Expand Down
4 changes: 2 additions & 2 deletions sim/dex-formats.ts
Expand Up @@ -40,7 +40,7 @@ export class RuleTable extends Map<string, string> {
minTeamSize!: number;
maxTeamSize!: number;
chosenTeamSize!: number | null;
maxChosenTotalLevel!: number | null;
maxTotalLevel!: number | null;
minSourceGen!: number;
minLevel!: number;
maxLevel!: number;
Expand Down Expand Up @@ -643,7 +643,7 @@ export class DexFormats {
ruleTable.minTeamSize = Number(ruleTable.valueRules.get('minteamsize')) || 0;
ruleTable.maxTeamSize = Number(ruleTable.valueRules.get('maxteamsize')) || 6;
ruleTable.chosenTeamSize = Number(ruleTable.valueRules.get('chosenteamsize')) || null;
ruleTable.maxChosenTotalLevel = Number(ruleTable.valueRules.get('maxchosentotallevel')) || null;
ruleTable.maxTotalLevel = Number(ruleTable.valueRules.get('maxtotallevel')) || null;
ruleTable.minSourceGen = Number(ruleTable.valueRules.get('minsourcegen')) || 1;
ruleTable.minLevel = Number(ruleTable.valueRules.get('minlevel')) || 1;
ruleTable.maxLevel = Number(ruleTable.valueRules.get('maxlevel')) || 100;
Expand Down
6 changes: 3 additions & 3 deletions sim/side.ts
Expand Up @@ -771,17 +771,17 @@ export class Side {
return this.emitChoiceError(`Can't choose for Team Preview: The Pokémon in slot ${pos + 1} can only switch in once`);
}
}
if (ruleTable.maxChosenTotalLevel) {
if (ruleTable.maxTotalLevel) {
let totalLevel = 0;
for (const pos of positions) totalLevel += this.pokemon[pos].level;

if (totalLevel > ruleTable.maxChosenTotalLevel) {
if (totalLevel > ruleTable.maxTotalLevel) {
if (!data) {
// autoChoose
positions = [...this.pokemon.keys()].sort((a, b) => (this.pokemon[a].level - this.pokemon[b].level))
.slice(0, chosenTeamSize);
} else {
return this.emitChoiceError(`Your selected team has a total level of ${totalLevel}, but it can't be above ${ruleTable.maxChosenTotalLevel}; please select a valid team of ${chosenTeamSize} Pokémon`);
return this.emitChoiceError(`Your selected team has a total level of ${totalLevel}, but it can't be above ${ruleTable.maxTotalLevel}; please select a valid team of ${chosenTeamSize} Pokémon`);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sim/team-validator.ts
Expand Up @@ -934,7 +934,7 @@ export class TeamValidator {
let totalEV = 0;
for (const stat in set.evs) totalEV += set.evs[stat as 'hp'];
// Not having this affect Nintendo Cup formats because it is annoying to deal with having to lower a base stat by 1 for every Pokemon.
if (!this.format.debug && !ruleTable.has('maxchosentotallevel')) {
if (!this.format.debug && !ruleTable.has('maxtotallevel')) {
if (set.level > 1 && (allowEVs || allowAVs) && totalEV === 0) {
problems.push(`${name} has exactly 0 EVs - did you forget to EV it? (If this was intentional, add exactly 1 to one of your EVs, which won't change its stats but will tell us that it wasn't a mistake).`);
} else if (allowEVs && !capEVs && [508, 510].includes(totalEV)) {
Expand Down

0 comments on commit ecb5ffa

Please sign in to comment.