mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
* Axebane Guardian - Fixed netMana hadling.
This commit is contained in:
parent
ce20eb545e
commit
28057fff80
4 changed files with 49 additions and 73 deletions
|
@ -28,25 +28,18 @@
|
||||||
package mage.sets.returntoravnica;
|
package mage.sets.returntoravnica;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.Rarity;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
import mage.abilities.effects.common.ManaEffect;
|
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||||
import mage.abilities.keyword.DefenderAbility;
|
import mage.abilities.keyword.DefenderAbility;
|
||||||
import mage.abilities.mana.SimpleManaAbility;
|
import mage.abilities.mana.DynamicManaAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.choices.ChoiceColor;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.predicate.mageobject.AbilityPredicate;
|
import mage.filter.predicate.mageobject.AbilityPredicate;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.players.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -54,6 +47,12 @@ import mage.players.Player;
|
||||||
*/
|
*/
|
||||||
public class AxebaneGuardian extends CardImpl {
|
public class AxebaneGuardian extends CardImpl {
|
||||||
|
|
||||||
|
private static final FilterPermanent filter = new FilterControlledCreaturePermanent("creatures with defender you control");
|
||||||
|
|
||||||
|
static{
|
||||||
|
filter.add(new AbilityPredicate(DefenderAbility.class));
|
||||||
|
}
|
||||||
|
|
||||||
public AxebaneGuardian(UUID ownerId) {
|
public AxebaneGuardian(UUID ownerId) {
|
||||||
super(ownerId, 115, "Axebane Guardian", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{G}");
|
super(ownerId, 115, "Axebane Guardian", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{G}");
|
||||||
this.expansionSetCode = "RTR";
|
this.expansionSetCode = "RTR";
|
||||||
|
@ -66,8 +65,10 @@ public class AxebaneGuardian extends CardImpl {
|
||||||
|
|
||||||
// Defender
|
// Defender
|
||||||
this.addAbility(DefenderAbility.getInstance());
|
this.addAbility(DefenderAbility.getInstance());
|
||||||
|
|
||||||
// {tap}: Add X mana in any combination of colors to your mana pool, where X is the number of creatures with defender you control.
|
// {tap}: Add X mana in any combination of colors to your mana pool, where X is the number of creatures with defender you control.
|
||||||
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new AxebaneGuardianManaEffect(), new TapSourceCost()));
|
this.addAbility(new DynamicManaAbility(new Mana(0,0,0,0,0,0,1), new PermanentsOnBattlefieldCount(filter), new TapSourceCost(),
|
||||||
|
"Add X mana in any combination of colors to your mana pool, where X is the number of creatures with defender you control."));
|
||||||
}
|
}
|
||||||
|
|
||||||
public AxebaneGuardian(final AxebaneGuardian card) {
|
public AxebaneGuardian(final AxebaneGuardian card) {
|
||||||
|
@ -79,61 +80,3 @@ public class AxebaneGuardian extends CardImpl {
|
||||||
return new AxebaneGuardian(this);
|
return new AxebaneGuardian(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class AxebaneGuardianManaEffect extends ManaEffect {
|
|
||||||
|
|
||||||
|
|
||||||
private static final FilterPermanent filter = new FilterControlledCreaturePermanent("creatures with defender you control");
|
|
||||||
static{
|
|
||||||
filter.add(new AbilityPredicate(DefenderAbility.class));
|
|
||||||
}
|
|
||||||
public AxebaneGuardianManaEffect() {
|
|
||||||
super();
|
|
||||||
this.staticText = "Add X mana in any combination of colors to your mana pool, where X is the number of creatures with defender you control";
|
|
||||||
}
|
|
||||||
|
|
||||||
public AxebaneGuardianManaEffect(final AxebaneGuardianManaEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AxebaneGuardianManaEffect copy() {
|
|
||||||
return new AxebaneGuardianManaEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
|
||||||
if(player != null){
|
|
||||||
int x = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
|
|
||||||
|
|
||||||
Mana mana = new Mana();
|
|
||||||
for(int i = 0; i < x; i++){
|
|
||||||
ChoiceColor choiceColor = new ChoiceColor();
|
|
||||||
while (!player.choose(Outcome.Benefit, choiceColor, game)) {
|
|
||||||
if (!player.isInGame()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (choiceColor.getColor().isBlack()) {
|
|
||||||
mana.addBlack();
|
|
||||||
} else if (choiceColor.getColor().isBlue()) {
|
|
||||||
mana.addBlue();
|
|
||||||
} else if (choiceColor.getColor().isRed()) {
|
|
||||||
mana.addRed();
|
|
||||||
} else if (choiceColor.getColor().isGreen()) {
|
|
||||||
mana.addGreen();
|
|
||||||
} else if (choiceColor.getColor().isWhite()) {
|
|
||||||
mana.addWhite();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player.getManaPool().addMana(mana, game, source);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -58,8 +58,11 @@ public class CryptOfAgadeem extends CardImpl {
|
||||||
super(ownerId, 212, "Crypt of Agadeem", Rarity.RARE, new CardType[]{CardType.LAND}, "");
|
super(ownerId, 212, "Crypt of Agadeem", Rarity.RARE, new CardType[]{CardType.LAND}, "");
|
||||||
this.expansionSetCode = "ZEN";
|
this.expansionSetCode = "ZEN";
|
||||||
|
|
||||||
|
// Crypt of Agadeem enters the battlefield tapped.
|
||||||
this.addAbility(new EntersBattlefieldTappedAbility());
|
this.addAbility(new EntersBattlefieldTappedAbility());
|
||||||
|
// {T}: Add {B} to your mana pool.
|
||||||
this.addAbility(new BlackManaAbility());
|
this.addAbility(new BlackManaAbility());
|
||||||
|
// {2}, {T}: Add {B} to your mana pool for each black creature card in your graveyard.
|
||||||
DynamicManaAbility ability = new DynamicManaAbility(Mana.BlackMana, new CardsInControllerGraveyardCount(filter), new GenericManaCost(2));
|
DynamicManaAbility ability = new DynamicManaAbility(Mana.BlackMana, new CardsInControllerGraveyardCount(filter), new GenericManaCost(2));
|
||||||
ability.addCost(new TapSourceCost());
|
ability.addCost(new TapSourceCost());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
|
@ -31,7 +31,10 @@ import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
|
import mage.choices.ChoiceColor;
|
||||||
|
import mage.constants.Outcome;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -70,7 +73,7 @@ public class DynamicManaEffect extends BasicManaEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
computeMana(game, source);
|
computeMana(false, game, source);
|
||||||
game.getPlayer(source.getControllerId()).getManaPool().addMana(computedMana, game, source);
|
game.getPlayer(source.getControllerId()).getManaPool().addMana(computedMana, game, source);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +86,7 @@ public class DynamicManaEffect extends BasicManaEffect {
|
||||||
return super.getText(mode) + " for each " + amount.getMessage();
|
return super.getText(mode) + " for each " + amount.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mana computeMana(Game game, Ability source){
|
public Mana computeMana(boolean netMana ,Game game, Ability source){
|
||||||
this.computedMana.clear();
|
this.computedMana.clear();
|
||||||
int count = amount.calculate(game, source, this);
|
int count = amount.calculate(game, source, this);
|
||||||
if (mana.getBlack() > 0) {
|
if (mana.getBlack() > 0) {
|
||||||
|
@ -96,6 +99,33 @@ public class DynamicManaEffect extends BasicManaEffect {
|
||||||
computedMana.setRed(count);
|
computedMana.setRed(count);
|
||||||
} else if (mana.getWhite() > 0) {
|
} else if (mana.getWhite() > 0) {
|
||||||
computedMana.setWhite(count);
|
computedMana.setWhite(count);
|
||||||
|
} else if (mana.getAny() > 0) {
|
||||||
|
if (netMana) {
|
||||||
|
computedMana.setAny(count);
|
||||||
|
} else {
|
||||||
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
if (controller != null) {
|
||||||
|
for(int i = 0; i < count; i++){
|
||||||
|
ChoiceColor choiceColor = new ChoiceColor();
|
||||||
|
while (!controller.choose(Outcome.Benefit, choiceColor, game)) {
|
||||||
|
if (!controller.isInGame()) {
|
||||||
|
return computedMana;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (choiceColor.getColor().isBlack()) {
|
||||||
|
computedMana.addBlack();
|
||||||
|
} else if (choiceColor.getColor().isBlue()) {
|
||||||
|
computedMana.addBlue();
|
||||||
|
} else if (choiceColor.getColor().isRed()) {
|
||||||
|
computedMana.addRed();
|
||||||
|
} else if (choiceColor.getColor().isGreen()) {
|
||||||
|
computedMana.addGreen();
|
||||||
|
} else if (choiceColor.getColor().isWhite()) {
|
||||||
|
computedMana.addWhite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
computedMana.setColorless(count);
|
computedMana.setColorless(count);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,6 @@ public class DynamicManaAbility extends ManaAbility {
|
||||||
if (game == null) {
|
if (game == null) {
|
||||||
return new Mana();
|
return new Mana();
|
||||||
}
|
}
|
||||||
return new Mana(manaEffect.computeMana(game, this));
|
return new Mana(manaEffect.computeMana(true, game, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue