Skip to content

201911/will#1

Open
ifdwill wants to merge 3 commits intomasterfrom
201911/Will
Open

201911/will#1
ifdwill wants to merge 3 commits intomasterfrom
201911/Will

Conversation

@ifdwill
Copy link
Copy Markdown
Collaborator

@ifdwill ifdwill commented Nov 25, 2019

  • Update to card to make immutable object (so that other things can't change it. Makes it easier to make changes to the card class down the line).

  • Update to the RARITY enum so that it's a bit cleaner to work with (eliminates the need to make the switch statement in packfactory)

  • Override hashCode() method (good practice to always do when overriding equals)

COMMON(3),
PROVINCE(1),
RARE(0)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

added values to the enum


public Card copy() {
return new Card(name, rarity);
return new Card(name, rarity, id);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

oh, this is wrong right now. gonna undo this

hash = 31 * hash + name.hashCode();
return hash;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

hashCode will need more work later, but it's probably good to have. Right now, if you have like conflict Tadaka and dynasty Tadaka, they would be considered the same object with your equals method. Suggestion is to add an id field to the card class.

break;
}
for (int i = 0; i < count; i++) {
for (int i = 0; i < c.getRarity().getCardCount(); i++) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

adding the cardcount to the enum makes it so that you don't need this switch statement. Could be useful if more "rarities" (though unlikely) are added down the line. Looks a bit cleaner though.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant