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

Commit

Permalink
Fixed a bug in ENDLESS mode where you could win/lose without even sta…
Browse files Browse the repository at this point in the history
…rting a round
  • Loading branch information
yarb00 committed Jan 27, 2024
1 parent e3d4a4d commit d6d24f1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 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.0" };
const std::string version{ "1.0.1" };

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 @@ -77,22 +77,22 @@ void Russian_roulette_plus_plus::game(gamemodes _gamemode)
system("cls");

const int number_two{ rand() % 6 + 1 };
int attempts_left{};
int attempts_left{ 0 };
bool is_player_move{ false };
game_results game_result{ game_results::DRAW };

if (_gamemode == gamemodes::ENDLESS)
{
for (attempts_left; true; attempts_left)
for (attempts_left; true; 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 != 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 != 0)
{
game_result = game_results::PLAYER_WIN;
break;
Expand Down

0 comments on commit d6d24f1

Please sign in to comment.