* Game: fixed random sort order of choices in choose dialogs

This commit is contained in:
Oleg Agafonov 2023-03-21 03:11:55 +04:00
parent 6b05562336
commit a7480aeab1
40 changed files with 78 additions and 71 deletions

View file

@ -19,6 +19,7 @@ import mage.target.TargetPermanent;
import mage.util.CardUtil;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
@ -108,7 +109,7 @@ public class RemoveCounterCost extends CostImpl {
}
} else { // Multiple counters, player much choose which type to remove from
Choice choice = new ChoiceImpl(true);
Set<String> choices = new HashSet<>();
Set<String> choices = new LinkedHashSet<>();
for (Counter counter : targetObject.getCounters(game).values()) {
if (targetObject.getCounters(game).getCount(counter.getName()) > 0) {
choices.add(counter.getName());

View file

@ -338,7 +338,7 @@ public class ContinuousEffects implements Serializable {
* event
*/
private Map<ReplacementEffect, Set<Ability>> getApplicableReplacementEffects(GameEvent event, Game game) {
Map<ReplacementEffect, Set<Ability>> replaceEffects = new HashMap<>();
Map<ReplacementEffect, Set<Ability>> replaceEffects = new LinkedHashMap<>();
if (auraReplacementEffect.checksEventType(event, game) && auraReplacementEffect.applies(event, null, game)) {
replaceEffects.put(auraReplacementEffect, null);
}

View file

@ -13,6 +13,7 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
/**
@ -69,7 +70,7 @@ public class RemoveCounterTargetEffect extends OneShotEffect {
String counterName = null;
if (permanent.getCounters(game).size() > 1) {
Choice choice = new ChoiceImpl(true);
Set<String> choices = new HashSet<>();
Set<String> choices = new LinkedHashSet<>();
for (Counter counterOnPermanent : permanent.getCounters(game).values()) {
if (permanent.getCounters(game).getCount(counterOnPermanent.getName()) > 0) {
choices.add(counterOnPermanent.getName());

View file

@ -2906,7 +2906,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (rollsAmount == 1) {
return rollDieInnerWithReplacement(game, source, rollDieType, sidesAmount, chaosSidesAmount, planarSidesAmount);
}
Set<Object> choices = new HashSet<>();
Set<Object> choices = new LinkedHashSet<>();
for (int j = 0; j < rollsAmount; j++) {
choices.add(rollDieInnerWithReplacement(game, source, rollDieType, sidesAmount, chaosSidesAmount, planarSidesAmount));
}

View file

@ -1738,7 +1738,7 @@ public final class CardUtil {
// HashMap uses inner class for Keys without serialization support,
// so you can't use it for client-server data
if (data != null && data.getClass().getName().endsWith("$KeySet")) {
throw new IllegalArgumentException("Can't use KeySet as param, use new HashSet<>(data.keySet()) instead");
throw new IllegalArgumentException("Can't use KeySet as param, use new LinkedHashSet<>(data.keySet()) instead");
}
}
}