From 834e245acc27a321953c09181fbf4e5989b83c78 Mon Sep 17 00:00:00 2001 From: ShawnieBoy Date: Sat, 6 Feb 2016 06:00:14 +0000 Subject: [PATCH] re-attempt Ancestral Memories --- incomplete/Ancestral_Memories.groovy | 90 +++++++++++----------------- 1 file changed, 36 insertions(+), 54 deletions(-) diff --git a/incomplete/Ancestral_Memories.groovy b/incomplete/Ancestral_Memories.groovy index dd35cd8200..384d1edb67 100644 --- a/incomplete/Ancestral_Memories.groovy +++ b/incomplete/Ancestral_Memories.groovy @@ -1,69 +1,51 @@ -def DrawTwo = { +def TakeTwo = { final MagicGame game, final MagicEvent event -> - event.processChosenCards(game, { - final MagicCard card -> - game.doAction(new MagicRemoveCardAction(card,MagicLocationType.OwnersLibrary)); - game.doAction(new MagicMoveCardAction(card,MagicLocationType.OwnersLibrary,MagicLocationType.OwnersHand)); - }); -}; - -def DiscardRest = { - final MagicGame game, final MagicEvent event -> - final MagicPlayer player = event.getPlayer(); - final int amount = (player.getLibrary().size() < 6) ? player.getLibrary().size() : 5; - for(int i = 0; i < amount; i++) { - game.doAction(new MagicMillLibraryAction(player,1)); - } -}; + event.processChosenCards(game, { + final MagicCard chosen -> + final MagicPlayer player = event.getPlayer(); + final MagicCardList top = new MagicCardList(player.getLibrary().getCardsFromTop(7)); + for (final MagicCard card : top) { + if (card == chosen) { + game.doAction(new ShiftCardAction( + card, + MagicLocationType.OwnersLibrary, + MagicLocationType.OwnersHand + )); + game.logAppendMessage(player, "A card is put into ${player.getName()}'s hand."); + } else { + game.doAction(new ShiftCardAction( + card, + MagicLocationType.OwnersLibrary, + MagicLocationType.Graveyard + )); + } + } + }); +} [ new MagicSpellCardEvent() { @Override - public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) { + public MagicEvent getEvent(final MagicCardOnStack cardOnStack, final MagicPayedCost payedCost) { return new MagicEvent( cardOnStack, this, - "PN looks at the top seven cards of his or her library. Then PN puts two of them into your hand and the rest into his or her graveyard." + "PN looks at the top seven cards of his or her library. " + + "PN puts two of them into his or her hand and the rest into his or her graveyard." ); } - + @Override public void executeEvent(final MagicGame game, final MagicEvent event) { - final MagicCardList choiceList = new MagicCardList(); - final int size = event.getPlayer().getLibrary().size(); - if (size == 1) game.doAction(new MagicDrawAction(event.getPlayer(),1)); - else if (size == 2) game.doAction(new MagicDrawAction(event.getPlayer(),2)); //truth to be told: "index out of bounds" is something to be hated naturally - else if (8 > size && size > 2) { - for(int i = 1; i <= size; i++) { - choiceList.add(event.getPlayer().getLibrary().get(size-i)); - } - game.addEvent(new MagicEvent( - event.getSource(), - new MagicFromCardListChoice(choiceList,2), - DrawTwo, - "\$" - )); - game.addEvent(new MagicEvent( - event.getSource(), - DiscardRest, - "" - )); - } else if (size > 7) { - for(int i = 0; i < 7; i++) { - choiceList.add(event.getPlayer().getLibrary().get(7-i)); - } - game.addEvent(new MagicEvent( - event.getSource(), - new MagicFromCardListChoice(choiceList,2), - DrawTwo, - "\$" - )); - game.addEvent(new MagicEvent( - event.getSource(), - DiscardRest, - "" - )); - } + final MagicCardList topCards = event.getPlayer().getLibrary().getCardsFromTop(7); + game.addEvent(new MagicEvent( + event.getSource(), + new MagicFromCardListChoice(topCards, 2), + MagicGraveyardTargetPicker.ReturnToHand, + TakeTwo, + "" + )); } } ] +//Only processes the first card chosen