Some null exceptions checking and fixed some other minor problems.

This commit is contained in:
LevelX2 2018-05-26 01:22:28 +02:00
parent af2d55f8aa
commit fcc6174e5e
13 changed files with 156 additions and 130 deletions

View file

@ -347,7 +347,8 @@ public class ContinuousEffects implements Serializable {
}
// boolean checkLKI = event.getType().equals(EventType.ZONE_CHANGE) || event.getType().equals(EventType.DESTROYED_PERMANENT);
//get all applicable transient Replacement effects
for (ReplacementEffect effect : replacementEffects) {
for (Iterator<ReplacementEffect> iterator = replacementEffects.iterator(); iterator.hasNext();) {
ReplacementEffect effect = iterator.next();
if (!effect.checksEventType(event, game)) {
continue;
}
@ -378,7 +379,8 @@ public class ContinuousEffects implements Serializable {
replaceEffects.put(effect, applicableAbilities);
}
}
for (PreventionEffect effect : preventionEffects) {
for (Iterator<PreventionEffect> iterator = preventionEffects.iterator(); iterator.hasNext();) {
PreventionEffect effect = iterator.next();
if (!effect.checksEventType(event, game)) {
continue;
}
@ -932,8 +934,7 @@ public class ContinuousEffects implements Serializable {
System.out.println(game.getTurn() + ", " + game.getPhase() + ": " + "need apply " + layer.stream()
.map((eff) -> {return eff.getClass().getName().replaceAll(".+\\.(.+)", "$1");})
.collect(Collectors.joining(", ")));
*/
*/
for (ContinuousEffect effect : layer) {
if (activeLayerEffects.contains(effect) && !appliedEffects.contains(effect.getId())) { // Effect does still exist and was not applied yet
Set<UUID> dependentTo = effect.isDependentTo(layer);

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.keyword;
import java.util.*;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.StaticAbility;
@ -41,8 +42,6 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import java.util.*;
/**
* 20121001 702.31. Kicker 702.31a Kicker is a static ability that functions
* while the spell with kicker is on the stack. "Kicker [cost]" means "You may
@ -134,7 +133,8 @@ public class KickerAbility extends StaticAbility implements OptionalAdditionalSo
cost.reset();
}
String key = getActivationKey(source, "", game);
for (String activationKey : activations.keySet()) {
for (Iterator<String> iterator = activations.keySet().iterator(); iterator.hasNext();) {
String activationKey = iterator.next();
if (activationKey.startsWith(key) && activations.get(activationKey) > 0) {
activations.put(key, 0);
}
@ -212,10 +212,10 @@ public class KickerAbility extends StaticAbility implements OptionalAdditionalSo
&& player.chooseUse(Outcome.Benefit, "Pay " + times + kickerCost.getText(false) + " ?", ability, game)) {
this.activateKicker(kickerCost, ability, game);
if (kickerCost instanceof Costs) {
for (Iterator itKickerCost = ((Costs) kickerCost).iterator(); itKickerCost.hasNext(); ) {
for (Iterator itKickerCost = ((Costs) kickerCost).iterator(); itKickerCost.hasNext();) {
Object kickerCostObject = itKickerCost.next();
if ((kickerCostObject instanceof Costs) || (kickerCostObject instanceof CostsImpl)) {
for (@SuppressWarnings("unchecked") Iterator<Cost> itDetails = ((Costs) kickerCostObject).iterator(); itDetails.hasNext(); ) {
for (@SuppressWarnings("unchecked") Iterator<Cost> itDetails = ((Costs) kickerCostObject).iterator(); itDetails.hasNext();) {
addKickerCostsToAbility(itDetails.next(), ability, game);
}
} else {

View file

@ -142,7 +142,7 @@ public class Deck implements Serializable {
cardInfo = CardRepository.instance.findCard("Silvercoat Lion");
Logger.getLogger(Deck.class).error("Tried to restart the DB: " + (cardInfo == null ? "not successful" : "successful"));
}
return new GameException("Card not found - " + deckCardInfo.getCardName() + " - " + deckCardInfo.getSetCode() + " for deck - " + deckName + '\n'
return new GameException("Card not found - " + deckCardInfo.getCardName() + " - " + deckCardInfo.getSetCode() + "/" + deckCardInfo.getCardNum() + " for deck - " + deckName + '\n'
+ "Possible reason is, that you use cards in your deck, that are only supported in newer versions of the server.\n"
+ "So it can help to use the same card from another set, that's already supported from this server.");

View file

@ -29,7 +29,6 @@ package mage.game.combat;
import java.io.Serializable;
import java.util.*;
import mage.abilities.common.ControllerAssignCombatDamageToBlockersAbility;
import mage.abilities.common.ControllerDivideCombatDamageAbility;
import mage.abilities.common.DamageAsThoughNotBlockedAbility;
@ -178,7 +177,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
}
if (attackers.size() != 1) {
multiAttackerDamage(first, game);
// } else {
// } else {
// singleAttackerDamage(first, game);
}
}
@ -334,7 +333,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
defenderDamage(attacker, damage, game);
} else if (!blockerOrder.isEmpty()) {
// Assign the damage left to first blocker
assigned.put(blockerOrder.get(0), assigned.get(blockerOrder.get(0)) + damage);
assigned.put(blockerOrder.get(0), assigned.get(blockerOrder.get(0)) == null ? 0 : assigned.get(blockerOrder.get(0)) + damage);
}
}
for (UUID blockerId : blockerOrder) {
@ -430,7 +429,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
}
}
public boolean checkSoleBlockerAfter (Permanent blocker, Game game) {
public boolean checkSoleBlockerAfter(Permanent blocker, Game game) {
// this solves some corner cases (involving banding) when finding out whether a blocker is blocking alone or not
if (blocker.getBlocking() == 1) {
if (game.getCombat().blockingGroups.get(blocker.getId()) == null) {
@ -454,9 +453,9 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
* {@link #singleBlockerDamage}.
*
* Handles abilities like "{this} an block any number of creatures.".
*
* Blocker damage for blockers blocking single creatures is handled in
* the single/multi blocker methods, so this shouldn't be used anymore.
*
* Blocker damage for blockers blocking single creatures is handled in the
* single/multi blocker methods, so this shouldn't be used anymore.
*
* @param first
* @param game
@ -782,7 +781,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
/**
* There are effects, that set an attacker to be blocked. Therefore this
* setter can be used.
*
*
* This method lacks a band check, use setBlocked(blocked, game) instead.
*
* @param blocked
@ -870,8 +869,8 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
}
/**
* Decides damage distribution for blocking creatures with banding or
* if defending player controls the Defensive Formation enchantment.
* Decides damage distribution for blocking creatures with banding or if
* defending player controls the Defensive Formation enchantment.
*
* @param game
*/