from list to set

This commit is contained in:
Anthony Calosa
2024-11-14 06:00:02 +08:00
parent 85913a3d6c
commit 71ecf91bb5
12 changed files with 45 additions and 34 deletions

View File

@@ -573,7 +573,7 @@ public class GameAction {
}
if (c.hasChosenColorSpire()) {
copied.setChosenColorID(ImmutableList.copyOf(c.getChosenColorID()));
copied.setChosenColorID(ImmutableSet.copyOf(c.getChosenColorID()));
}
// update state for view
@@ -2236,7 +2236,7 @@ public class GameAction {
Localizer.getInstance().getMessage("lblChooseNColors", Lang.getNumeral(2));
SpellAbility sa = new SpellAbility.EmptySa(ApiType.ChooseColor, c, takesAction);
sa.putParam("AILogic", "MostProminentInComputerDeck");
List<String> chosenColors = takesAction.getController().chooseColors(prompt, sa, 2, 2, colorChoices);
Set<String> chosenColors = new HashSet<>(takesAction.getController().chooseColors(prompt, sa, 2, 2, colorChoices));
c.setChosenColorID(chosenColors);
}
}

View File

@@ -293,7 +293,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
private String chosenType2 = "";
private List<String> notedTypes = new ArrayList<>();
private List<String> chosenColors;
private List<String> chosenColorID;
private Set<String> chosenColorID;
private List<String> chosenName = new ArrayList<>();
private Integer chosenNumber;
private Player chosenPlayer;
@@ -2121,13 +2121,13 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
public boolean hasChosenColor(String s) {
return chosenColors != null && chosenColors.contains(s);
}
public final List<String> getChosenColorID() {
public final Set<String> getChosenColorID() {
if (chosenColorID == null) {
return Lists.newArrayList();
return Sets.newHashSet();
}
return chosenColorID;
}
public final void setChosenColorID(final List<String> s) {
public final void setChosenColorID(final Set<String> s) {
chosenColorID = s;
view.updateChosenColorID(this);
}

View File

@@ -433,7 +433,7 @@ public class CardView extends GameEntityView {
void updateChosenColors(Card c) {
set(TrackableProperty.ChosenColors, c.getChosenColors());
}
public List<String> getChosenColorID() {
public Set<String> getChosenColorID() {
return get(TrackableProperty.ChosenColorID);
}
void updateChosenColorID(Card c) {

View File

@@ -67,7 +67,7 @@ public enum TrackableProperty {
ChosenType2(TrackableTypes.StringType),
NotedTypes(TrackableTypes.StringListType),
ChosenColors(TrackableTypes.StringListType),
ChosenColorID(TrackableTypes.StringListType),
ChosenColorID(TrackableTypes.StringSetType),
ChosenCards(TrackableTypes.CardViewCollectionType),
ChosenNumber(TrackableTypes.StringType),
StoredRolls(TrackableTypes.StringListType),