forked from External/mage
Spells on the stack can now get counters.
This commit is contained in:
parent
5de03a4165
commit
3b3f136d34
6 changed files with 38 additions and 21 deletions
|
|
@ -41,7 +41,6 @@ import mage.cards.SplitCard;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.MageObjectType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ import mage.target.targetpointer.TargetPointer;
|
|||
public class StackAbilityView extends CardView {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private CardView sourceCard;
|
||||
private final CardView sourceCard;
|
||||
|
||||
public StackAbilityView(Game game, StackAbility ability, String sourceName, CardView sourceCard) {
|
||||
this.id = ability.getId();
|
||||
|
|
@ -55,7 +55,7 @@ public class StackAbilityView extends CardView {
|
|||
this.sourceCard = sourceCard;
|
||||
this.sourceCard.setMageObjectType(mageObjectType);
|
||||
this.name = "Ability";
|
||||
this.rules = new ArrayList<String>();
|
||||
this.rules = new ArrayList<>();
|
||||
rules.add(ability.getRule(sourceName));
|
||||
this.power = ability.getPower().toString();
|
||||
this.toughness = ability.getToughness().toString();
|
||||
|
|
@ -65,17 +65,19 @@ public class StackAbilityView extends CardView {
|
|||
this.superTypes = ability.getSupertype();
|
||||
this.color = ability.getColor();
|
||||
this.manaCost = ability.getManaCost().getSymbols();
|
||||
this.counters = sourceCard.getCounters();
|
||||
|
||||
updateTargets(game, ability);
|
||||
}
|
||||
|
||||
private void updateTargets(Game game, StackAbility ability) {
|
||||
List<String> names = new ArrayList<String>();
|
||||
List<String> names = new ArrayList<>();
|
||||
for(UUID modeId : ability.getModes().getSelectedModes()) {
|
||||
ability.getModes().setMode(ability.getModes().get(modeId));
|
||||
if (ability.getTargets().size() > 0) {
|
||||
setTargets(ability.getTargets());
|
||||
} else {
|
||||
List<UUID> targetList = new ArrayList<UUID>();
|
||||
List<UUID> targetList = new ArrayList<>();
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
TargetPointer targetPointer = effect.getTargetPointer();
|
||||
if (targetPointer instanceof FixedTarget) {
|
||||
|
|
|
|||
|
|
@ -889,6 +889,10 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getTargetDescription(Targets targets, Game game) {
|
||||
return getTargetDescriptionForLog(targets, game);
|
||||
}
|
||||
|
||||
protected String getTargetDescriptionForLog(Targets targets, Game game) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (targets.size() > 0) {
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ public enum MageObjectType {
|
|||
CARD ("Card", false, true),
|
||||
COPY_CARD ("Copy of a Card", false, true),
|
||||
TOKEN ("Token", true, true),
|
||||
SPELL ("Spell", false, false),
|
||||
SPELL ("Spell", false, true),
|
||||
PERMANENT ("Permanent", true, true),
|
||||
EMBLEM ("Emblem", false, false),
|
||||
COMMANDER ("Commander", false, false);
|
||||
|
||||
private String text;
|
||||
private boolean permanent;
|
||||
private boolean canHaveCounters;
|
||||
private final String text;
|
||||
private final boolean permanent;
|
||||
private final boolean canHaveCounters;
|
||||
|
||||
|
||||
MageObjectType(String text, boolean permanent, boolean canHaveCounters) {
|
||||
|
|
|
|||
|
|
@ -372,6 +372,7 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
public boolean chooseNewTargets(Game game, UUID playerId, boolean forceChange, boolean onlyOneTarget) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
StringBuilder newTargetDescription = new StringBuilder();
|
||||
// Fused split spells or spells where "Splice on Arcane" was used can have more than one ability
|
||||
for (SpellAbility spellAbility : spellAbilities) {
|
||||
// Some spells can have more than one mode
|
||||
|
|
@ -386,9 +387,11 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
}
|
||||
|
||||
}
|
||||
newTargetDescription.append(getSpellAbility().getTargetDescription(mode.getTargets(), game));
|
||||
}
|
||||
|
||||
}
|
||||
game.informPlayers(this.getName() + " is now " + newTargetDescription.toString());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -851,26 +854,38 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
|
||||
@Override
|
||||
public Counters getCounters() {
|
||||
return null;
|
||||
return card.getCounters();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCounters(String name, int amount, Game game) {}
|
||||
public void addCounters(String name, int amount, Game game) {
|
||||
card.addCounters(name, amount, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCounters(String name, int amount, Game game, ArrayList<UUID> appliedEffects) {}
|
||||
public void addCounters(String name, int amount, Game game, ArrayList<UUID> appliedEffects) {
|
||||
card.addCounters(name, amount, game, appliedEffects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCounters(Counter counter, Game game) {}
|
||||
public void addCounters(Counter counter, Game game) {
|
||||
card.addCounters(counter, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCounters(Counter counter, Game game, ArrayList<UUID> appliedEffects) {}
|
||||
public void addCounters(Counter counter, Game game, ArrayList<UUID> appliedEffects) {
|
||||
card.addCounters(counter, game, appliedEffects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCounters(String name, int amount, Game game) {}
|
||||
public void removeCounters(String name, int amount, Game game) {
|
||||
card.removeCounters(name, amount, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCounters(Counter counter, Game game) {}
|
||||
public void removeCounters(Counter counter, Game game) {
|
||||
card.removeCounters(counter, game);
|
||||
}
|
||||
|
||||
public Card getCard() {
|
||||
return card;
|
||||
|
|
|
|||
|
|
@ -105,13 +105,10 @@ public class SpellStack extends ArrayDeque<StackObject> {
|
|||
|
||||
public Spell getSpell(UUID id) {
|
||||
for (StackObject stackObject: this) {
|
||||
if (stackObject.getId().equals(id)) {
|
||||
if (stackObject instanceof Spell) {
|
||||
if (stackObject instanceof Spell) {
|
||||
if (stackObject.getId().equals(id) || stackObject.getSourceId().equals(id)) {
|
||||
return (Spell)stackObject;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue