fixed Vantress Gargoyle erroring

This commit is contained in:
Evan Kranzler 2019-09-15 10:56:43 -04:00
parent 6af989d6a0
commit db7f61e6c5

View file

@ -4,17 +4,16 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.CardsInHandCondition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.RestrictionEffect;
import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveEachPlayerEffect;
import mage.abilities.effects.common.combat.CantBlockSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -26,8 +25,6 @@ import java.util.UUID;
*/
public final class VantressGargoyle extends CardImpl {
private static final Condition condition = new CardsInHandCondition(ComparisonType.FEWER_THAN, 4);
public VantressGargoyle(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}{U}");
@ -39,13 +36,10 @@ public final class VantressGargoyle extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// Vantress Gargoyle can't attack unless defending player has seven or more cards in their graveyard.
this.addAbility(new SimpleStaticAbility(new VantressGargoyleEffect()));
this.addAbility(new SimpleStaticAbility(new VantressGargoyleAttackEffect()));
// Vantress Gargoyle can't block unless you have four or more cards in hand.
this.addAbility(new SimpleStaticAbility(new ConditionalContinuousEffect(
new CantBlockSourceEffect(Duration.WhileOnBattlefield), condition,
"{this} can't block unless you have four or more cards in hand"
)));
this.addAbility(new SimpleStaticAbility(new VantressGargoyleBlockEffect()));
// {T}: Each player puts the top card of their library into their graveyard.
this.addAbility(new SimpleActivatedAbility(
@ -63,14 +57,14 @@ public final class VantressGargoyle extends CardImpl {
}
}
class VantressGargoyleEffect extends RestrictionEffect {
class VantressGargoyleAttackEffect extends RestrictionEffect {
VantressGargoyleEffect() {
VantressGargoyleAttackEffect() {
super(Duration.WhileOnBattlefield);
staticText = "{this} can't attack unless defending player has seven or more cards in their graveyard";
}
private VantressGargoyleEffect(final VantressGargoyleEffect effect) {
private VantressGargoyleAttackEffect(final VantressGargoyleAttackEffect effect) {
super(effect);
}
@ -86,7 +80,37 @@ class VantressGargoyleEffect extends RestrictionEffect {
}
@Override
public VantressGargoyleEffect copy() {
return new VantressGargoyleEffect(this);
public VantressGargoyleAttackEffect copy() {
return new VantressGargoyleAttackEffect(this);
}
}
}
class VantressGargoyleBlockEffect extends RestrictionEffect {
VantressGargoyleBlockEffect() {
super(Duration.WhileOnBattlefield);
staticText = "{this} can't block unless you have four or more cards in hand";
}
private VantressGargoyleBlockEffect(final VantressGargoyleBlockEffect effect) {
super(effect);
}
@Override
public VantressGargoyleBlockEffect copy() {
return new VantressGargoyleBlockEffect(this);
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
Player player = game.getPlayer(source.getControllerId());
return player != null
&& player.getHand().size() < 4
&& permanent.getId().equals(source.getSourceId());
}
}