mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
* Some fixes to possible exceptions.
This commit is contained in:
parent
3e4e555a20
commit
3ac7fc2726
6 changed files with 30 additions and 25 deletions
|
@ -727,7 +727,10 @@ public class HumanPlayer extends PlayerImpl {
|
|||
// It's end of turn phase
|
||||
if (!skippedAtLeastOnce
|
||||
|| (playerId.equals(game.getActivePlayerId())
|
||||
&& !controllingPlayer.getUserData().getUserSkipPrioritySteps().isStopOnAllEndPhases())) {
|
||||
&& !controllingPlayer
|
||||
.getUserData()
|
||||
.getUserSkipPrioritySteps()
|
||||
.isStopOnAllEndPhases())) {
|
||||
skippedAtLeastOnce = true;
|
||||
if (passWithManaPoolCheck(game)) {
|
||||
return false;
|
||||
|
@ -1060,7 +1063,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
while (!abort) {
|
||||
if (passedAllTurns
|
||||
|| passedUntilEndStepBeforeMyTurn
|
||||
|| (!getControllingPlayersUserData(game).getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction()
|
||||
|| (!getControllingPlayersUserData(game)
|
||||
.getUserSkipPrioritySteps()
|
||||
.isStopOnDeclareAttackersDuringSkipAction()
|
||||
&& (passedTurn
|
||||
|| passedTurnSkipStack
|
||||
|| passedUntilEndOfTurn
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*/
|
||||
package mage.abilities;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
|
@ -37,9 +39,6 @@ import mage.game.Game;
|
|||
import mage.util.ThreadLocalStringBuilder;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -164,7 +163,6 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
.filter(ability -> ability.getZone().match(zone))
|
||||
.collect(Collectors.toCollection(AbilitiesImpl::new));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -241,7 +239,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
|
||||
@Override
|
||||
public boolean contains(T ability) {
|
||||
for (Iterator<T> iterator = this.iterator(); iterator.hasNext(); ) { // simple loop can cause java.util.ConcurrentModificationException
|
||||
for (Iterator<T> iterator = this.iterator(); iterator.hasNext();) { // simple loop can cause java.util.ConcurrentModificationException
|
||||
T test = iterator.next();
|
||||
// Checking also by getRule() without other restrictions is a problem when a triggered ability will be copied to a permanent that had the same ability
|
||||
// already before the copy. Because then it keeps the triggered ability twice and it triggers twice.
|
||||
|
@ -280,7 +278,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
|
||||
@Override
|
||||
public boolean containsKey(UUID abilityId) {
|
||||
return stream().anyMatch(ability -> ability.getId().equals(abilityId));
|
||||
return stream().anyMatch(ability -> abilityId.equals(ability.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -295,7 +293,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
@Override
|
||||
public int getOutcomeTotal() {
|
||||
return stream().mapToInt(ability -> ability.getEffects().getOutcomeTotal()).sum();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mage.choices;
|
||||
|
||||
public class ChoiceColorOrArtifact extends ChoiceColor {
|
||||
|
||||
public ChoiceColorOrArtifact() {
|
||||
this.choices.add("Artifacts");
|
||||
this.message = "Choose protection from";
|
||||
|
@ -16,6 +17,6 @@ public class ChoiceColorOrArtifact extends ChoiceColor {
|
|||
}
|
||||
|
||||
public boolean isArtifactSelected() {
|
||||
return choice.equals("Artifacts");
|
||||
return "Artifacts".equals(choice);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,13 +35,14 @@ import mage.constants.PhaseStep;
|
|||
* @author LevelX2
|
||||
*/
|
||||
public class SkipPrioritySteps implements Serializable {
|
||||
boolean upkeep;
|
||||
boolean draw;
|
||||
boolean main1;
|
||||
boolean beforeCombat;
|
||||
boolean endOfCombat;
|
||||
boolean main2;
|
||||
boolean endOfTurn;
|
||||
|
||||
boolean upkeep = false;
|
||||
boolean draw = false;
|
||||
boolean main1 = true;
|
||||
boolean beforeCombat = false;
|
||||
boolean endOfCombat = false;
|
||||
boolean main2 = true;
|
||||
boolean endOfTurn = false;
|
||||
|
||||
public boolean isUpkeep() {
|
||||
return upkeep;
|
||||
|
@ -100,7 +101,7 @@ public class SkipPrioritySteps implements Serializable {
|
|||
}
|
||||
|
||||
public boolean isPhaseStepSet(PhaseStep phaseStep) {
|
||||
switch(phaseStep) {
|
||||
switch (phaseStep) {
|
||||
case UPKEEP:
|
||||
return isUpkeep();
|
||||
case DRAW:
|
||||
|
@ -119,5 +120,5 @@ public class SkipPrioritySteps implements Serializable {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class UserData implements Serializable {
|
|||
}
|
||||
|
||||
public static UserData getDefaultUserDataView() {
|
||||
return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, getDefaultFlagName(), false, true, true, false, false, false, false, "");
|
||||
return new UserData(UserGroup.DEFAULT, 0, false, false, true, new UserSkipPrioritySteps(), getDefaultFlagName(), false, true, true, false, false, false, false, "");
|
||||
}
|
||||
|
||||
public void setGroupId(int groupId) {
|
||||
|
|
|
@ -33,15 +33,15 @@ import java.io.Serializable;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class UserSkipPrioritySteps implements Serializable {
|
||||
|
||||
final SkipPrioritySteps yourTurn;
|
||||
final SkipPrioritySteps opponentTurn;
|
||||
|
||||
boolean stopOnDeclareAttackersDuringSkipAction;
|
||||
boolean stopOnDeclareBlockerIfNoneAvailable;
|
||||
boolean stopOnAllMainPhases;
|
||||
boolean stopOnAllEndPhases;
|
||||
boolean stopOnDeclareAttackersDuringSkipAction = true;
|
||||
boolean stopOnDeclareBlockerIfNoneAvailable = true;
|
||||
boolean stopOnAllMainPhases = true;
|
||||
boolean stopOnAllEndPhases = true;
|
||||
|
||||
public UserSkipPrioritySteps() {
|
||||
yourTurn = new SkipPrioritySteps();
|
||||
|
|
Loading…
Reference in a new issue