mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
* 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 {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package mage.players;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import mage.MageItem;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectReference;
|
||||
import mage.Mana;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.costs.AlternativeSourceCosts;
|
||||
import mage.abilities.costs.Cost;
|
||||
|
|
@ -38,10 +41,6 @@ import mage.target.TargetCard;
|
|||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.util.Copyable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import mage.Mana;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
|
@ -366,8 +365,9 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param game
|
||||
* @param noMana if it's a spell i can be cast without paying mana
|
||||
* @param ignoreTiming if it's cast during the resolution of another spell
|
||||
* no sorcery or play land timing restriction are checked. For a land it has
|
||||
* to be the turn of the player playing that card.
|
||||
* no sorcery or play land timing restriction are
|
||||
* checked. For a land it has to be the turn of the
|
||||
* player playing that card.
|
||||
* @param reference mage object that allows to play the card
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -377,8 +377,9 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param card the land card to play
|
||||
* @param game
|
||||
* @param ignoreTiming false - it won't be checked if the stack is empty and
|
||||
* you are able to play a Sorcery. It's still checked, if you are able to
|
||||
* play a land concerning the number of lands you already played.
|
||||
* you are able to play a Sorcery. It's still checked,
|
||||
* if you are able to play a land concerning the number
|
||||
* of lands you already played.
|
||||
* @return
|
||||
*/
|
||||
boolean playLand(Card card, Game game, boolean ignoreTiming);
|
||||
|
|
@ -446,11 +447,11 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
void revealCards(Ability source, Cards cards, Game game);
|
||||
|
||||
void revealCards(String name, Cards cards, Game game);
|
||||
void revealCards(String titelSuffix, Cards cards, Game game);
|
||||
|
||||
void revealCards(Ability source, String name, Cards cards, Game game);
|
||||
void revealCards(Ability source, String titelSuffix, Cards cards, Game game);
|
||||
|
||||
void revealCards(String name, Cards cards, Game game, boolean postToLog);
|
||||
void revealCards(String titelSuffix, Cards cards, Game game, boolean postToLog);
|
||||
|
||||
/**
|
||||
* Adds the cards to the reveal window and adds the source object's id name
|
||||
|
|
@ -532,10 +533,11 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param cards - list of cards that have to be moved
|
||||
* @param game - game
|
||||
* @param anyOrder - true = if player can determine the order of the cards
|
||||
* else false = random order
|
||||
* 401.4. If an effect puts two or more cards in a specific position in a library
|
||||
* at the same time, the owner of those cards may arrange them in any order.
|
||||
* That library’s owner doesn’t reveal the order in which the cards go into the library.
|
||||
* else false = random order 401.4. If an effect puts two or
|
||||
* more cards in a specific position in a library at the
|
||||
* same time, the owner of those cards may arrange them in
|
||||
* any order. That library’s owner doesn’t reveal the order
|
||||
* in which the cards go into the library.
|
||||
* @param source - source ability
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -636,9 +638,9 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
void untap(Game game);
|
||||
|
||||
ManaOptions getManaAvailable(Game game);
|
||||
|
||||
|
||||
void addAvailableTriggeredMana(List<Mana> netManaAvailable);
|
||||
|
||||
|
||||
List<List<Mana>> getAvailableTriggeredMana();
|
||||
|
||||
List<ActivatedAbility> getPlayable(Game game, boolean hidden);
|
||||
|
|
@ -747,9 +749,10 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* @param game
|
||||
* @param tapped the cards are tapped on the battlefield
|
||||
* @param faceDown the cards are face down in the to zone
|
||||
* @param byOwner the card is moved (or put onto battlefield) by the owner
|
||||
* of the card and if target zone is battlefield controls the permanent
|
||||
* (instead of the controller of the source)
|
||||
* @param byOwner the card is moved (or put onto battlefield) by the
|
||||
* owner of the card and if target zone is battlefield
|
||||
* controls the permanent (instead of the controller
|
||||
* of the source)
|
||||
* @param appliedEffects
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -967,7 +967,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
if (cards.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
game.informPlayers(getName() + " shuffels " + CardUtil.numberToText(cards.size(), "a")
|
||||
game.informPlayers(getLogName() + " shuffels " + CardUtil.numberToText(cards.size(), "a")
|
||||
+ " card" + (cards.size() == 1 ? "" : "s")
|
||||
+ " into their library.");
|
||||
boolean status = moveCards(cards, Zone.LIBRARY, source, game);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue