- Fixed NPEs in the new prompt input code (we should not assume that SA vars will be filled in at all times).

This commit is contained in:
Agetian
2017-01-21 19:20:46 +00:00
parent 001b6aea84
commit 828359c0bc
3 changed files with 12 additions and 10 deletions

View File

@@ -61,8 +61,8 @@ public class InputConfirm extends InputSyncronizedBase {
noButtonText = noButtonText0;
defaultYes = defaultYes0;
result = defaultYes0;
this.sa = null;
this.card = null;
this.sa = null;
this.card = null;
}
public InputConfirm(final PlayerControllerHuman controller, String message0, SpellAbility sa0) {
@@ -80,8 +80,8 @@ public class InputConfirm extends InputSyncronizedBase {
noButtonText = noButtonText0;
defaultYes = defaultYes0;
result = defaultYes0;
this.sa = sa0;
this.card = sa.getView().getHostCard();
this.sa = sa0;
this.card = sa != null ? sa.getView().getHostCard() : null;
}
public InputConfirm(final PlayerControllerHuman controller, String message0, CardView card0) {
@@ -99,8 +99,8 @@ public class InputConfirm extends InputSyncronizedBase {
noButtonText = noButtonText0;
defaultYes = defaultYes0;
result = defaultYes0;
this.sa = null ;
this.card = card0;
this.sa = null ;
this.card = card0;
}
/** {@inheritDoc} */

View File

@@ -36,7 +36,9 @@ public abstract class InputSelectManyBase<T extends GameEntity> extends InputSyn
protected InputSelectManyBase(final PlayerControllerHuman controller, final int min, final int max, final SpellAbility sa0) {
this(controller,min,max);
this.sa = sa0;
this.card = sa0.getView().getHostCard();
if (sa0 != null) {
this.card = sa0.getView().getHostCard();
}
}
protected InputSelectManyBase(final PlayerControllerHuman controller, final int min, final int max, final CardView card0) {

View File

@@ -1031,9 +1031,9 @@ public class PlayerControllerHuman
default: labels = ImmutableList.copyOf(kindOfChoice.toString().split("Or"));
}
// return getGui().confirm(CardView.get(sa.getHostCard()), question, defaultVal == null || defaultVal.booleanValue(), labels);
final InputConfirm inp = new InputConfirm(this, question, labels.get(0), labels.get(1), defaultVal == null || defaultVal.booleanValue(), sa);
inp.showAndWait();
return inp.getResult();
final InputConfirm inp = new InputConfirm(this, question, labels.get(0), labels.get(1), defaultVal == null || defaultVal.booleanValue(), sa);
inp.showAndWait();
return inp.getResult();
}
@Override