mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
commited a workaround for preferences dependency
This commit is contained in:
@@ -1,10 +1,25 @@
|
||||
package forge;
|
||||
|
||||
public enum PreferencesBridge {
|
||||
|
||||
public class PreferencesBridge {
|
||||
public static PreferencesSet Instance;
|
||||
|
||||
Instance;
|
||||
|
||||
public static enum GamePref {
|
||||
|
||||
public interface PreferencesSet {
|
||||
|
||||
public abstract boolean getEnableAiCheats();
|
||||
|
||||
public abstract boolean getCloneModeSource();
|
||||
|
||||
public abstract String getLogEntryType();
|
||||
|
||||
public abstract String getCurrentAiProfile();
|
||||
|
||||
public abstract boolean canRandomFoil();
|
||||
|
||||
public abstract boolean isManaBurnEnabled();
|
||||
|
||||
public abstract boolean areBlocksFree();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.PreferencesBridge;
|
||||
import forge.card.CardType;
|
||||
import forge.card.MagicColor;
|
||||
import forge.deck.CardPool;
|
||||
@@ -98,7 +99,7 @@ public class AiController {
|
||||
player = computerPlayer;
|
||||
game = game0;
|
||||
|
||||
canCheatShuffle = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ENABLE_AI_CHEATS);
|
||||
canCheatShuffle = PreferencesBridge.Instance.getEnableAiCheats();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Observable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.PreferencesBridge;
|
||||
import forge.game.event.IGameEventVisitor;
|
||||
|
||||
|
||||
@@ -106,7 +107,7 @@ public class GameLog extends Observable {
|
||||
}
|
||||
|
||||
public GameLogEntryType getGameLogEntryTypeSetting() {
|
||||
String logEntryType = Singletons.getModel().getPreferences().getPref(FPref.DEV_LOG_ENTRY_TYPE);
|
||||
String logEntryType = PreferencesBridge.Instance.getLogEntryType();
|
||||
return GameLogEntryType.valueOf(logEntryType);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import forge.PreferencesBridge;
|
||||
import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
@@ -96,7 +97,7 @@ public class Match {
|
||||
* TODO: Write javadoc for this method.
|
||||
*/
|
||||
public void startGame(final Game game, final CountDownLatch latch) {
|
||||
final boolean canRandomFoil = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_RANDOM_FOIL) && gameType == GameType.Constructed;
|
||||
final boolean canRandomFoil = PreferencesBridge.Instance.canRandomFoil() && gameType == GameType.Constructed;
|
||||
|
||||
// This code could be run run from EDT.
|
||||
game.getAction().invoke(new Runnable() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Command;
|
||||
import forge.PreferencesBridge;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
@@ -83,7 +84,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
// determine the image to be used for the clone
|
||||
String imageFileName = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE) ? tgtCard.getImageKey() : cardToCopy.getImageKey();
|
||||
String imageFileName = PreferencesBridge.Instance.getCloneModeSource() ? tgtCard.getImageKey() : cardToCopy.getImageKey();
|
||||
if (sa.hasParam("ImageSource")) { // Allow the image to be stipulated by using a defined card source
|
||||
List<Card> cloneImgSources = AbilityUtils.getDefinedCards(host, sa.getParam("ImageSource"), sa);
|
||||
if (!cloneImgSources.isEmpty()) {
|
||||
|
||||
@@ -22,11 +22,13 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import forge.PreferencesBridge;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameStage;
|
||||
@@ -432,7 +434,7 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
|
||||
for (Player p : game.getPlayers()) {
|
||||
int burn = p.getManaPool().clearPool(true);
|
||||
boolean dealDamage = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_MANABURN);
|
||||
boolean dealDamage = PreferencesBridge.Instance.isManaBurnEnabled();
|
||||
|
||||
if (dealDamage) {
|
||||
p.loseLife(burn);
|
||||
@@ -708,8 +710,7 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasPaid = blockCost.getTotalMana().isZero() && blockCost.isOnlyManaCost() && (!hasBlockCost
|
||||
|| Singletons.getModel().getPreferences().getPrefBoolean(FPref.MATCHPREF_PROMPT_FREE_BLOCKS)); // true if needless to pay
|
||||
boolean hasPaid = blockCost.getTotalMana().isZero() && blockCost.isOnlyManaCost() && (!hasBlockCost || PreferencesBridge.Instance.areBlocksFree()); // true if needless to pay
|
||||
|
||||
if (!hasPaid) {
|
||||
hasPaid = blocker.getController().getController().payManaOptional(blocker, blockCost, null, "Pay cost to declare " + blocker + " a blocker. ", ManaPaymentPurpose.DeclareBlocker);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.game.player;
|
||||
|
||||
import forge.PreferencesBridge;
|
||||
import forge.ai.AiProfileUtil;
|
||||
import forge.game.Game;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class LobbyPlayerAi extends LobbyPlayer {
|
||||
Player ai = new Player(getName(), game);
|
||||
ai.setFirstController(createControllerFor(ai));
|
||||
|
||||
String currentAiProfile = Singletons.getModel().getPreferences().getPref(FPref.UI_CURRENT_AI_PROFILE);
|
||||
String currentAiProfile = PreferencesBridge.Instance.getCurrentAiProfile();
|
||||
String lastProfileChosen = game.getMatch().getPlayedGames().isEmpty() ? currentAiProfile : getAiProfile();
|
||||
|
||||
// TODO: implement specific AI profiles for quest mode.
|
||||
|
||||
Reference in New Issue
Block a user