mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Implemented Guardian Project
This commit is contained in:
parent
c220638a09
commit
f0afe31a6b
2 changed files with 150 additions and 0 deletions
149
Mage.Sets/src/mage/cards/g/GuardianProject.java
Normal file
149
Mage.Sets/src/mage/cards/g/GuardianProject.java
Normal file
|
@ -0,0 +1,149 @@
|
|||
package mage.cards.g;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardIdPredicate;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.filter.predicate.other.OwnerIdPredicate;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.filter.predicate.permanent.TokenPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class GuardianProject extends CardImpl {
|
||||
|
||||
public GuardianProject(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}");
|
||||
|
||||
// Whenever a nontoken creature enters the battlefield under your control, if that creature does not have the same name as another creature you control or a creature card in your graveyard, draw a card.
|
||||
this.addAbility(new GuardianProjectTriggeredAbility());
|
||||
}
|
||||
|
||||
private GuardianProject(final GuardianProject card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuardianProject copy() {
|
||||
return new GuardianProject(this);
|
||||
}
|
||||
}
|
||||
|
||||
class GuardianProjectTriggeredAbility extends EntersBattlefieldAllTriggeredAbility {
|
||||
|
||||
public static final FilterPermanent filter = new FilterControlledCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(new TokenPredicate()));
|
||||
}
|
||||
|
||||
GuardianProjectTriggeredAbility() {
|
||||
super(new GuardianProjectEffect(null), filter);
|
||||
}
|
||||
|
||||
private GuardianProjectTriggeredAbility(final GuardianProjectTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuardianProjectTriggeredAbility copy() {
|
||||
return new GuardianProjectTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
if (!filter.match(permanent, sourceId, controllerId, game)) {
|
||||
return false;
|
||||
}
|
||||
if (checkCondition(permanent, controllerId, game)) {
|
||||
this.getEffects().clear();
|
||||
this.addEffect(new GuardianProjectEffect(new MageObjectReference(permanent, game)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a nontoken creature enters the battlefield under your control, " +
|
||||
"if that creature does not have the same name as another creature you control " +
|
||||
"or a creature card in your graveyard, draw a card.";
|
||||
}
|
||||
|
||||
// This is needed as checkInterveningIfClause can't access trigger event information
|
||||
static boolean checkCondition(Permanent permanent, UUID controllerId, Game game) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
if (!permanent.getName().equals("")) {
|
||||
FilterCard filterCard = new FilterCard();
|
||||
filterCard.add(new NamePredicate(permanent.getName()));
|
||||
filterCard.add(new OwnerIdPredicate(controllerId));
|
||||
if (player.getGraveyard().count(filterCard, game) > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
FilterPermanent filterPermanent = new FilterCreaturePermanent();
|
||||
filterPermanent.add(new NamePredicate(permanent.getName()));
|
||||
filterPermanent.add(Predicates.not(new CardIdPredicate(permanent.getId())));
|
||||
filterPermanent.add(new ControllerIdPredicate(controllerId));
|
||||
if (game.getBattlefield().getActivePermanents(filterPermanent, controllerId, game).size() > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class GuardianProjectEffect extends OneShotEffect {
|
||||
|
||||
private final MageObjectReference mor;
|
||||
|
||||
GuardianProjectEffect(MageObjectReference mor) {
|
||||
super(Outcome.Benefit);
|
||||
this.mor = mor;
|
||||
}
|
||||
|
||||
private GuardianProjectEffect(final GuardianProjectEffect effect) {
|
||||
super(effect);
|
||||
this.mor = effect.mor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuardianProjectEffect copy() {
|
||||
return new GuardianProjectEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
if (GuardianProjectTriggeredAbility.checkCondition(
|
||||
mor.getPermanentOrLKIBattlefield(game), source.getControllerId(), game)
|
||||
) {
|
||||
player.drawCards(1, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -74,6 +74,7 @@ public final class RavnicaAllegiance extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Gruul Guildgate", 250, Rarity.COMMON, mage.cards.g.GruulGuildgate.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Gruul Locket", 234, Rarity.COMMON, mage.cards.g.GruulLocket.class));
|
||||
cards.add(new SetCardInfo("Gruul Spellbreaker", 179, Rarity.RARE, mage.cards.g.GruulSpellbreaker.class));
|
||||
cards.add(new SetCardInfo("Guardian Project", 130, Rarity.RARE, mage.cards.g.GuardianProject.class));
|
||||
cards.add(new SetCardInfo("Gutterbones", 76, Rarity.RARE, mage.cards.g.Gutterbones.class));
|
||||
cards.add(new SetCardInfo("Hackrobat", 181, Rarity.UNCOMMON, mage.cards.h.Hackrobat.class));
|
||||
cards.add(new SetCardInfo("Hallowed Fountain", 251, Rarity.RARE, mage.cards.h.HallowedFountain.class));
|
||||
|
|
Loading…
Reference in a new issue