I am having trouble passing the task:
If that username has been used before, it should print
Welcome back, <username>! You have played <games_played> games, and your best game took <best_game> guesses.
, with<username>
being a users name from the database,<games_played>
being the total number of games that user has played, and<best_game>
being the fewest number of guesses it took that user to win the game
The code below comes in the else
statement after a check to see if the username exists in the database.
Current Code
GAMES_PLAYED_RESULT=$($PSQL "select COUNT(games_id) FROM games inner join users using(user_id) where username='$USERNAME'")
BEST_GAME_RESULT=$($PSQL "select min(number_of_guesses) from games inner join users using(user_id) where username='$USERNAME'")
echo "Welcome back $USERNAME! You have played $GAMES_PLAYED_RESULT games, and your best game took $BEST_GAME_RESULT guesses."
When I play the game I get the following output:
Enter your username:
willhouse
Welcome back willhouse! You have played 3 games, and your best game took 2 guesses.
Guess the secret number between 1 and 1000:
500
It’s lower than that, guess again:
400
…
50
It’s higher than that, guess again:
70
It’s lower than that, guess again:
60
…
It’s higher than that, guess again:
64
You guessed it in 11 tries. The secret number was 64. Nice job!
Am I missing something? Any help would be greatly appreciated.
Thank you
-Richard