forked from External/mage
[TDM] Implement Abzan Devotee (#13464)
* [TDM] Implement Abzan Devotee * small update to constructors
This commit is contained in:
parent
f30060ae95
commit
9e0bd2d407
6 changed files with 147 additions and 85 deletions
|
|
@ -0,0 +1,75 @@
|
|||
package mage.abilities.effects.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.choices.Choice;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class AddManaFromColorChoicesEffect extends ManaEffect {
|
||||
|
||||
private final List<ManaType> manaTypes = new ArrayList<>();
|
||||
private final List<Mana> netMana = new ArrayList<>();
|
||||
|
||||
public AddManaFromColorChoicesEffect(ManaType... manaTypes) {
|
||||
super();
|
||||
for (ManaType manaType : manaTypes) {
|
||||
this.manaTypes.add(manaType);
|
||||
}
|
||||
this.manaTypes
|
||||
.stream()
|
||||
.map(CardUtil::manaTypeToColoredManaSymbol)
|
||||
.map(Mana::new)
|
||||
.forEach(netMana::add);
|
||||
staticText = "add " + CardUtil
|
||||
.concatWithOr(this.netMana.stream().map(s -> "{" + s + '}').collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private AddManaFromColorChoicesEffect(final AddManaFromColorChoicesEffect effect) {
|
||||
super(effect);
|
||||
this.manaTypes.addAll(effect.manaTypes);
|
||||
effect.netMana.stream().map(Mana::copy).forEach(this.netMana::add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddManaFromColorChoicesEffect copy() {
|
||||
return new AddManaFromColorChoicesEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return netMana;
|
||||
}
|
||||
|
||||
public List<Mana> getNetMana() {
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
if (game == null || manaTypes.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Choice choice = ManaType.getChoiceOfManaTypes(manaTypes, false);
|
||||
if (choice.getChoices().size() <= 1) {
|
||||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
} else {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null || !player.choose(Outcome.PutManaInPool, choice, game)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
ManaType chosenType = ManaType.findByName(choice.getChoice());
|
||||
return chosenType == null ? null : new Mana(chosenType);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ package mage.abilities.mana;
|
|||
import mage.MageIdentifier;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.effects.mana.AddManaFromColorChoicesEffect;
|
||||
import mage.abilities.effects.mana.AddManaOfAnyColorEffect;
|
||||
import mage.abilities.effects.mana.BasicManaEffect;
|
||||
import mage.abilities.effects.mana.ManaEffect;
|
||||
|
|
@ -37,6 +38,14 @@ public class LimitedTimesPerTurnActivatedManaAbility extends ActivatedManaAbilit
|
|||
new Mana(0, 0, 0, 0, 0, 0, effect.getAmount(), 0));
|
||||
}
|
||||
|
||||
public LimitedTimesPerTurnActivatedManaAbility(AddManaFromColorChoicesEffect effect, Cost cost) {
|
||||
this(effect, cost, 1);
|
||||
}
|
||||
|
||||
public LimitedTimesPerTurnActivatedManaAbility(AddManaFromColorChoicesEffect effect, Cost cost, int maxActivationPerTurn) {
|
||||
this(Zone.BATTLEFIELD, effect, cost, maxActivationPerTurn, effect.getNetMana());
|
||||
}
|
||||
|
||||
public LimitedTimesPerTurnActivatedManaAbility(Zone zone, ManaEffect effect, Cost cost, int maxActivationPerTurn, Mana mana) {
|
||||
this(zone, effect, cost, maxActivationPerTurn, Arrays.asList(mana));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue