MBS - Spin Engine + modifications to Restriction Effect

This commit is contained in:
BetaSteward 2011-08-26 15:42:29 -04:00
parent 1828ad033d
commit a38e441e08
20 changed files with 127 additions and 21 deletions

View file

@ -128,7 +128,7 @@ class ManaclesOfDecaySecondEffect extends RestrictionEffect<ManaclesOfDecaySecon
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}

View file

@ -102,7 +102,7 @@ class CageOfHandsEffect extends RestrictionEffect<CageOfHandsEffect> {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}

View file

@ -100,7 +100,7 @@ class RecumbentBlissEffect extends RestrictionEffect<RecumbentBlissEffect> {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}

View file

@ -92,7 +92,7 @@ class TectonicRiftEffect extends RestrictionEffect<TectonicRiftEffect> {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}

View file

@ -99,7 +99,7 @@ class HeroOfOxidRidgeEffect extends RestrictionEffect<HeroOfOxidRidgeEffect> {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}

View file

@ -115,7 +115,7 @@ class SignalPestEffect extends RestrictionEffect<SignalPestEffect> {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
if (blocker.getAbilities().contains(FlyingAbility.getInstance()) || blocker.getAbilities().contains(ReachAbility.getInstance())) {
return true;
}

View file

@ -0,0 +1,105 @@
/*
* Copyright 2011 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.sets.mirrodinbesieged;
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.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.RestrictionEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class SpinEngine extends CardImpl<SpinEngine> {
public SpinEngine(UUID ownerId) {
super(ownerId, 135, "Spin Engine", Rarity.COMMON, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}");
this.expansionSetCode = "MBS";
this.subtype.add("Construct");
this.power = new MageInt(3);
this.toughness = new MageInt(1);
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SpinEngineEffect(), new ManaCostsImpl("{R}"));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}
public SpinEngine(final SpinEngine card) {
super(card);
}
@Override
public SpinEngine copy() {
return new SpinEngine(this);
}
}
class SpinEngineEffect extends RestrictionEffect<SpinEngineEffect> {
public SpinEngineEffect() {
super(Duration.EndOfTurn);
}
public SpinEngineEffect(final SpinEngineEffect effect) {
super(effect);
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent.getId().equals(source.getSourceId())) {
return true;
}
return false;
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
UUID targetId = source.getFirstTarget();
if (targetId != null && blocker.getId().equals(targetId))
return false;
return true;
}
@Override
public SpinEngineEffect copy() {
return new SpinEngineEffect(this);
}
}

View file

@ -93,7 +93,7 @@ class TrainingDroneEffect extends RestrictionEffect<TrainingDroneEffect> {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}

View file

@ -87,7 +87,7 @@ class RuthlessInvasionEffect extends RestrictionEffect<RuthlessInvasionEffect> {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}

View file

@ -33,6 +33,7 @@ import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.EvasionAbility;
import mage.abilities.common.AttacksEachTurnStaticAbility;
import mage.abilities.effects.common.CantBlockSourceEffect;
@ -101,7 +102,7 @@ class JuggernautEffect extends CantBlockSourceEffect {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
return !blocker.hasSubtype("Wall");
}

View file

@ -101,7 +101,7 @@ class PacifismEffect extends RestrictionEffect<PacifismEffect> {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}

View file

@ -61,7 +61,7 @@ class CantBlockEffect extends RestrictionEffect<CantBlockEffect> {
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return !blocker.getAbilities().containsKey(CantBlockAbility.getInstance().getId());
}

View file

@ -61,11 +61,11 @@ public abstract class RestrictionEffect<T extends RestrictionEffect<T>> extends
return true;
}
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return true;
}
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
return true;
}

View file

@ -57,7 +57,7 @@ public class CantBlockSourceEffect extends RestrictionEffect<CantBlockSourceEffe
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Game game) {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}

View file

@ -89,7 +89,7 @@ class FearEffect extends RestrictionEffect<FearEffect> {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
if (blocker.getCardType().contains(Constants.CardType.ARTIFACT) || blocker.getColor().isBlack()) {
return true;
}

View file

@ -87,7 +87,7 @@ class FlyingEffect extends RestrictionEffect<FlyingEffect> {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
if (blocker.getAbilities().containsKey(FlyingAbility.getInstance().getId()) || blocker.getAbilities().containsKey(ReachAbility.getInstance().getId()))
return true;
return false;

View file

@ -47,7 +47,7 @@ class IntimidateEffect extends RestrictionEffect<IntimidateEffect> {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
boolean result = false;
if (blocker.getCardType().contains(Constants.CardType.ARTIFACT) && (blocker.getCardType().contains(Constants.CardType.CREATURE)))
result = true;

View file

@ -73,7 +73,7 @@ class LandwalkEffect extends RestrictionEffect<LandwalkEffect> {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
return !game.getBattlefield().contains(filter, blocker.getControllerId(), 1);
}

View file

@ -87,7 +87,7 @@ class UnblockableEffect extends RestrictionEffect<UnblockableEffect> {
}
@Override
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Game game) {
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}

View file

@ -680,14 +680,14 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
Permanent attacker = game.getPermanent(attackerId);
//20101001 - 509.1b
for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(this, game)) {
if (!effect.canBlock(attacker, this, game))
if (!effect.canBlock(attacker, this, game.getContinuousEffects().getAbility(effect.getId()), game))
return false;
}
// check also attacker's restriction effects
for (RestrictionEffect effect : game.getContinuousEffects().getApplicableRestrictionEffects(attacker, game)) {
/*if (!effect.canBlock(attacker, this, game))
return false;*/
if (!effect.canBeBlocked(attacker, this, game))
if (!effect.canBeBlocked(attacker, this, game.getContinuousEffects().getAbility(effect.getId()), game))
return false;
}
if (attacker.hasProtectionFrom(this))