forked from External/mage
* Doubling Cube - Added support for possible mana calculation (related to #6698).
This commit is contained in:
parent
27db13605e
commit
c48331f216
15 changed files with 379 additions and 79 deletions
|
|
@ -22,6 +22,7 @@ import mage.constants.ManaType;
|
|||
public abstract class TriggeredManaAbility extends TriggeredAbilityImpl implements ManaAbility {
|
||||
|
||||
protected List<Mana> netMana = new ArrayList<>();
|
||||
protected boolean poolDependant;
|
||||
|
||||
public TriggeredManaAbility(Zone zone, ManaEffect effect) {
|
||||
this(zone, effect, false);
|
||||
|
|
@ -37,6 +38,7 @@ public abstract class TriggeredManaAbility extends TriggeredAbilityImpl implemen
|
|||
public TriggeredManaAbility(final TriggeredManaAbility ability) {
|
||||
super(ability);
|
||||
this.netMana.addAll(ability.netMana);
|
||||
this.poolDependant = ability.poolDependant;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -60,6 +62,23 @@ public abstract class TriggeredManaAbility extends TriggeredAbilityImpl implemen
|
|||
return new ArrayList<>(netMana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Mana possibleManaInPool) {
|
||||
if (isPoolDependant()) {
|
||||
List<Mana> poolDependantNetMana = new ArrayList<>();
|
||||
for (Effect effect : getEffects()) {
|
||||
if (effect instanceof ManaEffect) {
|
||||
List<Mana> effectNetMana = ((ManaEffect) effect).getNetMana(game, possibleManaInPool, this);
|
||||
if (effectNetMana != null) {
|
||||
poolDependantNetMana.addAll(effectNetMana);
|
||||
}
|
||||
}
|
||||
}
|
||||
return poolDependantNetMana;
|
||||
}
|
||||
return getNetMana(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ManaType> getProducableManaTypes(Game game) {
|
||||
Set<ManaType> manaTypes = new HashSet<>();
|
||||
|
|
@ -80,4 +99,16 @@ public abstract class TriggeredManaAbility extends TriggeredAbilityImpl implemen
|
|||
public boolean definesMana(Game game) {
|
||||
return !netMana.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPoolDependant() {
|
||||
return poolDependant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TriggeredManaAbility setPoolDependant(boolean poolDependant) {
|
||||
this.poolDependant = poolDependant;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue