Added delirium hint as enum

This commit is contained in:
Oleg Agafonov 2019-02-05 23:12:42 +04:00
parent 330f8cf5d0
commit 6a7253d22f
4 changed files with 80 additions and 22 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.i; package mage.cards.i;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -12,6 +10,7 @@ import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect; import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.abilities.hint.DeliriumHint;
import mage.abilities.keyword.ReachAbility; import mage.abilities.keyword.ReachAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -24,8 +23,9 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.permanent.token.SpiderToken; import mage.game.permanent.token.SpiderToken;
import mage.target.common.TargetOpponent; import mage.target.common.TargetOpponent;
import java.util.UUID;
/** /**
*
* @author fireshoes * @author fireshoes
*/ */
public final class IshkanahGrafwidow extends CardImpl { public final class IshkanahGrafwidow extends CardImpl {
@ -53,7 +53,7 @@ public final class IshkanahGrafwidow extends CardImpl {
DeliriumCondition.instance, DeliriumCondition.instance,
"<i>Delirium</i> &mdash; When {this} enters the battlefield, if there are four or more card types among cards in your graveyard, " "<i>Delirium</i> &mdash; When {this} enters the battlefield, if there are four or more card types among cards in your graveyard, "
+ "create three 1/2 green Spider creature tokens with reach."); + "create three 1/2 green Spider creature tokens with reach.");
this.addAbility(ability); this.addAbility(ability.addHint(DeliriumHint.instance));
// {5}{B}: Target opponent loses 1 life for each Spider you control. // {5}{B}: Target opponent loses 1 life for each Spider you control.
PermanentsOnBattlefieldCount count = new PermanentsOnBattlefieldCount(filter); PermanentsOnBattlefieldCount count = new PermanentsOnBattlefieldCount(filter);

View file

@ -1,17 +1,11 @@
package mage.abilities.condition.common; package mage.abilities.condition.common;
import java.util.EnumSet;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.cards.Card; import mage.abilities.dynamicvalue.common.CardTypesInGraveyardCount;
import mage.constants.CardType;
import mage.game.Game; import mage.game.Game;
import mage.players.Player;
/** /**
*
*
* @author fireshoes * @author fireshoes
*/ */
public enum DeliriumCondition implements Condition { public enum DeliriumCondition implements Condition {
@ -20,15 +14,7 @@ public enum DeliriumCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); return CardTypesInGraveyardCount.instance.calculate(game, source, null) >= 4;
if (controller != null) {
EnumSet<CardType> foundCardTypes = EnumSet.noneOf(CardType.class);
for (Card card : controller.getGraveyard().getCards(game)) {
foundCardTypes.addAll(card.getCardType());
}
return foundCardTypes.size() >= 4;
}
return false;
} }
@Override @Override

View file

@ -0,0 +1,47 @@
package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.game.Game;
import mage.players.Player;
import java.util.EnumSet;
/**
* @author JayDi85
*/
public enum CardTypesInGraveyardCount implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Player controller = game.getPlayer(sourceAbility.getControllerId());
if (controller != null) {
EnumSet<CardType> foundCardTypes = EnumSet.noneOf(CardType.class);
for (Card card : controller.getGraveyard().getCards(game)) {
foundCardTypes.addAll(card.getCardType());
}
return foundCardTypes.size();
}
return 0;
}
@Override
public CardTypesInGraveyardCount copy() {
return instance;
}
@Override
public String toString() {
return "1";
}
@Override
public String getMessage() {
return "the number of opponents you attacked this turn";
}
}

View file

@ -0,0 +1,25 @@
package mage.abilities.hint;
import mage.abilities.Ability;
import mage.abilities.condition.common.DeliriumCondition;
import mage.abilities.dynamicvalue.common.CardTypesInGraveyardCount;
import mage.game.Game;
/**
* @author JayDi85
*/
public enum DeliriumHint implements Hint {
instance;
private static final ConditionHint hint = new ConditionHint(DeliriumCondition.instance, "4+ card types in the graveyard");
@Override
public String getText(Game game, Ability ability) {
return hint.getText(game, ability) + " (current: " + CardTypesInGraveyardCount.instance.calculate(game, ability, null) + ")";
}
@Override
public Hint copy() {
return instance;
}
}