{
  onStart(pokemon) {
    if (!pokemon.originalTypes) {
      pokemon.originalTypes = [...pokemon.types];
    }
    if (pokemon.hp > pokemon.maxhp / 2) {
      const move1 = this.dex.moves.get(pokemon.moveSlots[0]?.id);
      const move2 = this.dex.moves.get(pokemon.moveSlots[1]?.id);
      if (!move1 || !move2) return;

      const types = [move1.type, move2.type];
      const uniqueTypes = [...new Set(types)].slice(0, 2);

      if (
        pokemon.types.length === uniqueTypes.length &&
        uniqueTypes.every(t => pokemon.hasType(t))
      ) {
        return;
      }

      if (!pokemon.setType(uniqueTypes)) return;
      this.add('-start', pokemon, 'typechange', uniqueTypes.join('/'));
    }
  },

  onUpdate(pokemon) {
    if (pokemon.hp <= pokemon.maxhp / 2 && pokemon.originalTypes) {
      if (
        pokemon.types.length !== pokemon.originalTypes.length ||
        !pokemon.originalTypes.every(t => pokemon.hasType(t))
      ) {
        pokemon.setType(pokemon.originalTypes);
        this.add('-start', pokemon, 'typechange', pokemon.originalTypes.join('/'));
      }
    }
    if (pokemon.hp > pokemon.maxhp / 2 && pokemon.originalTypes) {
      const move1 = this.dex.moves.get(pokemon.moveSlots[0]?.id);
      const move2 = this.dex.moves.get(pokemon.moveSlots[1]?.id);
      if (!move1 || !move2) return;

      const types = [move1.type, move2.type];
      const uniqueTypes = [...new Set(types)].slice(0, 2);

      if (
        pokemon.types.length !== uniqueTypes.length ||
        !uniqueTypes.every(t => pokemon.hasType(t))
      ) {
        if (!pokemon.setType(uniqueTypes)) return;
        this.add('-start', pokemon, 'typechange', uniqueTypes.join('/'));
      }
    }
  },

  flags: {},
  name: "Chromatic Scales",
  rating: 3,
  num: -931
}

