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

WIP: Allow objects to have multiple names #12839

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

theelk801
Copy link
Contributor

Just need to get this one started already, closes #12805

@github-actions github-actions bot added the engine label Sep 9, 2024
return false;
}
return CardUtil.haveSameNames(card, creatureName, game) && Objects.equals(ownerId, card.getOwnerId());
return spellAbility != null && card != null && card.isOwnedBy(ownerId) && card.sharesName(creature, game);
Copy link
Contributor

Choose a reason for hiding this comment

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

need to null check spell ability before calling getCharacteristics

boolean hasName(String name, Game game);

default boolean sharesName(MageObject mageObject, Game game) {
return !mageObject.getName().isEmpty() && hasName(mageObject.getName(), game);
Copy link
Member

Choose a reason for hiding this comment

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

Make sure you don’t use empty string logic for names, it’s fail in equal code (face down cards with empty names are not equal, but strings are). Use !CardUtil.haveEmptyName instead string.isEmpty()

The main idea behind old code with haveSameName and haveEmptyName:

  • protect from empty string compare errors (see above);
  • support diff object types in diff zones due diff naming rules (see commented tests with use cases in test_NamesEquals);
  • introduce independent from empty strings in object names (e.g. it can have any value for GUI or other purpose and fully support of mtg rules).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I'm gonna make sure I handle that all correctly, this is basically just placeholder code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor needed: Support for objects having multiple names
3 participants