mirror of
https://github.com/correl/mage.git
synced 2025-04-07 17:00:08 -09:00
Cleaned up ReturnToHandChosenControllesPermanentEffect.
This commit is contained in:
parent
76a7aeb957
commit
f2cf08d5b2
3 changed files with 14 additions and 34 deletions
Mage.Sets/src/mage/sets/planarchaos
Mage/src/mage/abilities/effects/common
|
@ -29,7 +29,6 @@ package mage.sets.planarchaos;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
import mage.abilities.effects.common.ReturnToHandChosenControlledPermanentEffect;
|
import mage.abilities.effects.common.ReturnToHandChosenControlledPermanentEffect;
|
||||||
import mage.abilities.keyword.FlashAbility;
|
import mage.abilities.keyword.FlashAbility;
|
||||||
|
@ -38,12 +37,7 @@ import mage.abilities.keyword.FearAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.players.Player;
|
|
||||||
import mage.target.common.TargetControlledPermanent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -65,8 +59,9 @@ public class DustElemental extends CardImpl {
|
||||||
// Flying; fear
|
// Flying; fear
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
this.addAbility(FearAbility.getInstance());
|
this.addAbility(FearAbility.getInstance());
|
||||||
|
|
||||||
// When Dust Elemental enters the battlefield, return three creatures you control to their owner's hand.
|
// When Dust Elemental enters the battlefield, return three creatures you control to their owner's hand.
|
||||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new ReturnToHandChosenControlledPermanentEffect(filter,1,3)));
|
this.addAbility(new EntersBattlefieldTriggeredAbility(new ReturnToHandChosenControlledPermanentEffect(filter, 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DustElemental(final DustElemental card) {
|
public DustElemental(final DustElemental card) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class StormfrontRiders extends CardImpl {
|
||||||
// Flying
|
// Flying
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
// When Stormfront Riders enters the battlefield, return two creatures you control to their owner's hand.
|
// When Stormfront Riders enters the battlefield, return two creatures you control to their owner's hand.
|
||||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new ReturnToHandChosenControlledPermanentEffect(new FilterControlledCreaturePermanent("creatures you control"),1,2)));
|
this.addAbility(new EntersBattlefieldTriggeredAbility(new ReturnToHandChosenControlledPermanentEffect(new FilterControlledCreaturePermanent("creatures you control"), 2)));
|
||||||
// Whenever Stormfront Riders or another creature is returned to your hand from the battlefield, put a 1/1 white Soldier creature token onto the battlefield.
|
// Whenever Stormfront Riders or another creature is returned to your hand from the battlefield, put a 1/1 white Soldier creature token onto the battlefield.
|
||||||
this.addAbility(new ZoneChangeAllTriggeredAbility(Zone.BATTLEFIELD, Zone.BATTLEFIELD, Zone.HAND, new CreateTokenEffect(new SoldierToken()),
|
this.addAbility(new ZoneChangeAllTriggeredAbility(Zone.BATTLEFIELD, Zone.BATTLEFIELD, Zone.HAND, new CreateTokenEffect(new SoldierToken()),
|
||||||
filter,"Whenever {this} or another creature is returned to your hand from the battlefield, ", false));
|
filter,"Whenever {this} or another creature is returned to your hand from the battlefield, ", false));
|
||||||
|
|
|
@ -27,14 +27,13 @@
|
||||||
*/
|
*/
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.cards.CardsImpl;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.common.FilterControlledPermanent;
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetControlledPermanent;
|
import mage.target.common.TargetControlledPermanent;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
@ -44,27 +43,18 @@ import mage.util.CardUtil;
|
||||||
* @author Plopmans
|
* @author Plopmans
|
||||||
*/
|
*/
|
||||||
public class ReturnToHandChosenControlledPermanentEffect extends OneShotEffect {
|
public class ReturnToHandChosenControlledPermanentEffect extends OneShotEffect {
|
||||||
|
|
||||||
private final FilterControlledPermanent filter;
|
private final FilterControlledPermanent filter;
|
||||||
private int number;
|
private int number;
|
||||||
private int minNumber;
|
|
||||||
|
|
||||||
public ReturnToHandChosenControlledPermanentEffect(FilterControlledPermanent filter) {
|
public ReturnToHandChosenControlledPermanentEffect(FilterControlledPermanent filter) {
|
||||||
this(filter, 1);
|
this(filter, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReturnToHandChosenControlledPermanentEffect(FilterControlledPermanent filter, int number) {
|
public ReturnToHandChosenControlledPermanentEffect(FilterControlledPermanent filter, int number) {
|
||||||
super(Outcome.ReturnToHand);
|
super(Outcome.ReturnToHand);
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.number = number;
|
this.number = number;
|
||||||
this.minNumber = number;
|
|
||||||
this.staticText = getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReturnToHandChosenControlledPermanentEffect(FilterControlledPermanent filter, int minNumber, int maxNumber) {
|
|
||||||
super(Outcome.ReturnToHand);
|
|
||||||
this.filter = filter;
|
|
||||||
this.number = maxNumber;
|
|
||||||
this.minNumber = minNumber;
|
|
||||||
this.staticText = getText();
|
this.staticText = getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,10 +62,7 @@ public class ReturnToHandChosenControlledPermanentEffect extends OneShotEffect {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.filter = effect.filter;
|
this.filter = effect.filter;
|
||||||
this.number = effect.number;
|
this.number = effect.number;
|
||||||
this.minNumber = this.minNumber;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnToHandChosenControlledPermanentEffect copy() {
|
public ReturnToHandChosenControlledPermanentEffect copy() {
|
||||||
|
@ -84,15 +71,13 @@ public class ReturnToHandChosenControlledPermanentEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (player != null) {
|
if (controller != null) {
|
||||||
TargetControlledPermanent target = new TargetControlledPermanent(minNumber, number, filter, true);
|
int available = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
|
||||||
if (player.choose(this.outcome, target, source.getSourceId(), game)) {
|
if (available > 0) {
|
||||||
for (UUID targetCreatureId : target.getTargets()) {
|
TargetControlledPermanent target = new TargetControlledPermanent(Math.min(number, available), number, filter, true);
|
||||||
Permanent permanent = game.getPermanent(targetCreatureId);
|
if (controller.chooseTarget(this.outcome, target, source, game)) {
|
||||||
if (permanent != null) {
|
controller.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, Zone.HAND, source, game);
|
||||||
player.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue