mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
[ARN] updated implementation of Guardian Beast
This commit is contained in:
parent
c7c042a644
commit
38f68911b1
1 changed files with 18 additions and 21 deletions
|
@ -1,20 +1,19 @@
|
|||
package mage.cards.g;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.InvertCondition;
|
||||
import mage.abilities.condition.common.SourceTappedCondition;
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
|
||||
import mage.abilities.keyword.IndestructibleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterObject;
|
||||
import mage.filter.FilterStackObject;
|
||||
import mage.filter.StaticFilters;
|
||||
|
@ -25,8 +24,10 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
*/
|
||||
public final class GuardianBeast extends CardImpl {
|
||||
|
@ -48,13 +49,14 @@ public final class GuardianBeast extends CardImpl {
|
|||
|
||||
// As long as Guardian Beast is untapped, noncreature artifacts you control can't be enchanted, they're indestructible, and other players can't gain control of them.
|
||||
// This effect doesn't remove Auras already attached to those artifacts.
|
||||
Effect effect = new ConditionalContinuousEffect(new GainAbilityControlledEffect(IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield, filter),
|
||||
SourceTappedCondition.UNTAPPED,
|
||||
"As long as Guardian Beast is untapped, noncreature artifacts you control can't be enchanted, they're indestructible");
|
||||
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect);
|
||||
ability.addEffect(new GuardianBeastConditionalEffect(this.getId()));
|
||||
Ability ability = new SimpleStaticAbility(new ConditionalContinuousEffect(
|
||||
new GainAbilityControlledEffect(
|
||||
IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield, filter
|
||||
), SourceTappedCondition.UNTAPPED, "As long as {this} is untapped, " +
|
||||
"noncreature artifacts you control can't be enchanted, they're indestructible"
|
||||
));
|
||||
ability.addEffect(new GuardianBeastConditionalEffect());
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
||||
private GuardianBeast(final GuardianBeast card) {
|
||||
|
@ -69,17 +71,13 @@ public final class GuardianBeast extends CardImpl {
|
|||
|
||||
class GuardianBeastConditionalEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
private final UUID guardianBeastId;
|
||||
|
||||
public GuardianBeastConditionalEffect(UUID guardianBeastId) {
|
||||
public GuardianBeastConditionalEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Neutral);
|
||||
staticText = ", and other players can't gain control of them. This effect doesn't remove Auras already attached to those artifacts";
|
||||
this.guardianBeastId = guardianBeastId;
|
||||
}
|
||||
|
||||
public GuardianBeastConditionalEffect(final GuardianBeastConditionalEffect effect) {
|
||||
super(effect);
|
||||
this.guardianBeastId = effect.guardianBeastId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,15 +97,14 @@ class GuardianBeastConditionalEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
Permanent targetPermanent = game.getPermanent(event.getTargetId());
|
||||
Permanent guardianBeast = game.getPermanent(guardianBeastId);
|
||||
|
||||
if (guardianBeast == null || guardianBeast.isTapped() || sourceObject == null || targetPermanent == null) {
|
||||
if (permanent == null || permanent.isTapped() || targetPermanent == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Objects.equals(targetPermanent.getControllerId(), guardianBeast.getControllerId())) {
|
||||
if (!Objects.equals(targetPermanent.getControllerId(), permanent.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue