mirror of
https://github.com/correl/mage.git
synced 2024-12-30 19:10:36 +00:00
[MOC] Use utility functions for Rashmi and Ragavan.
This commit is contained in:
parent
1eae1c533e
commit
b4f368eee8
1 changed files with 11 additions and 18 deletions
|
@ -1,27 +1,26 @@
|
||||||
package mage.cards.r;
|
package mage.cards.r;
|
||||||
|
|
||||||
import mage.ApprovingObject;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
||||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||||
import mage.abilities.effects.ContinuousEffect;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.CreateTokenEffect;
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.cards.CardsImpl;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
|
import mage.filter.FilterCard;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
|
import mage.filter.predicate.mageobject.ManaValuePredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.token.TreasureToken;
|
import mage.game.permanent.token.TreasureToken;
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetOpponent;
|
import mage.target.common.TargetOpponent;
|
||||||
import mage.target.targetpointer.FixedTargets;
|
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
import mage.watchers.common.SpellsCastWatcher;
|
import mage.watchers.common.SpellsCastWatcher;
|
||||||
|
|
||||||
|
@ -49,9 +48,7 @@ public final class RashmiAndRagavan extends CardImpl {
|
||||||
// Then you may cast the exiled card without paying its mana cost if it’s a spell with mana value
|
// Then you may cast the exiled card without paying its mana cost if it’s a spell with mana value
|
||||||
// less than the number of artifacts you control.
|
// less than the number of artifacts you control.
|
||||||
// If you don’t cast it this way, you may cast it this turn.
|
// If you don’t cast it this way, you may cast it this turn.
|
||||||
Ability ability = new RashmiAndRagavanTriggeredAbility();
|
this.addAbility(new RashmiAndRagavanTriggeredAbility());
|
||||||
ability.addTarget(new TargetOpponent());
|
|
||||||
this.addAbility(ability, new SpellsCastWatcher());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private RashmiAndRagavan(final RashmiAndRagavan card) {
|
private RashmiAndRagavan(final RashmiAndRagavan card) {
|
||||||
|
@ -68,6 +65,8 @@ class RashmiAndRagavanTriggeredAbility extends SpellCastControllerTriggeredAbili
|
||||||
|
|
||||||
RashmiAndRagavanTriggeredAbility() {
|
RashmiAndRagavanTriggeredAbility() {
|
||||||
super(new CreateTokenEffect(new TreasureToken()), false);
|
super(new CreateTokenEffect(new TreasureToken()), false);
|
||||||
|
this.addTarget(new TargetOpponent());
|
||||||
|
this.addWatcher(new SpellsCastWatcher());
|
||||||
this.addEffect(new RashmiAndRagavanEffect());
|
this.addEffect(new RashmiAndRagavanEffect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +124,6 @@ class RashmiAndRagavanEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Boolean cardWasCast = false;
|
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||||
if (controller == null || player == null) {
|
if (controller == null || player == null) {
|
||||||
|
@ -149,17 +147,12 @@ class RashmiAndRagavanEffect extends OneShotEffect {
|
||||||
int artifactCount = new PermanentsOnBattlefieldCount(
|
int artifactCount = new PermanentsOnBattlefieldCount(
|
||||||
StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT
|
StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT
|
||||||
).calculate(game, source, this);
|
).calculate(game, source, this);
|
||||||
if (!card.isLand() && card.getManaValue() < artifactCount && controller.chooseUse(Outcome.PlayForFree, "Cast " + card.getName()
|
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
|
||||||
+ " without paying its mana cost?", source, game)) {
|
FilterCard filter = new FilterCard();
|
||||||
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
|
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, artifactCount));
|
||||||
cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true),
|
Boolean cardWasCast = CardUtil.castSpellWithAttributesForFree(controller, source, game, new CardsImpl(card), filter);
|
||||||
game, true, new ApprovingObject(source, game));
|
|
||||||
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
|
|
||||||
}
|
|
||||||
if (!cardWasCast) {
|
if (!cardWasCast) {
|
||||||
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.EndOfTurn, false, true);
|
CardUtil.makeCardPlayable(game, source, card, Duration.EndOfTurn, false, controller.getId(), null);
|
||||||
effect.setTargetPointer(new FixedTargets(cards, game));
|
|
||||||
game.addEffect(effect, source);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue