java.lang.Object
com.pixelmonmod.pixelmon.battles.controller.ai.MoveChoice
All Implemented Interfaces:
Comparable<MoveChoice>

public class MoveChoice extends Object implements Comparable<MoveChoice>
Represents the AI's move choice for the turn.
  • Field Details

    • user

      public PixelmonWrapper user
      The Pokémon using the move.
    • attack

      public Attack attack
      The attack to use.
    • targets

      public List<PixelmonWrapper> targets
      The targets of the attack to use.
    • result

      public MoveResults result
      The result of the simulated attack.
    • switchPokemon

      public UUID switchPokemon
      The UUID of the Pokémon to switch to.
    • tier

      public int tier
      The tier of usefulness of the move.
    • weight

      public float weight
      The usefulness of the move within the tier.
    • TIER_USELESS

      public static final int TIER_USELESS
      The move has no beneficial effects.
      See Also:
    • TIER_MINIMAL

      public static final int TIER_MINIMAL
      The Pokémon will not be able to make use of the move before fainting if the opponent acts optimally.
      See Also:
    • TIER_NORMAL

      public static final int TIER_NORMAL
      The move has an effect in battle.
      See Also:
    • TIER_KO

      public static final int TIER_KO
      The move KOes an opponent or has a similar high-priority effect.
      See Also:
  • Constructor Details

    • MoveChoice

      public MoveChoice(PixelmonWrapper user, Attack attack, List<PixelmonWrapper> targets)
      Makes a choice to attack.
      Parameters:
      attack - The attack to use.
      targets - the targets of the attack to use.
    • MoveChoice

      public MoveChoice(PixelmonWrapper user, UUID switchPokemon)
      Makes a choice to switch.
      Parameters:
      switchPokemon - The UUID of the Pokémon to switch to.
  • Method Details

    • isAttack

      public boolean isAttack()
      Checks if the choice is an attack.
      Returns:
      Whether the choice is an attack.
    • isStatusMove

      public boolean isStatusMove()
      Checks if the choice is a status move.
      Returns:
      Whether the choice is a status move.
    • isOffensiveMove

      public boolean isOffensiveMove()
      Checks if the choice is an offensive move.
      Returns:
      Whether the choice is an offensive move.
    • isSameType

      public boolean isSameType(MoveChoice other)
      Checks if this choice is the same type (attack/switch) as another type.
      Parameters:
      other - The choice to compare with.
      Returns:
      Whether this choice is the same type as the other type.
    • isSimilarWeight

      public boolean isSimilarWeight(MoveChoice other)
      Checks if this choice has a similar weight as another choice.
      Parameters:
      other - The choice to compare with.
      Returns:
      Whether this choice has a similar weight as the other choice.
    • raiseWeight

      public void raiseWeight(float newWeight)
      Raises the weight of the choice. Raises the tier to normal if it is currently useless and the weight is positive.
      Parameters:
      newWeight - The amount of weight to add to the current weight.
    • raiseWeightLimited

      public void raiseWeightLimited(float newWeight)
      Raises the weight of the choice, but not above 100.
      Parameters:
      newWeight - The amount of weight to add to the current weight.
    • setWeight

      public void setWeight(float newWeight)
      Sets the weight of the choice. Raises the tier to normal if it is currently useless and the weight is positive.
      Parameters:
      newWeight - The weight to set the choice to.
    • raiseTier

      public void raiseTier(int newTier)
      Raises the tier of the choice. If the tier is already higher than the new tier, do nothing.
      Parameters:
      newTier - The new tier to set the choice to.
    • lowerTier

      public void lowerTier(int newTier)
      Lowers the tier of the choice. If the tier is already lower than the new tier, do nothing.
      Parameters:
      newTier -
    • isMiddleTier

      public boolean isMiddleTier()
      Checks if the choice's tier is one of the middle tiers.
      Returns:
      Whether the choice's tier is one of the middle tiers.
    • resetWeight

      public void resetWeight()
      Sets the choice's tier and weight to 0.
    • hitsAlly

      public boolean hitsAlly()
      Checks if the move choice hits an ally.
      Returns:
      Whether the move hits an ally.
    • createList

      public List<MoveChoice> createList()
      Makes a list containing the choice.
      Returns:
      A list containing the choice.
    • compareTo

      public int compareTo(MoveChoice otherChoice)
      Specified by:
      compareTo in interface Comparable<MoveChoice>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • checkBestChoice

      public static void checkBestChoice(MoveChoice choice, List<MoveChoice> bestChoices)
      Checks whether a move choice is best and modifies the best choices if it is.
      Parameters:
      choice - The move choice to check.
      bestChoices - The current list of best choices.
    • checkBestChoice

      public static void checkBestChoice(MoveChoice choice, List<MoveChoice> bestChoices, boolean excludeStatus)
      Checks whether a move choice is best and modifies the best choices if it is.
      Parameters:
      choice - The move choice to check.
      bestChoices - The current list of best choices.
      excludeStatus - Whether to exclude status moves from the choices.
    • getMaxPriority

      public static float getMaxPriority(List<MoveChoice> choices)
      Gets the highest priority in a list of choices.
      Parameters:
      choices - The choices to find the highest priority for.
      Returns:
      The priority of the highest-priority choice in the list.
    • canOutspeed

      public static boolean canOutspeed(List<MoveChoice> opponentChoices, PixelmonWrapper pw, List<MoveChoice> userChoices)
      Checks if an opponent can outspeed a Pokémon.
      Parameters:
      opponentChoices - The choices to check for outspeeding.
      pw - The Pokémon to check for being outsped.
      userChoices - The Pokémon's choice to search for priority moves.
      Returns:
      Whether an opponent choice can outspeed the Pokémon.
    • canOHKO

      public static boolean canOHKO(List<MoveChoice> opponentChoices, PixelmonWrapper pw)
      Checks if a list of choices contains a Pokémon that can OHKO the specified Pokémon.
      Parameters:
      opponentChoices - The choices to check for OHKOing the Pokémon.
      pw - The Pokémon to check for being OHKOed.
      Returns:
      Whether a choice can OHKO the Pokémon.
    • canOutspeedAndOHKO

      public static boolean canOutspeedAndOHKO(List<MoveChoice> opponentChoices, PixelmonWrapper pw, List<MoveChoice> userChoices)
      Checks if a list of choices contains a Pokémon that can outspeed and OHKO the specified Pokémon.
      Parameters:
      opponentChoices - The choices to check for outspeeding and OHKOing the Pokémon.
      pw - The Pokémon to check for being outsped and OHKOed.
      Returns:
      Whether a choice can outspeed and OHKO the Pokémon.
    • canOutspeedAnd2HKO

      public static boolean canOutspeedAnd2HKO(List<MoveChoice> opponentChoices, PixelmonWrapper pw)
      Checks if a list of choices contains a Pokémon that can outspeed and at most 2HKO the specified Pokémon.
      Parameters:
      opponentChoices - The choices to check for outspeeding and 2HKOing the Pokémon.
      pw - The Pokémon to check for being outsped and 2HKOed.
      Returns:
      Whether a choice can outspeed and 2HKO the Pokémon.
    • canOutspeedAnd2HKO

      public static boolean canOutspeedAnd2HKO(List<MoveChoice> opponentChoices, PixelmonWrapper pw, List<MoveChoice> userChoices)
      Checks if a list of choices contains a Pokémon that can outspeed and at most 2HKO the specified Pokémon.
      Parameters:
      pw - The Pokémon to check for being outsped and 2HKOed.
      userChoices - The specified Pokémon choices to be checked for priority moves.
      opponentChoices - The choices to check for outspeeding and 2HKOing the Pokémon.
      Returns:
      Whether a choice can outspeed and 2HKO the Pokémon.
    • canOutspeedAndKO

      public static boolean canOutspeedAndKO(int numTurns, List<MoveChoice> opponentChoices, PixelmonWrapper pw, List<MoveChoice> userChoices)
    • canKOFromFull

      public static boolean canKOFromFull(List<MoveChoice> opponentChoices, PixelmonWrapper pw, int numTurns)
      Checks if the opponent can KO the Pokémon at full heatlh within a certain number of turns.
      Parameters:
      opponentChoices - The opponent choices for the turn.
      pw - The Pokémon to check for being KOed.
      numTurns - The maximum number of turns the opponent can take to KO the Pokémon.
      Returns:
      Whether the opponent can KO the Pokémon within the specified number of turns.
    • hasSuccessfulAttackChoice

      @SafeVarargs public static boolean hasSuccessfulAttackChoice(List<MoveChoice> choices, Optional<ImmutableAttack>... attackNames)
      Checks if a list of choices has certain attacks that can be used successfully.
      Parameters:
      choices - The list of choices to search through.
      attackNames - The names of attacks to look for.
      Returns:
      Whether a list of choices has certain attacks that can be used successfully.
    • hasSuccessfulAttackChoice

      @SafeVarargs public static boolean hasSuccessfulAttackChoice(List<MoveChoice> choices, RegistryValue<ImmutableAttack>... attackNames)
      Checks if a list of choices has certain attacks that can be used successfully.
      Parameters:
      choices - The list of choices to search through.
      attackNames - The names of attacks to look for.
      Returns:
      Whether a list of choices has certain attacks that can be used successfully.
    • getAffectedChoices

      public static List<MoveChoice> getAffectedChoices(MoveChoice choice, List<MoveChoice> opponentChoices)
      Filters a list of opponent choices to include only opponents that are affected by a move.
      Parameters:
      choice - The move choice to be used.
      opponentChoices - A list of all opponent choices.
      Returns:
      A filtered list of opponent choices including only opponents that are affected by the specified move.
    • getTargetedChoices

      public static List<MoveChoice> getTargetedChoices(PixelmonWrapper pw, List<MoveChoice> opponentChoices)
    • hasPriority

      @SafeVarargs public static boolean hasPriority(List<MoveChoice>... choices)
      Checks whether any choices in the given lists have priority.
      Parameters:
      choices - The choices to check.
      Returns:
      Whether any choices in the given lists have priority.
    • splitChoices

      public static List<List<MoveChoice>> splitChoices(List<PixelmonWrapper> pokemonList, List<MoveChoice> choices)
      Splits a list of choices into separate lists for each Pokémon's choice.
      Parameters:
      pokemonList - The different Pokémon that are using the choices.
      choices - The choices to split.
      Returns:
      Separated lists of choices for each Pokémon using them.
    • mergeChoices

      public static List<MoveChoice> mergeChoices(List<List<MoveChoice>> choices)
      Merges a separated list of choices into one list.
      Parameters:
      choices - The separated list of choices to merge.
      Returns:
      A merged list of choices from the separated list.
    • createChoicesFromChoices

      public static List<MoveChoice> createChoicesFromChoices(PixelmonWrapper pw, List<MoveChoice> choices, boolean includeAllies)
      Creates a list of choices consisting of another list of choices's attacks.
      Parameters:
      pw - The Pokémon using the choices.
      choices - The choices to create a new list of choices from.
      includeAllies - Whether to include moves that only target allies.
      Returns:
      A list of choices consisting of another list of choices's attacks.
    • getMaxDamagePercent

      public static float getMaxDamagePercent(PixelmonWrapper pw, List<MoveChoice> opponentChoices)
      Gets the maximum percent damage a list of choices can do to a Pokémon.
      Parameters:
      pw - The Pokémon to get the maximum damage for.
      opponentChoices - The choices doing damage to the Pokémon.
      Returns:
      The maximum percent damage the list of choices can do to a Pokémon.
    • createMoveChoicesFromList

      public static List<MoveChoice> createMoveChoicesFromList(List<Attack> possibleAttacks, PixelmonWrapper pw)
      Adds choices to a list based on a provided list of attacks.
      Parameters:
      possibleAttacks - The list of attacks to make choices for.
      pw - The Pokémon deciding on a move.
    • hasAttackCategory

      public static boolean hasAttackCategory(List<MoveChoice> choices, AttackCategory category)
      Checks if a list of choices has a move that is in a certain attack category.
      Parameters:
      choices - The list of choices to search.
      category - The attack category to search for.
      Returns:
      Whether the list of choices has a move that is in the specified attack category.
    • hasOffensiveAttackType

      public static boolean hasOffensiveAttackType(List<MoveChoice> choices, Element type)
      Checks if a list of choices has an offensive move of a certain type.
      Parameters:
      choices - The list of choices to search.
      type - The type to search for.
      Returns:
      Whether the list of choices has a move that is of the specified type.
    • hasSpreadMove

      public static boolean hasSpreadMove(List<MoveChoice> choices)
      Checks if a list of choices has a spread move.
      Parameters:
      choices - The list of choices to search.
      Returns:
      Whether the list of choices has a spread move.
    • sumWeights

      public static float sumWeights(List<MoveChoice> choices)
      Gets the sum of the weights of a list of choices.
      Parameters:
      choices - The list of choices to get a weight sum from.
      Returns:
      The sum of the weights of the list of choices.
    • canBreakProtect

      public static boolean canBreakProtect(List<PixelmonWrapper> opponents, List<MoveChoice> choices)
      Checks if the opponent can break through a Protect status.
      Parameters:
      opponents - The opponents of the Protect user.
      choices - The move choices of the opponent on the next turn.
      Returns:
      Whether the opponent can break through a Protect status.
    • hasMove

      @SafeVarargs public static boolean hasMove(List<MoveChoice> choices, Optional<ImmutableAttack>... moveNames)
      Checks if a list of move choices has a move.
      Parameters:
      choices - The move choices to search in.
      moveNames - The moves to look for.
      Returns:
      Whether the list of move choices has a certain move.
    • hasMove

      @SafeVarargs public static boolean hasMove(List<MoveChoice> choices, RegistryValue<ImmutableAttack>... moveNames)
      Checks if a list of move choices has a move.
      Parameters:
      choices - The move choices to search in.
      moveNames - The moves to look for.
      Returns:
      Whether the list of move choices has a certain move.