- refactoring related to #8375 "L/M/N/O/P/Q/R/S" cards

This commit is contained in:
Jeff Wadsworth 2021-10-22 11:49:00 -05:00
parent d42ca9767a
commit 8db2ba470b
41 changed files with 116 additions and 145 deletions

View file

@ -120,7 +120,8 @@ class AdarkarValkyrieDelayedTriggeredAbility extends DelayedTriggeredAbility {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((ZoneChangeEvent) event).isDiesEvent()
&& mor.refersTo(((ZoneChangeEvent) event).getTarget(), game)) {
&& mor.refersTo(((ZoneChangeEvent) event).getTarget(), game)
&& game.getState().getZone(event.getTargetId()) == Zone.GRAVEYARD) { // must be in the graveyard
getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
return true;

View file

@ -1,4 +1,3 @@
package mage.cards.m;
import java.util.UUID;
@ -80,14 +79,14 @@ class MammothHarnessTriggeredAbility extends BlocksOrBecomesBlockedSourceTrigger
if (event.getSourceId().equals(attachedTo.getId())) {
Permanent blocked = game.getPermanent(event.getTargetId());
if (blocked != null && filter.match(blocked, game)) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
return true;
}
}
if (event.getTargetId().equals(attachedTo.getId())) {
Permanent blocker = game.getPermanent(event.getSourceId());
if (blocker != null) {
this.getEffects().setTargetPointer(new FixedTarget(event.getSourceId()));
this.getEffects().setTargetPointer(new FixedTarget(event.getSourceId(), game));
return true;
}
}

View file

@ -88,11 +88,11 @@ class MassMutinyEffect extends OneShotEffect {
Permanent targetCreature = game.getPermanent(target.getFirstTarget());
if (targetCreature != null) {
ContinuousEffect effect1 = new GainControlTargetEffect(Duration.EndOfTurn);
effect1.setTargetPointer(new FixedTarget(targetCreature.getId()));
effect1.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect1, source);
ContinuousEffect effect2 = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect2.setTargetPointer(new FixedTarget(targetCreature.getId()));
effect2.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect2, source);
targetCreature.untap(game);

View file

@ -1,4 +1,3 @@
package mage.cards.m;
import java.util.List;
@ -83,7 +82,7 @@ class MobRuleEffect extends OneShotEffect {
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(filter, game);
for (Permanent creature : creatures) {
ContinuousEffect effect = new MobRuleControlAllEffect(source.getControllerId());
effect.setTargetPointer(new FixedTarget(creature.getId()));
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
game.addEffect(effect, source);
applied = true;
}
@ -93,7 +92,7 @@ class MobRuleEffect extends OneShotEffect {
}
for (Permanent creature : creatures) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature.getId()));
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
game.addEffect(effect, source);
applied = true;
}

View file

@ -100,11 +100,11 @@ class MoltenPrimordialEffect extends OneShotEffect {
Permanent targetCreature = game.getPermanent(target.getFirstTarget());
if (targetCreature != null) {
ContinuousEffect effect1 = new GainControlTargetEffect(Duration.EndOfTurn);
effect1.setTargetPointer(new FixedTarget(targetCreature.getId()));
effect1.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect1, source);
ContinuousEffect effect2 = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect2.setTargetPointer(new FixedTarget(targetCreature.getId()));
effect2.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect2, source);
targetCreature.untap(game);

View file

@ -81,7 +81,7 @@ class MyrBattlesphereTriggeredAbility extends TriggeredAbilityImpl {
Permanent source = game.getPermanent(event.getSourceId());
if (source != null && source.getId().equals(this.getSourceId())) {
UUID defenderId = game.getCombat().getDefenderId(event.getSourceId());
this.getEffects().get(0).setTargetPointer(new FixedTarget(defenderId));
this.getEffects().get(0).setTargetPointer(new FixedTarget(defenderId, game));
return true;
}
return false;

View file

@ -88,7 +88,7 @@ class MysticReflectionEffect extends OneShotEffect {
// The zone is ALL because if the targeted permanent leaves the battlefield, the replacement effect still applies.
SimpleStaticAbility staticAbilityOnCard = new SimpleStaticAbility(Zone.ALL, new MysticReflectionReplacementEffect(watcher.getEnteredThisTurn(), source.getSourceId().toString()));
MysticReflectionGainAbilityEffect gainAbilityEffect = new MysticReflectionGainAbilityEffect(staticAbilityOnCard);
gainAbilityEffect.setTargetPointer(new FixedTarget(targetedPermanent.getMainCard().getId()));
gainAbilityEffect.setTargetPointer(new FixedTarget(targetedPermanent.getMainCard().getId(), game));
game.addEffect(gainAbilityEffect, source);
return true;
}

View file

@ -1,4 +1,3 @@
package mage.cards.n;
import mage.MageObject;
@ -88,13 +87,14 @@ class NecromanticSelectionEffect extends OneShotEffect {
}
filter.add(Predicates.or(cardIdPredicates));
Target target = new TargetCardInGraveyard(filter);
if (controller.chooseTarget(outcome, target, source, game)) {
target.setNotTarget(true);
if (controller.chooseTarget(Outcome.Benefit, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
effect.setText("It's a black Zombie in addition to its other colors and types");
effect.setTargetPointer(new FixedTarget(card.getId()));
effect.setTargetPointer(new FixedTarget(card.getId(), game));
game.addEffect(effect, source);
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.n;
import java.util.UUID;
@ -17,7 +16,6 @@ import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
@ -31,7 +29,6 @@ public final class NecropolisRegent extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{B}{B}");
this.subtype.add(SubType.VAMPIRE);
this.power = new MageInt(6);
this.toughness = new MageInt(5);
@ -79,7 +76,7 @@ class NecropolisRegentTriggeredAbility extends TriggeredAbilityImpl {
if (creature != null && creature.isControlledBy(controllerId)) {
this.getEffects().clear();
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(event.getAmount()));
effect.setTargetPointer(new FixedTarget(creature.getId()));
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
this.addEffect(effect);
return true;
}

View file

@ -1,4 +1,3 @@
package mage.cards.n;
import java.util.UUID;
@ -102,7 +101,7 @@ class NettlingImpDelayedDestroyEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
DestroyTargetEffect effect = new DestroyTargetEffect();
effect.setTargetPointer(new FixedTarget(source.getFirstTarget()));
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility
= new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.ALL, effect, TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance));
delayedAbility.getDuration();

View file

@ -102,7 +102,7 @@ class NorrittDelayedDestroyEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
DestroyTargetEffect effect = new DestroyTargetEffect();
effect.setTargetPointer(new FixedTarget(source.getFirstTarget()));
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility
= new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.ALL, effect, TargetController.ANY, new InvertCondition(TargetAttackedThisTurnCondition.instance));
delayedAbility.getDuration();

View file

@ -1,4 +1,3 @@
package mage.cards.n;
import java.util.UUID;
@ -90,8 +89,8 @@ class NoyanDarEffect extends OneShotEffect {
targetId = target.getFirstTarget();
}
if (targetId != null) {
FixedTarget fixedTarget = new FixedTarget(targetId);
ContinuousEffect continuousEffect = new BecomesCreatureTargetEffect(new AwakenElementalToken(), false, true, Duration.Custom);
FixedTarget fixedTarget = new FixedTarget(targetId, game);
ContinuousEffect continuousEffect = new BecomesCreatureTargetEffect(new AwakenElementalToken(), false, true, Duration.EndOfGame);
continuousEffect.setTargetPointer(fixedTarget);
game.addEffect(continuousEffect, source);
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(3));
@ -102,7 +101,6 @@ class NoyanDarEffect extends OneShotEffect {
}
}
class AwakenElementalToken extends TokenImpl {
public AwakenElementalToken() {
@ -115,6 +113,7 @@ class AwakenElementalToken extends TokenImpl {
this.addAbility(HasteAbility.getInstance());
}
public AwakenElementalToken(final AwakenElementalToken token) {
super(token);
}

View file

@ -66,9 +66,9 @@ class OracleEnVecEffect extends OneShotEffect {
OracleEnVecEffect() {
super(Outcome.Benefit);
this.staticText = "Target opponent chooses any number of creatures they control. During that player's next turn, " +
"the chosen creatures attack if able, and other creatures can't attack. At the beginning of that turn's end step, " +
"destroy each of the chosen creatures that didn't attack this turn";
this.staticText = "Target opponent chooses any number of creatures they control. During that player's next turn, "
+ "the chosen creatures attack if able, and other creatures can't attack. At the beginning of that turn's end step, "
+ "destroy each of the chosen creatures that didn't attack this turn";
}
OracleEnVecEffect(final OracleEnVecEffect effect) {
@ -270,7 +270,7 @@ class OracleEnVecDestroyEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) {
Effect effect = new DestroyTargetEffect();
effect.setTargetPointer(new FixedTarget(targetId));
effect.setTargetPointer(new FixedTarget(targetId, game));
effect.apply(game, source);
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.o;
import java.util.HashMap;
@ -116,7 +115,7 @@ class OrderOfSuccessionEffect extends OneShotEffect {
Permanent creature = game.getPermanent(entry.getValue());
if (creature != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame, player.getId());
effect.setTargetPointer(new FixedTarget(creature.getId()));
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
game.addEffect(effect, source);
game.informPlayers(new StringBuilder(player.getLogName()).append(" gains control of ").append(creature.getName()).toString());
}

View file

@ -1,4 +1,3 @@
package mage.cards.p;
import mage.abilities.Ability;
@ -66,12 +65,13 @@ class PacksDisdainEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
if (player != null && player.choose(Outcome.UnboostCreature, typeChoice, game)) {
if (player != null
&& player.choose(Outcome.UnboostCreature, typeChoice, game)) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
DynamicValue negativePermanentsCount = new PermanentsOnBattlefieldCount(filter, -1);
ContinuousEffect effect = new BoostTargetEffect(negativePermanentsCount, negativePermanentsCount, Duration.EndOfTurn, true);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget()));
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
game.addEffect(effect, source);
return true;
}

View file

@ -97,7 +97,7 @@ class ParoxysmEffect extends OneShotEffect {
creatureAttachedTo.destroy(source, game, false);
} else {
ContinuousEffect effect = new BoostTargetEffect(3, 3, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creatureAttachedTo.getId()));
effect.setTargetPointer(new FixedTarget(creatureAttachedTo.getId(), game));
game.addEffect(effect, source);
}
return true;

View file

@ -1,4 +1,3 @@
package mage.cards.p;
import java.util.UUID;
@ -99,9 +98,10 @@ class PatronOfTheVeinCreatureDiesTriggeredAbility extends TriggeredAbilityImpl {
if (((ZoneChangeEvent) event).isDiesEvent()) {
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
Card creature = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (creature != null && creature.isCreature(game)) {
if (creature != null
&& creature.isCreature(game)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(creature.getId()));
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
}
return true;
}
@ -149,7 +149,7 @@ class PatronOfTheVeinExileCreatureEffect extends OneShotEffect {
if (card != null) {
Effect effect = new ExileTargetEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
effect.setTargetPointer(new FixedTarget(card.getId(), game));
effect.apply(game, source);
}

View file

@ -25,7 +25,6 @@ import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.ToughnessPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
@ -88,15 +87,15 @@ class PhantasmalMountEffect extends OneShotEffect {
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
if (targetCreature != null) {
ContinuousEffect effect = new BoostTargetEffect(1, 1, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget()));
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
game.addEffect(effect, source);
Effect sacrificeCreatureEffect = new SacrificeTargetEffect();
Effect sacrificePhantasmalMountEffect = new SacrificeTargetEffect();
ContinuousEffect gainAbility = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
gainAbility.setTargetPointer(new FixedTarget(source.getFirstTarget()));
gainAbility.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
game.addEffect(gainAbility, source);
sacrificeCreatureEffect.setTargetPointer(new FixedTarget(source.getFirstTarget()));
sacrificePhantasmalMountEffect.setTargetPointer(new FixedTarget(source.getSourceId()));
sacrificeCreatureEffect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
sacrificePhantasmalMountEffect.setTargetPointer(new FixedTarget(source.getSourceId(), game));
DelayedTriggeredAbility dTA = new PhantasmalMountDelayedTriggeredAbility(
sacrificeCreatureEffect,
source.getSourceId());

View file

@ -80,7 +80,7 @@ class PreacherEffect extends OneShotEffect {
new GainControlTargetEffect(Duration.Custom),
sourceTappedCondition,
"Gain control of target creature of an opponent's choice that they control for as long as {this} remains tapped");
effect.setTargetPointer(new FixedTarget(targetPermanent.getId()));
effect.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
game.addEffect(effect, source);
return true;
}

View file

@ -1,5 +1,3 @@
package mage.cards.r;
import java.util.UUID;
@ -18,7 +16,6 @@ import mage.constants.SuperType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.target.targetpointer.FixedTarget;
/**
@ -30,7 +27,6 @@ public final class RafiqOfTheMany extends CardImpl {
public RafiqOfTheMany(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{W}{U}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.KNIGHT);
@ -80,7 +76,7 @@ class RafiqOfTheManyAbility extends TriggeredAbilityImpl {
if (game.isActivePlayer(this.controllerId)) {
if (game.getCombat().attacksAlone()) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackers().get(0)));
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackers().get(0), game));
}
return true;
}

View file

@ -144,7 +144,7 @@ class RagingRiverEffect extends OneShotEffect {
}
}
RestrictionEffect effect = new CantBeBlockedByAllTargetEffect(filter, Duration.EndOfCombat);
effect.setTargetPointer(new FixedTarget(attacker.getId()));
effect.setTargetPointer(new FixedTarget(attacker.getId(), game));
game.addEffect(effect, source);
}
}

View file

@ -86,8 +86,8 @@ class RichesEffect extends OneShotEffect {
// Has to be done as a separate loop in case there's a situation where one creature's
// controller depends on another creatures controller.
for (UUID target : creaturesToSteal) {
GainControlTargetEffect eff = new GainControlTargetEffect(Duration.Custom, true);
eff.setTargetPointer(new FixedTarget(target));
GainControlTargetEffect eff = new GainControlTargetEffect(Duration.EndOfGame, true);
eff.setTargetPointer(new FixedTarget(target, game));
game.addEffect(eff, source);
}

View file

@ -1,4 +1,3 @@
package mage.cards.r;
import java.util.UUID;
@ -12,7 +11,6 @@ import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
@ -25,7 +23,6 @@ public final class RakingCanopy extends CardImpl {
public RakingCanopy(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}{G}");
// Whenever a creature with flying attacks you, Raking Canopy deals 4 damage to it.
this.addAbility(new RakingCanopyTriggeredAbility());
}
@ -63,12 +60,13 @@ class RakingCanopyTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent attacker = game.getPermanent(event.getSourceId());
if (attacker == null || !attacker.getAbilities().contains(FlyingAbility.getInstance())) {
if (attacker == null
|| !attacker.getAbilities().contains(FlyingAbility.getInstance())) {
return false;
}
if (event.getTargetId().equals(this.getControllerId())) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(attacker.getId()));
effect.setTargetPointer(new FixedTarget(attacker.getId(), game));
}
return true;
}

View file

@ -1,4 +1,3 @@
package mage.cards.r;
import java.util.HashSet;
@ -87,12 +86,12 @@ class ReinsOfPowerEffect extends OneShotEffect {
}
for (UUID creatureId : yourCreatures) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn, opponentId);
effect.setTargetPointer(new FixedTarget(creatureId));
effect.setTargetPointer(new FixedTarget(creatureId, game));
game.addEffect(effect, source);
}
for (UUID creatureId : opponentCreatures) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creatureId));
effect.setTargetPointer(new FixedTarget(creatureId, game));
game.addEffect(effect, source);
}

View file

@ -1,4 +1,3 @@
package mage.cards.r;
import java.util.UUID;
@ -59,7 +58,6 @@ enum LostLifeCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
@ -92,7 +90,7 @@ class RevengeEffect extends OneShotEffect {
Permanent target = game.getPermanent(targetPointer.getFirst(game, source));
if (target != null && target.isCreature(game)) {
ContinuousEffect effect = new BoostTargetEffect(4, 0, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(target.getId()));
effect.setTargetPointer(new FixedTarget(target.getId(), game));
game.addEffect(effect, source);
return true;
}

View file

@ -1,4 +1,3 @@
package mage.cards.r;
import java.util.UUID;
@ -36,7 +35,6 @@ public final class RideDown extends CardImpl {
public RideDown(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{R}{W}");
// Destroy target blocking creature. Creatures that were blocked by that creature this combat gain trample until end of turn.
this.getSpellAbility().addEffect(new RideDownEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
@ -79,7 +77,7 @@ class RideDownEffect extends OneShotEffect {
if (combatGroup.getBlockers().contains(blockingCreature.getId())) {
for (UUID attackerId : combatGroup.getAttackers()) {
ContinuousEffect effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(attackerId));
effect.setTargetPointer(new FixedTarget(attackerId, game));
game.addEffect(effect, source);
}
break;

View file

@ -11,7 +11,6 @@ import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
@ -67,7 +66,7 @@ class RighteousIndignationTriggeredAbility extends TriggeredAbilityImpl {
if (blocked != null) {
if (blocked.getColor(game).contains(ObjectColor.BLACK)
|| blocked.getColor(game).contains(ObjectColor.RED)) {
getEffects().get(0).setTargetPointer(new FixedTarget(blocker.getId()));
getEffects().get(0).setTargetPointer(new FixedTarget(blocker.getId(), game));
return true;
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.r;
import java.util.UUID;
@ -72,21 +71,25 @@ class RiskyMoveGetControlEffect extends OneShotEffect {
MageObject sourceObject = source.getSourceObject(game);
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Player newController = game.getPlayer(getTargetPointer().getFirst(game, source));
if (newController != null && controller != null && sourceObject != null && sourceObject.equals(sourcePermanent)) {
if (newController != null
&& controller != null
&& sourceObject != null
&& sourceObject.equals(sourcePermanent)) {
// remove old control effects of the same player
for (ContinuousEffect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) {
if (effect instanceof GainControlTargetEffect) {
UUID checkId = (UUID) effect.getValue("RiskyMoveSourceId");
UUID controllerId = (UUID) effect.getValue("RiskyMoveControllerId");
if (source.getSourceId().equals(checkId) && newController.getId().equals(controllerId)) {
if (source.getSourceId().equals(checkId)
&& newController.getId().equals(controllerId)) {
effect.discard();
}
}
}
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, newController.getId());
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame, true, newController.getId());
effect.setValue("RiskyMoveSourceId", source.getSourceId());
effect.setValue("RiskyMoveControllerId", newController.getId());
effect.setTargetPointer(new FixedTarget(sourcePermanent.getId()));
effect.setTargetPointer(new FixedTarget(sourcePermanent.getId(), game));
effect.setText("and gains control of it");
game.addEffect(effect, source);
return true;
@ -126,7 +129,6 @@ class RiskyMoveTriggeredAbility extends TriggeredAbilityImpl {
}
}
class RiskyMoveFlipCoinEffect extends OneShotEffect {
public RiskyMoveFlipCoinEffect() {
@ -151,12 +153,16 @@ class RiskyMoveFlipCoinEffect extends OneShotEffect {
Target target2 = new TargetOpponent(true);
if (target1.canChoose(source.getSourceId(), controller.getId(), game)) {
while (!target1.isChosen() && target1.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) {
while (!target1.isChosen()
&& target1.canChoose(source.getSourceId(), controller.getId(), game)
&& controller.canRespond()) {
controller.chooseTarget(outcome, target1, source, game);
}
}
if (target2.canChoose(source.getSourceId(), controller.getId(), game)) {
while (!target2.isChosen() && target2.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) {
while (!target2.isChosen()
&& target2.canChoose(source.getSourceId(), controller.getId(), game)
&& controller.canRespond()) {
controller.chooseTarget(outcome, target2, source, game);
}
}
@ -164,7 +170,7 @@ class RiskyMoveFlipCoinEffect extends OneShotEffect {
Player chosenOpponent = game.getPlayer(target2.getFirstTarget());
if (!controller.flipCoin(source, game, true)) {
if (permanent != null && chosenOpponent != null) {
ContinuousEffect effect = new RiskyMoveCreatureGainControlEffect(Duration.Custom, chosenOpponent.getId());
ContinuousEffect effect = new RiskyMoveCreatureGainControlEffect(Duration.EndOfGame, chosenOpponent.getId());
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
game.informPlayers(chosenOpponent.getLogName() + " has gained control of " + permanent.getLogName());

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import java.util.UUID;
@ -83,10 +82,10 @@ class SereneMasterEffect extends OneShotEffect {
int newSourcePower = attackingCreature.getPower().getValue();
int newAttackerPower = sourceCreature.getPower().getValue();
ContinuousEffect effect = new SetPowerToughnessTargetEffect(newSourcePower, sourceCreature.getToughness().getValue(), Duration.EndOfCombat);
effect.setTargetPointer(new FixedTarget(source.getSourceId()));
effect.setTargetPointer(new FixedTarget(source.getSourceId(), game));
game.addEffect(effect, source);
effect = new SetPowerToughnessTargetEffect(newAttackerPower, attackingCreature.getToughness().getValue(), Duration.EndOfCombat);
effect.setTargetPointer(new FixedTarget(attackingCreature.getId()));
effect.setTargetPointer(new FixedTarget(attackingCreature.getId(), game));
game.addEffect(effect, source);
return true;
}

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import java.util.UUID;
@ -71,7 +70,7 @@ class MayRemoveM1M1CouterTargetEffect extends OneShotEffect {
if (target.getCounters(game).getCount(CounterType.M1M1) > 0) {
if (controller.chooseUse(outcome, "Remove a -1/-1 counter from " + target.getIdName() + "?", source, game)) {
Effect effect = new RemoveCounterTargetEffect(CounterType.M1M1.createInstance());
effect.setTargetPointer(new FixedTarget(target.getId()));
effect.setTargetPointer(new FixedTarget(target.getId(), game));
effect.apply(game, source);
}
}
@ -84,4 +83,3 @@ class MayRemoveM1M1CouterTargetEffect extends OneShotEffect {
return new MayRemoveM1M1CouterTargetEffect(this);
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import java.util.UUID;
@ -91,7 +90,7 @@ class ShowOfDominanceEffect extends OneShotEffect {
}
}
if (selectedCreature != null) {
FixedTarget target = new FixedTarget(selectedCreature.getId());
FixedTarget target = new FixedTarget(selectedCreature.getId(), game);
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(4));
effect.setTargetPointer(target);

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import java.util.UUID;
@ -14,7 +13,6 @@ import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
@ -29,8 +27,6 @@ public final class SigilCaptain extends CardImpl {
this.subtype.add(SubType.RHINO);
this.subtype.add(SubType.SOLDIER);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
@ -73,7 +69,7 @@ class SigilCaptainTriggeredAbility extends TriggeredAbilityImpl {
&& permanent.getPower().getValue() == 1
&& permanent.getToughness().getValue() == 1) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
}
return true;
}

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import java.util.UUID;
@ -81,7 +80,7 @@ class SigilOfValorTriggeredAbility extends TriggeredAbilityImpl {
UUID attackerId = game.getCombat().getAttackers().get(0);
if (equipment != null
&& equipment.isAttachedTo(attackerId)) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(attackerId));
this.getEffects().get(0).setTargetPointer(new FixedTarget(attackerId, game));
return true;
}
}

View file

@ -83,7 +83,7 @@ class CreaturesYouControlBecomesTargetTriggeredAbility extends TriggeredAbilityI
|| object.isSorcery(game)) {
if (getTargets().isEmpty()) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
}
}
return true;

View file

@ -102,7 +102,7 @@ class SkyfireKirinEffect extends OneShotEffect {
}
if (targetCreature != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(targetCreature.getId()));
effect.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
game.addEffect(effect, source);
return true;
}

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import java.util.UUID;
@ -94,8 +93,8 @@ class SokenzanRenegadeEffect extends OneShotEffect {
}
}
if (newController != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, newController.getId());
effect.setTargetPointer(new FixedTarget(sourcePermanent.getId()));
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame, newController.getId());
effect.setTargetPointer(new FixedTarget(sourcePermanent.getId(), game));
game.addEffect(effect, source);
if (!source.isControlledBy(newController.getId())) {
game.informPlayers(newController.getLogName() + " got control of " + sourcePermanent.getLogName());

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import mage.MageInt;
@ -71,7 +70,7 @@ class SoulScarMageDamageReplacementEffect extends ReplacementEffectImpl {
Permanent toGetCounters = game.getPermanent(event.getTargetId());
if (toGetCounters != null) {
AddCountersTargetEffect addCounters = new AddCountersTargetEffect(CounterType.M1M1.createInstance(), StaticValue.get(event.getAmount()));
addCounters.setTargetPointer(new FixedTarget(toGetCounters.getId()));
addCounters.setTargetPointer(new FixedTarget(toGetCounters.getId(), game));
addCounters.apply(game, source);
return true;
}

View file

@ -77,7 +77,7 @@ class CreatureControlledAttacksAloneTriggeredAbility extends TriggeredAbilityImp
public boolean checkTrigger(GameEvent event, Game game) {
if (game.isActivePlayer(this.controllerId)) {
if (game.getCombat().attacksAlone()) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(game.getCombat().getAttackers().get(0)));
this.getEffects().get(0).setTargetPointer(new FixedTarget(game.getCombat().getAttackers().get(0), game));
return true;
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import java.util.UUID;
@ -17,7 +16,6 @@ import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -82,7 +80,7 @@ class SpinalGraftTriggeredAbility extends TriggeredAbilityImpl {
if (enchantment != null && enchantment.getAttachedTo() != null) {
UUID enchanted = enchantment.getAttachedTo();
if (event.getTargetId().equals(enchanted)) {
getEffects().get(0).setTargetPointer(new FixedTarget(enchanted));
getEffects().get(0).setTargetPointer(new FixedTarget(enchanted, game));
return true;
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import java.util.UUID;
@ -94,7 +93,7 @@ class SporogenesisTriggeredAbility extends TriggeredAbilityImpl {
&& permanent.isCreature(game)
&& permanent.getCounters(game).containsKey(CounterType.FUNGUS)) {
Effect effect = this.getEffects().get(0);
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
return true;
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import mage.abilities.TriggeredAbilityImpl;
@ -71,7 +70,7 @@ class SwordOfKaldraTriggeredAbility extends TriggeredAbilityImpl {
if (equipment != null
&& equipment.getAttachedTo() != null
&& event.getSourceId().equals(equipment.getAttachedTo())) {
getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
return true;
}
return false;