mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
* Fixed a problem with triggered mana abilities. Fixed a problem that AI did not always select the needed mana color. Fixed a problem with Reflecting Pool not taking triggered mana abilities into account.
This commit is contained in:
parent
f07408f995
commit
d2561c1752
74 changed files with 744 additions and 436 deletions
|
|
@ -14,6 +14,24 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* 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 org.mage.test.cards.mana;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ReflectingPoolTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Reflecting Pool does not count Crumbling Vestige as a source of all mana
|
||||
* colors
|
||||
*/
|
||||
@Test
|
||||
public void testTriggeredManaAbility() {
|
||||
addCard(Zone.HAND, playerA, "Lightning Bolt", 1); // {R}
|
||||
|
||||
// {T}: Add to your mana pool one mana of any type that a land you control could produce.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Reflecting Pool", 1);
|
||||
// Crumbling Vestige enters the battlefield tapped.
|
||||
// When Crumbling Vestige enters the battlefield, add one mana of any color to your mana pool.
|
||||
// {T}: Add {C} to you mana pool.
|
||||
addCard(Zone.HAND, playerA, "Crumbling Vestige", 1);
|
||||
|
||||
playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Crumbling Vestige");
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Crumbling Vestige", 1);
|
||||
assertGraveyardCount(playerA, "Lightning Bolt", 1);
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 17);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ import mage.abilities.costs.Costs;
|
|||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
|
|
@ -414,7 +414,7 @@ public class TestPlayer implements Player {
|
|||
|
||||
for (MageObject mageObject : manaObjects) {
|
||||
if (mageObject instanceof Permanent) {
|
||||
for (Ability manaAbility : ((Permanent) mageObject).getAbilities(game).getAvailableManaAbilities(Zone.BATTLEFIELD, game)) {
|
||||
for (Ability manaAbility : ((Permanent) mageObject).getAbilities(game).getAvailableActivatedManaAbilities(Zone.BATTLEFIELD, game)) {
|
||||
if (manaAbility.toString().startsWith(groups[0])) {
|
||||
Ability newManaAbility = manaAbility.copy();
|
||||
computerPlayer.activateAbility((ActivatedAbility) newManaAbility, game);
|
||||
|
|
@ -423,7 +423,7 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
}
|
||||
} else if (mageObject instanceof Card) {
|
||||
for (Ability manaAbility : ((Card) mageObject).getAbilities(game).getAvailableManaAbilities(game.getState().getZone(mageObject.getId()), game)) {
|
||||
for (Ability manaAbility : ((Card) mageObject).getAbilities(game).getAvailableActivatedManaAbilities(game.getState().getZone(mageObject.getId()), game)) {
|
||||
if (manaAbility.toString().startsWith(groups[0])) {
|
||||
Ability newManaAbility = manaAbility.copy();
|
||||
computerPlayer.activateAbility((ActivatedAbility) newManaAbility, game);
|
||||
|
|
@ -432,7 +432,7 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for (Ability manaAbility : mageObject.getAbilities().getAvailableManaAbilities(game.getState().getZone(mageObject.getId()), game)) {
|
||||
for (Ability manaAbility : mageObject.getAbilities().getAvailableActivatedManaAbilities(game.getState().getZone(mageObject.getId()), game)) {
|
||||
if (manaAbility.toString().startsWith(groups[0])) {
|
||||
Ability newManaAbility = manaAbility.copy();
|
||||
computerPlayer.activateAbility((ActivatedAbility) newManaAbility, game);
|
||||
|
|
@ -444,7 +444,7 @@ public class TestPlayer implements Player {
|
|||
}
|
||||
List<Permanent> manaPermsWithCost = computerPlayer.getAvailableManaProducersWithCost(game);
|
||||
for (Permanent perm : manaPermsWithCost) {
|
||||
for (ManaAbility manaAbility : perm.getAbilities().getAvailableManaAbilities(Zone.BATTLEFIELD, game)) {
|
||||
for (ActivatedManaAbilityImpl manaAbility : perm.getAbilities().getAvailableActivatedManaAbilities(Zone.BATTLEFIELD, game)) {
|
||||
if (manaAbility.toString().startsWith(groups[0]) && manaAbility.canActivate(computerPlayer.getId(), game)) {
|
||||
Ability newManaAbility = manaAbility.copy();
|
||||
computerPlayer.activateAbility((ActivatedAbility) newManaAbility, game);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import mage.abilities.costs.mana.ManaCost;
|
|||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.mana.BasicManaAbility;
|
||||
import mage.abilities.mana.BlackManaAbility;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||
import mage.abilities.mana.RedManaAbility;
|
||||
import mage.abilities.mana.WhiteManaAbility;
|
||||
import mage.cards.Card;
|
||||
|
|
@ -188,10 +188,10 @@ public class ManaUtilTest extends CardTestPlayerBase {
|
|||
Card card = CardRepository.instance.findCard(landName).getCard();
|
||||
Assert.assertNotNull(card);
|
||||
|
||||
HashMap<UUID, ManaAbility> useableAbilities = getManaAbilities(card);
|
||||
HashMap<UUID, ActivatedManaAbilityImpl> useableAbilities = getManaAbilities(card);
|
||||
Assert.assertEquals(expected1, useableAbilities.size());
|
||||
|
||||
useableAbilities = ManaUtil.tryToAutoPay(unpaid, (LinkedHashMap<UUID, ManaAbility>) useableAbilities);
|
||||
useableAbilities = ManaUtil.tryToAutoPay(unpaid, (LinkedHashMap<UUID, ActivatedManaAbilityImpl>) useableAbilities);
|
||||
Assert.assertEquals(expected2, useableAbilities.size());
|
||||
}
|
||||
|
||||
|
|
@ -216,12 +216,12 @@ public class ManaUtilTest extends CardTestPlayerBase {
|
|||
Card card = CardRepository.instance.findCard(landName).getCard();
|
||||
Assert.assertNotNull(card);
|
||||
|
||||
HashMap<UUID, ManaAbility> useableAbilities = getManaAbilities(card);
|
||||
HashMap<UUID, ActivatedManaAbilityImpl> useableAbilities = getManaAbilities(card);
|
||||
Assert.assertEquals(expected1, useableAbilities.size());
|
||||
|
||||
useableAbilities = ManaUtil.tryToAutoPay(unpaid, (LinkedHashMap<UUID, ManaAbility>) useableAbilities);
|
||||
useableAbilities = ManaUtil.tryToAutoPay(unpaid, (LinkedHashMap<UUID, ActivatedManaAbilityImpl>) useableAbilities);
|
||||
Assert.assertEquals(1, useableAbilities.size());
|
||||
ManaAbility ability = useableAbilities.values().iterator().next();
|
||||
ActivatedManaAbilityImpl ability = useableAbilities.values().iterator().next();
|
||||
Assert.assertTrue("Wrong mana ability has been chosen", expectedChosen.isInstance(ability));
|
||||
}
|
||||
|
||||
|
|
@ -251,12 +251,12 @@ public class ManaUtilTest extends CardTestPlayerBase {
|
|||
* @param card Card to extract mana abilities from.
|
||||
* @return
|
||||
*/
|
||||
private HashMap<UUID, ManaAbility> getManaAbilities(Card card) {
|
||||
HashMap<UUID, ManaAbility> useableAbilities = new LinkedHashMap<>();
|
||||
private HashMap<UUID, ActivatedManaAbilityImpl> getManaAbilities(Card card) {
|
||||
HashMap<UUID, ActivatedManaAbilityImpl> useableAbilities = new LinkedHashMap<>();
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof ManaAbility) {
|
||||
if (ability instanceof ActivatedManaAbilityImpl) {
|
||||
ability.newId(); // we need to assign id manually as we are not in game
|
||||
useableAbilities.put(ability.getId(), (ManaAbility) ability);
|
||||
useableAbilities.put(ability.getId(), (ActivatedManaAbilityImpl) ability);
|
||||
}
|
||||
}
|
||||
return useableAbilities;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue