Merge pull request #2736 from shootbot/master

Fixed Asylum Visitor and Spined Sliver bugs
This commit is contained in:
LevelX2 2017-01-02 17:30:07 +01:00 committed by GitHub
commit f777668a4d
2 changed files with 86 additions and 23 deletions

View file

@ -29,12 +29,15 @@ package mage.cards.a;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.MadnessAbility; import mage.abilities.keyword.MadnessAbility;
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.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
@ -74,7 +77,7 @@ public class AsylumVisitor extends CardImpl {
class AsylumVisitorTriggeredAbility extends TriggeredAbilityImpl { class AsylumVisitorTriggeredAbility extends TriggeredAbilityImpl {
public AsylumVisitorTriggeredAbility() { public AsylumVisitorTriggeredAbility() {
super(Zone.BATTLEFIELD, null); super(Zone.BATTLEFIELD, new AsylumVisitorEffect());
} }
public AsylumVisitorTriggeredAbility(final AsylumVisitorTriggeredAbility ability) { public AsylumVisitorTriggeredAbility(final AsylumVisitorTriggeredAbility ability) {
@ -93,16 +96,10 @@ class AsylumVisitorTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Player you = game.getPlayer(this.getControllerId());
Player upkeepPlayer = game.getPlayer(event.getPlayerId()); Player upkeepPlayer = game.getPlayer(event.getPlayerId());
if (upkeepPlayer != null && upkeepPlayer.getHand().isEmpty()) {
if (you != null && upkeepPlayer != null && upkeepPlayer.getHand().isEmpty()) {
you.drawCards(1, game);
you.loseLife(1, game, false);
return true; return true;
} }
return false; return false;
} }
@ -111,3 +108,32 @@ class AsylumVisitorTriggeredAbility extends TriggeredAbilityImpl {
return "At the beginning of each player's upkeep, if that player has no cards in hand, you draw a card and you lose 1 life."; return "At the beginning of each player's upkeep, if that player has no cards in hand, you draw a card and you lose 1 life.";
} }
} }
class AsylumVisitorEffect extends OneShotEffect {
public AsylumVisitorEffect() {
super(Outcome.DrawCard);
this.staticText = "you draw a card and you lose 1 life";
}
public AsylumVisitorEffect(final AsylumVisitorEffect effect) {
super(effect);
}
@Override
public AsylumVisitorEffect copy() {
return new AsylumVisitorEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player upkeepPlayer = game.getPlayer(game.getActivePlayerId());
if (you != null && upkeepPlayer != null && upkeepPlayer.getHand().isEmpty()) {
you.drawCards(1, game);
you.loseLife(1, game, false);
return true;
}
return false;
}
}

View file

@ -30,19 +30,19 @@ package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BecomesBlockedByCreatureTriggeredAbility; import mage.abilities.common.BecomesBlockedAllTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.BlockedCreatureCount;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
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.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.target.targetpointer.TargetPointer;
/** /**
* *
@ -64,14 +64,10 @@ public class SpinedSliver extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Whenever a Sliver becomes blocked, that Sliver gets +1/+1 until end of turn for each creature blocking it. // Whenever a Sliver becomes blocked, that Sliver gets +1/+1 until end of turn for each creature blocking it.
BlockedCreatureCount value = new BlockedCreatureCount(); BlockersCount value = new BlockersCount();
Effect effect = new BoostSourceEffect(value, value, Duration.EndOfTurn, true); Effect effect = new BoostTargetEffect(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");
Ability ability = new BecomesBlockedByCreatureTriggeredAbility(effect, false); this.addAbility(new BecomesBlockedAllTriggeredAbility(effect, false, filter, true));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new GainAbilityAllEffect(ability,
Duration.WhileOnBattlefield, filter,
"Whenever a Sliver becomes blocked, that Sliver gets +1/+1 until end of turn for each creature blocking it.")));
} }
public SpinedSliver(final SpinedSliver card) { public SpinedSliver(final SpinedSliver card) {
@ -83,3 +79,44 @@ public class SpinedSliver extends CardImpl {
return new SpinedSliver(this); return new SpinedSliver(this);
} }
} }
class BlockersCount implements DynamicValue {
private String message;
public BlockersCount() {
this.message = "each creature blocking it";
}
public BlockersCount(final BlockersCount blockersCount) {
super();
this.message = blockersCount.message;
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
TargetPointer attacker = effect.getTargetPointer();
UUID attackerId = attacker.getFirst(game, sourceAbility);
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
if (combatGroup.getAttackers().contains(attackerId)) {
return combatGroup.getBlockers().size();
}
}
return 0;
}
@Override
public BlockersCount copy() {
return new BlockersCount(this);
}
@Override
public String getMessage() {
return message;
}
@Override
public String toString() {
return "X";
}
}