Merge pull request #6 from magefree/master

update
This commit is contained in:
Li REN 2013-06-15 01:14:08 -07:00
commit a1b065c170
4 changed files with 41 additions and 23 deletions

View file

@ -27,12 +27,17 @@
*/
package mage.sets.riseoftheeldrazi;
import mage.Constants.*;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -40,7 +45,6 @@ import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import mage.util.functions.EmptyApplyToPermanent;
import java.util.UUID;
/**
*
@ -106,32 +110,34 @@ class RenegadeDoppelgangerTriggeredAbility extends TriggeredAbilityImpl<Renegade
}
}
class RenegadeDoppelgangerEffect extends ContinuousEffectImpl<RenegadeDoppelgangerEffect> {
class RenegadeDoppelgangerEffect extends OneShotEffect<RenegadeDoppelgangerEffect> {
RenegadeDoppelgangerEffect() {
super(Duration.EndOfTurn, Layer.CopyEffects_1, SubLayer.NA, Outcome.Copy);
public RenegadeDoppelgangerEffect() {
super(Outcome.Benefit);
this.staticText = "have {this} become a copy of that creature until end of turn";
}
RenegadeDoppelgangerEffect(final RenegadeDoppelgangerEffect effect) {
public RenegadeDoppelgangerEffect(final RenegadeDoppelgangerEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
Permanent permanent = game.getPermanent(source.getSourceId());
if (creature == null || permanent == null) {
return false;
}
game.copyPermanent(creature, permanent, source, new EmptyApplyToPermanent());
return true;
}
@Override
public RenegadeDoppelgangerEffect copy() {
return new RenegadeDoppelgangerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent targetCreature = game.getPermanent(targetPointer.getFirst(game, source));
if (targetCreature == null) {
targetCreature = (Permanent) game.getLastKnownInformation(getTargetPointer().getFirst(game, source), Zone.BATTLEFIELD);
}
if (targetCreature == null || permanent == null) {
return false;
}
game.copyPermanent(Duration.EndOfTurn, targetCreature, permanent, source, new EmptyApplyToPermanent());
return false;
}
}

View file

@ -50,7 +50,11 @@ public class CopyEffect extends ContinuousEffectImpl<CopyEffect> {
private UUID sourceId;
public CopyEffect(Permanent target, UUID sourceId) {
super(Duration.Custom, Layer.CopyEffects_1, SubLayer.NA, Outcome.BecomeCreature);
this(Duration.Custom, target, sourceId);
}
public CopyEffect(Duration duration, Permanent target, UUID sourceId) {
super(duration, Layer.CopyEffects_1, SubLayer.NA, Outcome.BecomeCreature);
this.target = target;
this.sourceId = sourceId;
}

View file

@ -65,6 +65,7 @@ import mage.util.functions.ApplyToPermanent;
import java.io.Serializable;
import java.util.*;
import mage.Constants.Duration;
public interface Game extends MageItem, Serializable {
@ -189,6 +190,8 @@ public interface Game extends MageItem, Serializable {
* @param applier
*/
Permanent copyPermanent(Permanent copyFromPermanent, Permanent copyToPermanent, Ability source, ApplyToPermanent applier);
Permanent copyPermanent(Duration duration, Permanent copyFromPermanent, Permanent copyToPermanent, Ability source, ApplyToPermanent applier);
Card copyCard(Card cardToCopy, Ability source, UUID newController);

View file

@ -997,6 +997,11 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
@Override
public Permanent copyPermanent(Permanent copyFromPermanent, Permanent copyToPermanent, Ability source, ApplyToPermanent applier) {
return copyPermanent(Duration.Custom, copyFromPermanent, copyToPermanent, source, applier);
}
@Override
public Permanent copyPermanent(Duration duration, Permanent copyFromPermanent, Permanent copyToPermanent, Ability source, ApplyToPermanent applier) {
Permanent permanent = copyFromPermanent.copy();
//getState().addCard(permanent);
@ -1009,7 +1014,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
Ability newAbility = source.copy();
CopyEffect newEffect = new CopyEffect(permanent, copyToPermanent.getId());
CopyEffect newEffect = new CopyEffect(duration, permanent, copyToPermanent.getId());
newEffect.newId();
newEffect.setTimestamp();
newEffect.init(newAbility, this);