Target refactoring. Fixed Issue 273.

This commit is contained in:
magenoxx 2011-10-08 12:46:34 +04:00
parent c3a5910976
commit 82dcb53cb9
52 changed files with 63 additions and 55 deletions

View file

@ -138,12 +138,12 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
}
@Override
public boolean choose(Outcome outcome, Target target, Game game) {
return choose(outcome, target, game, null);
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) {
return choose(outcome, target, sourceId, game, null);
}
@Override
public boolean choose(Outcome outcome, Target target, Game game, Map<String, Serializable> options) {
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options) {
if (log.isDebugEnabled())
log.debug("chooseTarget: " + outcome.toString() + ":" + target.toString());
UUID opponentId = game.getOpponents(playerId).iterator().next();

View file

@ -207,19 +207,19 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
}
@Override
public boolean choose(Outcome outcome, Target target, Game game) {
return choose(outcome, target, game, null);
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) {
return choose(outcome, target, sourceId, game, null);
}
@Override
public boolean choose(Outcome outcome, Target target, Game game, Map<String, Serializable> options) {
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options) {
game.getState().setPriorityPlayerId(getId());
while (!abort) {
game.fireSelectTargetEvent(playerId, target.getMessage(), target.possibleTargets(null, playerId, game), target.isRequired(), options);
waitForResponse();
if (response.getUUID() != null) {
if (target instanceof TargetPermanent) {
if (((TargetPermanent)target).canTarget(playerId, response.getUUID(), null, game)) {
if (((TargetPermanent)target).canTarget(playerId, response.getUUID(), sourceId, game, false)) {
target.add(response.getUUID(), game);
if(target.doneChosing()){
return true;
@ -575,7 +575,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
while (remainingDamage > 0) {
Target target = new TargetCreatureOrPlayer();
if (singleTargetName != null) target.setTargetName(singleTargetName);
choose(Outcome.Damage, target, game);
choose(Outcome.Damage, target, sourceId, game);
if (targets.isEmpty() || targets.contains(target.getFirstTarget())) {
int damageAmount = getAmount(0, remainingDamage, "Select amount", game);
Permanent permanent = game.getPermanent(target.getFirstTarget());

View file

@ -127,7 +127,7 @@ class BackFromTheBrinkCost extends CostImpl<BackFromTheBrinkCost> {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
if (targets.choose(Outcome.Exile, controllerId, game)) {
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
Player player = game.getPlayer(controllerId);
if (player != null) {
Card card = player.getGraveyard().get(targets.getFirstTarget(), game);

View file

@ -102,7 +102,7 @@ class CivilizedScholarEffect extends OneShotEffect<CivilizedScholarEffect> {
if (player != null) {
player.drawCards(1, game);
TargetDiscard target = new TargetDiscard(player.getId());
player.choose(Constants.Outcome.Discard, target, game);
player.choose(Constants.Outcome.Discard, target, source.getSourceId(), game);
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {
player.discard(card, source, game);

View file

@ -102,7 +102,7 @@ class DivineReckoningEffect extends OneShotEffect<DivineReckoningEffect> {
Target target = new TargetControlledPermanent(1, 1, filter, false);
if (target.canChoose(player.getId(), game)) {
while (!target.isChosen() && target.canChoose(player.getId(), game)) {
player.choose(Constants.Outcome.Benefit, target, game);
player.choose(Constants.Outcome.Benefit, target, source.getSourceId(), game);
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {

View file

@ -163,7 +163,7 @@ class GarrukTheVeilCursedEffect extends OneShotEffect<GarrukTheVeilCursedEffect>
boolean sacrificed = false;
if (target.canChoose(player.getId(), game)) {
while (!target.isChosen() && target.canChoose(player.getId(), game)) {
player.choose(Constants.Outcome.Sacrifice, target, game);
player.choose(Constants.Outcome.Sacrifice, target, source.getSourceId(), game);
}
for (int idx = 0; idx < target.getTargets().size(); idx++) {

View file

@ -102,7 +102,7 @@ class HarvestPyreCost extends CostImpl<HarvestPyreCost> implements VariableCost
Player player = game.getPlayer(controllerId);
while (true) {
target.clearChosen();
if (target.choose(Outcome.Exile, controllerId, game)) {
if (target.choose(Outcome.Exile, controllerId, sourceId, game)) {
Card card = player.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
player.getGraveyard().remove(card);

View file

@ -100,7 +100,7 @@ class StitchersApprenticeEffect extends OneShotEffect<StitchersApprenticeEffect>
if (player != null) {
Target target = new TargetControlledPermanent(new FilterControlledCreaturePermanent());
if (target.canChoose(player.getId(), game) && player.choose(Outcome.Sacrifice, target, game)) {
if (target.canChoose(player.getId(), game) && player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
return permanent.sacrifice(source.getSourceId(), game);

View file

@ -96,7 +96,7 @@ class TributeToHungerEffect extends OneShotEffect<TributeToHungerEffect> {
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false);
if (target.canChoose(player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, game);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {

View file

@ -136,7 +136,7 @@ class PhylacteryLichEffect extends OneShotEffect<PhylacteryLichEffect> {
TargetControlledPermanent target = new TargetControlledPermanent(filter);
if (target.canChoose(source.getControllerId(), game)) {
target.setRequired(true);
if (player.choose(Outcome.Neutral, target, game)) {
if (player.choose(Outcome.Neutral, target, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.addCounters(new Counter("phylactery"), game);

View file

@ -98,7 +98,7 @@ class PutCreatureOnBattlefieldEffect extends OneShotEffect<PutCreatureOnBattlefi
}
TargetCardInHand target = new TargetCardInHand(new FilterCreatureCard());
if (player.choose(Outcome.PutCreatureInPlay, target, game)) {
if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
player.removeFromHand(card, game);

View file

@ -136,7 +136,7 @@ class SmallpoxEffect extends OneShotEffect<SmallpoxEffect> {
Target target = new TargetControlledPermanent(1, 1, filter, false);
if (target.canChoose(player.getId(), game)) {
while (!target.isChosen() && target.canChoose(player.getId(), game)) {
player.choose(Constants.Outcome.Sacrifice, target, game);
player.choose(Constants.Outcome.Sacrifice, target, source.getSourceId(), game);
}
for ( int idx = 0; idx < target.getTargets().size(); idx++) {

View file

@ -96,7 +96,7 @@ class PreeminentCaptainEffect extends OneShotEffect<PreeminentCaptainEffect> {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
TargetCardInHand target = new TargetCardInHand(new FilterSoldierCard());
if (target.choose(getOutcome(), player.getId(), game)) {
if (target.choose(getOutcome(), player.getId(), source.getSourceId(), game)) {
if (target.getTargets().size() > 0) {
UUID cardId = target.getFirstTarget();
Card card = player.getHand().get(cardId, game);
@ -108,7 +108,7 @@ class PreeminentCaptainEffect extends OneShotEffect<PreeminentCaptainEffect> {
permanent.setTapped(true);
TargetDefender def = new TargetDefender(game
.getCombat().getDefenders(), player.getId());
if (def.choose(getOutcome(), player.getId(), game)) {
if (def.choose(getOutcome(), player.getId(), source.getSourceId(), game)) {
// TODO -> If only one option, don't ask, as for
// normal attacking.
if (def.getTargets().size() > 0) {

View file

@ -95,7 +95,7 @@ class ConsumingVaporsEffect extends OneShotEffect<ConsumingVaporsEffect> {
//A spell or ability could have removed the only legal target this player
//had, if thats the case this ability should fizzle.
if (target.canChoose(player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, game);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if ( permanent != null ) {

View file

@ -100,7 +100,7 @@ class AuriokReplicaEffect extends PreventionEffectImpl<AuriokReplicaEffect> {
@Override
public void init(Ability source, Game game) {
this.target.choose(Outcome.PreventDamage, source.getControllerId(), game);
this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game);
}
@Override

View file

@ -100,7 +100,7 @@ class GlintHawkEffect extends OneShotEffect<GlintHawkEffect> {
TargetPermanent target = new TargetPermanent(1, 1, filter, false);
if (target.canChoose(player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, game);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if ( permanent != null ) {

View file

@ -85,7 +85,7 @@ class PsychicMiasmaEffect1 extends OneShotEffect<PsychicMiasmaEffect1> {
Player player = game.getPlayer(targetPointer.getFirst(source));
if (player != null) {
TargetDiscard target = new TargetDiscard(player.getId());
player.choose(Outcome.Discard, target, game);
player.choose(Outcome.Discard, target, source.getSourceId(), game);
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {
player.discard(card, source, game);

View file

@ -100,7 +100,7 @@ class ClarionUltimatumEffect extends OneShotEffect<ClarionUltimatumEffect> {
TargetControlledPermanent permanentsTarget = new TargetControlledPermanent(Math.min(permanentsCount, 5));
permanentsTarget.setRequired(true);
player.choose(Outcome.Benefit, permanentsTarget, game);
player.choose(Outcome.Benefit, permanentsTarget, source.getSourceId(), game);
List<Card> chosenCards = new ArrayList<Card>();
List<String> namesFiltered = new ArrayList<String>();

View file

@ -99,7 +99,7 @@ class EldraziMonumentEffect extends OneShotEffect<EldraziMonumentEffect> {
target.setRequired(true);
Player player = game.getPlayer(source.getControllerId());
if (target.canChoose(source.getControllerId(), game)) {
player.choose(this.outcome, target, game);
player.choose(this.outcome, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
return permanent.sacrifice(source.getSourceId(), game);

View file

@ -116,7 +116,7 @@ class QuestForTheHolyRelicEffect extends OneShotEffect<QuestForTheHolyRelicEffec
Permanent equipment = game.getPermanent(card.getId());
Target targetCreature = new TargetControlledCreaturePermanent();
if (equipment != null && player.choose(Outcome.BoostCreature, targetCreature, game)) {
if (equipment != null && player.choose(Outcome.BoostCreature, targetCreature, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(targetCreature.getFirstTarget());
permanent.addAttachment(equipment.getId(), game);
}

View file

@ -131,7 +131,7 @@ class WarrenInstigatorEffect extends OneShotEffect<WarrenInstigatorEffect> {
FilterCreatureCard filter = new FilterCreatureCard("Goblin creature card from your hand");
filter.getSubtype().add("Goblin");
TargetCardInHand target = new TargetCardInHand(filter);
if (player.choose(Outcome.PutCreatureInPlay, target, game)) {
if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
player.removeFromHand(card, game);

View file

@ -69,7 +69,7 @@ public class CopyPermanentEffect extends OneShotEffect<CopyPermanentEffect> {
if (player != null) {
Target target = new TargetPermanent(filter);
if (target.canChoose(source.getControllerId(), game)) {
player.choose(Outcome.Copy, target, game);
player.choose(Outcome.Copy, target, source.getSourceId(), game);
Permanent perm = game.getPermanent(target.getFirstTarget());
if (perm != null) {
perm = perm.copy();

View file

@ -54,7 +54,7 @@ public class DiscardTargetCost extends CostImpl<DiscardTargetCost> {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
if (targets.choose(Outcome.Discard, controllerId, game)) {
if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) {
Player player = game.getPlayer(controllerId);
for (UUID targetId: targets.get(0).getTargets()) {
Card card = player.getHand().get(targetId, game);

View file

@ -64,7 +64,7 @@ public class ExileFromGraveCost extends CostImpl<ExileFromGraveCost> {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
if (targets.choose(Outcome.Exile, controllerId, game)) {
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
Player player = game.getPlayer(controllerId);
for (UUID targetId: targets.get(0).getTargets()) {
Card card = player.getGraveyard().get(targetId, game);

View file

@ -58,7 +58,7 @@ public class ReturnToHandTargetCost extends CostImpl<ReturnToHandTargetCost> {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
if (targets.choose(Outcome.ReturnToHand, controllerId, game)) {
if (targets.choose(Outcome.ReturnToHand, controllerId, sourceId, game)) {
for (UUID targetId: targets.get(0).getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent == null)

View file

@ -60,7 +60,7 @@ public class SacrificeTargetCost extends CostImpl<SacrificeTargetCost> {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
if (targets.choose(Outcome.Sacrifice, controllerId, game)) {
if (targets.choose(Outcome.Sacrifice, controllerId, sourceId, game)) {
for (UUID targetId: targets.get(0).getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent == null)
@ -74,7 +74,7 @@ public class SacrificeTargetCost extends CostImpl<SacrificeTargetCost> {
@Override
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
return targets.canChoose(controllerId, game);
return targets.canChoose(sourceId, controllerId, game);
}
@Override

View file

@ -57,7 +57,7 @@ public class TapTargetCost extends CostImpl<TapTargetCost> {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
if (target.choose(Outcome.Tap, controllerId, game)) {
if (target.choose(Outcome.Tap, controllerId, sourceId, game)) {
for (UUID targetId: (List<UUID>)target.getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent == null)

View file

@ -68,7 +68,7 @@ public class TapVariableTargetCost extends CostImpl<TapVariableTargetCost> imple
amountPaid = 0;
while (true) {
target.clearChosen();
if (target.choose(Outcome.Tap, controllerId, game)) {
if (target.choose(Outcome.Tap, controllerId, sourceId, game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null && permanent.tap(game)) {
amountPaid++;

View file

@ -79,7 +79,7 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect<Planeswalke
redirectTarget.add(game.getBattlefield().getAllActivePermanents(filter, target.getId()).get(0).getId(), game);
}
else {
player.choose(Outcome.Damage, redirectTarget, game);
player.choose(Outcome.Damage, redirectTarget, source.getSourceId(), game);
}
return true;
}

View file

@ -90,7 +90,7 @@ public class ExileFromZoneTargetEffect extends OneShotEffect<ExileFromZoneTarget
default:
}
if (target != null && target.canChoose(player.getId(), game)) {
if (target.choose(Outcome.Exile, player.getId(), game)) {
if (target.choose(Outcome.Exile, player.getId(), source.getSourceId(), game)) {
for (UUID cardId: target.getTargets()) {
Card card = game.getCard(cardId);
if (card != null)

View file

@ -79,7 +79,7 @@ public class SacrificeAllEffect extends OneShotEffect<SacrificeAllEffect> {
TargetControlledPermanent target = new TargetControlledPermanent(numTargets, numTargets, filter, false);
if (target.canChoose(player.getId(), game)) {
while (!target.isChosen()) {
player.choose(Outcome.Sacrifice, target, game);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
perms.addAll(target.getTargets());
}

View file

@ -82,7 +82,7 @@ public class SacrificeEffect extends OneShotEffect<SacrificeEffect>{
if (target.canChoose(player.getId(), game)) {
boolean abilityApplied = false;
while (!target.isChosen() && target.canChoose(player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, game);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
for ( int idx = 0; idx < target.getTargets().size(); idx++) {

View file

@ -68,7 +68,7 @@ public class ProliferateEffect extends OneShotEffect<ProliferateEffect> {
Map<String, Serializable> options = new HashMap<String, Serializable>();
options.put("UI.right.btn.text", "Done");
while (target.canChoose(controller.getId(), game)) {
if (!controller.choose(Outcome.Benefit, target, game, options)) {
if (!controller.choose(Outcome.Benefit, target, source.getSourceId(), game, options)) {
break;
}
}

View file

@ -121,7 +121,7 @@ class AnnihilatorEffect extends OneShotEffect<AnnihilatorEffect> {
if (target.canChoose(player.getId(), game)) {
boolean abilityApplied = false;
while (!target.isChosen() && target.canChoose(player.getId(), game)) {
player.choose(Outcome.Sacrifice, target, game);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
for ( int idx = 0; idx < target.getTargets().size(); idx++) {

View file

@ -404,7 +404,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
else {
choosingPlayer = this.getPlayer(choosingPlayerId);
}
if (choosingPlayer.choose(Outcome.Benefit, targetPlayer, this)) {
if (choosingPlayer.choose(Outcome.Benefit, targetPlayer, null, this)) {
startingPlayerId = ((List<UUID>)targetPlayer.getTargets()).get(0);
fireInformEvent(state.getPlayer(startingPlayerId).getName() + " will start");
}

View file

@ -206,8 +206,8 @@ public interface Player extends MageItem, Copyable<Player> {
public void setResponseInteger(Integer data);
public abstract void priority(Game game);
public abstract boolean choose(Outcome outcome, Target target, Game game);
public abstract boolean choose(Outcome outcome, Target target, Game game, Map<String, Serializable> options);
public abstract boolean choose(Outcome outcome, Target target, UUID sourceId, Game game);
public abstract boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options);
public abstract boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game);
public abstract boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game);
public abstract boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game);

View file

@ -408,7 +408,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
if (hand.size() == 0)
break;
TargetDiscard target = new TargetDiscard(playerId);
choose(Outcome.Discard, target, game);
choose(Outcome.Discard, target, source.getSourceId(), game);
Card card = hand.get(target.getFirstTarget(), game);
if (card != null && discard(card, source, game)) {
numDiscarded++;
@ -1093,7 +1093,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
newTarget = new TargetCardInLibrary(library.count(target.getFilter(), game), target.getMaxNumberOfTargets(), target.getFilter());
else
newTarget = target;
if (newTarget.choose(Outcome.Neutral, playerId, game)) {
if (newTarget.choose(Outcome.Neutral, playerId, null, game)) {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIBRARY_SEARCHED, playerId, playerId));
return true;
}

View file

@ -63,7 +63,7 @@ public interface Target extends Serializable {
//methods for non-targets
public boolean canChoose(UUID sourceControllerId, Game game);
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game);
public boolean choose(Outcome outcome, UUID playerId, Game game);
public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Game game);
public void add(UUID id, Game game);
public void remove(UUID targetId);

View file

@ -212,11 +212,11 @@ public abstract class TargetImpl<T extends TargetImpl<T>> implements Target {
}
@Override
public boolean choose(Outcome outcome, UUID playerId, Game game) {
public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Game game) {
Player player = game.getPlayer(playerId);
while (!isChosen() && !doneChosing()) {
chosen = targets.size() >= minNumberOfTargets;
if (!player.choose(outcome, this, game)) {
if (!player.choose(outcome, this, sourceId, game)) {
return chosen;
}
chosen = targets.size() >= minNumberOfTargets;

View file

@ -94,6 +94,14 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
return false;
}
public boolean canTarget(UUID controllerId, UUID id, UUID sourceId, Game game, boolean flag) {
Permanent permanent = game.getPermanent(id);
if (permanent != null) {
return filter.match(permanent, sourceId, controllerId, game);
}
return false;
}
@Override
public FilterPermanent getFilter() {
return this.filter;
@ -115,7 +123,7 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
return true;
int count = 0;
MageObject targetSource = game.getObject(sourceId);
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, game)) {
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource)) {
count++;
if (count >= remainingTargets)
@ -155,7 +163,7 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<UUID>();
MageObject targetSource = game.getObject(sourceId);
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, game)) {
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource)) {
possibleTargets.add(permanent.getId());
}

View file

@ -72,13 +72,13 @@ public class Targets extends ArrayList<Target> {
return true;
}
public boolean choose(Outcome outcome, UUID playerId, Game game) {
public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Game game) {
if (this.size() > 0) {
if (!canChoose(playerId, game))
return false;
while (!isChosen()) {
Target target = this.getUnchosen().get(0);
if (!target.choose(outcome, playerId, game))
if (!target.choose(outcome, playerId, sourceId, game))
return false;
}
}

View file

@ -66,7 +66,7 @@ public class TargetCardInLibrary extends TargetCard<TargetCardInLibrary> {
}
@Override
public boolean choose(Outcome outcome, UUID playerId, Game game) {
public boolean choose(Outcome outcome, UUID playerId, UUID sourceId, Game game) {
Player player = game.getPlayer(playerId);
while (!isChosen() && !doneChosing()) {
chosen = targets.size() >= minNumberOfTargets;