Random foiling moved to per-player settings, is set up before starting a match

This commit is contained in:
Maxmtg
2014-01-24 04:35:22 +00:00
parent 7687637783
commit 308039739f
5 changed files with 20 additions and 13 deletions

View File

@@ -8,7 +8,6 @@ public class Dependencies {
@Deprecated public abstract boolean getCloneModeSource(); @Deprecated public abstract boolean getCloneModeSource();
@Deprecated public abstract String getLogEntryType(); @Deprecated public abstract String getLogEntryType();
@Deprecated public abstract String getCurrentAiProfile(); @Deprecated public abstract String getCurrentAiProfile();
@Deprecated public abstract boolean canRandomFoil();
@Deprecated public abstract boolean isManaBurnEnabled(); @Deprecated public abstract boolean isManaBurnEnabled();
@Deprecated public abstract boolean areBlocksFree(); @Deprecated public abstract boolean areBlocksFree();
} }

View File

@@ -16,7 +16,6 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import forge.Dependencies;
import forge.deck.CardPool; import forge.deck.CardPool;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckSection; import forge.deck.DeckSection;
@@ -97,14 +96,13 @@ public class Match {
* TODO: Write javadoc for this method. * TODO: Write javadoc for this method.
*/ */
public void startGame(final Game game, final CountDownLatch latch) { public void startGame(final Game game, final CountDownLatch latch) {
final boolean canRandomFoil = Dependencies.preferences.canRandomFoil() && gameType == GameType.Constructed;
// This code could be run run from EDT. // This code could be run run from EDT.
game.getAction().invoke(new Runnable() { game.getAction().invoke(new Runnable() {
@Override @Override
public void run() { public void run() {
prepareAllZones(game, canRandomFoil); prepareAllZones(game);
if (useAnte) { // Deciding which cards go to ante if (useAnte) { // Deciding which cards go to ante
Multimap<Player, Card> list = game.chooseCardsForAnte(); Multimap<Player, Card> list = game.chooseCardsForAnte();
for (Entry<Player, Card> kv : list.entries()) { for (Entry<Player, Card> kv : list.entries()) {
@@ -254,7 +252,7 @@ public class Match {
library.setCards(newLibrary); library.setCards(newLibrary);
} }
private void prepareAllZones(final Game game, final boolean canRandomFoil) { private void prepareAllZones(final Game game) {
// need this code here, otherwise observables fail // need this code here, otherwise observables fail
Trigger.resetIDs(); Trigger.resetIDs();
game.getTriggerHandler().clearDelayedTrigger(); game.getTriggerHandler().clearDelayedTrigger();
@@ -305,9 +303,9 @@ public class Match {
Random generator = MyRandom.getRandom(); Random generator = MyRandom.getRandom();
preparePlayerLibrary(player, ZoneType.Library, myDeck.getMain(), canRandomFoil, generator); preparePlayerLibrary(player, ZoneType.Library, myDeck.getMain(), psc.useRandomFoil(), generator);
if (myDeck.has(DeckSection.Sideboard)) { if (myDeck.has(DeckSection.Sideboard)) {
preparePlayerLibrary(player, ZoneType.Sideboard, myDeck.get(DeckSection.Sideboard), canRandomFoil, generator); preparePlayerLibrary(player, ZoneType.Sideboard, myDeck.get(DeckSection.Sideboard), psc.useRandomFoil(), generator);
} }
player.shuffle(null); player.shuffle(null);

View File

@@ -155,4 +155,13 @@ public class RegisteredPlayer {
public void restoreDeck() { public void restoreDeck() {
currentDeck = (Deck) originalDeck.copyTo(originalDeck.getName()); currentDeck = (Deck) originalDeck.copyTo(originalDeck.getName());
} }
private boolean randomFoil = false;
public void setRandomFoil(boolean useRandomFoil) {
this.randomFoil = useRandomFoil;
}
public boolean useRandomFoil() {
return randomFoil;
}
} }

View File

@@ -23,11 +23,6 @@ public class PreferencesProvider implements Dependencies.PreferencesMethods {
return Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE); return Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE);
} }
@Override
public boolean canRandomFoil() {
return Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_RANDOM_FOIL);
}
@Override @Override
public boolean isManaBurnEnabled() { public boolean isManaBurnEnabled() {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View File

@@ -558,6 +558,12 @@ public enum FControl implements KeyEventDispatcher {
} }
public void startMatch(GameType gameType, List<RegisteredPlayer> starter) { public void startMatch(GameType gameType, List<RegisteredPlayer> starter) {
boolean useRandomFoil = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_RANDOM_FOIL);
for(RegisteredPlayer rp : starter) {
rp.setRandomFoil(useRandomFoil);
}
boolean useAnte = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE); boolean useAnte = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE);
final Match mc = new Match(gameType, starter, useAnte); final Match mc = new Match(gameType, starter, useAnte);
SOverlayUtils.startGameOverlay(); SOverlayUtils.startGameOverlay();