diff --git a/src/c/rockPaperScissors.c b/src/c/rockPaperScissors.c index fa87c41..bb65845 100644 --- a/src/c/rockPaperScissors.c +++ b/src/c/rockPaperScissors.c @@ -63,4 +63,28 @@ int getPlayerInput(){ inputValid = validatePlayerInput(inputPlayer); } return inputPlayer; +} + +int play(int rounds){ + int playerWins = 0, computerWins = 0; + int roundsToWin = (rounds/2)+1; + int computerInput, playerInput; + int roundwinner = NOWINNER; + int winner = NOTWONYET; + + printf("Lets play a game\n"); + while (winner == NOTWONYET){ + playerInput = getPlayerInput(); + computerInput = getComputerInput(); + roundwinner = findWinner(playerInput, computerInput); + if (roundwinner == PLAYERWINSROUND){ + playerWins += 1; + } + else if (roundwinner == COMPUTERWINSROUND){ + computerWins += 1; + } + winner = wasGameWon(roundsToWin, playerWins, computerWins); + printf("Something happened\n"); + } + printf("Someone won\n"); } \ No newline at end of file diff --git a/src/c/rockPaperScissors.h b/src/c/rockPaperScissors.h index e935a05..503e375 100644 --- a/src/c/rockPaperScissors.h +++ b/src/c/rockPaperScissors.h @@ -27,5 +27,6 @@ int getComputerInput(); int wasGameWon(int roundsToWin, int playerWins, int computerWins); bool validatePlayerInput(int playerInput); int getPlayerInput(); +int play(int rounds); #endif \ No newline at end of file diff --git a/test/c/test_rockPaperScissors.c b/test/c/test_rockPaperScissors.c index 5b492e4..d3708a2 100644 --- a/test/c/test_rockPaperScissors.c +++ b/test/c/test_rockPaperScissors.c @@ -214,9 +214,4 @@ void test_rockPaperScissors_invalidPlayerInput(void) TEST_ASSERT_EQUAL_INT(false, result); } -#endif // TEST - -/*Testcases: -rockPaperScissors_outputResult -rockPaperScissors_invalidInput -*/ \ No newline at end of file +#endif // TEST \ No newline at end of file