From 5b0272edde440c8a4a18acc3960b9f4744bdcaf4 Mon Sep 17 00:00:00 2001 From: drmDev Date: Mon, 28 Mar 2016 04:51:42 -0400 Subject: [PATCH] Asylum Visitor (SOI) and tests implementation --- .../shadowsoverinnistrad/AsylumVisitor.java | 114 ++++++++++++++++++ .../cards/single/soi/AsylumVisitorTest.java | 93 ++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/shadowsoverinnistrad/AsylumVisitor.java create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/soi/AsylumVisitorTest.java diff --git a/Mage.Sets/src/mage/sets/shadowsoverinnistrad/AsylumVisitor.java b/Mage.Sets/src/mage/sets/shadowsoverinnistrad/AsylumVisitor.java new file mode 100644 index 00000000000..d11a3fdad9d --- /dev/null +++ b/Mage.Sets/src/mage/sets/shadowsoverinnistrad/AsylumVisitor.java @@ -0,0 +1,114 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.shadowsoverinnistrad; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.keyword.MadnessAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.players.Player; + +/** + * + * @author escplan9 (Derek Monturo - dmontur1 at gmail dot com) + */ +public class AsylumVisitor extends CardImpl { + + public AsylumVisitor(UUID ownerId) { + super(ownerId, 99, "Asylum Visitor", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{B}"); + this.expansionSetCode = "SOI"; + this.subtype.add("Vampire"); + this.subtype.add("Wizard"); + this.power = new MageInt(3); + this.toughness = new MageInt(1); + + // At the beginning of each player's upkeep, if that player has no cards in hand, you draw a card and you lose 1 life. + this.addAbility(new AsylumVisitorTriggeredAbility()); + + // Madness {1}{B} + this.addAbility(new MadnessAbility(this, new ManaCostsImpl("{1}{B}"))); + } + + public AsylumVisitor(final AsylumVisitor card) { + super(card); + } + + @Override + public AsylumVisitor copy() { + return new AsylumVisitor(this); + } +} + +class AsylumVisitorTriggeredAbility extends TriggeredAbilityImpl { + + public AsylumVisitorTriggeredAbility() { + super(Zone.BATTLEFIELD, null); + } + + public AsylumVisitorTriggeredAbility(final AsylumVisitorTriggeredAbility ability) { + super(ability); + } + + @Override + public AsylumVisitorTriggeredAbility copy() { + return new AsylumVisitorTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == EventType.UPKEEP_STEP_PRE; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + + Player you = game.getPlayer(this.getControllerId()); + Player upkeepPlayer = game.getPlayer(event.getPlayerId()); + + if (you != null && upkeepPlayer != null && upkeepPlayer.getHand().isEmpty()) { + you.drawCards(1, game); + you.loseLife(1, game); + return true; + } + + return false; + } + + @Override + public String getRule() { + return "At the beginning of each player's upkeep, if that player has no cards in hand, you draw a card and you lose 1 life."; + } +} \ No newline at end of file diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/soi/AsylumVisitorTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/soi/AsylumVisitorTest.java new file mode 100644 index 00000000000..78b165753b0 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/soi/AsylumVisitorTest.java @@ -0,0 +1,93 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.mage.test.cards.single.soi; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * Tests for Asylum Visitor: + * {1}{B} 3/1 Vampire Wizard Creature + * + * At the beginning of each player's upkeep, if that player has no cards in hand, you draw a card and you lose 1 life. + * Madness {1}{B} + * + * @author escplan9 (Derek Monturo - dmontur1 at gmail dot com) + */ +public class AsylumVisitorTest extends CardTestPlayerBase { + + /** + * No cards in own hand - draw card and lose life. + */ + @Test + public void testNoCardsInOwnHand() { + + addCard(Zone.BATTLEFIELD, playerA, "Asylum Visitor", 1); + + setStopAt(1, PhaseStep.UPKEEP); + execute(); + + assertLife(playerA, 19); + assertLife(playerB, 20); + assertHandCount(playerA, 1); + } + + /** + * Cards in own hand. + */ + @Test + public void testCardsInOwnHand() { + + addCard(Zone.BATTLEFIELD, playerA, "Asylum Visitor", 1); + addCard(Zone.HAND, playerA, "Bronze Sable", 3); // 2/1 artifact creature + + setStopAt(1, PhaseStep.UPKEEP); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + assertHandCount(playerA, 3); // 3 bronze sables! + } + + /** + * No cards in opponent's hand - draw card and lose life. + */ + @Test + public void testNoCardsInOpponentsHand() { + + addCard(Zone.HAND, playerA, "Asylum Visitor", 1); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Asylum Visitor"); + + setStopAt(2, PhaseStep.UPKEEP); + execute(); + + assertLife(playerA, 19); + assertLife(playerB, 20); + assertHandCount(playerA, 1); + } + + /** + * Cards in opponent's hand. + */ + @Test + public void testCardsInOpponentsHand() { + + addCard(Zone.HAND, playerA, "Asylum Visitor", 1); + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3); + addCard(Zone.HAND, playerB, "Bronze Sable", 3); // 2/1 artifact creature + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Asylum Visitor"); + setStopAt(2, PhaseStep.UPKEEP); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + assertHandCount(playerA, 0); + assertHandCount(playerB, 3); // 3 bronze sables! + } +}