Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chosen letter support (Unsets) #6636

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

Northmoc
Copy link
Contributor

A decent draft, I think

@Northmoc Northmoc added Game Mechanics Low priority Good for a rainy day Unfinity Wacky stuff labels Nov 26, 2024
@Hanmac
Copy link
Contributor

Hanmac commented Nov 27, 2024

In case you’re wondering, we’ve chosen to allow Y to be both a consonant and a vowel, depending on what the card cares about. Y? Because we’re nice, and because Y has a great legal team.

xD

Comment on lines +16 to +20
List<String> letters = Lists.newArrayList("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
List<String> consonants = Lists.newArrayList("B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q",
"R", "S", "T", "V", "W", "X", "Y", "Z");
List<String> choices = sa.hasParam("Consonant") ? consonants : letters;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo, I would have used Constants for this? And only make a new List if "Exclude" is used?

Also need extra list for Vowels

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good – I am not sure how to set that up so it would be good to learn

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?

List<String> LETTERS = Lists.newArrayList();
//... inside function:
List<String> choices = LETTERS;
if (sa.hasParam("Exclude"))  {
  choices = Lists.newArrayList(choices); // makes copy
  choices.removeAll(Arrays.asList(sa.getParam("Exclude").split(",")));
}

hm the chooseLetter implementations does remove the letter anyway from the list, so you can't give them the constant ? :(

List<String> chosen = Lists.newArrayList();
for (int i = 0; i <=n; i++) {
String choice = Aggregates.random(letters);
letters.remove(choice);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Hanmac mentioned, it's probably safest to avoid transforming the input array in these methods. In this case you could just use the second parameter of Aggregates.random and set it to n.

@@ -193,6 +193,8 @@ public final void reveal(List<CardView> cards, ZoneType zone, PlayerView owner,
public abstract PlayerZone chooseStartingHand(List<PlayerZone> zones);
public abstract Mana chooseManaFromPool(List<Mana> manaChoices);

public abstract List<String> chooseLetter(int n, String ai, List<String> letters);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe pass in the whole SpellAbility rather than just the AI parameter? Not sure that it matters here but most other methods in this class do it that way.

Collections.sort(letters);
chosenLetters = letters;
view.updateChosenLetters(this);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to transfer the chosen letters in CardCopyService, and similar places. Maybe do a few usage searches on similar methods.

It might be worth it someday to split Card's chosen_____ fields off into their own class. They each add a lot of similar boilerplate to Cards and related functions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth it someday to split Card's chosen_____ fields off into their own class. They each add a lot of similar boilerplate to Cards and related functions.

that is my department, i need to refactor that anyway for Linked Abilities stuff, where you could have different sets of Chosen Values.

} else if (property.startsWith("ChosenLetter")) {
final List<String> letters = source.getChosenLetters();
if (letters == null) return false; // some things check before letters have been chosen
String name = cardState.getName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe apply .toUpperCase to name here so you don't have to check it twice below? Also in case we ever have any cards that start with a lowercase letter. Can't think of any right now besides "capital offense".

@Hanmac
Copy link
Contributor

Hanmac commented Nov 28, 2024

Apropos Letter in Card Name, we should normalize them for names like Bartolomé so é counts as e

see:

public static String normalizeText(String text) {
if (text == null)
return IPaperCard.NO_ARTIST_NAME;
return Normalizer.normalize(text, Normalizer.Form.NFD);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Game Mechanics Low priority Good for a rainy day Unfinity Wacky stuff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants