mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Added test and fixed some possible null pointer exception.
This commit is contained in:
parent
13c8f3263f
commit
bf43ea9936
10 changed files with 130 additions and 31 deletions
|
|
@ -328,13 +328,16 @@ public abstract class AbilityImpl implements Ability {
|
|||
if (sourceObject != null && !this.getAbilityType().equals(AbilityType.TRIGGERED)) { // triggered abilities check this already in playerImpl.triggerAbility
|
||||
sourceObject.adjustTargets(this, game);
|
||||
}
|
||||
// Flashback abilities haven't made the choices the underlying spell might need for targetting.
|
||||
if (!(this instanceof FlashbackAbility) && getTargets().size() > 0 && getTargets().chooseTargets(
|
||||
getEffects().get(0).getOutcome(), this.controllerId, this, noMana, game) == false) {
|
||||
if ((variableManaCost != null || announceString != null) && !game.isSimulation()) {
|
||||
game.informPlayer(controller, (sourceObject != null ? sourceObject.getIdName() : "") + ": no valid targets with this value of X");
|
||||
// Flashback abilities haven't made the choices the underlying spell might need for targeting.
|
||||
if (!(this instanceof FlashbackAbility)
|
||||
&& getTargets().size() > 0) {
|
||||
Outcome outcome = getEffects().isEmpty() ? Outcome.Detriment : getEffects().get(0).getOutcome();
|
||||
if (getTargets().chooseTargets(outcome, this.controllerId, this, noMana, game) == false) {
|
||||
if ((variableManaCost != null || announceString != null) && !game.isSimulation()) {
|
||||
game.informPlayer(controller, (sourceObject != null ? sourceObject.getIdName() : "") + ": no valid targets with this value of X");
|
||||
}
|
||||
return false; // when activation of ability is canceled during target selection
|
||||
}
|
||||
return false; // when activation of ability is canceled during target selection
|
||||
}
|
||||
} // end modes
|
||||
|
||||
|
|
|
|||
|
|
@ -85,13 +85,14 @@ public class AddConditionalManaOfAnyColorEffect extends ManaEffect {
|
|||
|
||||
int value = amount.calculate(game, source, this);
|
||||
boolean result = false;
|
||||
ChoiceColor choice = new ChoiceColor(false);
|
||||
for (int i = 0; i < value; i++) {
|
||||
if (!choice.isChosen()) {
|
||||
if (!controller.choose(outcome, choice, game)) {
|
||||
return false;
|
||||
}
|
||||
ChoiceColor choice = new ChoiceColor(true);
|
||||
while (!choice.isChosen()) {
|
||||
controller.choose(outcome, choice, game);
|
||||
if (!controller.isInGame()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < value; i++) {
|
||||
Mana mana = null;
|
||||
if (choice.getColor().isBlack()) {
|
||||
mana = manaBuilder.setMana(Mana.BlackMana(1), source, game).build();
|
||||
|
|
|
|||
|
|
@ -193,8 +193,11 @@ public abstract class ExpansionSet implements Serializable {
|
|||
|
||||
if (15 > theBooster.size()) {
|
||||
List<CardInfo> commons = getCardsByRarity(Rarity.COMMON);
|
||||
while (15 > theBooster.size()) {
|
||||
while (15 > theBooster.size() && !commons.isEmpty()) {
|
||||
addToBooster(theBooster, commons);
|
||||
if (commons.isEmpty()) {
|
||||
commons = getCardsByRarity(Rarity.COMMON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public enum CardRepository {
|
|||
// raise this if db structure was changed
|
||||
private static final long CARD_DB_VERSION = 47;
|
||||
// raise this if new cards were added to the server
|
||||
private static final long CARD_CONTENT_VERSION = 63;
|
||||
private static final long CARD_CONTENT_VERSION = 64;
|
||||
|
||||
private Dao<CardInfo, Object> cardDao;
|
||||
private Set<String> classNames;
|
||||
|
|
|
|||
|
|
@ -1499,6 +1499,17 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
|
||||
@Override
|
||||
public void addTriggeredAbility(TriggeredAbility ability) {
|
||||
if (ability.getControllerId() == null) {
|
||||
String sourceName = "no sourceId";
|
||||
if (ability.getSourceId() != null) {
|
||||
MageObject mageObject = getObject(ability.getSourceId());
|
||||
if (mageObject != null) {
|
||||
sourceName = mageObject.getName();
|
||||
}
|
||||
}
|
||||
logger.fatal("Added triggered ability without controller: " + sourceName + " rule: " + ability.getRule());
|
||||
return;
|
||||
}
|
||||
if (ability instanceof TriggeredManaAbility || ability instanceof DelayedTriggeredManaAbility) {
|
||||
// 20110715 - 605.4
|
||||
Ability manaAbiltiy = ability.copy();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue