mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08: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
|
// It's end of turn phase
|
||||||
if (!skippedAtLeastOnce
|
if (!skippedAtLeastOnce
|
||||||
|| (playerId.equals(game.getActivePlayerId())
|
|| (playerId.equals(game.getActivePlayerId())
|
||||||
&& !controllingPlayer.getUserData().getUserSkipPrioritySteps().isStopOnAllEndPhases())) {
|
&& !controllingPlayer
|
||||||
|
.getUserData()
|
||||||
|
.getUserSkipPrioritySteps()
|
||||||
|
.isStopOnAllEndPhases())) {
|
||||||
skippedAtLeastOnce = true;
|
skippedAtLeastOnce = true;
|
||||||
if (passWithManaPoolCheck(game)) {
|
if (passWithManaPoolCheck(game)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1060,7 +1063,9 @@ public class HumanPlayer extends PlayerImpl {
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
if (passedAllTurns
|
if (passedAllTurns
|
||||||
|| passedUntilEndStepBeforeMyTurn
|
|| passedUntilEndStepBeforeMyTurn
|
||||||
|| (!getControllingPlayersUserData(game).getUserSkipPrioritySteps().isStopOnDeclareAttackersDuringSkipAction()
|
|| (!getControllingPlayersUserData(game)
|
||||||
|
.getUserSkipPrioritySteps()
|
||||||
|
.isStopOnDeclareAttackersDuringSkipAction()
|
||||||
&& (passedTurn
|
&& (passedTurn
|
||||||
|| passedTurnSkipStack
|
|| passedTurnSkipStack
|
||||||
|| passedUntilEndOfTurn
|
|| passedUntilEndOfTurn
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
*/
|
*/
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
import mage.abilities.keyword.ProtectionAbility;
|
||||||
|
|
@ -37,9 +39,6 @@ import mage.game.Game;
|
||||||
import mage.util.ThreadLocalStringBuilder;
|
import mage.util.ThreadLocalStringBuilder;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @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))
|
.filter(ability -> ability.getZone().match(zone))
|
||||||
.collect(Collectors.toCollection(AbilitiesImpl::new));
|
.collect(Collectors.toCollection(AbilitiesImpl::new));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -241,7 +239,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(T ability) {
|
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();
|
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
|
// 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.
|
// 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
|
@Override
|
||||||
public boolean containsKey(UUID abilityId) {
|
public boolean containsKey(UUID abilityId) {
|
||||||
return stream().anyMatch(ability -> ability.getId().equals(abilityId));
|
return stream().anyMatch(ability -> abilityId.equals(ability.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -295,7 +293,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
||||||
@Override
|
@Override
|
||||||
public int getOutcomeTotal() {
|
public int getOutcomeTotal() {
|
||||||
return stream().mapToInt(ability -> ability.getEffects().getOutcomeTotal()).sum();
|
return stream().mapToInt(ability -> ability.getEffects().getOutcomeTotal()).sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package mage.choices;
|
package mage.choices;
|
||||||
|
|
||||||
public class ChoiceColorOrArtifact extends ChoiceColor {
|
public class ChoiceColorOrArtifact extends ChoiceColor {
|
||||||
|
|
||||||
public ChoiceColorOrArtifact() {
|
public ChoiceColorOrArtifact() {
|
||||||
this.choices.add("Artifacts");
|
this.choices.add("Artifacts");
|
||||||
this.message = "Choose protection from";
|
this.message = "Choose protection from";
|
||||||
|
|
@ -16,6 +17,6 @@ public class ChoiceColorOrArtifact extends ChoiceColor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isArtifactSelected() {
|
public boolean isArtifactSelected() {
|
||||||
return choice.equals("Artifacts");
|
return "Artifacts".equals(choice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,14 @@ import mage.constants.PhaseStep;
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class SkipPrioritySteps implements Serializable {
|
public class SkipPrioritySteps implements Serializable {
|
||||||
boolean upkeep;
|
|
||||||
boolean draw;
|
boolean upkeep = false;
|
||||||
boolean main1;
|
boolean draw = false;
|
||||||
boolean beforeCombat;
|
boolean main1 = true;
|
||||||
boolean endOfCombat;
|
boolean beforeCombat = false;
|
||||||
boolean main2;
|
boolean endOfCombat = false;
|
||||||
boolean endOfTurn;
|
boolean main2 = true;
|
||||||
|
boolean endOfTurn = false;
|
||||||
|
|
||||||
public boolean isUpkeep() {
|
public boolean isUpkeep() {
|
||||||
return upkeep;
|
return upkeep;
|
||||||
|
|
@ -100,7 +101,7 @@ public class SkipPrioritySteps implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPhaseStepSet(PhaseStep phaseStep) {
|
public boolean isPhaseStepSet(PhaseStep phaseStep) {
|
||||||
switch(phaseStep) {
|
switch (phaseStep) {
|
||||||
case UPKEEP:
|
case UPKEEP:
|
||||||
return isUpkeep();
|
return isUpkeep();
|
||||||
case DRAW:
|
case DRAW:
|
||||||
|
|
@ -119,5 +120,5 @@ public class SkipPrioritySteps implements Serializable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ public class UserData implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserData getDefaultUserDataView() {
|
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) {
|
public void setGroupId(int groupId) {
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,15 @@ import java.io.Serializable;
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class UserSkipPrioritySteps implements Serializable {
|
public class UserSkipPrioritySteps implements Serializable {
|
||||||
|
|
||||||
final SkipPrioritySteps yourTurn;
|
final SkipPrioritySteps yourTurn;
|
||||||
final SkipPrioritySteps opponentTurn;
|
final SkipPrioritySteps opponentTurn;
|
||||||
|
|
||||||
boolean stopOnDeclareAttackersDuringSkipAction;
|
boolean stopOnDeclareAttackersDuringSkipAction = true;
|
||||||
boolean stopOnDeclareBlockerIfNoneAvailable;
|
boolean stopOnDeclareBlockerIfNoneAvailable = true;
|
||||||
boolean stopOnAllMainPhases;
|
boolean stopOnAllMainPhases = true;
|
||||||
boolean stopOnAllEndPhases;
|
boolean stopOnAllEndPhases = true;
|
||||||
|
|
||||||
public UserSkipPrioritySteps() {
|
public UserSkipPrioritySteps() {
|
||||||
yourTurn = new SkipPrioritySteps();
|
yourTurn = new SkipPrioritySteps();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue