Skip to content

23-2_Robin#24

Open
westfacingsun wants to merge 1 commit intorocketacademy:mainfrom
westfacingsun:main
Open

23-2_Robin#24
westfacingsun wants to merge 1 commit intorocketacademy:mainfrom
westfacingsun:main

Conversation

@westfacingsun
Copy link

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

@westfacingsun westfacingsun changed the title modified index.html and script.js files for Beat That project 23-2_Robin Jul 24, 2023
@mahe993
Copy link

mahe993 commented Jul 27, 2023

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);
Copy link

Choose a reason for hiding this comment

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

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.

Comment on lines +52 to +58
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]) {
Copy link

Choose a reason for hiding this comment

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

this would be a good scenario to use else ifs so that the program doesnt unnecessarily continue checking if conditions

Comment on lines +77 to +84
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])
Copy link

Choose a reason for hiding this comment

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

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]

Comment on lines +67 to +86
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])
);
}
Copy link

Choose a reason for hiding this comment

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

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

Comment on lines +98 to +107
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.`;
};
Copy link

Choose a reason for hiding this comment

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

👍👍

Copy link

Choose a reason for hiding this comment

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

Although, i wouldnt expect a function named playerDiceRolls to return me a string

@mahe993
Copy link

mahe993 commented Jul 27, 2023

What was the one issue you have that you did not solve? maybe we can find some time to go through it in class

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