Add Terastal Crescendo online competition (#11471)

* Add Terastal Crescendo online competition

* Fix build
This commit is contained in:
Kris Johnson 2025-10-01 21:13:50 -06:00 committed by GitHub
parent 8f75a35759
commit f52bc482bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 10 deletions

View File

@ -272,6 +272,14 @@ export const Formats: import('../sim/dex-formats').FormatList = [
ruleset: ['Flat Rules', '!! Adjust Level = 50', 'Min Source Gen = 9', 'VGC Timer', 'Force Open Team Sheets', 'Best of = 3', 'Limit Two Restricted'],
restricted: ['Restricted Legendary', 'Mythical'],
},
{
name: "[Gen 9] Terastal Crescendo",
mod: 'gen9',
gameType: 'doubles',
ruleset: ['Flat Rules', '!! Picked Team Size = 2', 'Min Team Size = 4', '!! Adjust Level = 50', 'Min Source Gen = 9', 'VGC Timer', 'Limit One Restricted', 'Force Select = Koraidon | Miraidon'],
unbanlist: ['Koraidon', 'Miraidon'],
restricted: ['Koraidon', 'Miraidon'],
},
{
name: "[Gen 9] Doubles Custom Game",
mod: 'gen9',

View File

@ -566,22 +566,26 @@ export const Rulesets: import('../sim/dex-formats').FormatDataTable = {
forceselect: {
effectType: 'ValidatorRule',
name: 'Force Select',
desc: `Forces a Pokemon to be on the team and selected at Team Preview. Usage: Force Select = [Pokemon], e.g. "Force Select = Magikarp"`,
desc: `Forces a Pokemon to be on the team and selected at Team Preview. Usage: Force Select = [Pokemon], e.g. "Force Select = Magikarp" or "Force Select = Koraidon | Miraidon"`,
hasValue: true,
onValidateRule(value) {
if (!this.dex.species.get(value).exists) throw new Error(`Misspelled Pokemon "${value}"`);
const values = value.split('|');
if (values.some(v => !this.dex.species.get(v).exists)) throw new Error(`Misspelled Pokemon provided in "${value}"`);
},
onValidateTeam(team) {
let hasSelection = false;
const species = this.dex.species.get(this.ruleTable.valueRules.get('forceselect'));
const speciesNameList = this.ruleTable.valueRules.get('forceselect')!.split('|')
.map(value => this.dex.species.get(value).name);
for (const set of team) {
if (species.name === set.species) {
if (speciesNameList.includes(set.species)) {
hasSelection = true;
break;
}
}
if (!hasSelection) {
return [`Your team must contain ${species.name}.`];
return [
`Your team must contain ${speciesNameList.length > 1 ? `one of: ${speciesNameList.join(', ')}` : speciesNameList[0]}.`,
];
}
},
// hardcoded in sim/side

View File

@ -1023,22 +1023,23 @@ export class Side {
}
}
if (ruleTable.valueRules.has('forceselect')) {
const species = this.battle.dex.species.get(ruleTable.valueRules.get('forceselect'));
const speciesList = ruleTable.valueRules.get('forceselect')!.split('|')
.map(entry => this.battle.dex.species.get(entry).name);
if (!data) {
// autoChoose
positions = [...this.pokemon.keys()].filter(pos => this.pokemon[pos].species.name === species.name)
.concat([...this.pokemon.keys()].filter(pos => this.pokemon[pos].species.name !== species.name))
positions = [...this.pokemon.keys()].filter(pos => speciesList.includes(this.pokemon[pos].species.name))
.concat([...this.pokemon.keys()].filter(pos => !speciesList.includes(this.pokemon[pos].species.name)))
.slice(0, pickedTeamSize);
} else {
let hasSelection = false;
for (const pos of positions) {
if (this.pokemon[pos].species.name === species.name) {
if (speciesList.includes(this.pokemon[pos].species.name)) {
hasSelection = true;
break;
}
}
if (!hasSelection) {
return this.emitChoiceError(`You must bring ${species.name} to the battle.`);
return this.emitChoiceError(`You must bring ${speciesList.length > 1 ? `one of ${speciesList.join(', ')}` : speciesList[0]} to the battle.`);
}
}
}