Fix TODO on Siege Behemoth

This commit is contained in:
Noah Gleason 2018-07-09 22:34:23 -04:00
parent 9108104fe5
commit e0932efa8b
No known key found for this signature in database
GPG key ID: EC030EC6B0650A40

View file

@ -3,19 +3,21 @@ package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DamageAsThoughNotBlockedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.SourceAttackingCondition;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.HexproofAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
@ -34,15 +36,9 @@ public final class SiegeBehemoth extends CardImpl {
// Hexproof
this.addAbility(HexproofAbility.getInstance());
// As long as Siege Behemoth is attacking, for each creature you control, you may have that creature assign its combat damage as though it weren't blocked.
// TODO: DamageAsThoughNotBlockedAbility should be done by rule modifying effect instead of adding ability (if controlled creature looses all abilities it should'nt loose this effect)
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
new ConditionalContinuousEffect(
new GainAbilityControlledEffect(DamageAsThoughNotBlockedAbility.getInstance(), Duration.WhileOnBattlefield, filter),
SourceAttackingCondition.instance,
"As long as {this} is attacking, for each creature you control, you may have that creature assign its combat damage as though it weren't blocked"
)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SiegeBehemothEffect()));
}
public SiegeBehemoth(final SiegeBehemoth card) {
@ -54,3 +50,39 @@ public final class SiegeBehemoth extends CardImpl {
return new SiegeBehemoth(this);
}
}
class SiegeBehemothEffect extends AsThoughEffectImpl {
public SiegeBehemothEffect() {
super(AsThoughEffectType.DAMAGE_NOT_BLOCKED, Duration.WhileOnBattlefield, Outcome.Damage);
this.staticText = "As long as {this} is attacking, for each creature you control, you may have that creature assign its combat damage as though it weren't blocked";
}
public SiegeBehemothEffect(SiegeBehemothEffect effect) {
super(effect);
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
if (sourcePermanent != null && sourcePermanent.isAttacking()){
Player controller = game.getPlayer(source.getControllerId());
Permanent otherCreature = game.getPermanent(sourceId);
if (controller != null && otherCreature != null && otherCreature.isControlledBy(controller.getId())){
return controller.chooseUse(Outcome.Damage, "Do you wish to assign damage for "
+ otherCreature.getLogName() + " as though it weren't blocked?", source, game);
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public SiegeBehemothEffect copy() {
return new SiegeBehemothEffect(this);
}
}