mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
refactors: common class for "return all xxx from your graveyard to the battlefield" (#13034)
* refactor: new ReturnFromYourGraveyardToBattlefieldAllEffect * refactor: new ShuffleYourGraveyardIntoLibraryEffect also new PutIntoGraveFromLibrarySourceTriggeredAbility
This commit is contained in:
parent
001f9e866f
commit
2969ba58be
32 changed files with 308 additions and 1024 deletions
|
|
@ -0,0 +1,27 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class PutIntoGraveFromLibrarySourceTriggeredAbility extends ZoneChangeTriggeredAbility {
|
||||
|
||||
public PutIntoGraveFromLibrarySourceTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public PutIntoGraveFromLibrarySourceTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.LIBRARY, Zone.GRAVEYARD, effect, "When {this} is put into your graveyard from your library, ", optional);
|
||||
}
|
||||
|
||||
protected PutIntoGraveFromLibrarySourceTriggeredAbility(final PutIntoGraveFromLibrarySourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PutIntoGraveFromLibrarySourceTriggeredAbility copy() {
|
||||
return new PutIntoGraveFromLibrarySourceTriggeredAbility(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -13,8 +12,8 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class DestroyAllEffect extends OneShotEffect {
|
||||
|
||||
private FilterPermanent filter;
|
||||
private boolean noRegen;
|
||||
private final FilterPermanent filter;
|
||||
private final boolean noRegen;
|
||||
|
||||
public DestroyAllEffect(FilterPermanent filter) {
|
||||
this(filter, false);
|
||||
|
|
@ -24,11 +23,7 @@ public class DestroyAllEffect extends OneShotEffect {
|
|||
super(Outcome.DestroyPermanent);
|
||||
this.filter = filter;
|
||||
this.noRegen = noRegen;
|
||||
if (noRegen) {
|
||||
staticText = "destroy all " + filter.getMessage() + ". They can't be regenerated";
|
||||
} else {
|
||||
staticText = "destroy all " + filter.getMessage();
|
||||
}
|
||||
this.staticText = "destroy all " + filter.getMessage() + (noRegen ? ". They can't be regenerated" : "");
|
||||
}
|
||||
|
||||
protected DestroyAllEffect(final DestroyAllEffect effect) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class ExileAllEffect extends OneShotEffect {
|
|||
super(Outcome.Exile);
|
||||
this.filter = filter;
|
||||
this.forSource = forSource;
|
||||
setText();
|
||||
this.staticText = "exile all " + filter.getMessage();
|
||||
}
|
||||
|
||||
protected ExileAllEffect(final ExileAllEffect effect) {
|
||||
|
|
@ -58,9 +58,4 @@ public class ExileAllEffect extends OneShotEffect {
|
|||
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("exile all ").append(filter.getMessage());
|
||||
staticText = sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class ReturnFromYourGraveyardToBattlefieldAllEffect extends OneShotEffect {
|
||||
|
||||
private final FilterCard filter;
|
||||
private final boolean tapped;
|
||||
|
||||
public ReturnFromYourGraveyardToBattlefieldAllEffect(FilterCard filter) {
|
||||
this(filter, false);
|
||||
}
|
||||
|
||||
public ReturnFromYourGraveyardToBattlefieldAllEffect(FilterCard filter, boolean tapped) {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.filter = filter;
|
||||
this.tapped = tapped;
|
||||
staticText = "return all " + filter.getMessage() + " from your graveyard to the battlefield" + (tapped ? " tapped" : "");
|
||||
}
|
||||
|
||||
protected ReturnFromYourGraveyardToBattlefieldAllEffect(final ReturnFromYourGraveyardToBattlefieldAllEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.tapped = effect.tapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
return controller.moveCards(controller.getGraveyard().getCards(filter, source.getControllerId(), source, game),
|
||||
Zone.BATTLEFIELD, source, game, tapped, false, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReturnFromYourGraveyardToBattlefieldAllEffect copy() {
|
||||
return new ReturnFromYourGraveyardToBattlefieldAllEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public class ShuffleYourGraveyardIntoLibraryEffect extends OneShotEffect {
|
||||
|
||||
public ShuffleYourGraveyardIntoLibraryEffect() {
|
||||
super(Outcome.Neutral);
|
||||
this.staticText = "shuffle your graveyard into your library";
|
||||
}
|
||||
|
||||
protected ShuffleYourGraveyardIntoLibraryEffect(final ShuffleYourGraveyardIntoLibraryEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShuffleYourGraveyardIntoLibraryEffect copy() {
|
||||
return new ShuffleYourGraveyardIntoLibraryEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
return controller != null && controller.shuffleCardsToLibrary(controller.getGraveyard(), game, source);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue