{
    onSwitchIn() {
        const side = this.effectState.target.side;
        const faintedAllies = side.pokemon.filter(pokemon => pokemon.fainted && pokemon.ability !== 'noability');

        if (faintedAllies.length) {
            const lastFaintedAlly = faintedAllies[faintedAllies.length - 1];
            const ability = lastFaintedAlly.getAbility();

            if (!ability.flags["noreceiver"] && this.effectState.target.setAbility(ability)) {
                this.add("-ability", this.effectState.target, ability, "[from] ability: Power of Alchemy", "[of] " + lastFaintedAlly);
            }
        }
    },
    flags: { failroleplay: 1, noreceiver: 1, noentrain: 1, notrace: 1 },
    name: "Power of Alchemy",
    rating: 0,
    num: 223,
}
