forked from External/mage
* Reworked some card movement to player methods (#4866).
This commit is contained in:
parent
aad36dda19
commit
083c4bc5d4
27 changed files with 247 additions and 373 deletions
|
|
@ -1,17 +1,12 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
|
@ -20,17 +15,20 @@ import mage.players.Player;
|
|||
*/
|
||||
public class ShuffleIntoLibraryTargetEffect extends OneShotEffect {
|
||||
|
||||
boolean optional;
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect() {
|
||||
super(Outcome.Detriment);
|
||||
this(false);
|
||||
}
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect(String effectText) {
|
||||
public ShuffleIntoLibraryTargetEffect(boolean optional) {
|
||||
super(Outcome.Detriment);
|
||||
this.staticText = effectText;
|
||||
this.optional = optional;
|
||||
}
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect(final ShuffleIntoLibraryTargetEffect effect) {
|
||||
super(effect);
|
||||
this.optional = effect.optional;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -40,19 +38,26 @@ public class ShuffleIntoLibraryTargetEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
MageObject cardObject = game.getObject(getTargetPointer().getFirst(game, source));
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (permanent != null && controller != null) {
|
||||
if (controller.moveCards(permanent, Zone.LIBRARY, source, game)) {
|
||||
game.getPlayer(permanent.getOwnerId()).shuffleLibrary(source, game);
|
||||
if (cardObject != null && controller != null && cardObject instanceof Card) {
|
||||
if (!optional
|
||||
|| controller.chooseUse(Outcome.Benefit, "Do you wish to shuffle " + cardObject.getIdName() + " into "
|
||||
+ (((Card) cardObject).getOwnerId().equals(source.getControllerId()) ? "your" : "its owners")
|
||||
+ " library?", source, game)) {
|
||||
Player owner = game.getPlayer(((Card) cardObject).getOwnerId());
|
||||
if (owner != null) {
|
||||
return owner.shuffleCardsToLibrary(((Card) cardObject), game, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
public String getText(Mode mode
|
||||
) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue