mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Implement Chaos battles
This commit is contained in:
@@ -33,7 +33,7 @@ public class ConquestWinLose extends ControlWinLose {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void actionOnQuit() {
|
public final void actionOnQuit() {
|
||||||
FModel.getConquest().finishEvent();
|
FModel.getConquest().finishEvent(getView());
|
||||||
super.actionOnQuit();
|
super.actionOnQuit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class ConquestEventScreen extends LaunchScreen {
|
|||||||
LoadingOverlay.show("Starting battle...", new Runnable() {
|
LoadingOverlay.show("Starting battle...", new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FModel.getConquest().launchEvent(FModel.getConquest().getModel().getSelectedCommander(), event);
|
FModel.getConquest().launchEvent(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import forge.model.FModel;
|
|||||||
import forge.planarconquest.ConquestData;
|
import forge.planarconquest.ConquestData;
|
||||||
import forge.planarconquest.ConquestEvent.ChaosWheelOutcome;
|
import forge.planarconquest.ConquestEvent.ChaosWheelOutcome;
|
||||||
import forge.planarconquest.ConquestEvent.ConquestEventRecord;
|
import forge.planarconquest.ConquestEvent.ConquestEventRecord;
|
||||||
|
import forge.planarconquest.ConquestChaosBattle;
|
||||||
import forge.planarconquest.ConquestEvent;
|
import forge.planarconquest.ConquestEvent;
|
||||||
import forge.planarconquest.ConquestLocation;
|
import forge.planarconquest.ConquestLocation;
|
||||||
import forge.planarconquest.ConquestPlane;
|
import forge.planarconquest.ConquestPlane;
|
||||||
@@ -27,6 +28,7 @@ import forge.planarconquest.ConquestPlane.Region;
|
|||||||
import forge.planarconquest.ConquestPreferences.CQPref;
|
import forge.planarconquest.ConquestPreferences.CQPref;
|
||||||
import forge.planarconquest.ConquestPlaneData;
|
import forge.planarconquest.ConquestPlaneData;
|
||||||
import forge.screens.FScreen;
|
import forge.screens.FScreen;
|
||||||
|
import forge.screens.LoadingOverlay;
|
||||||
import forge.toolbox.FDisplayObject;
|
import forge.toolbox.FDisplayObject;
|
||||||
import forge.toolbox.FOptionPane;
|
import forge.toolbox.FOptionPane;
|
||||||
import forge.toolbox.FScrollPane;
|
import forge.toolbox.FScrollPane;
|
||||||
@@ -106,7 +108,7 @@ public class ConquestMultiverseScreen extends FScreen {
|
|||||||
awardPlaneswalkCharge();
|
awardPlaneswalkCharge();
|
||||||
break;
|
break;
|
||||||
case CHAOS:
|
case CHAOS:
|
||||||
triggerChaosTravel();
|
launchChaosBattle();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,9 +172,13 @@ public class ConquestMultiverseScreen extends FScreen {
|
|||||||
FOptionPane.showMessageDialog(null, "Received Planeswalk Charge");
|
FOptionPane.showMessageDialog(null, "Received Planeswalk Charge");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void triggerChaosTravel() {
|
private void launchChaosBattle() {
|
||||||
//TODO
|
LoadingOverlay.show("Chaos approaching...", new Runnable() {
|
||||||
FOptionPane.showMessageDialog(null, "Chaos Travel");
|
@Override
|
||||||
|
public void run() {
|
||||||
|
FModel.getConquest().launchEvent(new ConquestChaosBattle());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlaneGrid extends FScrollPane {
|
private class PlaneGrid extends FScrollPane {
|
||||||
|
|||||||
@@ -81,13 +81,14 @@ public class ConquestController {
|
|||||||
return decks;
|
return decks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void launchEvent(ConquestCommander commander, ConquestEvent event) {
|
public void launchEvent(ConquestEvent event) {
|
||||||
if (activeEvent != null) { return; }
|
if (activeEvent != null) { return; }
|
||||||
|
|
||||||
//determine game variants
|
//determine game variants
|
||||||
Set<GameType> variants = new HashSet<GameType>();
|
Set<GameType> variants = new HashSet<GameType>();
|
||||||
event.addVariants(variants);
|
event.addVariants(variants);
|
||||||
|
|
||||||
|
final ConquestCommander commander = model.getSelectedCommander();
|
||||||
final RegisteredPlayer humanStart = new RegisteredPlayer(commander.getDeck());
|
final RegisteredPlayer humanStart = new RegisteredPlayer(commander.getDeck());
|
||||||
final RegisteredPlayer aiStart = new RegisteredPlayer(event.getOpponentDeck());
|
final RegisteredPlayer aiStart = new RegisteredPlayer(event.getOpponentDeck());
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ public class ConquestController {
|
|||||||
rp.setRandomFoil(useRandomFoil);
|
rp.setRandomFoil(useRandomFoil);
|
||||||
}
|
}
|
||||||
final GameRules rules = new GameRules(GameType.PlanarConquest);
|
final GameRules rules = new GameRules(GameType.PlanarConquest);
|
||||||
rules.setGamesPerMatch(1); //only play one game at a time
|
rules.setGamesPerMatch(event.gamesPerMatch());
|
||||||
rules.setManaBurn(FModel.getPreferences().getPrefBoolean(FPref.UI_MANABURN));
|
rules.setManaBurn(FModel.getPreferences().getPrefBoolean(FPref.UI_MANABURN));
|
||||||
rules.setCanCloneUseTargetsImage(FModel.getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE));
|
rules.setCanCloneUseTargetsImage(FModel.getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE));
|
||||||
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
|
final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
|
||||||
@@ -170,23 +171,13 @@ public class ConquestController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showGameOutcome(final GameView game, final IWinLoseView<? extends IButton> view) {
|
public void showGameOutcome(final GameView game, final IWinLoseView<? extends IButton> view) {
|
||||||
if (game.isMatchWonBy(humanPlayer)) {
|
activeEvent.showGameOutcome(model, game, humanPlayer, view);
|
||||||
view.getBtnRestart().setVisible(false);
|
|
||||||
view.getBtnQuit().setText("Great!");
|
|
||||||
model.addWin(activeEvent);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
view.getBtnRestart().setVisible(true);
|
|
||||||
view.getBtnRestart().setText("Retry");
|
|
||||||
view.getBtnQuit().setText("Quit");
|
|
||||||
model.addLoss(activeEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
model.saveData();
|
|
||||||
FModel.getConquestPreferences().save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishEvent() {
|
public void finishEvent(final IWinLoseView<? extends IButton> view) {
|
||||||
|
if (activeEvent == null) { return; }
|
||||||
|
|
||||||
|
activeEvent.onFinished(model, view);
|
||||||
activeEvent = null;
|
activeEvent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public final class ConquestData {
|
|||||||
|
|
||||||
private final File directory;
|
private final File directory;
|
||||||
private final String xmlFilename;
|
private final String xmlFilename;
|
||||||
|
private final ConquestRecord chaosBattleRecord;
|
||||||
private final EnumMap<ConquestPlane, ConquestPlaneData> planeDataMap = new EnumMap<ConquestPlane, ConquestPlaneData>(ConquestPlane.class);
|
private final EnumMap<ConquestPlane, ConquestPlaneData> planeDataMap = new EnumMap<ConquestPlane, ConquestPlaneData>(ConquestPlane.class);
|
||||||
private final HashSet<PaperCard> unlockedCards = new HashSet<PaperCard>();
|
private final HashSet<PaperCard> unlockedCards = new HashSet<PaperCard>();
|
||||||
private final List<ConquestCommander> commanders = new ArrayList<ConquestCommander>();
|
private final List<ConquestCommander> commanders = new ArrayList<ConquestCommander>();
|
||||||
@@ -81,6 +82,7 @@ public final class ConquestData {
|
|||||||
unlockCard(card);
|
unlockCard(card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
chaosBattleRecord = new ConquestRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConquestData(File directory0) {
|
public ConquestData(File directory0) {
|
||||||
@@ -88,6 +90,7 @@ public final class ConquestData {
|
|||||||
directory = directory0;
|
directory = directory0;
|
||||||
xmlFilename = directory.getPath() + ForgeConstants.PATH_SEPARATOR + XML_FILE;
|
xmlFilename = directory.getPath() + ForgeConstants.PATH_SEPARATOR + XML_FILE;
|
||||||
|
|
||||||
|
ConquestRecord chaosBattleRecord0 = null;
|
||||||
try {
|
try {
|
||||||
XmlReader xml = new XmlReader(xmlFilename);
|
XmlReader xml = new XmlReader(xmlFilename);
|
||||||
CardDb cardDb = FModel.getMagicDb().getCommonCards();
|
CardDb cardDb = FModel.getMagicDb().getCommonCards();
|
||||||
@@ -95,6 +98,7 @@ public final class ConquestData {
|
|||||||
aetherShards = xml.read("aetherShards", aetherShards);
|
aetherShards = xml.read("aetherShards", aetherShards);
|
||||||
currentLocation = xml.read("currentLocation", ConquestLocation.class);
|
currentLocation = xml.read("currentLocation", ConquestLocation.class);
|
||||||
selectedCommanderIndex = xml.read("selectedCommanderIndex", selectedCommanderIndex);
|
selectedCommanderIndex = xml.read("selectedCommanderIndex", selectedCommanderIndex);
|
||||||
|
chaosBattleRecord0 = xml.read("chaosBattleRecord", ConquestRecord.class);
|
||||||
xml.read("unlockedCards", unlockedCards, cardDb);
|
xml.read("unlockedCards", unlockedCards, cardDb);
|
||||||
xml.read("newCards", newCards, cardDb);
|
xml.read("newCards", newCards, cardDb);
|
||||||
xml.read("commanders", commanders, ConquestCommander.class);
|
xml.read("commanders", commanders, ConquestCommander.class);
|
||||||
@@ -103,6 +107,10 @@ public final class ConquestData {
|
|||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
if (chaosBattleRecord0 == null) {
|
||||||
|
chaosBattleRecord0 = new ConquestRecord();
|
||||||
|
}
|
||||||
|
chaosBattleRecord = chaosBattleRecord0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -224,6 +232,10 @@ public final class ConquestData {
|
|||||||
return Math.round(100f * (float)conquered / (float)total) + "%";
|
return Math.round(100f * (float)conquered / (float)total) + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConquestRecord getChaosBattleRecord() {
|
||||||
|
return chaosBattleRecord;
|
||||||
|
}
|
||||||
|
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
FileUtil.ensureDirectoryExists(directory);
|
FileUtil.ensureDirectoryExists(directory);
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package forge.planarconquest;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import forge.LobbyPlayer;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
|
import forge.game.GameView;
|
||||||
|
import forge.interfaces.IButton;
|
||||||
|
import forge.interfaces.IWinLoseView;
|
||||||
import forge.util.XmlReader;
|
import forge.util.XmlReader;
|
||||||
import forge.util.XmlWriter;
|
import forge.util.XmlWriter;
|
||||||
import forge.util.XmlWriter.IXmlWritable;
|
import forge.util.XmlWriter.IXmlWritable;
|
||||||
@@ -41,6 +45,28 @@ public abstract class ConquestEvent {
|
|||||||
conquered = conquered0;
|
conquered = conquered0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int gamesPerMatch() {
|
||||||
|
return 1; //events are one game by default
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showGameOutcome(final ConquestData model, final GameView game, final LobbyPlayer humanPlayer, final IWinLoseView<? extends IButton> view) {
|
||||||
|
if (game.isMatchWonBy(humanPlayer)) {
|
||||||
|
view.getBtnRestart().setVisible(false);
|
||||||
|
view.getBtnQuit().setText("Great!");
|
||||||
|
model.addWin(this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
view.getBtnRestart().setVisible(true);
|
||||||
|
view.getBtnRestart().setText("Retry");
|
||||||
|
view.getBtnQuit().setText("Quit");
|
||||||
|
model.addLoss(this);
|
||||||
|
}
|
||||||
|
model.saveData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFinished(final ConquestData model, final IWinLoseView<? extends IButton> view) {
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract Deck buildOpponentDeck();
|
protected abstract Deck buildOpponentDeck();
|
||||||
public abstract void addVariants(Set<GameType> variants);
|
public abstract void addVariants(Set<GameType> variants);
|
||||||
public abstract String getEventName();
|
public abstract String getEventName();
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ public class ConquestPreferences extends PreferencesStore<ConquestPreferences.CQ
|
|||||||
BOOSTER_COMMONS("11"),
|
BOOSTER_COMMONS("11"),
|
||||||
BOOSTER_UNCOMMONS("3"),
|
BOOSTER_UNCOMMONS("3"),
|
||||||
BOOSTER_RARES("1"),
|
BOOSTER_RARES("1"),
|
||||||
BOOSTERS_PER_MYTHIC("8");
|
BOOSTERS_PER_MYTHIC("8"),
|
||||||
|
|
||||||
|
CHAOS_BATTLE_WINS_MEDIUMAI("2"),
|
||||||
|
CHAOS_BATTLE_WINS_HARDAI("5"),
|
||||||
|
CHAOS_BATTLE_WINS_EXPERTAI("10");
|
||||||
|
|
||||||
private final String strDefaultVal;
|
private final String strDefaultVal;
|
||||||
|
|
||||||
|
|||||||
@@ -47,13 +47,16 @@ public class QuestEventDuelManager {
|
|||||||
public QuestEventDuelManager(final File dir) {
|
public QuestEventDuelManager(final File dir) {
|
||||||
allDuels = new StorageBase<QuestEventDuel>("Quest duels", new QuestDuelReader(dir));
|
allDuels = new StorageBase<QuestEventDuel>("Quest duels", new QuestDuelReader(dir));
|
||||||
assembleDuelDifficultyLists();
|
assembleDuelDifficultyLists();
|
||||||
} // End assembleAllEvents()
|
}
|
||||||
|
|
||||||
/** @return List<QuestEventDuel> */
|
|
||||||
public Iterable<QuestEventDuel> getAllDuels() {
|
public Iterable<QuestEventDuel> getAllDuels() {
|
||||||
return allDuels;
|
return allDuels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Iterable<QuestEventDuel> getDuels(QuestEventDifficulty difficulty) {
|
||||||
|
return sortedDuels.get(difficulty);
|
||||||
|
}
|
||||||
|
|
||||||
// define fallback orders if there aren't enough opponents defined for a particular difficultly level
|
// define fallback orders if there aren't enough opponents defined for a particular difficultly level
|
||||||
private static List<QuestEventDifficulty> _easyOrder = Arrays.asList(QuestEventDifficulty.EASY, QuestEventDifficulty.MEDIUM, QuestEventDifficulty.HARD, QuestEventDifficulty.EXPERT);
|
private static List<QuestEventDifficulty> _easyOrder = Arrays.asList(QuestEventDifficulty.EASY, QuestEventDifficulty.MEDIUM, QuestEventDifficulty.HARD, QuestEventDifficulty.EXPERT);
|
||||||
private static List<QuestEventDifficulty> _mediumOrder = Arrays.asList(QuestEventDifficulty.MEDIUM, QuestEventDifficulty.HARD, QuestEventDifficulty.EASY, QuestEventDifficulty.EXPERT);
|
private static List<QuestEventDifficulty> _mediumOrder = Arrays.asList(QuestEventDifficulty.MEDIUM, QuestEventDifficulty.HARD, QuestEventDifficulty.EASY, QuestEventDifficulty.EXPERT);
|
||||||
|
|||||||
Reference in New Issue
Block a user