mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
Add Terastal Crescendo online competition (#11471)
* Add Terastal Crescendo online competition * Fix build
This commit is contained in:
parent
8f75a35759
commit
f52bc482bb
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
11
sim/side.ts
11
sim/side.ts
|
|
@ -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.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user