mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
Extracted common effect (optional skip untap). This closes issue #66.
This commit is contained in:
parent
494723b11b
commit
4ab7766675
5 changed files with 152 additions and 117 deletions
|
@ -27,27 +27,30 @@
|
|||
*/
|
||||
package mage.sets.championsofkamigawa;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.*;
|
||||
import java.util.UUID;
|
||||
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.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.SkipUntapOptionalAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.abilities.keyword.ShroudAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
|
@ -65,7 +68,7 @@ public class HisokasGuard extends CardImpl<HisokasGuard> {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
// You may choose not to untap Hisoka's Guard during your untap step.
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new HisokasGuardRestrictionEffect()));
|
||||
this.addAbility(new SkipUntapOptionalAbility());
|
||||
|
||||
// {1}{U}, {T}: Target creature you control other than Hisoka's Guard has shroud for as long as Hisoka's Guard remains tapped. (It can't be the target of spells or abilities.)
|
||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
|
||||
|
@ -128,41 +131,12 @@ class HisokasGuardGainAbilityTargetEffect extends ContinuousEffectImpl<HisokasGu
|
|||
return true;
|
||||
} else {
|
||||
// if guard isn't tapped, the effect is no more valid
|
||||
if (!hisokasGuard.isTapped())
|
||||
if (!hisokasGuard.isTapped()) {
|
||||
hisokasGuard.clearConnectedCards("HisokasGuard");
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class HisokasGuardRestrictionEffect extends RestrictionEffect<HisokasGuardRestrictionEffect> {
|
||||
|
||||
public HisokasGuardRestrictionEffect() {
|
||||
super(Constants.Duration.WhileOnBattlefield);
|
||||
staticText = "You may choose not to untap {this} during your untap step";
|
||||
}
|
||||
|
||||
public HisokasGuardRestrictionEffect(final HisokasGuardRestrictionEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return permanent.getId().equals(source.getSourceId()) && permanent.isTapped();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUntapped(Permanent permanent, Game game) {
|
||||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
return player != null && player.chooseUse(Constants.Outcome.Benefit, "Untap " + permanent.getName() + "?", game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HisokasGuardRestrictionEffect copy() {
|
||||
return new HisokasGuardRestrictionEffect(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -27,14 +27,17 @@
|
|||
*/
|
||||
package mage.sets.scarsofmirrodin;
|
||||
|
||||
import mage.Constants;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.SkipUntapOptionalAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
|
@ -42,10 +45,8 @@ import mage.abilities.effects.common.TapTargetEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetArtifactPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
|
@ -61,15 +62,15 @@ public class RustTick extends CardImpl<RustTick> {
|
|||
this.toughness = new MageInt(3);
|
||||
|
||||
// You may choose not to untap Rust Tick during your untap step.
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new RustTickSelfRestrictionEffect()));
|
||||
this.addAbility(new SkipUntapOptionalAbility());
|
||||
|
||||
// {1}, {tap}: Tap target artifact. It doesn't untap during its controller's untap step for as long as Rust Tick remains tapped.
|
||||
Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new RustTickTapTargetEffect(), new GenericManaCost(1));
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RustTickTapTargetEffect(), new GenericManaCost(1));
|
||||
ability.addCost(new TapSourceCost());
|
||||
ability.addTarget(new TargetArtifactPermanent());
|
||||
this.addAbility(ability);
|
||||
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new RustTickRestrictionEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new RustTickRestrictionEffect()));
|
||||
}
|
||||
|
||||
public RustTick(final RustTick card) {
|
||||
|
@ -96,7 +97,9 @@ class RustTickTapTargetEffect extends TapTargetEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent rustTick = game.getPermanent(source.getSourceId());
|
||||
if (rustTick != null) rustTick.clearConnectedCards("RustTick");
|
||||
if (rustTick != null) {
|
||||
rustTick.clearConnectedCards("RustTick");
|
||||
}
|
||||
for (UUID target : targetPointer.getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
if (permanent != null) {
|
||||
|
@ -124,7 +127,7 @@ class RustTickTapTargetEffect extends TapTargetEffect {
|
|||
class RustTickRestrictionEffect extends RestrictionEffect<RustTickRestrictionEffect> {
|
||||
|
||||
public RustTickRestrictionEffect() {
|
||||
super(Constants.Duration.WhileOnBattlefield);
|
||||
super(Duration.WhileOnBattlefield);
|
||||
}
|
||||
|
||||
public RustTickRestrictionEffect(final RustTickRestrictionEffect effect) {
|
||||
|
@ -156,32 +159,3 @@ class RustTickRestrictionEffect extends RestrictionEffect<RustTickRestrictionEff
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class RustTickSelfRestrictionEffect extends RestrictionEffect<RustTickSelfRestrictionEffect> {
|
||||
|
||||
public RustTickSelfRestrictionEffect() {
|
||||
super(Constants.Duration.WhileOnBattlefield);
|
||||
staticText = "You may choose not to untap Rust Tick during your untap step";
|
||||
}
|
||||
|
||||
public RustTickSelfRestrictionEffect(final RustTickSelfRestrictionEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return permanent.getId().equals(source.getSourceId()) && permanent.isTapped();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUntapped(Permanent permanent, Game game) {
|
||||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
return player != null && player.chooseUse(Constants.Outcome.Benefit, "Untap Rust Tick?", game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RustTickSelfRestrictionEffect copy() {
|
||||
return new RustTickSelfRestrictionEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,21 +28,20 @@
|
|||
package mage.sets.urzaslegacy;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.SkipUntapOptionalAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.abilities.effects.common.continious.BoostAllEffect;
|
||||
import mage.abilities.keyword.EchoAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -57,10 +56,10 @@ public class ThranWeaponry extends CardImpl<ThranWeaponry> {
|
|||
// Echo {4}
|
||||
this.addAbility(new EchoAbility("{4}"));
|
||||
// You may choose not to untap Thran Weaponry during your untap step.
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new ThranWeaponryRestrictionEffect()));
|
||||
this.addAbility(new SkipUntapOptionalAbility());
|
||||
|
||||
// {2}, {tap}: All creatures get +2/+2 for as long as Thran Weaponry remains tapped.
|
||||
Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new ThranWeaponryEffect(), new ManaCostsImpl("{2}"));
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ThranWeaponryEffect(), new ManaCostsImpl("{2}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
||||
|
@ -78,10 +77,8 @@ public class ThranWeaponry extends CardImpl<ThranWeaponry> {
|
|||
|
||||
class ThranWeaponryEffect extends BoostAllEffect{
|
||||
|
||||
|
||||
|
||||
public ThranWeaponryEffect() {
|
||||
super(2, 2, Constants.Duration.WhileOnBattlefield);
|
||||
super(2, 2, Duration.WhileOnBattlefield);
|
||||
staticText = "All creatures get +2/+2 for as long as Thran Weaponry remains tapped";
|
||||
}
|
||||
|
||||
|
@ -94,8 +91,6 @@ class ThranWeaponryEffect extends BoostAllEffect{
|
|||
return new ThranWeaponryEffect(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent ThranWeaponry = game.getPermanent(source.getSourceId());
|
||||
|
@ -109,35 +104,4 @@ class ThranWeaponryEffect extends BoostAllEffect{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class ThranWeaponryRestrictionEffect extends RestrictionEffect<ThranWeaponryRestrictionEffect> {
|
||||
|
||||
public ThranWeaponryRestrictionEffect() {
|
||||
super(Constants.Duration.WhileOnBattlefield);
|
||||
staticText = "You may choose not to untap {this} during your untap step";
|
||||
}
|
||||
|
||||
public ThranWeaponryRestrictionEffect(final ThranWeaponryRestrictionEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return permanent.getId().equals(source.getSourceId()) && permanent.isTapped();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUntapped(Permanent permanent, Game game) {
|
||||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
return player != null && player.chooseUse(Constants.Outcome.Benefit, "Untap " + permanent.getName() + "?", game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThranWeaponryRestrictionEffect copy() {
|
||||
return new ThranWeaponryRestrictionEffect(this);
|
||||
}
|
||||
|
||||
}
|
53
Mage/src/mage/abilities/common/SkipUntapOptionalAbility.java
Normal file
53
Mage/src/mage/abilities/common/SkipUntapOptionalAbility.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.effects.common.SkipUntapOptionalSourceEffect;
|
||||
|
||||
/**
|
||||
* Implements:
|
||||
* You may choose not to untap {this} during your untap step
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class SkipUntapOptionalAbility extends SimpleStaticAbility {
|
||||
|
||||
public SkipUntapOptionalAbility() {
|
||||
super(Zone.BATTLEFIELD, new SkipUntapOptionalSourceEffect());
|
||||
}
|
||||
|
||||
private SkipUntapOptionalAbility(SkipUntapOptionalAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkipUntapOptionalAbility copy() {
|
||||
return new SkipUntapOptionalAbility(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.Duration;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
|
||||
public class SkipUntapOptionalSourceEffect extends RestrictionEffect<SkipUntapOptionalSourceEffect> {
|
||||
|
||||
public SkipUntapOptionalSourceEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
staticText = "You may choose not to untap {this} during your untap step";
|
||||
}
|
||||
|
||||
public SkipUntapOptionalSourceEffect(final SkipUntapOptionalSourceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return permanent.getId().equals(source.getSourceId()) && permanent.isTapped();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUntapped(Permanent permanent, Game game) {
|
||||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
return player != null && player.chooseUse(Constants.Outcome.Benefit, "Untap " + permanent.getName() + "?", game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkipUntapOptionalSourceEffect copy() {
|
||||
return new SkipUntapOptionalSourceEffect(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue