Skip to content

Commit

Permalink
Implemented Marble Priest
Browse files Browse the repository at this point in the history
  • Loading branch information
theelk801 committed Jun 10, 2018
1 parent 955ec50 commit 3dcfa77
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 4 deletions.
74 changes: 74 additions & 0 deletions Mage.Sets/src/mage/cards/m/MarblePriest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package mage.cards.m;

import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.PreventAllDamageToSourceEffect;
import mage.abilities.effects.common.combat.MustBeBlockedByAllSourceEffect;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;

/**
*
* @author TheElk801
*/
public final class MarblePriest extends CardImpl {

private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(SubType.WALL, "Walls");

public MarblePriest(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{5}");

this.subtype.add(SubType.CLERIC);
this.power = new MageInt(3);
this.toughness = new MageInt(3);

// All Walls able to block Marble Priest do so.
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
new MustBeBlockedByAllSourceEffect(
Duration.WhileOnBattlefield,
filter
)
));

// Prevent all combat damage that would be dealt to Marble Priest by Walls.
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
new MarblePriestPreventionEffect()
));
}

public MarblePriest(final MarblePriest card) {
super(card);
}

@Override
public MarblePriest copy() {
return new MarblePriest(this);
}
}

class MarblePriestPreventionEffect extends PreventAllDamageToSourceEffect {

public MarblePriestPreventionEffect() {
super(Duration.WhileOnBattlefield);
staticText = "Prevent all combat damage that would be dealt to {this} by Walls";
}

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return super.applies(event, source, game)
&& event.getFlag()
&& game.getObject(event.getSourceId()).hasSubtype(SubType.WALL, game)
&& event.getTargetId().equals(source.getSourceId());
}
}
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/Legends.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ private Legends() {
cards.add(new SetCardInfo("Lost Soul", 111, Rarity.COMMON, mage.cards.l.LostSoul.class));
cards.add(new SetCardInfo("Mana Drain", 65, Rarity.UNCOMMON, mage.cards.m.ManaDrain.class));
cards.add(new SetCardInfo("Mana Matrix", 285, Rarity.RARE, mage.cards.m.ManaMatrix.class));
cards.add(new SetCardInfo("Marble Priest", 231, Rarity.UNCOMMON, mage.cards.m.MarblePriest.class));
cards.add(new SetCardInfo("Marhault Elsdragon", 244, Rarity.UNCOMMON, mage.cards.m.MarhaultElsdragon.class));
cards.add(new SetCardInfo("Mirror Universe", 287, Rarity.RARE, mage.cards.m.MirrorUniverse.class));
cards.add(new SetCardInfo("Moat", 28, Rarity.RARE, mage.cards.m.Moat.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@


package mage.abilities.effects.common.combat;

import java.util.UUID;
import mage.constants.Duration;
import mage.abilities.Ability;
import mage.abilities.effects.RequirementEffect;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;

Expand All @@ -15,23 +15,33 @@
*/
public class MustBeBlockedByAllSourceEffect extends RequirementEffect {

private final FilterCreaturePermanent filter;

public MustBeBlockedByAllSourceEffect() {
this(Duration.WhileOnBattlefield);
}

public MustBeBlockedByAllSourceEffect(Duration duration) {
this(duration, StaticFilters.FILTER_PERMANENT_CREATURES);
}

public MustBeBlockedByAllSourceEffect(Duration duration, FilterCreaturePermanent filter) {
super(duration);
staticText = "All creatures able to block {this} do so";
this.filter = filter;
staticText = "All " + filter.getMessage() + " able to block {this} do so";
}

public MustBeBlockedByAllSourceEffect(final MustBeBlockedByAllSourceEffect effect) {
super(effect);
this.filter = effect.filter;
}

@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent sourceCreature = game.getPermanent(source.getSourceId());
if (sourceCreature != null && sourceCreature.isAttacking()) {
if (sourceCreature != null
&& sourceCreature.isAttacking()
&& filter.match(permanent, game)) {
return permanent.canBlock(source.getSourceId(), game);
}
return false;
Expand Down

0 comments on commit 3dcfa77

Please sign in to comment.