* Fixed available mana generation of Druids Repository, Workhouse, Iceberg, Krak Clan Ironworks, Rasputin Dreamweaver and Sirk Prospector (#6698).

This commit is contained in:
LevelX2 2020-07-28 01:03:33 +02:00
parent 82a9726a35
commit b5c93cf2da
9 changed files with 99 additions and 7 deletions

View file

@ -1,33 +1,74 @@
package mage.abilities.effects.mana;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.ConditionalMana;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.common.ManaEffect;
import mage.game.Game;
public class BasicManaEffect extends ManaEffect {
protected Mana manaTemplate;
private final DynamicValue netAmount;
public BasicManaEffect(Mana mana) {
this(mana, null);
this.manaTemplate = mana;
}
public BasicManaEffect(Mana mana, DynamicValue netAmount) {
super();
this.manaTemplate = mana;
staticText = "add " + mana.toString();
this.netAmount = netAmount;
}
public BasicManaEffect(ConditionalMana conditionalMana) {
super();
this.manaTemplate = conditionalMana;
staticText = "add " + manaTemplate.toString() + " " + conditionalMana.getDescription();
this.netAmount = null;
}
public BasicManaEffect(final BasicManaEffect effect) {
super(effect);
this.manaTemplate = effect.manaTemplate.copy();
this.netAmount = effect.netAmount;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
if (game != null && game.inCheckPlayableState() && netAmount != null) {
// calculate the maximum available mana
int count = netAmount.calculate(game, source, this);
Mana computedMana = new Mana();
if (manaTemplate.getBlack() > 0) {
computedMana.setBlack(count * manaTemplate.getBlack());
} else if (manaTemplate.getBlue() > 0) {
computedMana.setBlue(count * manaTemplate.getBlue());
} else if (manaTemplate.getGreen() > 0) {
computedMana.setGreen(count * manaTemplate.getGreen());
} else if (manaTemplate.getRed() > 0) {
computedMana.setRed(count * manaTemplate.getRed());
} else if (manaTemplate.getWhite() > 0) {
computedMana.setWhite(count * manaTemplate.getWhite());
} else if (manaTemplate.getColorless() > 0) {
computedMana.setColorless(count * manaTemplate.getColorless());
} else if (manaTemplate.getAny() > 0) {
computedMana.setAny(count * manaTemplate.getAny());
} else if (manaTemplate.getGeneric() > 0){
computedMana.setGeneric(count * manaTemplate.getGeneric());
}
return new ArrayList<>(Arrays.asList(computedMana));
}
return super.getNetMana(game, source);
}
@Override
public BasicManaEffect copy() {
return new BasicManaEffect(this);

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import mage.Mana;
import mage.abilities.costs.Cost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.effects.mana.BasicManaEffect;
import mage.constants.Zone;
@ -35,7 +36,20 @@ public class SimpleManaAbility extends ActivatedManaAbilityImpl {
}
public SimpleManaAbility(Zone zone, Mana mana, Cost cost) {
super(zone, new BasicManaEffect(mana), cost);
this(zone, mana, cost, null);
this.netMana.add(mana.copy());
this.predictable = true;
}
/**
*
* @param zone
* @param mana
* @param cost cost for one usage
* @param netAmount DynamicValu to calculate the max available mana if effect is repeatable
*/
public SimpleManaAbility(Zone zone, Mana mana, Cost cost, DynamicValue netAmount) {
super(zone, new BasicManaEffect(mana, netAmount), cost);
this.netMana.add(mana.copy());
this.predictable = true;
}