mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Implement rewards for Chaos battles
This commit is contained in:
@@ -11,6 +11,7 @@ import forge.interfaces.IButton;
|
||||
import forge.interfaces.IGuiGame;
|
||||
import forge.interfaces.IWinLoseView;
|
||||
import forge.model.FModel;
|
||||
import forge.planarconquest.ConquestPlane.AwardPool;
|
||||
import forge.planarconquest.ConquestPreferences.CQPref;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.quest.QuestEventDifficulty;
|
||||
@@ -22,6 +23,8 @@ import forge.util.Aggregates;
|
||||
public class ConquestChaosBattle extends ConquestEvent {
|
||||
private final QuestWorld world;
|
||||
private final QuestEventDuel duel;
|
||||
private AwardPool awardPool;
|
||||
private boolean finished;
|
||||
|
||||
public ConquestChaosBattle() {
|
||||
super(null, 0);
|
||||
@@ -86,6 +89,7 @@ public class ConquestChaosBattle extends ConquestEvent {
|
||||
if (game.isMatchWonBy(humanPlayer)) {
|
||||
view.getBtnQuit().setText("Great!");
|
||||
model.getChaosBattleRecord().addWin();
|
||||
setConquered(true);
|
||||
}
|
||||
else {
|
||||
view.getBtnQuit().setText("OK");
|
||||
@@ -107,5 +111,17 @@ public class ConquestChaosBattle extends ConquestEvent {
|
||||
model.getChaosBattleRecord().addLoss();
|
||||
model.saveData();
|
||||
}
|
||||
finished = true;
|
||||
}
|
||||
|
||||
public AwardPool getAwardPool() {
|
||||
if (awardPool == null) { //delay initializing until needed
|
||||
awardPool = new AwardPool(world.getAllCards());
|
||||
}
|
||||
return awardPool;
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return finished;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,8 +183,7 @@ public class ConquestController {
|
||||
activeEvent = null;
|
||||
}
|
||||
|
||||
public List<ConquestReward> awardBooster() {
|
||||
AwardPool pool = FModel.getConquest().getModel().getCurrentPlane().getAwardPool();
|
||||
public List<ConquestReward> awardBooster(AwardPool pool) {
|
||||
ConquestPreferences prefs = FModel.getConquestPreferences();
|
||||
List<PaperCard> rewards = new ArrayList<PaperCard>();
|
||||
int boostersPerMythic = prefs.getPrefInt(CQPref.BOOSTERS_PER_MYTHIC);
|
||||
|
||||
@@ -545,18 +545,16 @@ public enum ConquestPlane {
|
||||
|
||||
public AwardPool getAwardPool() {
|
||||
if (awardPool == null) { //delay initializing until needed
|
||||
awardPool = new AwardPool();
|
||||
awardPool = new AwardPool(cardPool.getAllCards());
|
||||
}
|
||||
return awardPool;
|
||||
}
|
||||
|
||||
public class AwardPool {
|
||||
public static class AwardPool {
|
||||
private final BoosterPool commons, uncommons, rares, mythics;
|
||||
private final int commonValue, uncommonValue, rareValue, mythicValue;
|
||||
|
||||
private AwardPool() {
|
||||
Iterable<PaperCard> cards = cardPool.getAllCards();
|
||||
|
||||
public AwardPool(Iterable<PaperCard> cards) {
|
||||
ConquestPreferences prefs = FModel.getConquestPreferences();
|
||||
|
||||
commons = new BoosterPool();
|
||||
|
||||
@@ -78,29 +78,26 @@ public class QuestWorld implements Comparable<QuestWorld>{
|
||||
return dir == null ? null : dir + "/challenges";
|
||||
}
|
||||
|
||||
/**
|
||||
* The quest world format if specified.
|
||||
* @return GameFormatQuest, the format
|
||||
*/
|
||||
public GameFormatQuest getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* toString.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public List<PaperCard> getAllCards() {
|
||||
GameFormat format0 = format;
|
||||
if (format0 == null) {
|
||||
format0 = FModel.getQuest().getMainFormat();
|
||||
}
|
||||
if (format0 != null) {
|
||||
return format0.getAllCards();
|
||||
}
|
||||
return FModel.getMagicDb().getCommonCards().getAllCards();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* FN_GET_NAME for reader.
|
||||
*/
|
||||
public static final Function<QuestWorld, String> FN_GET_NAME = new Function<QuestWorld, String>() {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user