mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
- refactored Ethereal Valkyrie to work with Split/MDFC/Adventure cards as per weirddan455 commit.
This commit is contained in:
parent
3af5cb9514
commit
aa13b06af9
2 changed files with 110 additions and 71 deletions
|
@ -10,9 +10,13 @@ import mage.abilities.effects.Effect;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.abilities.keyword.ForetellAbility;
|
||||
import mage.cards.AdventureCard;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.ModalDoubleFacesCard;
|
||||
import mage.cards.ModalDoubleFacesCardHalf;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
|
@ -125,22 +129,58 @@ class EtherealValkyrieEffect extends OneShotEffect {
|
|||
if (exileCard == null) {
|
||||
return false;
|
||||
}
|
||||
String foretellCost = CardUtil.reduceCost(exileCard.getSpellAbility().getManaCostsToPay(), 2).getText();
|
||||
game.getState().setValue(exileCard.getId().toString() + "Foretell Cost", foretellCost);
|
||||
game.getState().setValue(exileCard.getId().toString() + "Foretell Turn Number", game.getTurnNum());
|
||||
UUID exileId = CardUtil.getExileZoneId(exileCard.getId().toString() + "foretellAbility", game);
|
||||
controller.moveCardsToExile(exileCard, source, game, true, exileId, " Foretell Turn Number: " + game.getTurnNum());
|
||||
exileCard.setFaceDown(true, game);
|
||||
ForetellAbility foretellAbility = new ForetellAbility(exileCard, foretellCost);
|
||||
foretellAbility.setSourceId(exileCard.getId());
|
||||
foretellAbility.setControllerId(exileCard.getOwnerId());
|
||||
game.getState().addOtherAbility(exileCard, foretellAbility);
|
||||
foretellAbility.activate(game, true);
|
||||
ContinuousEffect effect = foretellAbility.new ForetellAddCostEffect(new MageObjectReference(exileCard, game));
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
// process Split, MDFC, and Adventure cards first
|
||||
// note that 'Foretell Cost' refers to the main card (left) and 'Foretell Split Cost' refers to the (right) card if it exists
|
||||
ForetellAbility foretellAbility = null;
|
||||
if (exileCard instanceof SplitCard) {
|
||||
String leftHalfCost = CardUtil.reduceCost(((SplitCard) exileCard).getLeftHalfCard().getManaCost(), 2).getText();
|
||||
String rightHalfCost = CardUtil.reduceCost(((SplitCard) exileCard).getRightHalfCard().getManaCost(), 2).getText();
|
||||
game.getState().setValue(exileCard.getMainCard().getId().toString() + "Foretell Cost", leftHalfCost);
|
||||
game.getState().setValue(exileCard.getMainCard().getId().toString() + "Foretell Split Cost", rightHalfCost);
|
||||
foretellAbility = new ForetellAbility(exileCard, leftHalfCost, rightHalfCost);
|
||||
} else if (exileCard instanceof ModalDoubleFacesCard) {
|
||||
ModalDoubleFacesCardHalf leftHalfCard = ((ModalDoubleFacesCard) exileCard).getLeftHalfCard();
|
||||
if (!leftHalfCard.isLand()) {
|
||||
String leftHalfCost = CardUtil.reduceCost(leftHalfCard.getManaCost(), 2).getText();
|
||||
game.getState().setValue(exileCard.getMainCard().getId().toString() + "Foretell Cost", leftHalfCost);
|
||||
ModalDoubleFacesCardHalf rightHalfCard = ((ModalDoubleFacesCard) exileCard).getRightHalfCard();
|
||||
if (rightHalfCard.isLand()) {
|
||||
foretellAbility = new ForetellAbility(exileCard, leftHalfCost);
|
||||
} else {
|
||||
String rightHalfCost = CardUtil.reduceCost(rightHalfCard.getManaCost(), 2).getText();
|
||||
game.getState().setValue(exileCard.getMainCard().getId().toString() + "Foretell Split Cost", rightHalfCost);
|
||||
foretellAbility = new ForetellAbility(exileCard, leftHalfCost, rightHalfCost);
|
||||
}
|
||||
}
|
||||
} else if (exileCard instanceof AdventureCard) {
|
||||
String creatureCost = CardUtil.reduceCost(exileCard.getMainCard().getManaCost(), 2).getText();
|
||||
String spellCost = CardUtil.reduceCost(((AdventureCard) exileCard).getSpellCard().getManaCost(), 2).getText();
|
||||
game.getState().setValue(exileCard.getMainCard().getId().toString() + "Foretell Cost", creatureCost);
|
||||
game.getState().setValue(exileCard.getMainCard().getId().toString() + "Foretell Split Cost", spellCost);
|
||||
foretellAbility = new ForetellAbility(exileCard, creatureCost, spellCost);
|
||||
} else {
|
||||
// normal card
|
||||
String costText = CardUtil.reduceCost(exileCard.getManaCost(), 2).getText();
|
||||
game.getState().setValue(exileCard.getId().toString() + "Foretell Cost", costText);
|
||||
foretellAbility = new ForetellAbility(exileCard, costText);
|
||||
}
|
||||
// all done pre-processing so stick the foretell cost effect onto the main card
|
||||
// note that the card is not foretell'd into exile, it is put into exile and made foretold
|
||||
if (foretellAbility != null) {
|
||||
game.getState().setValue(exileCard.getMainCard().getId().toString() + "Foretell Turn Number", game.getTurnNum());
|
||||
UUID exileId = CardUtil.getExileZoneId(exileCard.getMainCard().getId().toString() + "foretellAbility", game);
|
||||
controller.moveCardsToExile(exileCard, source, game, true, exileId, " Foretell Turn Number: " + game.getTurnNum());
|
||||
exileCard.setFaceDown(true, game);
|
||||
foretellAbility.setSourceId(exileCard.getId());
|
||||
foretellAbility.setControllerId(exileCard.getOwnerId());
|
||||
game.getState().addOtherAbility(exileCard, foretellAbility);
|
||||
foretellAbility.activate(game, true);
|
||||
ContinuousEffect effect = foretellAbility.new ForetellAddCostEffect(new MageObjectReference(exileCard, game));
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,56 +1,55 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.keyword.ForetellAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class ForetellSourceControllerTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public ForetellSourceControllerTriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect, false);
|
||||
}
|
||||
|
||||
public ForetellSourceControllerTriggeredAbility(final ForetellSourceControllerTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.TAKEN_SPECIAL_ACTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
//UUID specialAction = event.getTargetId();
|
||||
Card card = game.getCard(event.getSourceId());
|
||||
Player player = game.getPlayer(event.getPlayerId());
|
||||
if (card == null || player == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isControlledBy(player.getId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return card.getAbilities(game).containsClass(ForetellAbility.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever you foretell a card, " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForetellSourceControllerTriggeredAbility copy() {
|
||||
return new ForetellSourceControllerTriggeredAbility(this);
|
||||
}
|
||||
|
||||
}
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.keyword.ForetellAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class ForetellSourceControllerTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public ForetellSourceControllerTriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect, false);
|
||||
}
|
||||
|
||||
public ForetellSourceControllerTriggeredAbility(final ForetellSourceControllerTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.TAKEN_SPECIAL_ACTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Card card = game.getCard(event.getSourceId());
|
||||
Player player = game.getPlayer(event.getPlayerId());
|
||||
if (card == null || player == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isControlledBy(player.getId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return card.getAbilities(game).containsClass(ForetellAbility.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever you foretell a card, " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForetellSourceControllerTriggeredAbility copy() {
|
||||
return new ForetellSourceControllerTriggeredAbility(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue