mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Hellfire Mongrel - Fixed that the condition was also checked during resolution.
This commit is contained in:
parent
2708392e2d
commit
537700ad22
1 changed files with 18 additions and 36 deletions
|
@ -28,13 +28,19 @@
|
||||||
package mage.sets.zendikar;
|
package mage.sets.zendikar;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.Rarity;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
|
import mage.abilities.condition.Condition;
|
||||||
|
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Rarity;
|
||||||
|
import mage.constants.TargetController;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
@ -52,12 +58,15 @@ public class HellfireMongrel extends CardImpl {
|
||||||
this.subtype.add("Elemental");
|
this.subtype.add("Elemental");
|
||||||
this.subtype.add("Hound");
|
this.subtype.add("Hound");
|
||||||
|
|
||||||
this.color.setRed(true);
|
|
||||||
this.power = new MageInt(2);
|
this.power = new MageInt(2);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
|
|
||||||
// At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, Hellfire Mongrel deals 2 damage to him or her.
|
// At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, Hellfire Mongrel deals 2 damage to him or her.
|
||||||
this.addAbility(new HellfireMongrelTriggeredAbility());
|
this.addAbility(new ConditionalTriggeredAbility(
|
||||||
|
new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(2), TargetController.OPPONENT, false, true),
|
||||||
|
new CardsInActivePlayersHandCondition(),
|
||||||
|
"At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, {this} deals 2 damage to him or her.",
|
||||||
|
false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HellfireMongrel(final HellfireMongrel card) {
|
public HellfireMongrel(final HellfireMongrel card) {
|
||||||
|
@ -70,38 +79,11 @@ public class HellfireMongrel extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HellfireMongrelTriggeredAbility extends TriggeredAbilityImpl {
|
class CardsInActivePlayersHandCondition implements Condition {
|
||||||
|
|
||||||
public HellfireMongrelTriggeredAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HellfireMongrelTriggeredAbility(final HellfireMongrelTriggeredAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HellfireMongrelTriggeredAbility copy() {
|
public boolean apply(Game game, Ability source) {
|
||||||
return new HellfireMongrelTriggeredAbility(this);
|
Player player = game.getPlayer(game.getActivePlayerId());
|
||||||
}
|
return player != null && player.getHand().size() <= 2;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
|
||||||
Player player = game.getPlayer(event.getPlayerId());
|
|
||||||
if (player != null && player.getHand().size() < 3) {
|
|
||||||
this.getEffects().clear();
|
|
||||||
DamageTargetEffect effect = new DamageTargetEffect(2);
|
|
||||||
effect.setTargetPointer(new FixedTarget(player.getId()));
|
|
||||||
this.addEffect(effect);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, {this} deals 2 damage to him or her.";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue