Merge origin/master

This commit is contained in:
fireshoes 2015-01-15 16:46:46 -06:00
commit 0745fbb153
2 changed files with 174 additions and 47 deletions

View file

@ -28,17 +28,26 @@
package mage.sets.commander2014; package mage.sets.commander2014;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.UntapTargetEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect; import mage.abilities.effects.RequirementEffect;
import mage.abilities.effects.common.continious.GainControlTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.permanent.AttackingPredicate; import mage.filter.predicate.permanent.AttackingPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
/** /**
@ -60,14 +69,10 @@ public class DomineeringWill extends CardImpl {
this.color.setBlue(true); this.color.setBlue(true);
// Target player gains control of up to three target nonattacking creatures until end of turn. Untap those creatures. They block this turn if able. // Target player gains control of up to three target nonattacking creatures until end of turn. Untap those creatures. They block this turn if able.
this.getSpellAbility().addEffect(new GainControlTargetEffect(Duration.EndOfTurn)); this.getSpellAbility().addEffect(new DomineeringWillEffect());
Effect effect = new UntapTargetEffect(); this.getSpellAbility().addTarget(new TargetPlayer());
effect.setText("Untap those creatures"); this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 3, filter, false));
this.getSpellAbility().addEffect(effect);
effect = new BlocksIfAbleTargetEffect(Duration.EndOfTurn);
effect.setText("They block this turn if able");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0,3, filter, false));
} }
public DomineeringWill(final DomineeringWill card) { public DomineeringWill(final DomineeringWill card) {
@ -79,3 +84,143 @@ public class DomineeringWill extends CardImpl {
return new DomineeringWill(this); return new DomineeringWill(this);
} }
} }
class DomineeringWillEffect extends OneShotEffect {
public DomineeringWillEffect() {
super(Outcome.Benefit);
staticText = "Target player gains control of up to three target nonattacking creatures until end of turn. Untap those creatures. They block this turn if able";
}
public DomineeringWillEffect(final DomineeringWillEffect effect) {
super(effect);
}
@Override
public DomineeringWillEffect copy() {
return new DomineeringWillEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer != null) {
ContinuousEffect effect = new DomineeringWillControlEffect();
game.addEffect(effect, source);
Effect effect2 = new DomineeringWillUntapTargetEffect();
effect2.setText("Untap those creatures");
effect2.apply(game, source);
RequirementEffect effect3 = new DomineeringWillBlocksIfAbleTargetEffect(Duration.EndOfTurn);
effect3.setText("They block this turn if able");
game.addEffect(effect3, source);
return true;
}
return false;
}
}
class DomineeringWillControlEffect extends ContinuousEffectImpl {
public DomineeringWillControlEffect() {
super(Duration.EndOfTurn, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
}
public DomineeringWillControlEffect(final DomineeringWillControlEffect effect) {
super(effect);
}
@Override
public DomineeringWillControlEffect copy() {
return new DomineeringWillControlEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (targetPlayer != null) {
boolean targetStillExists = false;
for (UUID permanentId : source.getTargets().get(1).getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
targetStillExists = true;
if (targetPlayer != null) {
permanent.changeControllerId(targetPlayer.getId(), game);
permanent.getAbilities().setControllerId(targetPlayer.getId());
} else {
permanent.changeControllerId(source.getControllerId(), game);
permanent.getAbilities().setControllerId(source.getControllerId());
}
}
}
if (!targetStillExists) {
// no valid target exists, effect can be discarded
discard();
}
return true;
}
return false;
}
}
class DomineeringWillUntapTargetEffect extends OneShotEffect {
public DomineeringWillUntapTargetEffect() {
super(Outcome.Untap);
}
public DomineeringWillUntapTargetEffect(final DomineeringWillUntapTargetEffect effect) {
super(effect);
}
@Override
public DomineeringWillUntapTargetEffect copy() {
return new DomineeringWillUntapTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
for (UUID target : source.getTargets().get(1).getTargets()) {
Permanent permanent = game.getPermanent(target);
if (permanent != null) {
permanent.untap(game);
}
}
return true;
}
}
class DomineeringWillBlocksIfAbleTargetEffect extends RequirementEffect {
public DomineeringWillBlocksIfAbleTargetEffect(Duration duration) {
super(duration);
}
public DomineeringWillBlocksIfAbleTargetEffect(final DomineeringWillBlocksIfAbleTargetEffect effect) {
super(effect);
}
@Override
public DomineeringWillBlocksIfAbleTargetEffect copy() {
return new DomineeringWillBlocksIfAbleTargetEffect(this);
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return source.getTargets().get(1).getTargets().contains(permanent.getId());
}
@Override
public boolean mustAttack(Game game) {
return false;
}
@Override
public boolean mustBlock(Game game) {
return false;
}
@Override
public boolean mustBlockAny(Game game) {
return true;
}
}

View file

@ -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.";
} }
} }