mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- DGM: Added Goblin Test Pilot
This commit is contained in:
@@ -267,6 +267,9 @@ public final class AbilityFactory {
|
||||
abTgt.calculateStillToDivide(mapParams.get("DividedAsYouChoose"), hostC, null);
|
||||
abTgt.setDividedAsYouChoose(true);
|
||||
}
|
||||
if (mapParams.containsKey("TargetsAtRandom")) {
|
||||
abTgt.setRandomTarget(true);
|
||||
}
|
||||
return abTgt;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ public class Target {
|
||||
private boolean sameController = false;
|
||||
private boolean withoutSameCreatureType = false;
|
||||
private boolean singleTarget = false;
|
||||
private boolean randomTarget = false;
|
||||
private String definedController = null;
|
||||
|
||||
// How many can be targeted?
|
||||
@@ -695,10 +696,25 @@ public class Target {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getNumCandidates(final SpellAbility sa, final boolean isTargeted) {
|
||||
int candidates = 0;
|
||||
return getAllCandidates(sa, isTargeted).size();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getAllCandidates.
|
||||
* </p>
|
||||
*
|
||||
* @param sa
|
||||
* the sa
|
||||
* @param isTargeted
|
||||
* Check Valid Candidates and Targeting
|
||||
* @return a List<Object>.
|
||||
*/
|
||||
public final List<Object> getAllCandidates(final SpellAbility sa, final boolean isTargeted) {
|
||||
List<Object> candidates = new ArrayList<Object>();
|
||||
for (Player player : Singletons.getModel().getGame().getPlayers()) {
|
||||
if (sa.canTarget(player)) {
|
||||
candidates++;
|
||||
candidates.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -708,7 +724,7 @@ public class Target {
|
||||
boolean canTarget = (!isTargeted || c.canBeTargetedBy(sa));
|
||||
boolean isAlreadyTargeted = this.getTargetCards().contains(c);
|
||||
if (isValidTarget && canTarget && !isAlreadyTargeted) {
|
||||
candidates++;
|
||||
candidates.add(c);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -717,7 +733,7 @@ public class Target {
|
||||
boolean canTarget = (!isTargeted || c.canBeTargetedBy(sa));
|
||||
boolean isAlreadyTargeted = this.getTargetCards().contains(c);
|
||||
if (isValidTarget && canTarget && !isAlreadyTargeted) {
|
||||
candidates++;
|
||||
candidates.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -808,6 +824,20 @@ public class Target {
|
||||
this.differentZone = different;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the randomTarget
|
||||
*/
|
||||
public boolean isRandomTarget() {
|
||||
return randomTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param random the randomTarget to set
|
||||
*/
|
||||
public void setRandomTarget(boolean random) {
|
||||
this.randomTarget = random;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the differentControllers
|
||||
*/
|
||||
|
||||
@@ -32,6 +32,7 @@ import forge.game.player.Player;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -93,7 +94,12 @@ public class TargetSelection {
|
||||
final boolean mandatory = tgt.getMandatory() && tgt.hasCandidates(this.ability, true);
|
||||
|
||||
final boolean choiceResult;
|
||||
if (zone.size() == 1 && zone.get(0) == ZoneType.Stack) {
|
||||
final boolean random = tgt.isRandomTarget();
|
||||
if (random) {
|
||||
List<Object> candidates = tgt.getAllCandidates(this.ability, true);
|
||||
Object choice = Aggregates.random(candidates);
|
||||
return tgt.addTarget(choice);
|
||||
} else if (zone.size() == 1 && zone.get(0) == ZoneType.Stack) {
|
||||
// If Zone is Stack, the choices are handled slightly differently.
|
||||
// Handle everything inside function due to interaction with StackInstance
|
||||
return this.chooseCardFromStack(mandatory);
|
||||
|
||||
Reference in New Issue
Block a user