free blocks option moved to PlayerControllerHuman

This commit is contained in:
Maxmtg
2014-01-24 05:44:23 +00:00
parent 68acaf77c5
commit e4fb939e91
4 changed files with 7 additions and 14 deletions

View File

@@ -6,6 +6,5 @@ public class Dependencies {
public interface PreferencesMethods { public interface PreferencesMethods {
@Deprecated public abstract boolean getCloneModeSource(); @Deprecated public abstract boolean getCloneModeSource();
@Deprecated public abstract boolean isManaBurnEnabled(); @Deprecated public abstract boolean isManaBurnEnabled();
@Deprecated public abstract boolean areBlocksFree();
} }
} }

View File

@@ -696,8 +696,8 @@ public class PhaseHandler implements java.io.Serializable {
private static boolean payRequiredBlockCosts(Game game, Card blocker, Card attacker) { private static boolean payRequiredBlockCosts(Game game, Card blocker, Card attacker) {
Cost blockCost = new Cost(ManaCost.ZERO, true); Cost blockCost = new Cost(ManaCost.ZERO, true);
boolean hasBlockCost = false;
// Sort abilities to apply them in proper order // Sort abilities to apply them in proper order
boolean noCost = true;
List<ZoneType> checkZones = ZoneType.listValueOf("Battlefield,Command"); List<ZoneType> checkZones = ZoneType.listValueOf("Battlefield,Command");
for (Card card : game.getCardsIn(checkZones)) { for (Card card : game.getCardsIn(checkZones)) {
final ArrayList<StaticAbility> staticAbilities = card.getStaticAbilities(); final ArrayList<StaticAbility> staticAbilities = card.getStaticAbilities();
@@ -705,17 +705,12 @@ public class PhaseHandler implements java.io.Serializable {
Cost c1 = stAb.getBlockCost(blocker, attacker); Cost c1 = stAb.getBlockCost(blocker, attacker);
if (c1 != null) { if (c1 != null) {
blockCost.add(c1); blockCost.add(c1);
hasBlockCost = true; noCost = false;
} }
} }
} }
boolean hasPaid = blockCost.getTotalMana().isZero() && blockCost.isOnlyManaCost() && (!hasBlockCost || Dependencies.preferences.areBlocksFree()); // true if needless to pay return !noCost || blocker.getController().getController().payManaOptional(blocker, blockCost, null, "Pay cost to declare " + blocker + " a blocker. ", ManaPaymentPurpose.DeclareBlocker);
if (!hasPaid) {
hasPaid = blocker.getController().getController().payManaOptional(blocker, blockCost, null, "Pay cost to declare " + blocker + " a blocker. ", ManaPaymentPurpose.DeclareBlocker);
}
return hasPaid;
} }
/** /**

View File

@@ -13,9 +13,4 @@ public class PreferencesProvider implements Dependencies.PreferencesMethods {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_MANABURN); return Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_MANABURN);
} }
@Override
public boolean areBlocksFree() {
return Singletons.getModel().getPreferences().getPrefBoolean(FPref.MATCHPREF_PROMPT_FREE_BLOCKS);
}
} }

View File

@@ -723,6 +723,10 @@ public class PlayerControllerHuman extends PlayerController {
*/ */
@Override @Override
public boolean payManaOptional(Card c, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose) { public boolean payManaOptional(Card c, Cost cost, SpellAbility sa, String prompt, ManaPaymentPurpose purpose) {
if ( sa == null && cost.isOnlyManaCost() && cost.getTotalMana().isZero()
&& !Singletons.getModel().getPreferences().getPrefBoolean(FPref.MATCHPREF_PROMPT_FREE_BLOCKS))
return true;
return HumanPlay.payCostDuringAbilityResolve(player, c, cost, sa, prompt); return HumanPlay.payCostDuringAbilityResolve(player, c, cost, sa, prompt);
} }