mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
Fixed Issue 271
This commit is contained in:
parent
cb51589293
commit
b3ac9c2f87
3 changed files with 14 additions and 11 deletions
|
|
@ -247,11 +247,10 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
|
public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
|
||||||
game.getState().setPriorityPlayerId(getId());
|
game.getState().setPriorityPlayerId(getId());
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage(),
|
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getId(), playerId, game);
|
||||||
target.possibleTargets(source==null?null:source.getId(), playerId, game),
|
game.fireSelectTargetEvent(playerId, target.getMessage(), possibleTargets, target.isRequired(), getOptions(target));
|
||||||
target.isRequired(), getOptions(target));
|
|
||||||
waitForResponse();
|
waitForResponse();
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null && possibleTargets.contains(response.getUUID())) {
|
||||||
if (target instanceof TargetPermanent) {
|
if (target instanceof TargetPermanent) {
|
||||||
if (((TargetPermanent)target).canTarget(playerId, response.getUUID(), source, game)) {
|
if (((TargetPermanent)target).canTarget(playerId, response.getUUID(), source, game)) {
|
||||||
target.addTarget(response.getUUID(), source, game);
|
target.addTarget(response.getUUID(), source, game);
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -35,6 +35,7 @@ import mage.Constants.CardType;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
|
@ -44,6 +45,7 @@ import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.game.stack.StackObject;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
|
@ -167,7 +169,7 @@ class SearingBlazeTarget<T extends TargetCreaturePermanent<T>> extends TargetPer
|
||||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||||
UUID firstTarget = source.getFirstTarget();
|
UUID firstTarget = source.getFirstTarget();
|
||||||
Permanent permanent = game.getPermanent(id);
|
Permanent permanent = game.getPermanent(id);
|
||||||
if (firstTarget != null && permanent != null && !permanent.getControllerId().equals(firstTarget)) {
|
if (firstTarget != null && permanent != null && permanent.getControllerId().equals(firstTarget)) {
|
||||||
return super.canTarget(id, source, game);
|
return super.canTarget(id, source, game);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -177,14 +179,16 @@ class SearingBlazeTarget<T extends TargetCreaturePermanent<T>> extends TargetPer
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
|
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
|
||||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
// TODO: sourceId is the Id of an Ability; at the time this is passed the first target is selected but the call below return null
|
MageObject object = game.getObject(sourceId);
|
||||||
UUID playerId = game.getObject(sourceId).getAbilities().get(0).getFirstTarget();
|
if (object instanceof StackObject) {
|
||||||
|
UUID playerId = ((StackObject)object).getStackAbility().getFirstTarget();
|
||||||
for (UUID targetId : availablePossibleTargets) {
|
for (UUID targetId : availablePossibleTargets) {
|
||||||
Permanent permanent = game.getPermanent(targetId);
|
Permanent permanent = game.getPermanent(targetId);
|
||||||
if(permanent != null && permanent.getControllerId().equals(playerId)){
|
if(permanent != null && permanent.getControllerId().equals(playerId)){
|
||||||
possibleTargets.add(targetId);
|
possibleTargets.add(targetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue