mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
Implemented Fires of Invention
This commit is contained in:
parent
a6a21c6858
commit
ce920fa542
4 changed files with 139 additions and 10 deletions
99
Mage.Sets/src/mage/cards/f/FiresOfInvention.java
Normal file
99
Mage.Sets/src/mage/cards/f/FiresOfInvention.java
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
package mage.cards.f;
|
||||||
|
|
||||||
|
import mage.MageObject;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||||
|
import mage.abilities.effects.common.continuous.CastFromHandWithoutPayingManaCostEffect;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.filter.FilterCard;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
|
import mage.filter.predicate.ObjectSourcePlayer;
|
||||||
|
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.watchers.common.CastSpellLastTurnWatcher;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public final class FiresOfInvention extends CardImpl {
|
||||||
|
|
||||||
|
private static final FilterCard filter
|
||||||
|
= new FilterCard("spells with converted mana cost less than or equal to the number of lands you control");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(FiresOfInventionPredicate.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FiresOfInvention(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
|
||||||
|
|
||||||
|
// You can cast spells only during your turn and you can cast no more than two spells each turn.
|
||||||
|
this.addAbility(new SimpleStaticAbility(new FiresOfInventionCastEffect()));
|
||||||
|
|
||||||
|
// You may cast spells with converted mana cost less than or equal to the number of lands you control without paying their mana costs.
|
||||||
|
this.addAbility(new SimpleStaticAbility(new CastFromHandWithoutPayingManaCostEffect(filter, false)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private FiresOfInvention(final FiresOfInvention card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FiresOfInvention copy() {
|
||||||
|
return new FiresOfInvention(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum FiresOfInventionPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<MageObject>> {
|
||||||
|
instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) {
|
||||||
|
return input.getObject().getConvertedManaCost() <=
|
||||||
|
game.getBattlefield().countAll(StaticFilters.FILTER_LAND, game.getControllerId(input.getSourceId()), game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FiresOfInventionCastEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
|
|
||||||
|
FiresOfInventionCastEffect() {
|
||||||
|
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
||||||
|
staticText = "you can cast spells only during your turn and you can cast no more than two spells each turn";
|
||||||
|
}
|
||||||
|
|
||||||
|
private FiresOfInventionCastEffect(final FiresOfInventionCastEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FiresOfInventionCastEffect copy() {
|
||||||
|
return new FiresOfInventionCastEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checksEventType(GameEvent event, Game game) {
|
||||||
|
return event.getType() == GameEvent.EventType.CAST_SPELL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
|
if (!event.getPlayerId().equals(source.getControllerId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class);
|
||||||
|
if (watcher == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) > 2
|
||||||
|
|| !game.getActivePlayerId().equals(source.getControllerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -83,6 +83,7 @@ public final class ThroneOfEldraine extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Fervent Champion", 124, Rarity.RARE, mage.cards.f.FerventChampion.class));
|
cards.add(new SetCardInfo("Fervent Champion", 124, Rarity.RARE, mage.cards.f.FerventChampion.class));
|
||||||
cards.add(new SetCardInfo("Fierce Witchstalker", 154, Rarity.COMMON, mage.cards.f.FierceWitchstalker.class));
|
cards.add(new SetCardInfo("Fierce Witchstalker", 154, Rarity.COMMON, mage.cards.f.FierceWitchstalker.class));
|
||||||
cards.add(new SetCardInfo("Fireborn Knight", 210, Rarity.UNCOMMON, mage.cards.f.FirebornKnight.class));
|
cards.add(new SetCardInfo("Fireborn Knight", 210, Rarity.UNCOMMON, mage.cards.f.FirebornKnight.class));
|
||||||
|
cards.add(new SetCardInfo("Fires of Invention", 125, Rarity.RARE, mage.cards.f.FiresOfInvention.class));
|
||||||
cards.add(new SetCardInfo("Flaxen Intruder", 155, Rarity.UNCOMMON, mage.cards.f.FlaxenIntruder.class));
|
cards.add(new SetCardInfo("Flaxen Intruder", 155, Rarity.UNCOMMON, mage.cards.f.FlaxenIntruder.class));
|
||||||
cards.add(new SetCardInfo("Folio of Fancies", 46, Rarity.RARE, mage.cards.f.FolioOfFancies.class));
|
cards.add(new SetCardInfo("Folio of Fancies", 46, Rarity.RARE, mage.cards.f.FolioOfFancies.class));
|
||||||
cards.add(new SetCardInfo("Foulmire Knight", 90, Rarity.UNCOMMON, mage.cards.f.FoulmireKnight.class));
|
cards.add(new SetCardInfo("Foulmire Knight", 90, Rarity.UNCOMMON, mage.cards.f.FoulmireKnight.class));
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.SplitCardHalf;
|
import mage.cards.SplitCardHalf;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.filter.common.FilterNonlandCard;
|
import mage.filter.FilterCard;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
@ -19,13 +20,26 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class CastFromHandWithoutPayingManaCostEffect extends ContinuousEffectImpl {
|
public class CastFromHandWithoutPayingManaCostEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
|
private final FilterCard filter;
|
||||||
|
private final boolean fromHand;
|
||||||
|
|
||||||
public CastFromHandWithoutPayingManaCostEffect() {
|
public CastFromHandWithoutPayingManaCostEffect() {
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
this(StaticFilters.FILTER_CARDS_NON_LAND, true);
|
||||||
staticText = "You may cast nonland cards from your hand without paying their mana costs";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CastFromHandWithoutPayingManaCostEffect(final CastFromHandWithoutPayingManaCostEffect effect) {
|
public CastFromHandWithoutPayingManaCostEffect(FilterCard filter, boolean fromHand) {
|
||||||
|
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
||||||
|
this.filter = filter;
|
||||||
|
this.fromHand = fromHand;
|
||||||
|
staticText = "You may cast " + filter.getMessage()
|
||||||
|
+ (fromHand ? " from your hand" : "")
|
||||||
|
+ " without paying their mana costs";
|
||||||
|
}
|
||||||
|
|
||||||
|
private CastFromHandWithoutPayingManaCostEffect(final CastFromHandWithoutPayingManaCostEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
|
this.filter = effect.filter;
|
||||||
|
this.fromHand = effect.fromHand;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -36,13 +50,20 @@ public class CastFromHandWithoutPayingManaCostEffect extends ContinuousEffectImp
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null) {
|
if (controller == null) {
|
||||||
controller.getAlternativeSourceCosts().add(new AlternativeCostSourceAbility(
|
|
||||||
null, new CompoundCondition(SourceIsSpellCondition.instance, new IsBeingCastFromHandCondition()), null, new FilterNonlandCard(), true));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Condition condition;
|
||||||
|
if (fromHand) {
|
||||||
|
condition = new CompoundCondition(SourceIsSpellCondition.instance, IsBeingCastFromHandCondition.instance);
|
||||||
|
} else {
|
||||||
|
condition = SourceIsSpellCondition.instance;
|
||||||
|
}
|
||||||
|
controller.getAlternativeSourceCosts().add(new AlternativeCostSourceAbility(
|
||||||
|
null, condition, null, filter, true
|
||||||
|
));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
|
|
@ -55,7 +76,8 @@ public class CastFromHandWithoutPayingManaCostEffect extends ContinuousEffectImp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class IsBeingCastFromHandCondition implements Condition {
|
enum IsBeingCastFromHandCondition implements Condition {
|
||||||
|
instance;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,13 @@ public final class StaticFilters {
|
||||||
FILTER_CARD_A_NON_LAND.setLockedFilter(true);
|
FILTER_CARD_A_NON_LAND.setLockedFilter(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final FilterNonlandCard FILTER_CARDS_NON_LAND = new FilterNonlandCard("nonland cards");
|
||||||
|
|
||||||
|
static {
|
||||||
|
FILTER_CARDS_NON_LAND.setLockedFilter(true);
|
||||||
|
}
|
||||||
|
|
||||||
public static final FilterInstantOrSorceryCard FILTER_CARD_INSTANT_OR_SORCERY = new FilterInstantOrSorceryCard();
|
public static final FilterInstantOrSorceryCard FILTER_CARD_INSTANT_OR_SORCERY = new FilterInstantOrSorceryCard();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue