Menu

Submission for Descendants' Path

173

Comment

status: incomplete been tested for weeks, it works fine when creature card found on top of library, but still can't handle the "else..." part for non creature card. Almost give up. :) hope someone might continue this.

Config

name=Descendants' Path
image=http://magiccards.info/scans/en/avr/173.jpg
value=4.134
rarity=R
type=Enchantment
cost={2}{G}
timing=enchantment
oracle=At the beginning of your upkeep, reveal the top card of your library. If it's a creature card that shares a creature type with a creature you control, you may cast that card without paying its mana cost. Otherwise, put that card on the bottom of your library.
requires_groovy_code

Script

def action = {
    final MagicGame game, final MagicEvent event, final MagicCard card ->
    if (event.isYes()) {
		game.doAction(new MagicRemoveCardAction(card, MagicLocationType.TopOfOwnersLibrary));
		game.doAction(new MagicPlayCardAction(card, event.getPlayer())); 
    } else {
		game.doAction(new MagicRemoveCardAction(card, MagicLocationType.TopOfOwnersLibrary));
		game.doAction(new MagicMoveCardAction(card, MagicLocationType.TopOfOwnersLibrary, MagicLocationType.BottomOfOwnersLibrary));
    }
}

[
	new MagicAtUpkeepTrigger() {
		@Override
		public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPlayer upkeepPlayer) {
			return permanent.isController(upkeepPlayer) ?
				new MagicEvent(
					permanent,
					this,
					"reveal the top card of your library. "+
					"If it's a creature card that shares a creature type with a creature you control, "+
					"you may cast that card without paying its mana cost. "+
					"Otherwise, put that card on the bottom of your library."
				):
				MagicEvent.NONE;
		}

		@Override
		public void executeEvent(final MagicGame game, final MagicEvent event) {
			final MagicPlayer player = event.getPlayer();
			final MagicCard card = player.getLibrary().getCardAtTop();
			game.doAction(new MagicRevealAction(card));
			if (card.hasType(MagicType.Creature)) {
				final Set<MagicSubType> subTypes = card.getSubTypeFlags();
				for (final MagicSubType subType : subTypes) {
					if (player.getNrOfPermanents(subType) > 0) {
						game.addEvent(new MagicEvent(
							event.getSource(),
							new MagicMayChoice(),
							card,
							action,
							"PN may\$ cast the card without paying its mana cost."
						));
//						<- Requires a May Choice. If no, perform card action as if not a creature.
						break;
					}
				}
			} else {
				game.doAction(new MagicRemoveCardAction(card, MagicLocationType.TopOfOwnersLibrary));
				game.doAction(new MagicMoveCardAction(card, MagicLocationType.TopOfOwnersLibrary, MagicLocationType.BottomOfOwnersLibrary));
			}
		}
	}
]
Pushed