fixed some NPE issues with player target choosing

This commit is contained in:
Evan Kranzler 2022-03-25 21:16:38 -04:00
parent a6c2daeb5e
commit 945b60c8d0
5 changed files with 8 additions and 8 deletions

View file

@ -535,7 +535,7 @@ public class HumanPlayer extends PlayerImpl {
updateGameStatePriority("choose(5)", game);
prepareForResponse(game);
if (!isExecutingMacro()) {
game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(source.getSourceId(), game)), targetIds, required, getOptions(target, options));
game.fireSelectTargetEvent(getId(), new MessageToClient(target.getMessage(), getRelatedObjectName(source, game)), targetIds, required, getOptions(target, options));
}
waitForResponse(game);

View file

@ -67,7 +67,7 @@ class DrafnasRestorationTarget extends TargetCardInGraveyard {
Player targetPlayer = game.getPlayer(((StackObject) object).getStackAbility().getFirstTarget());
if (targetPlayer != null) {
for (Card card : targetPlayer.getGraveyard().getCards(filter, sourceControllerId, source, game)) {
if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
if (source == null || source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
possibleTargets.add(card.getId());
}
}

View file

@ -61,7 +61,7 @@ public class TargetCardInHand extends TargetCard {
Player player = game.getPlayer(sourceControllerId);
if (player != null) {
for (Card card : player.getHand().getCards(filter, sourceControllerId, source, game)) {
if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
if (source == null || source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
possibleTargets.add(card.getId());
}
}
@ -75,7 +75,7 @@ public class TargetCardInHand extends TargetCard {
Player player = game.getPlayer(sourceControllerId);
if (player != null) {
for (Card card : player.getHand().getCards(filter, sourceControllerId, source, game)) {
if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
if (source == null || source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
possibleTargets++;
if (possibleTargets >= this.minNumberOfTargets) {
return true;

View file

@ -100,7 +100,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Card card : player.getGraveyard().getCards(filter, sourceControllerId, source, game)) {
if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
if (source == null || source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
possibleTargets++;
if (possibleTargets >= this.minNumberOfTargets) {
return true;
@ -125,7 +125,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard {
if (player != null) {
Set<UUID> targetsInThisGraveyeard = new HashSet<>();
for (Card card : player.getGraveyard().getCards(filter, sourceControllerId, source, game)) {
if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
if (source == null || source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
targetsInThisGraveyeard.add(card.getId());
}
}

View file

@ -76,7 +76,7 @@ public class TargetCardInYourGraveyard extends TargetCard {
Set<UUID> possibleTargets = new HashSet<>();
Player player = game.getPlayer(sourceControllerId);
for (Card card : player.getGraveyard().getCards(filter, sourceControllerId, source, game)) {
if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
if (source == null || source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
possibleTargets.add(card.getId());
}
}
@ -116,7 +116,7 @@ public class TargetCardInYourGraveyard extends TargetCard {
}
int possibleTargets = 0;
for (Card card : player.getGraveyard().getCards(filter, sourceControllerId, source, game)) {
if (source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
if (source == null || source.getSourceId() == null || isNotTarget() || !game.replaceEvent(new TargetEvent(card, source.getSourceId(), sourceControllerId))) {
possibleTargets++;
if (possibleTargets >= this.minNumberOfTargets) {
return true;