Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
Fixed a bug in ATTEMPTS modes where you could win/lose without even s…
Browse files Browse the repository at this point in the history
…tarting a round
  • Loading branch information
yarb00 committed Jan 27, 2024
1 parent d6d24f1 commit 1f61494
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions russian-roulette-plus-plus/russian_roulette_plus_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void Russian_roulette_plus_plus::start()

void Russian_roulette_plus_plus::print_title()
{
const std::string version{ "1.0.1" };
const std::string version{ "1.0.2" };

std::cout << "\033[7mRussianRoulette++\033[27m (\033[4mhttps://github.com/yarb00/russian-roulette-plus-plus\033[24m)" << std::endl << "îò yarb00 (\033[4mhttps://github.com/yarb00\033[24m)" << std::endl << std::endl << "v" << version << std::endl << std::endl << "-----" << std::endl << std::endl;
}
Expand Down Expand Up @@ -132,16 +132,18 @@ void Russian_roulette_plus_plus::game(gamemodes _gamemode)

if (_gamemode != gamemodes::ENDLESS)
{
int real_attempts{ attempts_left };

for (attempts_left; attempts_left > 0; attempts_left--)
{
int number_one{ rand() % 6 + 1 };

if (number_one == number_two && is_player_move)
if (number_one == number_two && is_player_move && attempts_left - real_attempts != 0)
{
game_result = game_results::OPPONENT_WIN;
break;
}
else if (number_one == number_two && !is_player_move)
else if (number_one == number_two && !is_player_move && attempts_left - real_attempts != 0)
{
game_result = game_results::PLAYER_WIN;
break;
Expand Down

0 comments on commit 1f61494

Please sign in to comment.