Added copyCard method into Game interface

This commit is contained in:
magenoxx 2012-07-23 08:24:10 +04:00
parent 169277dd7b
commit 435798f7d5
3 changed files with 18 additions and 1 deletions

View file

@ -178,6 +178,8 @@ public interface Game extends MageItem, Serializable {
*/
public void copyPermanent(Permanent copyFromPermanent, Permanent copyToPermanent, Ability source, ApplyToPermanent applier);
public Card copyCard(Card cardToCopy, Ability source, UUID newController);
public void addTriggeredAbility(TriggeredAbility ability);
public void addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility);
public void applyEffects();

View file

@ -867,6 +867,19 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
state.addEffect(newEffect, newAbility);
}
@Override
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<Card>();
cards.add(copiedCard);
loadCards(cards, source.getControllerId());
return copiedCard;
}
@Override
public void addTriggeredAbility(TriggeredAbility ability) {
if (ability instanceof TriggeredManaAbility) {

View file

@ -101,8 +101,10 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
return result;
}
}
if (!card.isCopy()) {
card.moveToZone(Zone.GRAVEYARD, ability.getId(), game, false);
}
}
return result;
}