Skip to content

[CSC10012] A classic Poker Game using C++11 programming language and SDL2 Library, support strategy, graphics, and smooth gameplay.

License

Notifications You must be signed in to change notification settings

haolamnm/poker-game

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

71 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸƒ Poker Project

Start Screen
PvP Screen

This is a simple poker game project that we, @anhtri2407 and @haolamnm developed for our university CSC10012 course - Fundamentals of Programming. The game is developed in C++11 and uses the SDL2 library for graphical user interface.

NOTE: We actually get a perfect score 10/10 for this project.

Supported Platforms

For now, the game only supports MacOS and Windows. We have tried our best to make the game run smoothly on both platforms. Since we don't have a Linux computer, we can't test the game. If you are using Linux and encounter any problems, please let us know.

Getting Started

1. Installation

Since this project is developed in C++11 and uses the SDL2 library, if you are using Mac or Linux, you need to install the necessary libraries before running the game. The command should be like this:

Linux:

sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev

MacOS:

brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer

NOTE: You should read the official documentation for accurate installation, the above command may not work for you.

And if you are using Windows, you don't need to install anything because we already included the necessary libraries in the libs folder.

2. Folk the repository

You can fork the repository by clicking the Fork button on the top right corner of the page.

3. Clone the repository

If you have forked the repository, you can clone the repository by running the following command:

git clone https://github.com/haolamnm/poker-game.git

If you encounter the error fatal: early EOF, it may be due to your network connection or our repository is too large. You can try to clone the repository again using the following command:

git clone https://github.com/haolamnm/poker-game.git --depth=1

If that succeeds, you can download the full history of the repository by running the following command, notice that this is optional:

cd poker-game
git fetch --unshallow

4. Open the project

Use your favorite IDE to open the project. We recommend using Visual Studio Code for the best experience.

5. Run the game

5.1. Cleaning

We have already included the Makefile to compile and run the game at ease. First, to make sure everything is clean, you can run the following command:

MacOS:

make clean

Windows:

mingw32-make -f Makefile clean

NOTE: These commands can be used for cleaning the object files created if you want to recompile the game.

5.2. Compiling

After cleaning, you can compile the game by running the following command:

MacOS:

make all

Windows:

mingw32-make -f Makefile all

5.3. Running

Finally, you can run the game by running the following command:

MacOS:

make run

Windows:

mingw32-make -f Makefile run

How to play

There is a lot of information about how to play poker on the internet. You can read the Wikipedia page to understand the rules of the game. Or our poker attachment, which has a brief explanation of What is Poker and some basic hand rankings.

After that you can read the report attachment, at the section 4. Showcase of the Project to understand the UI of the game. That section will explain what is the role of each screen and button in the game.

In conclusion, you can play the game by following these steps:

  1. Create your own player profile in the Login Screen. Just type your username and password, the system will automatically notice you if the username is already taken, otherwise, it will prompt you to create a new player.
  2. If you play with your friends, log all of them in, you can see their username in the Home Screen at the bottom right corner.
  3. You can choose whether to play with your friends (PvP) or with the bot (PvE) in the Home Screen. You can head to the Settings Screen to change the game mode. There are 2 game modes: Basic and Draw Poker.
  4. After several games, you can check the leaderboard in the Leaderboard Screen to see who is the best player in the game.

If that still doesn't help, you can watch the following YouTube video to understand how to play the game:

Technical Stack

  • C++11: The game is developed in C++11, which is a modern version of C++ that has many new features.
  • SDL2: The game uses the SDL2 library for graphical user interface. We use SDL2 for creating windows, rendering graphics, and handling events.
  • Makefile: We use the Makefile to make the compiling and running process easier. You can compile and run the game by running a single command.
  • File I/O: We use the File I/O to store the player data.
  • LaTeX: We use LaTeX to write the report for the project.

For Developers

If you are a developer and want to contribute to the project, feel free to create a pull request. We are happy to review your code and merge it into the main branch.

Contact

Email: [email protected].

GitHub: @haolamnm.

LinkedIn: @haolamnm.

Class Diagram

classDiagram
    class GameEngine {
        -SDL_Window* window
        -SDL_Renderer* renderer
        -GameState currentGameState
        -GameMode currentGameMode
        -drawPokerRound currentDrawPokerRound
        +init()
        +handleEvents()
        +update()
        +render()
        +clean()
    }

    class Gameplay {
        -Deck deck
        -Storage storage
        -Leaderboard leaderboard
        +init()
        +dealCards()
        +whoWins()
        +savePlayerData()
        +showLeaderboard()
    }

    class Player {
        -std::string username
        -Hand hand
        -bool isBot
        -bool isFolded
        -unsigned int chips
        -float winrate
        -unsigned short rank
    }

    class Hand {
        -Card cards[5]
        -int handStrength
        -std::string handName
        +show()
        +sortCards()
        +evaluateHand()
    }

    class Card {
        -Suits suit
        -Ranks rank
        +suitToString()
        +rankToString()
    }

    class Deck {
        -Card cards[52]
        -int remainCards
        +setup()
        +shuffle()
        +reset()
    }

    class Storage {
        -std::map<std::string, Player> storage
        +verify()
        +createNewPlayer()
        +savePlayerData()
        +updatePlayerStorage()
    }

    class Login {
        -Storage storage
        -std::string status
        +login()
        +createNewPlayer()
    }

    class Lobby {
        -Login login
        -Gameplay game
        -std::vector<std::string> usernames
        +assignUsername()
        +removeUsername()
        +handleLeaderboard()
    }

    GameEngine --> Gameplay : uses
    GameEngine --> Lobby : uses
    Gameplay --> Player : manages
    Gameplay --> Deck : uses
    Gameplay --> Storage : uses
    Player --> Hand : has
    Hand --> Card : contains
    Deck --> Card : contains
    Storage --> Player : stores
    Login --> Storage : uses
    Lobby --> Login : uses
    Lobby --> Gameplay : uses
Loading

About

[CSC10012] A classic Poker Game using C++11 programming language and SDL2 Library, support strategy, graphics, and smooth gameplay.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages

  • C 89.0%
  • C++ 6.3%
  • TeX 2.9%
  • CMake 1.3%
  • Other 0.5%