mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
checkPropagandaEffects simplified due to synchronous execution
This commit is contained in:
@@ -97,7 +97,7 @@ public class Cost {
|
|||||||
public final ManaCost getTotalMana() {
|
public final ManaCost getTotalMana() {
|
||||||
for (final CostPart part : this.costParts) {
|
for (final CostPart part : this.costParts) {
|
||||||
if (part instanceof CostPartMana) {
|
if (part instanceof CostPartMana) {
|
||||||
return new ManaCost(new ManaCostParser(part.toString()));
|
return ((CostPartMana) part).getManaToPay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1122,62 +1122,36 @@ public class CombatUtil {
|
|||||||
* @param bLast
|
* @param bLast
|
||||||
* a boolean.
|
* a boolean.
|
||||||
*/
|
*/
|
||||||
public static void checkPropagandaEffects(final Card c, final boolean bLast) {
|
public static void checkPropagandaEffects(final GameState game, final Card c) {
|
||||||
Cost attackCost = new Cost(c, "0", true);
|
Cost attackCost = new Cost(c, "0", true);
|
||||||
final GameState game = Singletons.getModel().getGame();
|
|
||||||
// Sort abilities to apply them in proper order
|
// Sort abilities to apply them in proper order
|
||||||
for (Card card : Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield)) {
|
for (Card card : game.getCardsIn(ZoneType.Battlefield)) {
|
||||||
final ArrayList<StaticAbility> staticAbilities = card.getStaticAbilities();
|
final ArrayList<StaticAbility> staticAbilities = card.getStaticAbilities();
|
||||||
for (final StaticAbility stAb : staticAbilities) {
|
for (final StaticAbility stAb : staticAbilities) {
|
||||||
Cost additionalCost = stAb.getCostAbility("CantAttackUnless", c, game.getCombat().getDefenderByAttacker(c));
|
Cost additionalCost = stAb.getCostAbility("CantAttackUnless", c, game.getCombat().getDefenderByAttacker(c));
|
||||||
attackCost = Cost.combine(attackCost, additionalCost);
|
attackCost = Cost.combine(attackCost, additionalCost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attackCost.toSimpleString().equals("")) {
|
|
||||||
if (!c.hasKeyword("Vigilance")) {
|
|
||||||
c.tap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bLast) {
|
|
||||||
PhaseUtil.handleAttackingTriggers();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Card crd = c;
|
|
||||||
|
|
||||||
|
|
||||||
final PhaseType phase = game.getPhaseHandler().getPhase();
|
|
||||||
|
|
||||||
if (phase == PhaseType.COMBAT_DECLARE_ATTACKERS || phase == PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) {
|
|
||||||
final Ability ability = new AbilityStatic(c, attackCost, null) {
|
|
||||||
@Override
|
|
||||||
public void resolve() {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
boolean hasPaid = attackCost.getTotalMana().isZero() && attackCost.isOnlyManaCost(); // true if needless to pay
|
||||||
|
if (!hasPaid) {
|
||||||
|
final Ability ability = new AbilityStatic(c, attackCost, null) { @Override public void resolve() {} };
|
||||||
ability.setActivatingPlayer(c.getController());
|
ability.setActivatingPlayer(c.getController());
|
||||||
|
|
||||||
if (c.getController().isHuman()) {
|
if (c.getController().isHuman()) {
|
||||||
if ( GameActionUtil.payCostDuringAbilityResolve(ability, attackCost, null, game) ) {
|
hasPaid = GameActionUtil.payCostDuringAbilityResolve(ability, attackCost, null, game);
|
||||||
if (!crd.hasKeyword("Vigilance")) { crd.tap(); }
|
|
||||||
} else {
|
|
||||||
game.getCombat().removeFromCombat(crd);
|
|
||||||
}
|
|
||||||
} else { // computer
|
} else { // computer
|
||||||
if (ComputerUtilCost.canPayCost(ability, c.getController())) {
|
if (ComputerUtilCost.canPayCost(ability, c.getController())) {
|
||||||
ComputerUtil.playNoStack((AIPlayer)c.getController(), ability, game);
|
ComputerUtil.playNoStack((AIPlayer)c.getController(), ability, game);
|
||||||
if (!crd.hasKeyword("Vigilance")) {
|
hasPaid = true;
|
||||||
crd.tap();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( hasPaid ) {
|
||||||
|
if (!c.hasKeyword("Vigilance")) { c.tap(); }
|
||||||
} else {
|
} else {
|
||||||
// TODO remove the below line after Propaganda occurs
|
game.getCombat().removeFromCombat(c);
|
||||||
// during Declare_Attackers
|
|
||||||
game.getCombat().removeFromCombat(crd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (bLast)
|
|
||||||
PhaseUtil.handleAttackingTriggers();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
|||||||
|
|
||||||
case COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY:
|
case COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY:
|
||||||
if (this.inCombat()) {
|
if (this.inCombat()) {
|
||||||
PhaseUtil.handleDeclareAttackers(game.getCombat());
|
PhaseUtil.handleDeclareAttackers(game);
|
||||||
CombatUtil.showCombat();
|
CombatUtil.showCombat();
|
||||||
} else {
|
} else {
|
||||||
this.setPlayersPriorityPermission(false);
|
this.setPlayersPriorityPermission(false);
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ public class PhaseUtil {
|
|||||||
* handleDeclareAttackers.
|
* handleDeclareAttackers.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public static void handleDeclareAttackers(Combat combat) {
|
public static void handleDeclareAttackers(final GameState game) {
|
||||||
|
final Combat combat = game.getCombat();
|
||||||
combat.verifyCreaturesInPlay();
|
combat.verifyCreaturesInPlay();
|
||||||
|
|
||||||
// Handles removing cards like Mogg Flunkies from combat if group attack
|
// Handles removing cards like Mogg Flunkies from combat if group attack
|
||||||
@@ -143,9 +144,9 @@ public class PhaseUtil {
|
|||||||
final int size = list.size();
|
final int size = list.size();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
final Card c = list.get(i);
|
final Card c = list.get(i);
|
||||||
final boolean last = (i == (size - 1));
|
CombatUtil.checkPropagandaEffects(game, c);
|
||||||
CombatUtil.checkPropagandaEffects(c, last);
|
|
||||||
}
|
}
|
||||||
|
PhaseUtil.handleAttackingTriggers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user