- Added the capability to play Challenges vs predetermined decks (along with a few other related options to disallow specific quest mode things)

- Added Sorin vs Tibalt, and Tibalt vs Sorin as examples of Challenges that force you to use a specific Deck. (They seemed to be the best duel deck compatibility for the AI).
This commit is contained in:
Sol
2013-05-22 03:12:54 +00:00
parent 30454f3cab
commit 695b446c60
8 changed files with 239 additions and 11 deletions

View File

@@ -215,8 +215,9 @@ public class GameNew {
*
* TODO: Accept something like match state as parameter. Match should be aware of players,
* their decks and other special starting conditions.
* @param forceAnte Forces ante on or off no matter what your preferences
*/
public static void newGame(final GameState game, final boolean canRandomFoil) {
public static void newGame(final GameState game, final boolean canRandomFoil, Boolean forceAnte) {
Card.resetUniqueNumber();
// need this code here, otherwise observables fail
@@ -225,7 +226,7 @@ public class GameNew {
trigHandler.clearDelayedTrigger();
// friendliness
boolean useAnte = preferences.getPrefBoolean(FPref.UI_ANTE);
boolean useAnte = forceAnte != null ? forceAnte : preferences.getPrefBoolean(FPref.UI_ANTE);
final Set<CardPrinted> rAICards = new HashSet<CardPrinted>();
Map<Player, Set<CardPrinted>> removedAnteCards = new HashMap<Player, Set<CardPrinted>>();

View File

@@ -50,6 +50,8 @@ public class MatchController {
private int gamesPerMatch = 3;
private int gamesToWinMatch = 2;
private Boolean forceAnte = false;
private GameState currentGame = null;
@@ -66,6 +68,11 @@ public class MatchController {
players.putAll(map);
gameType = type;
}
public MatchController(GameType type, Map<LobbyPlayer, PlayerStartConditions> map, Boolean forceAnte) {
this(type, map);
this.forceAnte = forceAnte;
}
/**
* Gets the games played.
@@ -145,7 +152,7 @@ public class MatchController {
attachUiToMatch(this, FControl.SINGLETON_INSTANCE.getLobby().getGuiPlayer());
final boolean canRandomFoil = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_RANDOM_FOIL) && gameType == GameType.Constructed;
GameNew.newGame(currentGame, canRandomFoil);
GameNew.newGame(currentGame, canRandomFoil, this.forceAnte);
currentGame.setAge(GameAge.Mulligan);
} catch (Exception e) {

View File

@@ -353,7 +353,15 @@ public class SSubmenuQuestUtil {
}
final QuestController qData = Singletons.getModel().getQuest();
Deck deck = SSubmenuQuestUtil.getCurrentDeck();
Deck deck = null;
if (event instanceof QuestEventChallenge) {
// Predefined HumanDeck
deck = ((QuestEventChallenge) event).getHumanDeck();
}
if (deck == null) {
// If no predefined Deck, use the Player's Deck
deck = SSubmenuQuestUtil.getCurrentDeck();
}
if (deck == null) {
String msg = "Please select a Quest Deck.";
JOptionPane.showMessageDialog(null, msg, "No Deck", JOptionPane.ERROR_MESSAGE);
@@ -393,23 +401,37 @@ public class SSubmenuQuestUtil {
worker.execute();
int extraLifeHuman = 0;
Integer lifeHuman = null;
boolean useBazaar = true;
Boolean forceAnte = false;
int lifeAI = 20;
if (event instanceof QuestEventChallenge) {
lifeAI = ((QuestEventChallenge) event).getAILife();
lifeHuman = ((QuestEventChallenge) event).getHumanLife();
if (qData.getAssets().hasItem(QuestItemType.ZEPPELIN)) {
extraLifeHuman = 3;
}
useBazaar = ((QuestEventChallenge) event).isUseBazaar();
forceAnte = ((QuestEventChallenge) event).isForceAnte();
}
PlayerStartConditions humanStart = new PlayerStartConditions(SSubmenuQuestUtil.getCurrentDeck());
humanStart.setStartingLife(qData.getAssets().getLife(qData.getMode()) + extraLifeHuman);
humanStart.setCardsOnBattlefield(QuestUtil.getHumanStartingCards(qData, event));
PlayerStartConditions humanStart = new PlayerStartConditions(deck);
PlayerStartConditions aiStart = new PlayerStartConditions(event.getEventDeck());
aiStart.setStartingLife(lifeAI);
aiStart.setCardsOnBattlefield(QuestUtil.getComputerStartingCards(event));
if (lifeHuman != null) {
humanStart.setStartingLife(lifeHuman);
} else {
humanStart.setStartingLife(qData.getAssets().getLife(qData.getMode()) + extraLifeHuman);
}
if (useBazaar) {
humanStart.setCardsOnBattlefield(QuestUtil.getHumanStartingCards(qData, event));
aiStart.setStartingLife(lifeAI);
aiStart.setCardsOnBattlefield(QuestUtil.getComputerStartingCards(event));
}
MatchStartHelper msh = new MatchStartHelper();
msh.addPlayer(Singletons.getControl().getLobby().getQuestPlayer(), humanStart);
@@ -417,7 +439,7 @@ public class SSubmenuQuestUtil {
aiPlayer.setIconImageKey(event.getIconImageKey());
msh.addPlayer(aiPlayer, aiStart);
final MatchController mc = new MatchController(GameType.Quest, msh.getPlayerMap());
final MatchController mc = new MatchController(GameType.Quest, msh.getPlayerMap(), forceAnte);
FThreads.invokeInEdtLater(new Runnable(){
@Override
public void run() {

View File

@@ -22,6 +22,8 @@ import java.util.List;
import com.google.common.base.Function;
import forge.deck.Deck;
/**
* <p>
* QuestQuest class.
@@ -47,12 +49,18 @@ public class QuestEventChallenge extends QuestEvent {
/** The ai life. */
private int aiLife = 25;
private Integer humanLife = null;
/** The credits reward. */
private int creditsReward = 100;
/** The repeatable. */
private boolean repeatable = false;
private boolean useBazaar = true;
private Boolean forceAnte = null;
/** The wins reqd. */
private int winsReqd = 20;
@@ -63,6 +71,8 @@ public class QuestEventChallenge extends QuestEvent {
/** The ai extra cards. */
private List<String> aiExtraCards = new ArrayList<String>();
private Deck humanDeck = null;
/**
* Instantiates a new quest challenge.
*/
@@ -248,4 +258,60 @@ public class QuestEventChallenge extends QuestEvent {
public void setHumanExtraCards(final List<String> humanExtraCards0) {
this.humanExtraCards = humanExtraCards0;
}
/**
* @return the humanLife
*/
public Integer getHumanLife() {
return humanLife;
}
/**
* @param humanLife the humanLife to set
*/
public void setHumanLife(Integer humanLife) {
this.humanLife = humanLife;
}
/**
* @return the useBazaar
*/
public boolean isUseBazaar() {
return useBazaar;
}
/**
* @param useBazaar the useBazaar to set
*/
public void setUseBazaar(boolean useBazaar) {
this.useBazaar = useBazaar;
}
/**
* @return the forceAnte
*/
public Boolean isForceAnte() {
return forceAnte;
}
/**
* @param forceAnte the forceAnte to set
*/
public void setForceAnte(Boolean forceAnte) {
this.forceAnte = forceAnte;
}
/**
* @return the humanDeck
*/
public Deck getHumanDeck() {
return humanDeck;
}
/**
* @param humanDeck the humanDeck to set
*/
public void setHumanDeck(Deck humanDeck) {
this.humanDeck = humanDeck;
}
}

View File

@@ -9,6 +9,7 @@ import java.util.Map;
import forge.ImageCache;
import forge.deck.Deck;
import forge.deck.io.DeckSerializer;
import forge.properties.NewConstants;
import forge.quest.QuestEventChallenge;
import forge.quest.QuestEventDifficulty;
import forge.util.FileSection;
@@ -38,6 +39,23 @@ public class QuestChallengeReader extends StorageReaderFolder<QuestEventChalleng
qc.setCardReward(sectionQuest.get("Card Reward"));
qc.setHumanExtraCards(Arrays.asList(TextUtil.split(sectionQuest.get("HumanExtras", ""), '|')));
qc.setAiExtraCards(Arrays.asList(TextUtil.split(sectionQuest.get("AIExtras", ""), '|')));
// Less common properties
int humanLife = sectionQuest.getInt("HumanLife", 0);
if (humanLife != 0) {
qc.setHumanLife(humanLife);
}
qc.setUseBazaar(sectionQuest.getBoolean("UseBazaar", qc.isUseBazaar()));
String force = sectionQuest.get("ForceAnte", null);
if (force != null) {
qc.setForceAnte(Boolean.valueOf(force));
}
String humanDeck = sectionQuest.get("HumanDeck", null);
if (humanDeck != null) {
File humanFile = new File(NewConstants.DEFAULT_CHALLENGES_DIR, humanDeck);
qc.setHumanDeck(Deck.fromFile(humanFile));
}
// Common properties
FileSection sectionMeta = FileSection.parse(contents.get("metadata"), "=");