{
  name: "Stampede",
  rating: 4,
  num: -2010,
  flags: {},
  onStart(pokemon) {
    const side = pokemon.side;
    let fallen = 0;
    for (const ally of side.pokemon) {
      if (ally.fainted && ally !== pokemon) fallen++;
    }
    pokemon.abilityState.stampedefallen = Math.min(fallen, 5);
    if (pokemon.abilityState.stampedefallen && pokemon.abilityState.stampedefallen > 0) {
      this.add('-ability', pokemon, 'Stampede');
      this.add('-message', `${pokemon.name} charges ahead with increased speed! (${pokemon.abilityState.stampedefallen} fallen ally${pokemon.abilityState.stampedefallen === 1 ? '' : 'ies'})`);
    }
  },
  onModifySpe(spe, pokemon) {
    const boost = pokemon.abilityState.stampedefallen || 0;
    if (boost > 0) {
      return this.chainModify(1 + boost * 0.1);
    }
    return spe;
  },
  onEnd(pokemon) {
    if (pokemon.abilityState.stampedefallen && pokemon.abilityState.stampedefallen > 0) {
      this.add('-message', `${pokemon.name}'s Stampede boost faded.`);
    }
  }
}
