update potential NPE on CardView

This commit is contained in:
Anthony Calosa
2023-07-14 13:36:14 +08:00
parent 39395eaf06
commit 22a7de3622

View File

@@ -832,7 +832,13 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
}
}
if (GuiBase.getInterface().isLibgdxPort()) {
return this.getGui().confirm(wrapper.getView().getHostCard(), buildQuestion.toString().replaceAll("\n", " "));
CardView cardView;
SpellAbilityView spellAbilityView = wrapper.getView();
if (spellAbilityView != null) //updated view
cardView = spellAbilityView.getHostCard();
else
cardView = wrapper.getCardView();
return this.getGui().confirm(cardView, buildQuestion.toString().replaceAll("\n", " "));
} else {
final InputConfirm inp = new InputConfirm(this, buildQuestion.toString(), wrapper);
inp.showAndWait();
@@ -1432,8 +1438,9 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
GameEntity affected, final String question) {
if (GuiBase.getInterface().isLibgdxPort()) {
CardView cardView;
if (effectSA.getView() != null) //updated view
cardView = effectSA.getView().getHostCard();
SpellAbilityView spellAbilityView = effectSA.getView();
if (spellAbilityView != null) //updated view
cardView = spellAbilityView.getHostCard();
else //fallback
cardView = effectSA.getCardView();
return this.getGui().confirm(cardView, question.replaceAll("\n", " "));
@@ -1866,7 +1873,11 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
try {
cardView = CardView.getCardForUi(ImageUtil.getPaperCardFromImageKey(sa.getView().getHostCard().getCurrentState().getTrackableImageKey()));
} catch (Exception e) {
cardView = sa.getView().getHostCard();
SpellAbilityView spellAbilityView = sa.getView();
if (spellAbilityView != null) //updated view
cardView = spellAbilityView.getHostCard();
else //fallback
cardView = sa.getCardView();
}
return this.getGui().confirm(cardView, question.replaceAll("\n", " "));
} else {