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
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,54 @@ Cobblemon Challenge is an extremely simple plugin for Cobblemon that makes chall
easier! This is a server-side plugin that only needs to be installed on the Server.

#### Commands
There are four possible challenge properties:
1. Username (required)
2. Level or min/maxLevel (optional & mutually exclusive)
3. Handicap (optional)
4. NoPreview (optional, true if excluded & false if specified)

```/challenge <username>``` - Challenges specified player to a lvl 50 pokemon battle. They may accept or deny this challenge.

```/challenge <username> level <level>``` - Challenges specified player to a lvl X battle where X can be 1-100.

Example: ```/challenge TurtleHoarder level 100``` challenges TurtleHoarder to a level 100 battle.
```/challenge <username> minLevel <minLevel> maxLevel <maxLevel>``` - Challenges specified player to a lvl <minLevel> - <maxLevel> battle where <minLevel> & <maxLevel> can be 1-100.

```/challenge <username> handicapP1 <levelOffset> handicapP1 <levelOffset>``` - Challenges specified player to a battle where player1 (challenger) & player2 (challenged) are offset by the specified levels. <levelOffset> can be from (-99)-(99).

```/challenge <username> noPreview``` - Challenges specified player to a default battle with no preview of the rivals pokemon during starter selection.

##### Command Input Order:
There are 12 possible input combinations for challenge properties. The order of input must be username -> level or min/maxLevel -> handicap -> noPreview. If the challenge property is optional you may skip it when inputting the command. The default values will be used.

##### All Possible Commands:

```/challenge <username>```

```/challenge <username> handicapP1 <levelOffset> handicapP1 <levelOffset>```

```/challenge <username> noPreview```

```/challenge <username> handicapP1 <levelOffset> handicapP1 <levelOffset> noPreview```


```/challenge <username> level <level>```

```/challenge <username> level <level> handicapP1 <levelOffset> handicapP1 <levelOffset>```

```/challenge <username> level <level> noPreview```

```/challenge <username> level <level> handicapP1 <levelOffset> handicapP1 <levelOffset> noPreview```


```/challenge <username> minLevel <minLevel> maxLevel <maxLevel>```

```/challenge <username> minLevel <minLevel> maxLevel <maxLevel> handicapP1 <levelOffset> handicapP1 <levelOffset>```

```/challenge <username> minLevel <minLevel> maxLevel <maxLevel> noPreview```

```/challenge <username> minLevel <minLevel> maxLevel <maxLevel> handicapP1 <levelOffset> handicapP1 <levelOffset> noPreview```


#### Configurations
There are numerous options that will allow you to customize the Challenge experience to your server's needs. These
settings can be found in the Cobblemon Challenge config file:
Expand All @@ -24,6 +66,9 @@ that a challenge can be sent. This is set to 50 blocks by default.
```defaultChallengeLevel``` - The value that determines the level of a challenge if there is not level specified by the challenger.
This is set to 50 by default for lvl 50 battles.

```defaultHandicap``` - The value that determines each players final level of each Pokemon if a handicap is not specified by the challenger.
This is set to 0 by default.

```challengeExpirationTime``` - The value that determines how long a challenge should be pending before it expires. This is
set to 60000 milliseconds / 1 minute by default.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ 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 @@ -41,7 +42,7 @@ 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 @@ -50,13 +51,17 @@ 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