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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
package mage.constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import mage.Mana;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceColor;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
public enum ManaType {
|
||||
|
|
@ -34,7 +30,7 @@ public enum ManaType {
|
|||
return text;
|
||||
}
|
||||
|
||||
public static Choice getChoiceOfManaTypes(Set<ManaType> types, boolean onlyColors) {
|
||||
public static Choice getChoiceOfManaTypes(Collection<ManaType> types, boolean onlyColors) {
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
choice.setMessage("Pick a mana " + (onlyColors ? "color" : "type"));
|
||||
|
|
@ -124,8 +120,8 @@ public enum ManaType {
|
|||
* <p>
|
||||
* Used for things like mapping back to a ManaType after the user chose from several of them.
|
||||
*
|
||||
* @param name The name of the mana to find
|
||||
* @return The ManaType representing that mana (or null)
|
||||
* @param name The name of the mana to find
|
||||
* @return The ManaType representing that mana (or null)
|
||||
*/
|
||||
public static ManaType findByName(String name) {
|
||||
switch (name) {
|
||||
|
|
@ -153,6 +149,7 @@ public enum ManaType {
|
|||
}
|
||||
return manaTypes;
|
||||
}
|
||||
|
||||
public static Set<ManaType> getTrueManaTypes() {
|
||||
return EnumSet.of(BLACK, BLUE, GREEN, RED, WHITE, COLORLESS);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue