mirror of
https://github.com/correl/mage.git
synced 2024-11-16 03:00:12 +00:00
fixed NPE for LookLibraryControllerEffect
This commit is contained in:
parent
b31c23d686
commit
053c630b3c
1 changed files with 91 additions and 96 deletions
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
|
@ -103,14 +102,15 @@ public class LookLibraryControllerEffect extends OneShotEffect<LookLibraryContro
|
||||||
|
|
||||||
if (source instanceof SpellAbility) {
|
if (source instanceof SpellAbility) {
|
||||||
Card sourceCard = game.getCard(source.getSourceId());
|
Card sourceCard = game.getCard(source.getSourceId());
|
||||||
if (sourceCard != null)
|
if (sourceCard != null) {
|
||||||
windowName = sourceCard.getName();
|
windowName = sourceCard.getName();
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||||
if (sourcePermanent != null)
|
if (sourcePermanent != null) {
|
||||||
windowName = sourcePermanent.getName();
|
windowName = sourcePermanent.getName();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
|
@ -138,18 +138,11 @@ public class LookLibraryControllerEffect extends OneShotEffect<LookLibraryContro
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param card
|
|
||||||
* @param game
|
|
||||||
* @param source
|
|
||||||
*/
|
|
||||||
protected void cardLooked(Card card, Game game, Ability source) {
|
protected void cardLooked(Card card, Game game, Ability source) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void actionWithSelectedCards(Cards cards, Game game, Ability source, String windowName) {
|
protected void actionWithSelectedCards(Cards cards, Game game, Ability source, String windowName) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,23 +173,23 @@ public class LookLibraryControllerEffect extends OneShotEffect<LookLibraryContro
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to shuffle library if allowed
|
* Check to shuffle library if allowed
|
||||||
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param game
|
* @param game
|
||||||
*/
|
*/
|
||||||
protected void mayShuffle(Player player, Game game) {
|
protected void mayShuffle(Player player, Game game) {
|
||||||
if (this.mayShuffleAfter) {
|
if (this.mayShuffleAfter && player.chooseUse(Constants.Outcome.Benefit, "Shuffle you library?", game)) {
|
||||||
if (player.chooseUse(Constants.Outcome.Benefit, "Shuffle you library?", game)) {
|
|
||||||
player.shuffleLibrary(game);
|
player.shuffleLibrary(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected String getPutBackText() {
|
protected String getPutBackText() {
|
||||||
StringBuilder sb = new StringBuilder("card to put ");
|
StringBuilder sb = new StringBuilder("card to put ");
|
||||||
if (putOnTop)
|
if (putOnTop) {
|
||||||
sb.append("on your library (last chosen will be on top)");
|
sb.append("on your library (last chosen will be on top)");
|
||||||
else
|
} else {
|
||||||
sb.append("on bottom of your library (last chosen will be on bottom)");
|
sb.append("on bottom of your library (last chosen will be on bottom)");
|
||||||
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,10 +198,13 @@ public class LookLibraryControllerEffect extends OneShotEffect<LookLibraryContro
|
||||||
return setText(mode, "");
|
return setText(mode, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String setText(Mode mode, String middleText) {
|
public String setText(Mode mode, String middleText) {
|
||||||
int numberLook = numberOfCards.calculate(null, null);
|
int numberLook;
|
||||||
// int numberPick = numberToPick.calculate(null, null) ;
|
try {
|
||||||
|
numberLook = Integer.parseInt(numberOfCards.toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
numberLook = 0;
|
||||||
|
}
|
||||||
StringBuilder sb = new StringBuilder("Look at the top ");
|
StringBuilder sb = new StringBuilder("Look at the top ");
|
||||||
switch (numberLook) {
|
switch (numberLook) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -233,26 +229,25 @@ public class LookLibraryControllerEffect extends OneShotEffect<LookLibraryContro
|
||||||
sb.append(numberLook);
|
sb.append(numberLook);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (numberLook != 1)
|
if (numberLook != 1) {
|
||||||
sb.append(" cards ");
|
sb.append(" cards ");
|
||||||
|
}
|
||||||
|
|
||||||
sb.append("of your Library");
|
sb.append("of your Library");
|
||||||
if (numberLook == 0)
|
if (numberLook == 0) {
|
||||||
sb.append(", where {X} is the number of cards ").append(numberOfCards.getMessage());
|
sb.append(", where {X} is the number of cards ").append(numberOfCards.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!middleText.isEmpty()) {
|
if (!middleText.isEmpty()) {
|
||||||
sb.append(middleText);
|
sb.append(middleText);
|
||||||
}
|
} else if (numberLook > 1) {
|
||||||
else {
|
|
||||||
if (numberLook > 1)
|
|
||||||
sb.append(", then put them back in any order");
|
sb.append(", then put them back in any order");
|
||||||
}
|
}
|
||||||
if (this.mayShuffleAfter)
|
if (this.mayShuffleAfter) {
|
||||||
sb.append(". You may shuffle your library");
|
sb.append(". You may shuffle your library");
|
||||||
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue