{
    onUpdate(pokemon) {
        if (this.gameType !== 'doubles' && this.gameType !== 'triples') return;

        const allies = pokemon.allies();

        const dondozoAlly = allies.find(ally => ally.baseSpecies.baseSpecies === 'Dondozo');
        if (pokemon.baseSpecies.baseSpecies === 'Tatsugiri' && dondozoAlly) {
            if (!pokemon.getVolatile('commanding')) {
                if (dondozoAlly.getVolatile('commanded')) return;
                this.queue.cancelAction(pokemon);
                this.add('-activate', pokemon, 'ability: Commander', '[of] ' + dondozoAlly);
                pokemon.addVolatile('commanding');
                dondozoAlly.addVolatile('commanded', pokemon);
            } else {
                if (!dondozoAlly.fainted) return;
                pokemon.removeVolatile('commanding');
            }
        }

        const mantineAlly = allies.find(ally => ally.baseSpecies.baseSpecies === 'Mantine');
        if (pokemon.baseSpecies.baseSpecies === 'Remoraid' && mantineAlly) {
            if (!pokemon.getVolatile('commanding')) {
                if (mantineAlly.getVolatile('commanded')) return;
                this.queue.cancelAction(pokemon);
                this.add('-activate', pokemon, 'ability: Commander', '[of] ' + mantineAlly);
                pokemon.addVolatile('commanding');
                mantineAlly.addVolatile('commanded', pokemon);
            } else {
                if (!mantineAlly.fainted) return;
                pokemon.removeVolatile('commanding');
            }
        }

        if (pokemon.getVolatile('commanding') && (!dondozoAlly || dondozoAlly.fainted) && (!mantineAlly || mantineAlly.fainted)) {
            pokemon.removeVolatile('commanding');
        }
    },
    flags: {failroleplay: 1, noreceiver: 1, noentrain: 1, notrace: 1, failskillswap: 1},
    name: "Commander",
    rating: 0,
    num: 279,
}
