Conversation
|
Love the look to it, UIUX indeed! think you will love the DOM lesson! I did managed to break the game however, simply by clicking submit. The input validation was great but it somehow let me through to the next part of the program even though i did not input 1 or 2 when selecting score. That aside, I think you managed the user flow well enough that I completely understood what was happening, and was easy to play! which is totally awesome and well done for that! 🙌💯 |
| return myOutputValue; | ||
| } | ||
| if (gameMode == CHOOSE_DICE_ORDER) { | ||
| myOutputValue = finalNumber(input); |
There was a problem hiding this comment.
remember your block scopes, myOutputValue was declared in an if block before this, which means technically you should not be able to access myOutputValue here.
| if (bothPlayerRolls[0] > bothPlayerRolls[1]) { | ||
| myOutputValue = `${myOutputValue} <br> <h2>Player 1 wins!</h2><br> Press submit to roll Player 1's dice again.`; | ||
| } | ||
| if (bothPlayerRolls[1] > bothPlayerRolls[0]) { | ||
| myOutputValue = `${myOutputValue} <br> <h2>Player 2 wins!</h2><br> Press submit to roll Player 1's dice again.`; | ||
| } | ||
| if (bothPlayerRolls[1] == bothPlayerRolls[0]) { |
There was a problem hiding this comment.
this would be a good scenario to use else ifs so that the program doesnt unnecessarily continue checking if conditions
| var playerFinalNumber = Number( | ||
| String(playerRolls[0]) + String(playerRolls[1]) | ||
| ); | ||
| } | ||
| if (input == 2) { | ||
| // capture Player's number | ||
| var playerFinalNumber = Number( | ||
| String(playerRolls[1]) + String(playerRolls[0]) |
There was a problem hiding this comment.
this is fine, but I would rather not intentionally convert the number to string to concatenate them. Can we simply use numbers in this scenario?
var playerFinalNumber = playerRolls[1] * 10 + playerRolls[0]
| var finalNumber = function (input) { | ||
| var playerFinalNumber = ""; | ||
| // if the player inputs any number but 1 or 2, return this message. | ||
| // how to show this message again if they continue clicking submit? | ||
| if (gameMode == CHOOSE_DICE_ORDER && input != 1 && input != 2) { | ||
| return `Input not recognised. Please input either 1 or 2 to choose the number order.<br><br> | ||
| You rolled: <br> Dice One - <b>${playerRolls[0]}</b> and <br> Dice Two - <b>${playerRolls[1]}</b>`; | ||
| } | ||
| if (input == 1) { | ||
| // capture Player's number. Convert numbers to a string because the numbers will add together otherwise | ||
| var playerFinalNumber = Number( | ||
| String(playerRolls[0]) + String(playerRolls[1]) | ||
| ); | ||
| } | ||
| if (input == 2) { | ||
| // capture Player's number | ||
| var playerFinalNumber = Number( | ||
| String(playerRolls[1]) + String(playerRolls[0]) | ||
| ); | ||
| } |
There was a problem hiding this comment.
this is where the game breaks, remember that even though you do early return here for your input validation, this is not your main function. the main function that calls this continues execution, unless you specifically check in main for a certain condition that will stop execution. Otherwise, you can simply just click submit continually and it runs
| var playerDiceRolls = function () { | ||
| var counter = 0; | ||
| while (counter < 2) { | ||
| playerRolls.push(diceRoll()); | ||
| counter = counter + 1; | ||
| } | ||
| return `<h3>Greetings Player ${currentPlayer}!</h3> | ||
| You rolled: <br> Dice One - <b>${playerRolls[0]}</b> and <br> Dice Two - <b>${playerRolls[1]}</b><br><br> | ||
| Please input either 1 or 2 to decide the number order.`; | ||
| }; |
There was a problem hiding this comment.
Although, i wouldnt expect a function named playerDiceRolls to return me a string
|
What was the one issue you have that you did not solve? maybe we can find some time to go through it in class |
Please fill out the survey before submitting the pull request. Thanks!
🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
How many hours did you spend on this assignment?
Around 5 hours
Please fill in one error and/or error message you received while working on this assignment.
Alot of undefined messages as I wrongly typed variable / functions or placing "if" conditions before the wrong curly brackets
What part of the assignment did you spend the most time on?
Refactoring the code / making sure the code works as intended every time a new condition was added
Comfort Level (1-5):
2
Completeness Level (1-5):
4. Didn't manage to solve 1 issue that I had
What did you think of this deliverable?
Alot of layers to it!
Is there anything in this code that you feel pleased about?
I had the most fun changing the index.html part tbh