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

Allow any number of hearts and stop duplicate cards #105

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

Conversation

philharper
Copy link

  • Updated the creation of the hearts to create the number of hearts based off the lives
  • Fixed getRandomItem to stop duplicate cards appearing. Although I'm think this may already be sorted by the tooClose method before? I added this after making some changes in my fork to use local data to create a small Christmas game. I removed the tooClose check as the values were only from 1-100 so much more likely to be very close.

@philharper
Copy link
Author

Not sure why the checks failed? Looks more like an issue with the build image than the changes.

@@ -34,11 +34,14 @@ interface Props {
export default function Hearts(props: Props) {
const { lives } = props;

const elements: JSX.Element[] = [];
for (let counter = 1; counter <= lives; counter++) {

Choose a reason for hiding this comment

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

Hello! Thank you for your contribution. I also want to have a flexible number of lives, but it's a bit more complicated than you patch. What you're doing here is to add the same number of component Heart that the player has lives, but this isn't what we want: we want the hearts to still be displayed, but differently when we lost a life:
image

The actual number of lives is initialized here: https://github.com/tom-james-watson/wikitrivia/blob/master/lib/create-state.ts#L15
But as you spotted, we also need to have the number of <Heart> below dynamic.
So, we have to have the number of lives coming from somewhere. Should it be a const in a config file? Should we ask the users? Or let them select a level? (hard 3 lives, medium 5 lives, easy 8 lives?). What do you want?

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.

2 participants