Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public class ChallengeBattleBuilder {
public static Vector<PokemonEntity> clonedPokemonList = new Vector<>();
public static Vector<PokemonBattle> challengeBattles = new Vector<>();
private ChallengeFormat format = ChallengeFormat.STANDARD_6V6;
public void lvlxpvp(ServerPlayer player1, ServerPlayer player2, BattleFormat battleFormat, int level, List<Integer> player1Selection, List<Integer> player2Selection) throws ChallengeBuilderException {
public void lvlxpvp(ServerPlayer player1, ServerPlayer player2, BattleFormat battleFormat, int minLevel, int maxLevel, int handicapP1, int handicapP2, List<Integer> player1Selection, List<Integer> player2Selection) throws ChallengeBuilderException {

PartyStore p1Party = Cobblemon.INSTANCE.getStorage().getParty(player1);
PartyStore p2Party = Cobblemon.INSTANCE.getStorage().getParty(player2);

// Clone parties so original is not effected
List<BattlePokemon> player1Team = createBattleTeamFromParty(p1Party, player1Selection, level);
List<BattlePokemon> player2Team = createBattleTeamFromParty(p2Party, player2Selection, level);
List<BattlePokemon> player1Team = createBattleTeamFromParty(p1Party, player1Selection, minLevel, maxLevel, handicapP1);
List<BattlePokemon> player2Team = createBattleTeamFromParty(p2Party, player2Selection, minLevel, maxLevel, handicapP2);

PlayerBattleActor player1Actor = new PlayerBattleActor(player1.getUUID(), player1Team);
PlayerBattleActor player2Actor = new PlayerBattleActor(player2.getUUID(), player2Team);
Expand All @@ -44,7 +44,8 @@ public void lvlxpvp(ServerPlayer player1, ServerPlayer player2, BattleFormat bat
}

// Method to create our own clones according to the format
private List<BattlePokemon> createBattleTeamFromParty(PartyStore party, List<Integer> selectedSlots, int level) throws ChallengeBuilderException {
private List<BattlePokemon> createBattleTeamFromParty(PartyStore party, List<Integer> selectedSlots, int minLevel, int maxLevel, int handicap) throws ChallengeBuilderException {

List<BattlePokemon> battlePokemonList = new ArrayList<BattlePokemon>();
if (format == ChallengeFormat.STANDARD_6V6) {
int leadSlot = selectedSlots.get(0);
Expand All @@ -53,13 +54,16 @@ private List<BattlePokemon> createBattleTeamFromParty(PartyStore party, List<Int
CobblemonChallenge.LOGGER.error("Mysterious null lead pokemon selected.");
throw new ChallengeBuilderException();
}

BattlePokemon leadBattlePokemon = BattlePokemon.Companion.safeCopyOf(leadPokemon);
battlePokemonList.add(ChallengeUtil.applyFormatTransformations(format,leadBattlePokemon, level));
int adjustedLevel = ChallengeUtil.getBattlePokemonAdjustedLevel(leadPokemon.getLevel(), minLevel, maxLevel, handicap);
battlePokemonList.add(ChallengeUtil.applyFormatTransformations(format,leadBattlePokemon, adjustedLevel));
for (int slot = 0; slot < party.size(); slot++) {
if (slot != leadSlot) {
Pokemon pokemon = party.get(slot);
if (pokemon != null) {
BattlePokemon battlePokemon = ChallengeUtil.applyFormatTransformations(format, BattlePokemon.Companion.safeCopyOf(pokemon), level);
adjustedLevel = ChallengeUtil.getBattlePokemonAdjustedLevel(pokemon.getLevel(), minLevel, maxLevel, handicap);
BattlePokemon battlePokemon = ChallengeUtil.applyFormatTransformations(format, BattlePokemon.Companion.safeCopyOf(pokemon), adjustedLevel);
battlePokemonList.add(battlePokemon);
}
}
Expand Down
Loading