* Some fixes for getting source object on battlefield only if it not had a zone change meanwhile.

This commit is contained in:
LevelX2 2015-04-07 17:37:03 +02:00
parent 393444a87b
commit a62fc1f77c
6 changed files with 19 additions and 7 deletions

View file

@ -109,9 +109,11 @@ class TreacherousPitDwellerEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
if (permanent != null) {
return permanent.changeControllerId(source.getFirstTarget(), game);
} else {
discard();
}
return false;
}

View file

@ -199,7 +199,7 @@ class ShurikenControlEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent equipment = null;
Permanent equipment = null; // TODO: Meanwhile blinked object would be found regardless
for(Cost cost : source.getCosts()) {
if (cost instanceof ShurikenUnattachCost) {
equipment = ((ShurikenUnattachCost) cost).getEquipment();

View file

@ -53,7 +53,11 @@ public class JinxedIdol extends CardImpl {
public JinxedIdol(UUID ownerId) {
super(ownerId, 208, "Jinxed Idol", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "M11";
// At the beginning of your upkeep, Jinxed Idol deals 2 damage to you.
this.addAbility(new OnEventTriggeredAbility(EventType.UPKEEP_STEP_PRE, "beginning of your upkeep", new DamageControllerEffect(2)));
// Sacrifice a creature: Target opponent gains control of Jinxed Idol.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new JinxedIdolEffect(), new SacrificeTargetCost(new TargetControlledCreaturePermanent()));
ability.addTarget(new TargetOpponent());
this.addAbility(ability);
@ -88,9 +92,11 @@ class JinxedIdolEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
if (permanent != null) {
return permanent.changeControllerId(source.getFirstTarget(), game);
} else {
discard();
}
return false;
}

View file

@ -132,7 +132,7 @@ class ContestedWarZoneAbility extends TriggeredAbilityImpl {
class ContestedWarZoneEffect extends ContinuousEffectImpl {
public ContestedWarZoneEffect() {
super(Duration.EndOfGame, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
super(Duration.Custom, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
}
public ContestedWarZoneEffect(final ContestedWarZoneEffect effect) {
@ -146,10 +146,12 @@ class ContestedWarZoneEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
UUID controllerId = (UUID) game.getState().getValue(source.getSourceId().toString());
if (permanent != null && controllerId != null) {
return permanent.changeControllerId(controllerId, game);
} else {
discard();
}
return false;
}

View file

@ -113,7 +113,7 @@ class MeasureOfWickednessControlSourceEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Player targetOpponent = game.getPlayer(source.getFirstTarget());
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
if (permanent != null && targetOpponent != null) {
permanent.changeControllerId(targetOpponent.getId(), game);
} else {

View file

@ -93,9 +93,11 @@ class GoblinCadetsChangeControlEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
if (permanent != null) {
return permanent.changeControllerId(source.getFirstTarget(), game);
} else {
discard();
}
return false;
}