mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Moved some setters from Card to Permanent
This commit is contained in:
parent
e836671d22
commit
620a3b9a52
10 changed files with 58 additions and 190 deletions
|
@ -99,7 +99,6 @@ class PraetorsGraspEffect extends OneShotEffect {
|
|||
Card card = opponent.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
card.setFaceDown(true);
|
||||
card.setControllerId(player.getId());
|
||||
card.moveToExile(getId(), sourcePermanent.getName(), source.getSourceId(), game);
|
||||
game.addEffect(new PraetorsGraspPlayEffect(card.getId()), source);
|
||||
game.addEffect(new PraetorsGraspRevealEffect(card.getId()), source);
|
||||
|
|
|
@ -46,10 +46,7 @@ public interface Card extends MageObject {
|
|||
|
||||
UUID getOwnerId();
|
||||
int getCardNumber();
|
||||
void setCardNumber(int cid);
|
||||
Rarity getRarity();
|
||||
void setRarity(Rarity rarity);
|
||||
void setControllerId(UUID controllerId);
|
||||
void setOwnerId(UUID ownerId);
|
||||
void addAbility(Ability ability);
|
||||
void addWatcher(Watcher watcher);
|
||||
|
@ -59,20 +56,16 @@ public interface Card extends MageObject {
|
|||
List<Watcher> getWatchers();
|
||||
String getExpansionSetCode();
|
||||
String getTokenSetCode();
|
||||
void setExpansionSetCode(String expansionSetCode);
|
||||
void setFaceDown(boolean value);
|
||||
boolean isFaceDown();
|
||||
boolean turnFaceUp(Game game, UUID playerId);
|
||||
boolean turnFaceDown(Game game, UUID playerId);
|
||||
boolean isFlipCard();
|
||||
String getFlipCardName();
|
||||
void setFlipCard(boolean flipCard);
|
||||
void setFlipCardName(String flipCardName);
|
||||
boolean isSplitCard();
|
||||
|
||||
boolean canTransform();
|
||||
Card getSecondCardFace();
|
||||
void setSecondCardFace(Card card);
|
||||
boolean isNightCard();
|
||||
|
||||
void assignNewId();
|
||||
|
|
|
@ -63,7 +63,6 @@ import mage.game.Game;
|
|||
import mage.game.command.Commander;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
|
@ -218,11 +217,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
return rarity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRarity(Rarity rarity) {
|
||||
this.rarity = rarity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRules() {
|
||||
try {
|
||||
|
@ -268,11 +262,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
return spellAbility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControllerId(UUID controllerId) {
|
||||
abilities.setControllerId(controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwnerId(UUID ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
|
@ -294,11 +283,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
return tokenSetCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpansionSetCode(String expansionSetCode) {
|
||||
this.expansionSetCode = expansionSetCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getMana() {
|
||||
List<Mana> mana = new ArrayList<>();
|
||||
|
@ -411,7 +395,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
.append("] source [").append(sourceCard != null ? sourceCard.getName():"null").append("]").toString());
|
||||
return false;
|
||||
}
|
||||
setControllerId(event.getPlayerId());
|
||||
game.setZone(objectId, event.getToZone());
|
||||
game.addSimultaneousEvent(event);
|
||||
return game.getState().getZone(objectId) == toZone;
|
||||
|
@ -572,11 +555,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCardNumber(int cid) {
|
||||
this.cardNumber = cid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFaceDown(boolean value) {
|
||||
faceDown = value;
|
||||
|
@ -626,11 +604,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
return this.secondSideCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondCardFace(Card card) {
|
||||
this.secondSideCard = card;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNightCard() {
|
||||
return this.nightCard;
|
||||
|
@ -646,17 +619,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
return flipCardName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlipCard(boolean flipCard) {
|
||||
this.flipCard = flipCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlipCardName(String flipCardName) {
|
||||
this.flipCardName = flipCardName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSplitCard() {
|
||||
return splitCard;
|
||||
|
|
|
@ -155,16 +155,9 @@ public abstract class SplitCard extends CardImpl {
|
|||
return rules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControllerId(UUID controllerId) {
|
||||
abilities.setControllerId(controllerId);
|
||||
leftHalfCard.getAbilities().setControllerId(controllerId);
|
||||
rightHalfCard.getAbilities().setControllerId(controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwnerId(UUID ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
super.setOwnerId(ownerId);
|
||||
abilities.setControllerId(ownerId);
|
||||
leftHalfCard.getAbilities().setControllerId(ownerId);
|
||||
leftHalfCard.setOwnerId(ownerId);
|
||||
|
@ -205,6 +198,11 @@ class LeftHalfCard extends CardImpl {
|
|||
return new LeftHalfCard(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getOwnerId() {
|
||||
return splitCardParent.getOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImageName() {
|
||||
return splitCardParent.getImageName();
|
||||
|
@ -267,6 +265,11 @@ class RightHalfCard extends CardImpl {
|
|||
return new RightHalfCard(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getOwnerId() {
|
||||
return splitCardParent.getOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImageName() {
|
||||
return splitCardParent.getImageName();
|
||||
|
|
|
@ -1325,7 +1325,6 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
public Card copyCard(Card cardToCopy, Ability source, UUID newController) {
|
||||
Card copiedCard = cardToCopy.copy();
|
||||
copiedCard.assignNewId();
|
||||
copiedCard.setControllerId(newController);
|
||||
copiedCard.setCopy(true);
|
||||
Set<Card> cards = new HashSet<>();
|
||||
cards.add(copiedCard);
|
||||
|
|
|
@ -34,12 +34,14 @@ import java.util.UUID;
|
|||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Controllable;
|
||||
import mage.game.Game;
|
||||
|
||||
public interface Permanent extends Card, Controllable {
|
||||
|
||||
void setControllerId(UUID controllerId);
|
||||
boolean isTapped();
|
||||
boolean untap(Game game);
|
||||
boolean tap(Game game);
|
||||
|
@ -70,6 +72,13 @@ public interface Permanent extends Card, Controllable {
|
|||
boolean isMonstrous();
|
||||
void setMonstrous(boolean value);
|
||||
|
||||
void setCardNumber(int cid);
|
||||
void setExpansionSetCode(String expansionSetCode);
|
||||
void setRarity(Rarity rarity);
|
||||
void setFlipCard(boolean flipCard);
|
||||
void setFlipCardName(String flipCardName);
|
||||
void setSecondCardFace(Card card);
|
||||
|
||||
List<UUID> getAttachments();
|
||||
UUID getAttachedTo();
|
||||
void attachTo(UUID permanentId, Game game);
|
||||
|
|
|
@ -57,6 +57,7 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.EffectType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
|
@ -169,6 +170,12 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControllerId(UUID controllerId) {
|
||||
this.controllerId = controllerId;
|
||||
abilities.setControllerId(controllerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before each applyEffects or if after a permanent was copied for the copied object
|
||||
*
|
||||
|
@ -1180,4 +1187,35 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
morphed = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCardNumber(int cid) {
|
||||
this.cardNumber = cid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpansionSetCode(String expansionSetCode) {
|
||||
this.expansionSetCode = expansionSetCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRarity(Rarity rarity) {
|
||||
this.rarity = rarity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlipCard(boolean flipCard) {
|
||||
this.flipCard = flipCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlipCardName(String flipCardName) {
|
||||
this.flipCardName = flipCardName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondCardFace(Card card) {
|
||||
this.secondSideCard = card;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -548,9 +548,6 @@ public class Spell implements StackObject, Card {
|
|||
return card.getRarity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRarity(Rarity rarity) {}
|
||||
|
||||
@Override
|
||||
public List<CardType> getCardType() {
|
||||
if (this.getSpellAbility() instanceof BestowAbility) {
|
||||
|
@ -678,7 +675,6 @@ public class Spell implements StackObject, Card {
|
|||
return ability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControllerId(UUID controllerId) {
|
||||
this.ability.setControllerId(controllerId);
|
||||
for (SpellAbility spellAbility: spellAbilities) {
|
||||
|
@ -710,9 +706,6 @@ public class Spell implements StackObject, Card {
|
|||
return card.getTokenSetCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpansionSetCode(String expansionSetCode) {}
|
||||
|
||||
@Override
|
||||
public void setFaceDown(boolean value) {
|
||||
faceDown = value;
|
||||
|
@ -760,26 +753,11 @@ public class Spell implements StackObject, Card {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondCardFace(Card card) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNightCard() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlipCard(boolean flipCard) {
|
||||
throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlipCardName(String flipCardName) {
|
||||
throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Spell copy() {
|
||||
return new Spell(this);
|
||||
|
@ -876,11 +854,6 @@ public class Spell implements StackObject, Card {
|
|||
return card.getCardNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCardNumber(int cid) {
|
||||
card.setCardNumber(cid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUsesVariousArt() {
|
||||
return card.getUsesVariousArt();
|
||||
|
|
|
@ -55,7 +55,6 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.util.functions.CopyFunction;
|
||||
import mage.util.functions.CopyTokenFunction;
|
||||
|
||||
|
||||
|
@ -379,16 +378,6 @@ public class CardUtil {
|
|||
spellAbility.getManaCostsToPay().addAll(adjustedCost);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns function that copies params\abilities from one card to another.
|
||||
*
|
||||
* @param target
|
||||
*/
|
||||
@Deprecated
|
||||
//public static CopyFunction copyTo(Card target) {
|
||||
private static CopyFunction copyTo(Card target) {
|
||||
return new CopyFunction(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns function that copies params\abilities from one card to {@link Token}.
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.util.functions;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.CardType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
*/
|
||||
public class CopyFunction implements Function<Card, Card> {
|
||||
|
||||
protected Card target;
|
||||
protected Game game;
|
||||
|
||||
public CopyFunction(Card target) {
|
||||
if (target == null) {
|
||||
throw new IllegalArgumentException("Target can't be null");
|
||||
}
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Card apply(Card source) {
|
||||
if (target == null) {
|
||||
throw new IllegalArgumentException("Target can't be null");
|
||||
}
|
||||
|
||||
target.setName(source.getName());
|
||||
target.getColor().setColor(source.getColor());
|
||||
target.getManaCost().clear();
|
||||
target.getManaCost().add(source.getManaCost());
|
||||
target.getCardType().clear();
|
||||
for (CardType type : source.getCardType()) {
|
||||
target.getCardType().add(type);
|
||||
}
|
||||
target.getSubtype().clear();
|
||||
for (String type : source.getSubtype()) {
|
||||
target.getSubtype().add(type);
|
||||
}
|
||||
target.getSupertype().clear();
|
||||
for (String type : source.getSupertype()) {
|
||||
target.getSupertype().add(type);
|
||||
}
|
||||
target.setExpansionSetCode(source.getExpansionSetCode());
|
||||
target.getAbilities().clear();
|
||||
|
||||
for (Ability ability0 : source.getAbilities()) {
|
||||
Ability ability = ability0.copy();
|
||||
ability.newId();
|
||||
ability.setSourceId(target.getId());
|
||||
if(target instanceof Permanent) {
|
||||
((Permanent)target).addAbility(ability, game);
|
||||
} else {
|
||||
target.addAbility(ability);
|
||||
}
|
||||
}
|
||||
|
||||
target.getPower().setValue(source.getPower().getValue());
|
||||
target.getToughness().setValue(source.getToughness().getValue());
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
public Card from(Card source, Game game) {
|
||||
this.game = game;
|
||||
return apply(source);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue