Class MoveChoice
java.lang.Object
com.pixelmonmod.pixelmon.battles.controller.ai.MoveChoice
- All Implemented Interfaces:
Comparable<MoveChoice>
Represents the AI's move choice for the turn.
-
Field Summary
Modifier and TypeFieldDescriptionThe attack to use.The result of the simulated attack.The UUID of the Pokémon to switch to.The targets of the attack to use.int
The tier of usefulness of the move.static final int
The move KOes an opponent or has a similar high-priority effect.static final int
The Pokémon will not be able to make use of the move before fainting if the opponent acts optimally.static final int
The move has an effect in battle.static final int
The move has no beneficial effects.The Pokémon using the move.float
The usefulness of the move within the tier. -
Constructor Summary
ConstructorDescriptionMoveChoice
(PixelmonWrapper user, Attack attack, List<PixelmonWrapper> targets) Makes a choice to attack.MoveChoice
(PixelmonWrapper user, UUID switchPokemon) Makes a choice to switch. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canBreakProtect
(List<PixelmonWrapper> opponents, List<MoveChoice> choices) Checks if the opponent can break through a Protect status.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.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.static boolean
canOutspeed
(List<MoveChoice> opponentChoices, PixelmonWrapper pw, List<MoveChoice> userChoices) Checks if an opponent can outspeed a Pokémon.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.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.static boolean
canOutspeedAndKO
(int numTurns, List<MoveChoice> opponentChoices, PixelmonWrapper pw, List<MoveChoice> userChoices) 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.static void
checkBestChoice
(MoveChoice choice, List<MoveChoice> bestChoices) Checks whether a move choice is best and modifies the best choices if it is.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.int
compareTo
(MoveChoice otherChoice) static List<MoveChoice>
createChoicesFromChoices
(PixelmonWrapper pw, List<MoveChoice> choices, boolean includeAllies) Creates a list of choices consisting of another list of choices's attacks.Makes a list containing the choice.static List<MoveChoice>
createMoveChoicesFromList
(List<Attack> possibleAttacks, PixelmonWrapper pw) Adds choices to a list based on a provided list of attacks.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.static float
getMaxDamagePercent
(PixelmonWrapper pw, List<MoveChoice> opponentChoices) Gets the maximum percent damage a list of choices can do to a Pokémon.static float
getMaxPriority
(List<MoveChoice> choices) Gets the highest priority in a list of choices.static List<MoveChoice>
getTargetedChoices
(PixelmonWrapper pw, List<MoveChoice> opponentChoices) static boolean
hasAttackCategory
(List<MoveChoice> choices, AttackCategory category) Checks if a list of choices has a move that is in a certain attack category.static boolean
hasMove
(List<MoveChoice> choices, RegistryValue<ImmutableAttack>... moveNames) Checks if a list of move choices has a move.static boolean
hasMove
(List<MoveChoice> choices, Optional<ImmutableAttack>... moveNames) Checks if a list of move choices has a move.static boolean
hasOffensiveAttackType
(List<MoveChoice> choices, Element type) Checks if a list of choices has an offensive move of a certain type.static boolean
hasPriority
(List<MoveChoice>... choices) Checks whether any choices in the given lists have priority.static boolean
hasSpreadMove
(List<MoveChoice> choices) Checks if a list of choices has a spread move.static boolean
hasSuccessfulAttackChoice
(List<MoveChoice> choices, RegistryValue<ImmutableAttack>... attackNames) Checks if a list of choices has certain attacks that can be used successfully.static boolean
hasSuccessfulAttackChoice
(List<MoveChoice> choices, Optional<ImmutableAttack>... attackNames) Checks if a list of choices has certain attacks that can be used successfully.boolean
hitsAlly()
Checks if the move choice hits an ally.boolean
isAttack()
Checks if the choice is an attack.boolean
Checks if the choice's tier is one of the middle tiers.boolean
Checks if the choice is an offensive move.boolean
isSameType
(MoveChoice other) Checks if this choice is the same type (attack/switch) as another type.boolean
isSimilarWeight
(MoveChoice other) Checks if this choice has a similar weight as another choice.boolean
Checks if the choice is a status move.void
lowerTier
(int newTier) Lowers the tier of the choice.static List<MoveChoice>
mergeChoices
(List<List<MoveChoice>> choices) Merges a separated list of choices into one list.void
raiseTier
(int newTier) Raises the tier of the choice.void
raiseWeight
(float newWeight) Raises the weight of the choice.void
raiseWeightLimited
(float newWeight) Raises the weight of the choice, but not above 100.void
Sets the choice's tier and weight to 0.void
setWeight
(float newWeight) Sets the weight of the choice.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.static float
sumWeights
(List<MoveChoice> choices) Gets the sum of the weights of a list of choices.toString()
-
Field Details
-
user
The Pokémon using the move. -
attack
The attack to use. -
targets
The targets of the attack to use. -
result
The result of the simulated attack. -
switchPokemon
The UUID of the Pokémon to switch to. -
tier
public int tierThe tier of usefulness of the move. -
weight
public float weightThe usefulness of the move within the tier. -
TIER_USELESS
public static final int TIER_USELESSThe move has no beneficial effects.- See Also:
-
TIER_MINIMAL
public static final int TIER_MINIMALThe 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_NORMALThe move has an effect in battle.- See Also:
-
TIER_KO
public static final int TIER_KOThe move KOes an opponent or has a similar high-priority effect.- See Also:
-
-
Constructor Details
-
MoveChoice
Makes a choice to attack.- Parameters:
attack
- The attack to use.targets
- the targets of the attack to use.
-
MoveChoice
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
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
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
Makes a list containing the choice.- Returns:
- A list containing the choice.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<MoveChoice>
-
toString
-
checkBestChoice
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
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
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
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
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
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
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
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
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
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
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
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.
-