forked from External/mage
[AVR] Homicidal Seclusion + several tests
This commit is contained in:
parent
a40a1bb3f5
commit
e003b43214
4 changed files with 236 additions and 7 deletions
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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.avacynrestored;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.common.OneControlledCreatureCondition;
|
||||
import mage.abilities.decorator.ConditionalContinousEffect;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continious.BoostControlledEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
|
||||
import mage.abilities.keyword.LifelinkAbility;
|
||||
import mage.cards.CardImpl;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
*/
|
||||
public class HomicidalSeclusion extends CardImpl<HomicidalSeclusion> {
|
||||
|
||||
private static final String rule = "As long as you control exactly one creature, that creature gets +3/+1 and lifelink";
|
||||
|
||||
public HomicidalSeclusion(UUID ownerId) {
|
||||
super(ownerId, 108, "Homicidal Seclusion", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{4}{B}");
|
||||
this.expansionSetCode = "AVR";
|
||||
|
||||
this.color.setBlack(true);
|
||||
|
||||
// As long as you control exactly one creature, that creature gets +3/+1 and has lifelink.
|
||||
ContinuousEffect boostEffect = new BoostControlledEffect(3, 1, Constants.Duration.WhileOnBattlefield);
|
||||
Effect effect = new ConditionalContinousEffect(boostEffect, new OneControlledCreatureCondition(), rule);
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect));
|
||||
|
||||
ContinuousEffect lifelinkEffect = new GainAbilityControlledEffect(LifelinkAbility.getInstance(), Constants.Duration.WhileOnBattlefield);
|
||||
effect = new ConditionalContinousEffect(lifelinkEffect, new OneControlledCreatureCondition(), null);
|
||||
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, effect));
|
||||
}
|
||||
|
||||
public HomicidalSeclusion(final HomicidalSeclusion card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HomicidalSeclusion copy() {
|
||||
return new HomicidalSeclusion(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
package org.mage.test.cards.single;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.AbilitiesImpl;
|
||||
import mage.abilities.keyword.LifelinkAbility;
|
||||
import mage.filter.Filter;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noxx
|
||||
*/
|
||||
public class HomicidalSeclusionTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Tests that there will be no effect when there is more than one creature
|
||||
*/
|
||||
@Test
|
||||
public void testNoSingleCard() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Homicidal Seclusion");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Air Elemental", 1);
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Horned Turtle", 1);
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertPowerToughness(playerA, "Air Elemental", 4, 4, Filter.ComparisonScope.All);
|
||||
assertPowerToughness(playerA, "Horned Turtle", 1, 4, Filter.ComparisonScope.All);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests effect of a single card for a single creature
|
||||
*/
|
||||
@Test
|
||||
public void testSingleCard() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Homicidal Seclusion");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Horned Turtle", 1);
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain");
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertPowerToughness(playerA, "Horned Turtle", 4, 5, Filter.ComparisonScope.All);
|
||||
|
||||
Abilities abilities = new AbilitiesImpl();
|
||||
abilities.add(LifelinkAbility.getInstance());
|
||||
assertAbilities(playerA, "Horned Turtle", abilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests several copies of Homicidal Seclusion card
|
||||
*/
|
||||
@Test
|
||||
public void testMultiInstances() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Homicidal Seclusion", 2);
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Horned Turtle", 1);
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertPowerToughness(playerA, "Horned Turtle", 7, 6, Filter.ComparisonScope.All);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that effect will be applied later
|
||||
*/
|
||||
@Test
|
||||
public void testApplyInProgress() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Homicidal Seclusion");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Air Elemental");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain");
|
||||
addCard(Constants.Zone.HAND, playerA, "Lightning Bolt");
|
||||
|
||||
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", "Elite Vanguard");
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertPermanentCount(playerA, "Elite Vanguard", 0);
|
||||
assertPowerToughness(playerA, "Air Elemental", 7, 5, Filter.ComparisonScope.All);
|
||||
|
||||
Abilities abilities = new AbilitiesImpl();
|
||||
abilities.add(LifelinkAbility.getInstance());
|
||||
assertAbilities(playerA, "Air Elemental", abilities);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,25 +1,24 @@
|
|||
package org.mage.test.serverside.base.impl;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.PhaseStep;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.Filter;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.players.Player;
|
||||
import mage.sets.Sets;
|
||||
import org.junit.Assert;
|
||||
import org.mage.test.player.TestPlayer;
|
||||
import org.mage.test.serverside.base.CardTestAPI;
|
||||
import org.mage.test.serverside.base.MageTestPlayerBase;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.PhaseStep;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.ExileZone;
|
||||
import org.mage.test.player.TestPlayer;
|
||||
|
||||
/**
|
||||
* API for test initialization and asserting the test results.
|
||||
|
|
@ -326,7 +325,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
|
||||
if (permanent.getName().equals(cardName)) {
|
||||
found = permanent;
|
||||
break;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
*/
|
||||
public class OneControlledCreatureCondition implements Condition {
|
||||
|
||||
private static OneControlledCreatureCondition fInstance = new OneControlledCreatureCondition();
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
|
||||
public static Condition getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getBattlefield().countAll(filter, source.getControllerId()) == 1;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue