Fix #10631 (Forge, Neverwinter Charlatan)

This commit is contained in:
xenohedron 2023-07-16 16:19:31 -04:00
parent 809c02eb8d
commit a5dbf30605
2 changed files with 12 additions and 7 deletions

View file

@ -5,6 +5,7 @@ import mage.abilities.common.SacrificeAllTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.MultipliedValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
@ -28,6 +29,7 @@ import java.util.UUID;
public final class ForgeNeverwinterCharlatan extends CardImpl { public final class ForgeNeverwinterCharlatan extends CardImpl {
private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(new FilterControlledPermanent(SubType.TREASURE)); private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(new FilterControlledPermanent(SubType.TREASURE));
private static final DynamicValue twiceXValue = new MultipliedValue(xValue, 2);
private static final Hint hint = new ValueHint("Treasures you control", xValue); private static final Hint hint = new ValueHint("Treasures you control", xValue);
public ForgeNeverwinterCharlatan(UUID ownerId, CardSetInfo setInfo) { public ForgeNeverwinterCharlatan(UUID ownerId, CardSetInfo setInfo) {
@ -47,7 +49,7 @@ public final class ForgeNeverwinterCharlatan extends CardImpl {
// Forge, Neverwinter Charlatan gets +2/+0 for each Treasure you control. // Forge, Neverwinter Charlatan gets +2/+0 for each Treasure you control.
this.addAbility(new SimpleStaticAbility(new BoostSourceEffect( this.addAbility(new SimpleStaticAbility(new BoostSourceEffect(
xValue, StaticValue.get(0), Duration.WhileOnBattlefield twiceXValue, StaticValue.get(0), Duration.WhileOnBattlefield
).setText("{this} gets +2/+0 for each Treasure you control")).addHint(hint)); ).setText("{this} gets +2/+0 for each Treasure you control")).addHint(hint));
// Whenever one or more players sacrifice one or more creatures, you create a tapped Treasure token. This ability triggers only once each turn. // Whenever one or more players sacrifice one or more creatures, you create a tapped Treasure token. This ability triggers only once each turn.

View file

@ -44,22 +44,25 @@ public class SacrificeAllTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
boolean sacrificed = false;
switch (sacrificingPlayer) { switch (sacrificingPlayer) {
case YOU: case YOU:
if (event.getPlayerId().equals(getControllerId())) { if (!event.getPlayerId().equals(getControllerId())) {
sacrificed = true; return false;
} }
break; break;
case OPPONENT: case OPPONENT:
Player controller = game.getPlayer(getControllerId()); Player controller = game.getPlayer(getControllerId());
if (controller == null || controller.hasOpponent(event.getPlayerId(), game)) { if (controller == null || !controller.hasOpponent(event.getPlayerId(), game)) {
sacrificed = true; return false;
} }
break; break;
case ANY:
break;
default:
return false;
} }
Permanent sacrificedPermanent = game.getPermanentOrLKIBattlefield(event.getTargetId()); Permanent sacrificedPermanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
return sacrificed && filter.match(sacrificedPermanent, getControllerId(), this, game); return sacrificedPermanent != null && filter.match(sacrificedPermanent, getControllerId(), this, game);
} }
private String generateTriggerPhrase() { private String generateTriggerPhrase() {