mirror of
https://github.com/correl/mage.git
synced 2025-03-12 17:00:08 -09:00
Fixed BlockedCreatureCount handling.
This commit is contained in:
parent
48be09ad52
commit
b41c4822e9
6 changed files with 27 additions and 26 deletions
|
@ -45,8 +45,9 @@ import mage.target.TargetSpell;
|
|||
* @author emerald000
|
||||
*/
|
||||
public class RuneSnag extends CardImpl {
|
||||
|
||||
|
||||
private static final FilterCard filter = new FilterCard();
|
||||
|
||||
static {
|
||||
filter.add(new NamePredicate("Rune Snag"));
|
||||
}
|
||||
|
@ -55,7 +56,6 @@ public class RuneSnag extends CardImpl {
|
|||
super(ownerId, 46, "Rune Snag", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}");
|
||||
this.expansionSetCode = "CSP";
|
||||
|
||||
|
||||
// Counter target spell unless its controller pays {2} plus an additional {2} for each card named Rune Snag in each graveyard.
|
||||
Effect effect = new CounterUnlessPaysEffect(new IntPlusDynamicValue(2, new MultipliedValue(new CardsInAllGraveyardsCount(filter), 2)));
|
||||
effect.setText("Counter target spell unless its controller pays {2} plus an additional {2} for each card named Rune Snag in each graveyard");
|
||||
|
|
|
@ -31,8 +31,8 @@ import java.util.UUID;
|
|||
import mage.MageInt;
|
||||
import mage.abilities.common.BecomesBlockedTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.BlockedCreatureCount;
|
||||
import mage.abilities.dynamicvalue.MultipliedValue;
|
||||
import mage.abilities.dynamicvalue.common.BlockedCreatureCount;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -54,11 +54,8 @@ public class JohtullWurm extends CardImpl {
|
|||
this.toughness = new MageInt(6);
|
||||
|
||||
// Whenever Johtull Wurm becomes blocked, it gets -2/-1 until end of turn for each creature blocking it beyond the first.
|
||||
DynamicValue blockedCreatureCount = new BlockedCreatureCount();
|
||||
int value = Math.negateExact(Integer.parseInt(blockedCreatureCount.toString()) - 1);
|
||||
int powerValue = value * 2;
|
||||
|
||||
Effect effect = new BoostSourceEffect(powerValue, value, Duration.EndOfTurn);
|
||||
DynamicValue blockedCreatureCount = new BlockedCreatureCount("each creature blocking it beyond the first", true);
|
||||
Effect effect = new BoostSourceEffect(new MultipliedValue(blockedCreatureCount, -2), new MultipliedValue(blockedCreatureCount, -1), Duration.EndOfTurn);
|
||||
effect.setText("it gets -2/-1 until end of turn for each creature blocking it beyond the first");
|
||||
this.addAbility(new BecomesBlockedTriggeredAbility(effect, false));
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ package mage.sets.mirage;
|
|||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.BecomesBlockedTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.MultipliedValue;
|
||||
import mage.abilities.dynamicvalue.common.BlockedCreatureCount;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
|
@ -52,9 +54,8 @@ public class JungleWurm extends CardImpl {
|
|||
this.toughness = new MageInt(5);
|
||||
|
||||
// Whenever Jungle Wurm becomes blocked, it gets -1/-1 until end of turn for each creature blocking it beyond the first.
|
||||
BlockedCreatureCount blockedCreatureCount = new BlockedCreatureCount();
|
||||
int value = Math.negateExact(Integer.parseInt(blockedCreatureCount.toString()) - 1);
|
||||
|
||||
BlockedCreatureCount blockedCreatureCount = new BlockedCreatureCount("each creature blocking it beyond the first", true);
|
||||
DynamicValue value = new MultipliedValue(blockedCreatureCount, -1);
|
||||
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn);
|
||||
effect.setText("it gets -1/-1 until end of turn for each creature blocking it beyond the first");
|
||||
this.addAbility(new BecomesBlockedTriggeredAbility(effect, false));
|
||||
|
@ -68,4 +69,4 @@ public class JungleWurm extends CardImpl {
|
|||
public JungleWurm copy() {
|
||||
return new JungleWurm(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,7 @@ package mage.sets.ninthedition;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BecomesBlockedTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.BlockedCreatureCount;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
|
@ -39,8 +37,6 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -71,4 +67,4 @@ public class ElvishBerserker extends CardImpl {
|
|||
public ElvishBerserker copy() {
|
||||
return new ElvishBerserker(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ package mage.sets.urzaslegacy;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BecomesBlockedTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.MultipliedValue;
|
||||
|
@ -40,8 +39,6 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Rarity;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -59,7 +56,7 @@ public class GangOfElk extends CardImpl {
|
|||
this.toughness = new MageInt(4);
|
||||
|
||||
// Whenever Gang of Elk becomes blocked, it gets +2/+2 until end of turn for each creature blocking it.
|
||||
DynamicValue value = new MultipliedValue(new BlockedCreatureCount(),2);
|
||||
DynamicValue value = new MultipliedValue(new BlockedCreatureCount(), 2);
|
||||
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn);
|
||||
effect.setText("it gets +2/+2 until end of turn for each creature blocking it");
|
||||
this.addAbility(new BecomesBlockedTriggeredAbility(effect, false));
|
||||
|
@ -73,4 +70,4 @@ public class GangOfElk extends CardImpl {
|
|||
public GangOfElk copy() {
|
||||
return new GangOfElk(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,27 +38,37 @@ import mage.game.combat.CombatGroup;
|
|||
* @author Markedagain
|
||||
*/
|
||||
public class BlockedCreatureCount implements DynamicValue {
|
||||
|
||||
private String message;
|
||||
boolean beyondTheFirst;
|
||||
|
||||
public BlockedCreatureCount() {
|
||||
this("each creature blocking it");
|
||||
}
|
||||
|
||||
public BlockedCreatureCount(String message) {
|
||||
this(message, false);
|
||||
}
|
||||
|
||||
public BlockedCreatureCount(String message, boolean beyondTheFist) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public BlockedCreatureCount(final BlockedCreatureCount dynamicValue) {
|
||||
super();
|
||||
this.message = dynamicValue.message;
|
||||
this.beyondTheFirst = dynamicValue.beyondTheFirst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
for(CombatGroup combatGroup : game.getCombat().getGroups()) {
|
||||
if(combatGroup.getAttackers().contains(sourceAbility.getSourceId())) {
|
||||
int blockers = combatGroup.getBlockers().size();
|
||||
return blockers > 1 ? (blockers) : 0;
|
||||
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
|
||||
if (combatGroup.getAttackers().contains(sourceAbility.getSourceId())) {
|
||||
int blockers = combatGroup.getBlockers().size();
|
||||
if (beyondTheFirst) {
|
||||
blockers = blockers > 0 ? blockers - 1 : 0;
|
||||
}
|
||||
return blockers;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue