[LGN] fixed Berserk Murlodont not functioning correctly (fixes #7801)

This commit is contained in:
Evan Kranzler 2021-05-05 09:59:43 -04:00
parent ff64cb0cec
commit 6bb474a6d0
11 changed files with 88 additions and 63 deletions

View file

@ -39,7 +39,7 @@ public final class AsajjVentress extends CardImpl {
this.addAbility(DoubleStrikeAbility.getInstance()); this.addAbility(DoubleStrikeAbility.getInstance());
// When Asajj Ventress becomes blocked, she gets +1/+1 for each creature blocking her until end of turn. // When Asajj Ventress becomes blocked, she gets +1/+1 for each creature blocking her until end of turn.
BlockedCreatureCount value = new BlockedCreatureCount(); BlockedCreatureCount value = BlockedCreatureCount.ALL;
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true); Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true);
effect.setText("she gets +1/+1 for each creature blocking her until end of turn"); effect.setText("she gets +1/+1 for each creature blocking her until end of turn");
this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false)); this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false));

View file

@ -46,7 +46,7 @@ public final class BeastmastersMagemark extends CardImpl {
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, false)); ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, false));
this.addAbility(ability); this.addAbility(ability);
// Whenever a creature you control that's enchanted becomes blocked, it gets +1/+1 until end of turn for each creature blocking it. // Whenever a creature you control that's enchanted becomes blocked, it gets +1/+1 until end of turn for each creature blocking it.
BlockedCreatureCount value = new BlockedCreatureCount(); BlockedCreatureCount value = BlockedCreatureCount.ALL;
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true); Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true);
effect.setText("it gets +1/+1 until end of turn for each creature blocking it"); effect.setText("it gets +1/+1 until end of turn for each creature blocking it");
this.addAbility(new BecomesBlockedAllTriggeredAbility(effect, false, filter, false)); this.addAbility(new BecomesBlockedAllTriggeredAbility(effect, false, filter, false));

View file

@ -1,42 +1,42 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BecomesBlockedAllTriggeredAbility; import mage.abilities.common.BecomesBlockedAllTriggeredAbility;
import mage.abilities.dynamicvalue.common.BlockedCreatureCount; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.Effect; import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import java.util.List;
import java.util.UUID;
/** /**
* * @author TheElk801
* @author Markedagain
*/ */
public final class BerserkMurlodont extends CardImpl { public final class BerserkMurlodont extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a Beast"); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(SubType.BEAST, "a Beast");
static {
filter.add(SubType.BEAST.getPredicate());
}
public BerserkMurlodont(UUID ownerId, CardSetInfo setInfo) { public BerserkMurlodont(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}");
this.subtype.add(SubType.BEAST); this.subtype.add(SubType.BEAST);
this.power = new MageInt(3); this.power = new MageInt(3);
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// Whenever a Beast becomes blocked, it gets +1/+1 until end of turn for each creature blocking it. // Whenever a Beast becomes blocked, it gets +1/+1 until end of turn for each creature blocking it.
BlockedCreatureCount value = new BlockedCreatureCount(); this.addAbility(new BecomesBlockedAllTriggeredAbility(
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true); new BerserkMurlodontEffect(), false, filter, false
effect.setText("it gets +1/+1 until end of turn for each creature blocking it"); ));
this.addAbility(new BecomesBlockedAllTriggeredAbility(effect, false, filter, false));
} }
private BerserkMurlodont(final BerserkMurlodont card) { private BerserkMurlodont(final BerserkMurlodont card) {
@ -48,3 +48,40 @@ public final class BerserkMurlodont extends CardImpl {
return new BerserkMurlodont(this); return new BerserkMurlodont(this);
} }
} }
class BerserkMurlodontEffect extends OneShotEffect {
BerserkMurlodontEffect() {
super(Outcome.Benefit);
staticText = "it gets +1/+1 until end of turn for each creature blocking it";
}
private BerserkMurlodontEffect(final BerserkMurlodontEffect effect) {
super(effect);
}
@Override
public BerserkMurlodontEffect copy() {
return new BerserkMurlodontEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
return false;
}
int blockers = game
.getCombat()
.getGroups()
.stream()
.filter(combatGroup -> combatGroup.getAttackers().contains(permanent.getId()))
.map(CombatGroup::getBlockers)
.mapToInt(List::size)
.sum();
game.addEffect(new BoostTargetEffect(
blockers, blockers, Duration.EndOfTurn
).setTargetPointer(new FixedTarget(permanent, game)), source);
return true;
}
}

View file

@ -27,7 +27,7 @@ public final class ElvishBerserker extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// Whenever Elvish Berserker becomes blocked, it gets +1/+1 until end of turn for each creature blocking it. // Whenever Elvish Berserker becomes blocked, it gets +1/+1 until end of turn for each creature blocking it.
BlockedCreatureCount value = new BlockedCreatureCount(); BlockedCreatureCount value = BlockedCreatureCount.ALL;
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true); Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true);
effect.setText("it gets +1/+1 until end of turn for each creature blocking it"); effect.setText("it gets +1/+1 until end of turn for each creature blocking it");
this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false)); this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false));

View file

@ -30,7 +30,7 @@ public final class GangOfElk extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// Whenever Gang of Elk becomes blocked, it gets +2/+2 until end of turn for each creature blocking it. // 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(BlockedCreatureCount.ALL, 2);
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true); Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true);
effect.setText("it gets +2/+2 until end of turn for each creature blocking it"); effect.setText("it gets +2/+2 until end of turn for each creature blocking it");
this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false)); this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false));

View file

@ -1,37 +1,37 @@
package mage.cards.j; package mage.cards.j;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.BecomesBlockedSourceTriggeredAbility; import mage.abilities.common.BecomesBlockedSourceTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.MultipliedValue; import mage.abilities.dynamicvalue.MultipliedValue;
import mage.abilities.dynamicvalue.common.BlockedCreatureCount; import mage.abilities.dynamicvalue.common.BlockedCreatureCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.SubType;
import java.util.UUID;
/** /**
*
* @author fireshoes * @author fireshoes
*/ */
public final class JohtullWurm extends CardImpl { public final class JohtullWurm extends CardImpl {
private static final DynamicValue xValue1 = new MultipliedValue(BlockedCreatureCount.BEYOND_FIRST, -2);
private static final DynamicValue xValue2 = new MultipliedValue(BlockedCreatureCount.BEYOND_FIRST, -1);
public JohtullWurm(UUID ownerId, CardSetInfo setInfo) { public JohtullWurm(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{G}");
this.subtype.add(SubType.WURM); this.subtype.add(SubType.WURM);
this.power = new MageInt(6); this.power = new MageInt(6);
this.toughness = new MageInt(6); 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. // 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("each creature blocking it beyond the first", true); this.addAbility(new BecomesBlockedSourceTriggeredAbility(new BoostSourceEffect(
Effect effect = new BoostSourceEffect(new MultipliedValue(blockedCreatureCount, -2), new MultipliedValue(blockedCreatureCount, -1), Duration.EndOfTurn, true); xValue2, xValue1, Duration.EndOfTurn, true
effect.setText("it gets -2/-1 until end of turn for each creature blocking it beyond the first"); ).setText("it gets -2/-1 until end of turn for each creature blocking it beyond the first"), false));
this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false));
} }
private JohtullWurm(final JohtullWurm card) { private JohtullWurm(final JohtullWurm card) {

View file

@ -20,7 +20,7 @@ import java.util.UUID;
public final class JungleWurm extends CardImpl { public final class JungleWurm extends CardImpl {
private static final DynamicValue xValue = new MultipliedValue( private static final DynamicValue xValue = new MultipliedValue(
new BlockedCreatureCount("", true), -1 BlockedCreatureCount.BEYOND_FIRST, -1
); );
public JungleWurm(UUID ownerId, CardSetInfo setInfo) { public JungleWurm(UUID ownerId, CardSetInfo setInfo) {

View file

@ -29,7 +29,7 @@ public final class RabidElephant extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// Whenever Rabid Elephant becomes blocked, it gets +2/+2 until end of turn for each creature blocking it. // Whenever Rabid Elephant 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(BlockedCreatureCount.ALL, 2);
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true); Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true);
effect.setText("it gets +2/+2 until end of turn for each creature blocking it"); effect.setText("it gets +2/+2 until end of turn for each creature blocking it");
this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false)); this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false));

View file

@ -26,7 +26,7 @@ public final class SparringGolem extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Whenever Sparring Golem becomes blocked, it gets +1/+1 until end of turn for each creature blocking it. // Whenever Sparring Golem becomes blocked, it gets +1/+1 until end of turn for each creature blocking it.
BlockedCreatureCount value = new BlockedCreatureCount(); BlockedCreatureCount value = BlockedCreatureCount.ALL;
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true); Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true);
effect.setText("it gets +1/+1 until end of turn for each creature blocking it"); effect.setText("it gets +1/+1 until end of turn for each creature blocking it");
this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false)); this.addAbility(new BecomesBlockedSourceTriggeredAbility(effect, false));

View file

@ -1,9 +1,9 @@
package mage.abilities.common; package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
@ -11,16 +11,15 @@ import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public class BecomesBlockedAllTriggeredAbility extends TriggeredAbilityImpl { public class BecomesBlockedAllTriggeredAbility extends TriggeredAbilityImpl {
private FilterCreaturePermanent filter; private final FilterCreaturePermanent filter;
private boolean setTargetPointer; private final boolean setTargetPointer;
public BecomesBlockedAllTriggeredAbility(Effect effect, boolean optional) { public BecomesBlockedAllTriggeredAbility(Effect effect, boolean optional) {
this(effect, optional, new FilterCreaturePermanent("a creature"), false); this(effect, optional, StaticFilters.FILTER_PERMANENT_CREATURE_A, false);
} }
public BecomesBlockedAllTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter, boolean setTargetPointer) { public BecomesBlockedAllTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter, boolean setTargetPointer) {
@ -45,7 +44,7 @@ public class BecomesBlockedAllTriggeredAbility extends TriggeredAbilityImpl {
Permanent permanent = game.getPermanent(event.getTargetId()); Permanent permanent = game.getPermanent(event.getTargetId());
if (filter.match(permanent, getSourceId(), getControllerId(), game)) { if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (setTargetPointer) { if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId())); this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
} }
return true; return true;
} }

View file

@ -10,47 +10,36 @@ import mage.game.combat.CombatGroup;
/** /**
* @author Markedagain * @author Markedagain
*/ */
public class BlockedCreatureCount implements DynamicValue { public enum BlockedCreatureCount implements DynamicValue {
ALL("each creature blocking it", false),
BEYOND_FIRST("each creature blocking it beyond the first", true);
private final String message; private final String message;
private final boolean beyondTheFirst; private final boolean beyondTheFirst;
public BlockedCreatureCount() { BlockedCreatureCount(String message, boolean beyondTheFirst) {
this("each creature blocking it");
}
public BlockedCreatureCount(String message) {
this(message, false);
}
public BlockedCreatureCount(String message, boolean beyondTheFirst) {
this.message = message; this.message = message;
this.beyondTheFirst = beyondTheFirst; this.beyondTheFirst = beyondTheFirst;
} }
public BlockedCreatureCount(final BlockedCreatureCount dynamicValue) {
super();
this.message = dynamicValue.message;
this.beyondTheFirst = dynamicValue.beyondTheFirst;
}
@Override @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
for (CombatGroup combatGroup : game.getCombat().getGroups()) { for (CombatGroup combatGroup : game.getCombat().getGroups()) {
if (combatGroup.getAttackers().contains(sourceAbility.getSourceId())) { if (!combatGroup.getAttackers().contains(sourceAbility.getSourceId())) {
int blockers = combatGroup.getBlockers().size(); continue;
if (beyondTheFirst) {
blockers = blockers > 0 ? blockers - 1 : 0;
}
return blockers;
} }
int blockers = combatGroup.getBlockers().size();
if (beyondTheFirst) {
blockers = blockers > 0 ? blockers - 1 : 0;
}
return blockers;
} }
return 0; return 0;
} }
@Override @Override
public BlockedCreatureCount copy() { public BlockedCreatureCount copy() {
return new BlockedCreatureCount(this); return this;
} }
@Override @Override