mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Willbender - Fixed that target of abilities could not be changed.
This commit is contained in:
parent
f6c1538bda
commit
e334d85078
3 changed files with 45 additions and 29 deletions
|
@ -31,7 +31,7 @@ import mage.MageObject;
|
|||
import mage.abilities.Mode;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.target.Target;
|
||||
|
||||
/**
|
||||
|
@ -48,10 +48,10 @@ public class NumberOfTargetsPredicate implements Predicate<MageObject> {
|
|||
|
||||
@Override
|
||||
public boolean apply(MageObject input, Game game) {
|
||||
Spell spell = game.getStack().getSpell(input.getId());
|
||||
if (spell != null) {
|
||||
StackObject stackObject = game.getState().getStack().getStackObject(input.getId());
|
||||
if (stackObject != null) {
|
||||
int numberOfTargets = 0;
|
||||
for (Mode mode : spell.getSpellAbility().getModes().getSelectedModes()) {
|
||||
for (Mode mode : stackObject.getStackAbility().getModes().getSelectedModes()) {
|
||||
for (Target target : mode.getTargets()) {
|
||||
numberOfTargets += target.getTargets().size();
|
||||
}
|
||||
|
@ -60,6 +60,18 @@ public class NumberOfTargetsPredicate implements Predicate<MageObject> {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
// Spell spell = game.getStack().getSpell(input.getId());
|
||||
// if (spell != null) {
|
||||
// int numberOfTargets = 0;
|
||||
// for (Mode mode : spell.getSpellAbility().getModes().getSelectedModes()) {
|
||||
// for (Target target : mode.getTargets()) {
|
||||
// numberOfTargets += target.getTargets().size();
|
||||
// }
|
||||
// }
|
||||
// if (numberOfTargets == targets) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,9 @@ public class StackAbility extends StackObjImpl implements Ability {
|
|||
|
||||
@Override
|
||||
public Abilities<Ability> getAbilities() {
|
||||
return emptyAbilites;
|
||||
Abilities<Ability> abilities = new AbilitiesImpl<>();
|
||||
abilities.add(ability);
|
||||
return abilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -113,7 +113,7 @@ public abstract class StackObjImpl implements StackObject {
|
|||
if (this instanceof Spell) {
|
||||
objectAbilities.addAll(((Spell) this).getSpellAbilities());
|
||||
} else {
|
||||
objectAbilities.addAll(getAbilities());
|
||||
objectAbilities.add(getStackAbility());
|
||||
}
|
||||
for (Ability ability : objectAbilities) {
|
||||
// Some spells can have more than one mode
|
||||
|
@ -210,6 +210,7 @@ public abstract class StackObjImpl implements StackObject {
|
|||
again = true;
|
||||
}
|
||||
} else // if possible add the alternate Target - it may not be included in the old definition nor in the already selected targets of the new definition
|
||||
{
|
||||
if (newTarget.getTargets().contains(tempTarget.getFirstTarget()) || target.getTargets().contains(tempTarget.getFirstTarget())) {
|
||||
if (targetController.isHuman()) {
|
||||
if (targetController.chooseUse(Outcome.Benefit, "This target was already selected from origin spell. Reset to original target?", ability, game)) {
|
||||
|
@ -239,6 +240,7 @@ public abstract class StackObjImpl implements StackObject {
|
|||
// valid target was selected, add it to the new target definition
|
||||
newTarget.addTarget(tempTarget.getFirstTarget(), target.getTargetAmount(targetId), ability, game, false);
|
||||
}
|
||||
}
|
||||
} while (again && targetController.canRespond());
|
||||
}
|
||||
} // keep the target
|
||||
|
|
Loading…
Reference in a new issue