[SOI] Bound by Moonsilver Implementation

This commit is contained in:
Jared Hall 2016-03-27 17:15:56 -04:00
parent a15f206233
commit 42a7b38cf1
6 changed files with 176 additions and 1 deletions

View file

@ -106,4 +106,8 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
return true;
}
public boolean canTransform(Game game) {
return true;
}
}

View file

@ -0,0 +1,61 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.AttachmentType;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author halljared
*/
public class CantAttackBlockTransformAttachedEffect extends RestrictionEffect{
public CantAttackBlockTransformAttachedEffect() {
super(Duration.WhileOnBattlefield);
staticText = "Enchanted creature can't attack, block, or transform.";
}
public CantAttackBlockTransformAttachedEffect(final CantAttackBlockTransformAttachedEffect effect) {
super(effect);
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
if (permanent.getId().equals(enchantment.getAttachedTo())) {
return true;
}
}
return false;
}
@Override
public boolean canAttack(Game game) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}
@Override
public boolean canTransform(Game game) {
return false;
}
@Override
public CantAttackBlockTransformAttachedEffect copy() {
return new CantAttackBlockTransformAttachedEffect(this);
}
}

View file

@ -72,7 +72,7 @@ public class TransformSourceEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
if (permanent.canTransform()) {
if (permanent.canTransform(game)) {
// check not to transform twice the same side
if (permanent.isTransformed() != fromDayToNight) {
if (withoutTrigger) {

View file

@ -249,6 +249,14 @@ public interface Permanent extends Card, Controllable {
*/
boolean canUseActivatedAbilities(Game game);
/**
* Checks by restriction effects if the permanent can transform
*
* @param game
* @return true - permanent can transform
*/
boolean canTransform(Game game);
boolean removeFromCombat(Game game);
boolean removeFromCombat(Game game, boolean withInfo);

View file

@ -1190,6 +1190,20 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return true;
}
@Override
public boolean canTransform(Game game) {
for (Map.Entry entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
RestrictionEffect effect = (RestrictionEffect) entry.getKey();
for (Ability ability : (HashSet<Ability>) entry.getValue()) {
if (!effect.canTransform(game)) {
return false;
}
}
}
return true;
}
@Override
public void setAttacking(boolean attacking) {
this.attacking = attacking;