mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Domineering Will - Fixed not correctly working effects.
This commit is contained in:
parent
981a27ccbf
commit
ef3e432188
2 changed files with 15 additions and 116 deletions
|
@ -30,25 +30,25 @@ package mage.sets.commander2014;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.RequirementEffect;
|
||||
import mage.abilities.effects.common.UntapTargetEffect;
|
||||
import mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect;
|
||||
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.AttackingPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetpointer.SecondTargetPointer;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -66,7 +66,6 @@ public class DomineeringWill extends CardImpl {
|
|||
super(ownerId, 13, "Domineering Will", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{3}{U}");
|
||||
this.expansionSetCode = "C14";
|
||||
|
||||
|
||||
// Target player gains control of up to three target nonattacking creatures until end of turn. Untap those creatures. They block this turn if able.
|
||||
this.getSpellAbility().addEffect(new DomineeringWillEffect());
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
|
@ -102,14 +101,20 @@ class DomineeringWillEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (targetPlayer != null) {
|
||||
ContinuousEffect effect = new DomineeringWillControlEffect();
|
||||
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn, targetPlayer.getId());
|
||||
effect.setTargetPointer(new SecondTargetPointer());
|
||||
effect.setText("Target player gains control of up to three target nonattacking creatures until end of turn");
|
||||
game.addEffect(effect, source);
|
||||
Effect effect2 = new DomineeringWillUntapTargetEffect();
|
||||
|
||||
Effect effect2 = new UntapTargetEffect();
|
||||
effect2.setTargetPointer(new SecondTargetPointer());
|
||||
effect2.setText("Untap those creatures");
|
||||
effect2.apply(game, source);
|
||||
RequirementEffect effect3 = new DomineeringWillBlocksIfAbleTargetEffect(Duration.EndOfTurn);
|
||||
|
||||
RequirementEffect effect3 = new BlocksIfAbleTargetEffect(Duration.EndOfTurn);
|
||||
effect3.setTargetPointer(new SecondTargetPointer());
|
||||
effect3.setText("They block this turn if able");
|
||||
game.addEffect(effect3, source);
|
||||
return true;
|
||||
|
@ -117,109 +122,3 @@ class DomineeringWillEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class DomineeringWillControlEffect extends ContinuousEffectImpl {
|
||||
|
||||
public DomineeringWillControlEffect() {
|
||||
super(Duration.EndOfTurn, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
}
|
||||
|
||||
public DomineeringWillControlEffect(final DomineeringWillControlEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomineeringWillControlEffect copy() {
|
||||
return new DomineeringWillControlEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (targetPlayer != null) {
|
||||
boolean targetStillExists = false;
|
||||
for (UUID permanentId : source.getTargets().get(1).getTargets()) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
targetStillExists = true;
|
||||
if (targetPlayer != null) {
|
||||
permanent.changeControllerId(targetPlayer.getId(), game);
|
||||
permanent.getAbilities().setControllerId(targetPlayer.getId());
|
||||
} else {
|
||||
permanent.changeControllerId(source.getControllerId(), game);
|
||||
permanent.getAbilities().setControllerId(source.getControllerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!targetStillExists) {
|
||||
// no valid target exists, effect can be discarded
|
||||
discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class DomineeringWillUntapTargetEffect extends OneShotEffect {
|
||||
|
||||
public DomineeringWillUntapTargetEffect() {
|
||||
super(Outcome.Untap);
|
||||
}
|
||||
|
||||
public DomineeringWillUntapTargetEffect(final DomineeringWillUntapTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomineeringWillUntapTargetEffect copy() {
|
||||
return new DomineeringWillUntapTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID target : source.getTargets().get(1).getTargets()) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
if (permanent != null) {
|
||||
permanent.untap(game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class DomineeringWillBlocksIfAbleTargetEffect extends RequirementEffect {
|
||||
|
||||
public DomineeringWillBlocksIfAbleTargetEffect(Duration duration) {
|
||||
super(duration);
|
||||
}
|
||||
|
||||
public DomineeringWillBlocksIfAbleTargetEffect(final DomineeringWillBlocksIfAbleTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomineeringWillBlocksIfAbleTargetEffect copy() {
|
||||
return new DomineeringWillBlocksIfAbleTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return source.getTargets().get(1).getTargets().contains(permanent.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mustAttack(Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mustBlock(Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mustBlockAny(Game game) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -663,7 +663,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
if (mayBlock) {
|
||||
if (controller.isHuman()) {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayer(controller, "Creature should block this turn: " + creature.getLogName());
|
||||
game.informPlayer(controller, "Creature should block this turn: " + creature.getIdName());
|
||||
}
|
||||
} else {
|
||||
Player defender = game.getPlayer(creature.getControllerId());
|
||||
|
|
Loading…
Reference in a new issue