mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Merge origin/master
This commit is contained in:
commit
5460eb7b3c
7 changed files with 302 additions and 56 deletions
|
@ -55,7 +55,7 @@ import mage.target.Target;
|
|||
import mage.filter.predicate.mageobject.FromSetPredicate;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.SpellTargetAddress;
|
||||
import mage.util.TargetAddress;
|
||||
|
||||
/**
|
||||
* @author duncancmt
|
||||
|
@ -128,7 +128,7 @@ class InkTreaderNephilimTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (spell != null) {
|
||||
boolean allTargetsInkTreaderNephilim = true;
|
||||
boolean atLeastOneTargetsInkTreaderNephilim = false;
|
||||
for (SpellTargetAddress addr : SpellTargetAddress.walk(spell)) {
|
||||
for (TargetAddress addr : TargetAddress.walk(spell)) {
|
||||
Target targetInstance = addr.getTarget(spell);
|
||||
for (UUID target : targetInstance.getTargets()) {
|
||||
allTargetsInkTreaderNephilim &= target.equals(sourceId);
|
||||
|
@ -183,12 +183,12 @@ class InkTreaderNephilimEffect extends OneShotEffect {
|
|||
continue; // copy only for other creatures
|
||||
}
|
||||
boolean legal = true;
|
||||
for (SpellTargetAddress addr : SpellTargetAddress.walk(copy)) {
|
||||
for (TargetAddress addr : TargetAddress.walk(copy)) {
|
||||
Target targetInstance = addr.getTarget(copy);
|
||||
legal &= targetInstance.canTarget(permanent.getId(), addr.getSpellAbility(copy), game);
|
||||
}
|
||||
if (legal) {
|
||||
for (SpellTargetAddress addr : SpellTargetAddress.walk(copy)) {
|
||||
for (TargetAddress addr : TargetAddress.walk(copy)) {
|
||||
Target targetInstance = addr.getTarget(copy);
|
||||
int numTargets = targetInstance.getNumberOfTargets();
|
||||
targetInstance.clearChosen();
|
||||
|
|
|
@ -38,6 +38,7 @@ import mage.constants.Outcome;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.Game;
|
||||
|
@ -49,9 +50,7 @@ import mage.target.Target;
|
|||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.game.turn.TurnMod;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.MageObject;
|
||||
import mage.filter.predicate.Predicate;
|
||||
|
||||
import mage.filter.predicate.permanent.CanBeEnchantedByPredicate;
|
||||
/**
|
||||
* @author duncancmt
|
||||
*/
|
||||
|
@ -105,9 +104,15 @@ class BreathOfFuryAbility extends TriggeredAbilityImpl {
|
|||
if (damageEvent.isCombatDamage() &&
|
||||
enchantment != null &&
|
||||
enchantment.getAttachedTo().equals(event.getSourceId())) {
|
||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (creature != null) {
|
||||
for (Effect effect : getEffects()) {
|
||||
effect.setValue("TriggeringCreatureId", creature.getId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -139,21 +144,38 @@ class BreathOfFuryEffect extends OneShotEffect {
|
|||
if (enchantment == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent enchantedCreature = game.getPermanent(enchantment.getAttachedTo());
|
||||
Permanent enchantedCreature = game.getPermanent((UUID) getValue("TriggeringCreatureId"));
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control that could be enchanted by " + enchantment.getName());
|
||||
filter.add(new CanBeEnchantedPredicate(enchantment));
|
||||
filter.add(new CanBeEnchantedByPredicate(enchantment));
|
||||
Target target = new TargetControlledCreaturePermanent(filter);
|
||||
target.setNotTarget(true);
|
||||
// It's important to check that the creature was successfully sacrificed here. Effects that prevent sacrifice will also prevent Breath of Fury's effect from working.
|
||||
// Commanders going to the command zone and Rest in Peace style replacement effects don't make Permanent.sacrifice return false.
|
||||
if (enchantedCreature != null && controller != null
|
||||
&& enchantedCreature.sacrifice(source.getSourceId(), game)
|
||||
&& target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
|
||||
&& target.canChoose(source.getSourceId(), controller.getId(), game)) {
|
||||
controller.choose(outcome, target, source.getSourceId(), game);
|
||||
Permanent newCreature = game.getPermanent(target.getFirstTarget());
|
||||
if (newCreature != null &&
|
||||
newCreature.addAttachment(enchantment.getId(), game)) {
|
||||
boolean success = false;
|
||||
if (newCreature != null) {
|
||||
Permanent oldCreature = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (oldCreature != null) {
|
||||
if (oldCreature.getId().equals(newCreature.getId())) {
|
||||
success = true;
|
||||
} else {
|
||||
if (oldCreature.removeAttachment(enchantment.getId(), game)
|
||||
&& newCreature.addAttachment(enchantment.getId(), game)) {
|
||||
game.informPlayers(enchantment.getLogName() + " was unattached from " + oldCreature.getLogName() + " and attached to " + newCreature.getLogName());
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
} else if (newCreature.addAttachment(enchantment.getId(), game)) {
|
||||
game.informPlayers(enchantment.getLogName() + " was attached to " + newCreature.getLogName());
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterControlledCreaturePermanent(), controller.getId(), game)) {
|
||||
permanent.untap(game);
|
||||
}
|
||||
|
@ -165,22 +187,3 @@ class BreathOfFuryEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class CanBeEnchantedPredicate implements Predicate<Permanent> {
|
||||
|
||||
private final MageObject auraEnchantment;
|
||||
|
||||
public CanBeEnchantedPredicate(MageObject auraEnchantment){
|
||||
this.auraEnchantment = auraEnchantment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
return !input.cantBeEnchantedBy(auraEnchantment, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CanBeEnchanted(" + auraEnchantment.toString() + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ import mage.target.Target;
|
|||
import java.util.UUID;
|
||||
import mage.filter.predicate.mageobject.FromSetPredicate;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.SpellTargetAddress;
|
||||
import mage.util.TargetAddress;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
|
@ -127,7 +127,7 @@ class PrecursorGolemCopyTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (spell != null &&
|
||||
(spell.getCardType().contains(CardType.INSTANT) || spell.getCardType().contains(CardType.SORCERY))) {
|
||||
UUID targetGolem = null;
|
||||
for (SpellTargetAddress addr : SpellTargetAddress.walk(spell)) {
|
||||
for (TargetAddress addr : TargetAddress.walk(spell)) {
|
||||
Target targetInstance = addr.getTarget(spell);
|
||||
for (UUID target : targetInstance.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
|
@ -186,7 +186,7 @@ class PrecursorGolemCopySpellEffect extends OneShotEffect {
|
|||
continue; // copy only for other golems
|
||||
}
|
||||
boolean legal = true;
|
||||
for (SpellTargetAddress addr : SpellTargetAddress.walk(spell)) {
|
||||
for (TargetAddress addr : TargetAddress.walk(spell)) {
|
||||
Target target = addr.getTarget(spell);
|
||||
if (!target.canTarget(permanent.getId(), game)) {
|
||||
legal = false;
|
||||
|
@ -196,7 +196,7 @@ class PrecursorGolemCopySpellEffect extends OneShotEffect {
|
|||
if (legal) {
|
||||
Spell copy = spell.copySpell();
|
||||
copy.setCopiedSpell(true);
|
||||
for (SpellTargetAddress addr : SpellTargetAddress.walk(copy)) {
|
||||
for (TargetAddress addr : TargetAddress.walk(copy)) {
|
||||
Target target = addr.getTarget(copy);
|
||||
target.clearChosen();
|
||||
target.add(permanent.getId(), game);
|
||||
|
|
164
Mage.Sets/src/mage/sets/tenth/AuraGraft.java
Normal file
164
Mage.Sets/src/mage/sets/tenth/AuraGraft.java
Normal file
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.tenth;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continious.GainControlTargetEffect;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.ObjectPlayer;
|
||||
import mage.filter.predicate.ObjectPlayerPredicate;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.TargetAddress;
|
||||
|
||||
/**
|
||||
* @author duncancmt
|
||||
*/
|
||||
public class AuraGraft extends CardImpl {
|
||||
|
||||
public AuraGraft(UUID ownerId) {
|
||||
super(ownerId, 67, "Aura Graft", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{1}{U}");
|
||||
this.expansionSetCode = "10E";
|
||||
|
||||
FilterPermanent filter = new FilterPermanent("Aura that's attached to a permanent");
|
||||
filter.add(new SubtypePredicate("Aura"));
|
||||
filter.add(new AttachedToPermanentPredicate());
|
||||
this.getSpellAbility().addTarget(new TargetPermanent(filter));
|
||||
|
||||
Effect gainControlEffect = new GainControlTargetEffect(Duration.EndOfGame);
|
||||
//gainControlEffect.setText("Gain control of target Aura that's attached to a permanent");
|
||||
this.getSpellAbility().addEffect(gainControlEffect);
|
||||
|
||||
this.getSpellAbility().addEffect(new MoveTargetAuraEffect());
|
||||
}
|
||||
|
||||
public AuraGraft(final AuraGraft card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuraGraft copy() {
|
||||
return new AuraGraft(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class AttachedToPermanentPredicate implements ObjectPlayerPredicate<ObjectPlayer<Permanent>> {
|
||||
|
||||
public AttachedToPermanentPredicate() {
|
||||
super();
|
||||
}
|
||||
|
||||
public boolean apply(ObjectPlayer<Permanent> input, Game game) {
|
||||
Permanent attached = input.getObject();
|
||||
return attached != null && game.getPermanent(attached.getAttachedTo()) != null;
|
||||
}
|
||||
}
|
||||
|
||||
class PermanentCanBeAttachedToPredicate implements ObjectPlayerPredicate<ObjectPlayer<Permanent>> {
|
||||
protected Permanent aura;
|
||||
|
||||
public PermanentCanBeAttachedToPredicate(Permanent aura) {
|
||||
super();
|
||||
this.aura = aura;
|
||||
}
|
||||
|
||||
public boolean apply(ObjectPlayer<Permanent> input, Game game) {
|
||||
Permanent potentialAttachment = input.getObject();
|
||||
for (TargetAddress addr : TargetAddress.walk(aura)) {
|
||||
Target target = addr.getTarget(aura);
|
||||
Filter filter = target.getFilter();
|
||||
return filter.match(potentialAttachment, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class MoveTargetAuraEffect extends OneShotEffect {
|
||||
|
||||
public MoveTargetAuraEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "Attach it to another permanent it can enchant";
|
||||
}
|
||||
|
||||
public MoveTargetAuraEffect(final MoveTargetAuraEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MoveTargetAuraEffect copy() {
|
||||
return new MoveTargetAuraEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source){
|
||||
Permanent enchantment = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
if (enchantment == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent oldAttachment = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (oldAttachment == null) {
|
||||
return false;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FilterPermanent filter = new FilterPermanent("another permanent " + enchantment.getLogName() + " can enchant");
|
||||
filter.add(new AnotherPredicate());
|
||||
filter.add(new PermanentCanBeAttachedToPredicate(enchantment));
|
||||
Target target = new TargetPermanent(filter);
|
||||
target.setNotTarget(true);
|
||||
if (target.canChoose(oldAttachment.getId(), controller.getId(), game)
|
||||
&& controller.choose(outcome, target, oldAttachment.getId(), game)) {
|
||||
Permanent newAttachment = game.getPermanent(target.getFirstTarget());
|
||||
if (newAttachment != null &&
|
||||
oldAttachment.removeAttachment(enchantment.getId(), game)) {
|
||||
newAttachment.addAttachment(enchantment.getId(), game);
|
||||
game.informPlayers(enchantment.getLogName() + " was unattached from " + oldAttachment.getLogName() + " and attached to " + newAttachment.getLogName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.filter.predicate.permanent;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author duncancmt
|
||||
*/
|
||||
public class CanBeEnchantedByPredicate implements Predicate<Permanent> {
|
||||
|
||||
private final MageObject auraEnchantment;
|
||||
|
||||
public CanBeEnchantedByPredicate(MageObject auraEnchantment){
|
||||
this.auraEnchantment = auraEnchantment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
return !input.cantBeEnchantedBy(auraEnchantment, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CanBeEnchanted(" + auraEnchantment.toString() + ")";
|
||||
}
|
||||
}
|
|
@ -52,7 +52,7 @@ public interface Target extends Serializable {
|
|||
|
||||
/**
|
||||
* controlls if it will be checked, if the target can be targeted from source
|
||||
* @param notTarget true = check for protection, false = do not check for protection
|
||||
* @param notTarget true = do not check for protection, false = check for protection
|
||||
*/
|
||||
void setNotTarget(boolean notTarget);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.UUID;
|
|||
import mage.abilities.Mode;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.Target;
|
||||
|
||||
|
@ -39,30 +40,30 @@ import mage.target.Target;
|
|||
/**
|
||||
* @author duncancmt
|
||||
*/
|
||||
public class SpellTargetAddress {
|
||||
public class TargetAddress {
|
||||
protected int spellAbilityIndex;
|
||||
protected UUID mode;
|
||||
protected int targetIndex;
|
||||
|
||||
public SpellTargetAddress(int spellAbilityIndex, UUID mode, int targetIndex) {
|
||||
public TargetAddress(int spellAbilityIndex, UUID mode, int targetIndex) {
|
||||
this.spellAbilityIndex = spellAbilityIndex;
|
||||
this.mode = mode;
|
||||
this.targetIndex = targetIndex;
|
||||
}
|
||||
|
||||
protected static class SpellTargetAddressIterable implements Iterable<SpellTargetAddress> {
|
||||
protected final Spell spell;
|
||||
protected static class TargetAddressIterable implements Iterable<TargetAddress> {
|
||||
protected final Card card;
|
||||
|
||||
public SpellTargetAddressIterable(Spell spell) {
|
||||
this.spell = spell;
|
||||
public TargetAddressIterable(Card card) {
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
public Iterator<SpellTargetAddress> iterator() {
|
||||
return new SpellTargetAddressIterator(spell);
|
||||
public Iterator<TargetAddress> iterator() {
|
||||
return new TargetAddressIterator(card);
|
||||
}
|
||||
}
|
||||
|
||||
protected static class SpellTargetAddressIterator implements Iterator<SpellTargetAddress> {
|
||||
protected static class TargetAddressIterator implements Iterator<TargetAddress> {
|
||||
protected Iterator<SpellAbility> spellAbilityIterator;
|
||||
protected Integer lastSpellAbilityIndex = null;
|
||||
protected Iterator<UUID> modeIterator = null;
|
||||
|
@ -71,17 +72,25 @@ public class SpellTargetAddress {
|
|||
protected Iterator<Target> targetIterator = null;
|
||||
protected Integer lastTargetIndex = null;
|
||||
|
||||
public SpellTargetAddressIterator(Spell spell) {
|
||||
public TargetAddressIterator(Spell spell) {
|
||||
this.spellAbilityIterator = spell.getSpellAbilities().iterator();
|
||||
calcNext();
|
||||
}
|
||||
|
||||
public TargetAddressIterator(Card card) {
|
||||
this.lastSpellAbilityIndex = 0;
|
||||
this.spellAbilityIterator = null;
|
||||
this.modes = card.getSpellAbility().getModes();
|
||||
this.modeIterator = this.modes.getSelectedModes().iterator();
|
||||
calcNext();
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return lastTargetIndex != null;
|
||||
}
|
||||
|
||||
public SpellTargetAddress next() {
|
||||
SpellTargetAddress ret = new SpellTargetAddress(lastSpellAbilityIndex,
|
||||
public TargetAddress next() {
|
||||
TargetAddress ret = new TargetAddress(lastSpellAbilityIndex,
|
||||
lastMode,
|
||||
lastTargetIndex);
|
||||
calcNext();
|
||||
|
@ -96,7 +105,7 @@ public class SpellTargetAddress {
|
|||
protected void calcNext() {
|
||||
if (targetIterator == null) {
|
||||
if (modeIterator == null) {
|
||||
if (spellAbilityIterator.hasNext()) {
|
||||
if (spellAbilityIterator != null && spellAbilityIterator.hasNext()) {
|
||||
if (lastSpellAbilityIndex == null) {
|
||||
lastSpellAbilityIndex = 0;
|
||||
} else {
|
||||
|
@ -137,19 +146,34 @@ public class SpellTargetAddress {
|
|||
}
|
||||
|
||||
|
||||
public static Iterable<SpellTargetAddress> walk(Spell spell) {
|
||||
return new SpellTargetAddressIterable(spell);
|
||||
public static Iterable<TargetAddress> walk(Card card) {
|
||||
return new TargetAddressIterable(card);
|
||||
}
|
||||
|
||||
public Target getTarget(Spell spell) {
|
||||
return spell.getSpellAbilities().get(spellAbilityIndex).getModes().get(mode).getTargets().get(targetIndex);
|
||||
return getMode(spell).getTargets().get(targetIndex);
|
||||
}
|
||||
|
||||
public Target getTarget(Card card) {
|
||||
return getMode(card).getTargets().get(targetIndex);
|
||||
}
|
||||
|
||||
public Mode getMode(Spell spell) {
|
||||
return spell.getSpellAbilities().get(spellAbilityIndex).getModes().get(mode);
|
||||
return getSpellAbility(spell).getModes().get(mode);
|
||||
}
|
||||
|
||||
public Mode getMode(Card card) {
|
||||
return getSpellAbility(card).getModes().get(mode);
|
||||
}
|
||||
|
||||
public SpellAbility getSpellAbility(Spell spell) {
|
||||
return spell.getSpellAbilities().get(spellAbilityIndex);
|
||||
}
|
||||
|
||||
public SpellAbility getSpellAbility(Card card) {
|
||||
if (spellAbilityIndex > 0) {
|
||||
throw new IndexOutOfBoundsException("SpellAbility index " + spellAbilityIndex + " is out of bounds.");
|
||||
}
|
||||
return card.getSpellAbility();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue