-
Notifications
You must be signed in to change notification settings - Fork 778
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
base: master
Are you sure you want to change the base?
Conversation
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
Added more restrictions and checks on empty/face down names usage by tests (see a16215c). It must not affect PR's code or logic, but need little merge fix. |
For info: it must support legendary rule (if one of the name already used on battlefield then apply legendary rule), see #12534 (comment) |
Just need to get this one started already, closes #12805