mirror of
https://github.com/correl/mage.git
synced 2025-04-08 09:11:04 -09:00
* Squandered Resources - Fixed available mana calculation (#6698).
This commit is contained in:
parent
309b3f5636
commit
9dfc6eed69
2 changed files with 330 additions and 300 deletions
Mage.Sets/src/mage/cards/s
Mage.Tests/src/test/java/org/mage/test/cards/mana
|
@ -1,34 +1,33 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||
import mage.abilities.mana.SimpleManaAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledLandPermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.mana.AnyColorLandsProduceManaAbility;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.abilities.mana.SimpleManaAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterControlledLandPermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
/**
|
||||
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
|
||||
|
@ -68,14 +67,28 @@ class SquanderedResourcesEffect extends ManaEffect {
|
|||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netManas = new ArrayList<>();
|
||||
Set<ManaType> manaTypes = new HashSet<>();
|
||||
if (game != null && game.inCheckPlayableState()) {
|
||||
// add color combinations of available mana
|
||||
ManaOptions allPossibleMana = new ManaOptions();
|
||||
for (Permanent land : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), game)) {
|
||||
manaTypes.addAll(AnyColorLandsProduceManaAbility.getManaTypesFromPermanent(land, game));
|
||||
ManaOptions currentPossibleMana = new ManaOptions();
|
||||
Set<ManaType> manaTypes = AnyColorLandsProduceManaAbility.getManaTypesFromPermanent(land, game);
|
||||
if (manaTypes.size() == 5 && !manaTypes.contains(ManaType.COLORLESS) || manaTypes.size() == 6) {
|
||||
currentPossibleMana.add(Mana.AnyMana(1));
|
||||
if (manaTypes.contains(ManaType.COLORLESS)) {
|
||||
currentPossibleMana.add(new Mana(ManaType.COLORLESS));
|
||||
}
|
||||
} else {
|
||||
for (ManaType manaType : manaTypes) {
|
||||
currentPossibleMana.add(new Mana(manaType));
|
||||
}
|
||||
}
|
||||
allPossibleMana.addMana(currentPossibleMana);
|
||||
}
|
||||
} else {
|
||||
manaTypes = getManaTypesFromSacrificedPermanent(game, source);
|
||||
allPossibleMana.removeDuplicated();
|
||||
return allPossibleMana.stream().collect(Collectors.toList());
|
||||
}
|
||||
Set<ManaType> manaTypes = getManaTypesFromSacrificedPermanent(game, source);
|
||||
if (manaTypes.size() == 5 && !manaTypes.contains(ManaType.COLORLESS) && !manaTypes.contains(ManaType.GENERIC)) {
|
||||
netManas.add(Mana.AnyMana(1));
|
||||
} else {
|
||||
|
|
|
@ -214,7 +214,6 @@ public class NonTappingManaAbilitiesTest extends CardTestPlayerBase {
|
|||
// {T}: Add {U}. If you played a land this turn, add {B} instead.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "River of Tears", 1);
|
||||
|
||||
|
||||
// Sacrifice a land: Add one mana of any type the sacrificed land could produce.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Squandered Resources", 1);
|
||||
|
||||
|
@ -225,15 +224,15 @@ public class NonTappingManaAbilitiesTest extends CardTestPlayerBase {
|
|||
|
||||
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
|
||||
Assert.assertEquals("mana variations don't fit", 9, manaOptions.size());
|
||||
assertManaOptions("{C}{U}{R}{R}{G}", manaOptions);
|
||||
assertManaOptions("{C}{U}{U}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{U}{U}{R}{G}", manaOptions);
|
||||
assertManaOptions("{C}{U}{G}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{U}{R}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{W}{U}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{W}{U}{R}{G}", manaOptions);
|
||||
assertManaOptions("{C}{C}{U}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{C}{U}{R}{G}", manaOptions);
|
||||
assertManaOptions("{C}{U}{U}{U}{R}{R}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{U}{U}{U}{G}{G}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{U}{U}{U}{R}{G}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{C}{U}{U}{R}{R}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{C}{U}{U}{G}{G}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{C}{U}{U}{R}{G}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{W}{U}{U}{R}{R}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{W}{U}{U}{G}{G}{G}{G}", manaOptions);
|
||||
assertManaOptions("{C}{W}{U}{U}{R}{G}{G}{G}", manaOptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -253,7 +252,7 @@ public class NonTappingManaAbilitiesTest extends CardTestPlayerBase {
|
|||
|
||||
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
|
||||
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
|
||||
assertManaOptions("{G}{Any}{Any}", manaOptions);
|
||||
assertManaOptions("{G}{G}{Any}{Any}", manaOptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -272,4 +271,22 @@ public class NonTappingManaAbilitiesTest extends CardTestPlayerBase {
|
|||
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
|
||||
assertManaOptions("{R}{R}{R}{R}{R}{R}", manaOptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestSquanderedResourcesTwoSwamps() {
|
||||
setStrictChooseMode(true);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
|
||||
// Sacrifice a land: Add one mana of any type the sacrificed land could produce.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Squandered Resources", 1);
|
||||
|
||||
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertAllCommandsUsed();
|
||||
|
||||
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
|
||||
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
|
||||
assertManaOptions("{B}{B}{B}{B}", manaOptions);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue