forked from External/mage
Fixed issue with UntapTargetCost (#10559)
* Fixed issue with UntapTargetCost The target was allowed to actually target, so things like Halo Fountain wouldn't work on creatures with shroud. UntapTargetCost also keeps track of the permanents which were untapped, in case those are needed. Changed Benthic Explorers to use new UntapTargetCost * Fixed potential bug with Benthic Explorers
This commit is contained in:
parent
f5b4c7b251
commit
47456bf9c4
2 changed files with 25 additions and 54 deletions
|
|
@ -6,9 +6,11 @@ import mage.abilities.costs.CostImpl;
|
|||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -16,11 +18,14 @@ import java.util.UUID;
|
|||
*/
|
||||
public class UntapTargetCost extends CostImpl {
|
||||
|
||||
private final TargetControlledPermanent target;
|
||||
private final TargetPermanent target;
|
||||
|
||||
public UntapTargetCost(TargetControlledPermanent target) {
|
||||
public UntapTargetCost(TargetPermanent target) {
|
||||
this.target = target;
|
||||
this.text = makeText(target);
|
||||
|
||||
// It will never target as part of a cost
|
||||
this.target.setNotTarget(true);
|
||||
}
|
||||
|
||||
public UntapTargetCost(final UntapTargetCost cost) {
|
||||
|
|
@ -33,13 +38,22 @@ public class UntapTargetCost extends CostImpl {
|
|||
if (!target.choose(Outcome.Untap, controllerId, source.getSourceId(), source, game)) {
|
||||
return paid;
|
||||
}
|
||||
List<UUID> untapped = new ArrayList<>();
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
paid |= permanent.untap(game);
|
||||
|
||||
if (permanent.untap(game)) {
|
||||
untapped.add(targetId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
game.getState().setValue("UntapTargetCost" + ability.getSourceId().toString(), untapped); // remember the untapped permanent
|
||||
|
||||
paid |= untapped.size() >= target.getMinNumberOfTargets();
|
||||
return paid;
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +67,7 @@ public class UntapTargetCost extends CostImpl {
|
|||
return new UntapTargetCost(this);
|
||||
}
|
||||
|
||||
private static String makeText(TargetControlledPermanent target) {
|
||||
private static String makeText(TargetPermanent target) {
|
||||
StringBuilder sb = new StringBuilder("untap ");
|
||||
if (target.getMaxNumberOfTargets() > 1) {
|
||||
sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue