Merge branch 'questMode_wildOpponents' into 'master'

Wild opponents included in the "random duel choice"

See merge request core-developers/forge!3226
This commit is contained in:
Michael Kamensky
2020-10-04 12:44:20 +00:00

View File

@@ -1,5 +1,6 @@
package forge.quest;
import java.awt.image.renderable.RenderableImage;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@@ -147,31 +148,60 @@ public class MainWorldEventDuelManager implements QuestEventDuelManagerInterface
QuestEventDifficulty randomDuelDifficulty = QuestEventDifficulty.EASY;
double randomDouble = MyRandom.getRandom().nextDouble();
if (numberOfWins < questPreferences.getPrefInt(DifficultyPrefs.WINS_MEDIUMAI, index)) {
addDuel(duelOpponents, QuestEventDifficulty.EASY, 3);
randomDuelDifficulty = QuestEventDifficulty.EASY;
if(areWildDecksWanted() && isWildDeckAvailable() && randomDouble * 2 < 1) {
randomDuelDifficulty = QuestEventDifficulty.WILD;
} else {
randomDuelDifficulty = QuestEventDifficulty.EASY;
}
} else if (numberOfWins == questPreferences.getPrefInt(DifficultyPrefs.WINS_MEDIUMAI, index)) {
addDuel(duelOpponents, QuestEventDifficulty.EASY, 1);
addDuel(duelOpponents, QuestEventDifficulty.MEDIUM, 2);
randomDuelDifficulty = QuestEventDifficulty.MEDIUM;
if(areWildDecksWanted() && isWildDeckAvailable() && randomDouble * 2 < 1) {
randomDuelDifficulty = QuestEventDifficulty.WILD;
} else {
randomDuelDifficulty = QuestEventDifficulty.MEDIUM;
}
} else if (numberOfWins < questPreferences.getPrefInt(DifficultyPrefs.WINS_HARDAI, index)) {
addDuel(duelOpponents, QuestEventDifficulty.MEDIUM, 3);
randomDuelDifficulty = QuestEventDifficulty.MEDIUM;
} else if (numberOfWins == questPreferences.getPrefInt(DifficultyPrefs.WINS_HARDAI, index)) {
addDuel(duelOpponents, QuestEventDifficulty.MEDIUM, 1);
addDuel(duelOpponents, QuestEventDifficulty.HARD, 2);
randomDuelDifficulty = QuestEventDifficulty.HARD;
if(areWildDecksWanted() && isWildDeckAvailable() && randomDouble * 2 < 1) {
randomDuelDifficulty = QuestEventDifficulty.WILD;
} else {
randomDuelDifficulty = QuestEventDifficulty.HARD;
}
} else if (numberOfWins < questPreferences.getPrefInt(DifficultyPrefs.WINS_EXPERTAI, index)) {
addDuel(duelOpponents, QuestEventDifficulty.HARD, 3);
randomDuelDifficulty = QuestEventDifficulty.HARD;
if(areWildDecksWanted() && isWildDeckAvailable() && randomDouble * 2 < 1) {
randomDuelDifficulty = QuestEventDifficulty.WILD;
} else {
randomDuelDifficulty = QuestEventDifficulty.HARD;
}
} else {
addDuel(duelOpponents, QuestEventDifficulty.HARD, 2);
addDuel(duelOpponents, QuestEventDifficulty.EXPERT, 1);
if (MyRandom.getRandom().nextDouble() * 3 < 2) {
randomDuelDifficulty = QuestEventDifficulty.HARD;
} else {
randomDuelDifficulty = QuestEventDifficulty.EXPERT;
if(areWildDecksWanted() && isWildDeckAvailable()) {
if(randomDouble * 2 < 1) {
randomDuelDifficulty = QuestEventDifficulty.WILD;
} else if(randomDouble * 6 < 5) {
randomDuelDifficulty = QuestEventDifficulty.HARD;
} else {
randomDuelDifficulty = QuestEventDifficulty.EXPERT;
}
} else {
if (randomDouble * 3 < 2) {
randomDuelDifficulty = QuestEventDifficulty.HARD;
} else {
randomDuelDifficulty = QuestEventDifficulty.EXPERT;
}
}
}
if (moreDuelChoices) {
@@ -187,7 +217,7 @@ public class MainWorldEventDuelManager implements QuestEventDuelManagerInterface
}
}
//TODO put in preferences the number of wild duels to add
// Now to add the wild opponents
addDuel(duelOpponents, QuestEventDifficulty.WILD, FModel.getQuestPreferences().getPrefInt(QPref.WILD_OPPONENTS_NUMBER));
addRandomDuel(duelOpponents, randomDuelDifficulty);
@@ -195,6 +225,16 @@ public class MainWorldEventDuelManager implements QuestEventDuelManagerInterface
}
private boolean areWildDecksWanted() {
int wildOpponentsPreference = FModel.getQuestPreferences().getPrefInt(QPref.WILD_OPPONENTS_NUMBER);
return wildOpponentsPreference > 0;
}
private boolean isWildDeckAvailable() {
List<QuestEventDuel> wildList = (List<QuestEventDuel>) sortedDuels.get(QuestEventDifficulty.WILD);
return !wildList.isEmpty();
}
/**
* <p>
* assembleDuelDifficultyLists.