Skip to content

About

Web application for playing in poker with extended rules 🤡

Resources

Stars

7 stars

Watchers

1 watching

Forks

Latest commit

 

History

74 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

Bizarre Poker

Web application for playing oldschool card game in modern way.
Explore Usage topic »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

Did you mess sometimes with broken feelings? This game perfectly suits you. In classic poker game we probably get nothing higher than Tree of Kind or Flush. But everybody has real chance to get Four of Kind or even Poker in this game. A lot of jokers, huge decks, interesting combinations. It's funny, it's cheeky, it's bizarre!

Features

  • Single page application for WEB and Rest API for other clients.
  • Storing every game state on server side that user has no worries about losing connection or close his laptop. User can continue from point it was ended.
  • Almost realtime updating game state in WEB without any splecial actions.
  • A lot of thing easy to customize. Bizarre Poker has 4 pre-difined configurations (classic, foolish, crazy and bizarre) and you may add onother one.
  • force action which allows user to play not only with friends, but also alone.

Built With

server side


client side

(back to top)

Getting Started

This is a simple guide how to build up an application locally. Just follow this steps.

Prerequisites

  • python 3.10.4
  • pip 22.2.2
  • node 16.15.1
  • npm 8.11.0

Installation

  1. Clone the repo.
    $ git clone git@github.com:MishaVyb/bizarre-poker.git
  2. Prepare server side requirements in virtual environment.
    $ cd bizarre-poker/backend
    $ python3.10 -m venv venv
    $ source venv/bin/activate
    (venv) $ pip install -r requirements.txt
  3. Apply default data with user and games prepared especially for saving your time. You may pass this step and create users and games by your own later. But don`t forget to make migrations anyway.
    (venv) $ python manage.py migrate
    (venv) $ python manage.py apply_data
  4. Run Django server which provides Rest API for client side.
    (venv) $ python manage.py runserver
  5. Great. Now server is running.
    To make sure that everything is right, open new shell window and make a request to api root.
    $ curl -X GET http://127.0.0.1:8000/api/v1/
    
    {"games":"http://127.0.0.1:8000/api/v1/games/"}
  6. Almost done. Now we have to make a deal with client side.
    (venv) $ deactivate
    $ cd ../frontend
  7. Install dependencies and run react application:
    $ npm install
    $ npm start
  8. Thats all. Browser will open localhost automatically and you're supposed to see home page:

Screenshot 2022-10-23 at 15 43 54

(back to top)

Usage

Data

Look at default data prepared for informational purposes. You can change this file or make your own json to provide another initial data. It could be applied by django command:

$ python manage.py apply_data <path_to_json_data_file>

Don't confused with built in django command ./manage.py loaddata dump.json. The purpose is the same, but it's more easy to configurate custom json data file.

Configurations

Go to configurations module. You can describe new config json file or change provided. For exaple, we want simple game where players get their cards and compare combinations - that's all. No Biddings stages. No flop.

  • Create new config file.
$ touch backend/apps/games/configurations/setups/my_config.json
  • Specify list of stages and any other amounts you want.
{
    "name": "my_config",
    "stages": ["DealCardsStage", "OpposingStage"],
    "deal_cards_amount": 5,
    "jokers_amount": 10
}
class ConfigChoices(models.TextChoices):
    BIZARRE = 'bizarre'
    FOOLISH = 'foolish'
    ...
    MY_CONFIG = 'my_config'
  • If server is running, you have to restart it to apply changes.
    All config files are uploading at program launch.
$ python manage.py runserver
  • For now you can choose your custom configuration at game creation.
    Enjoy!

Screenshot 2022-10-23 at 16 00 30

Scripts

You can play game by writing small python scripts right in django shell. Or describe them as django command. Package services provides all necessary tools to make actions. Here's an example:

1.1. Before We Start

You may choose the way for writing game scripts.

Make script as Command

  • Create module with name of your game script.
$ cd backend/apps/games/management/commands/
$ touch my_game_script.py
  • Make all necessary imports.
from django.core.management.base import BaseCommand
from games.models import Game
from games.services import actions, processors, stages
from users.models import User
  • Create class inherited from BaseCommans.
class Command(BaseCommand):
    requires_migrations_checks = True

    def handle(self, *args, **options):
      ...

Or write script right in shell.

  • Run django shell and make all necessary imports.
$ python manage.py shell

2. Arrange users.

  • Let's take three players: misha, sima and bart. You can create them or get by usal Django ORM methods.
    Make sure you're importing User from users app (not django's default).
misha = User.objects.get('misha')
...

3. Run actions.

  • Create game with our users.
game = Game(players=[misha, sima, bart], commit=True)
  • Run actions in one line.
actions.StartAction.run(game)
actions.PlaceBlind.run(game)
...
  • You can specify who exactly makes action.
actions.PlaceBlind.run(game, bart)
actions.PlaceBet.run(game, misha, value=20)
...
  • But be carefull with making not available action.
try:
    actions.PlaceBetReply.run(game, bart)
except actions.ActionError as e:
    # at current moment game waiting that 'sima' reply to bet, not 'bart'
    pass
  • Finally, let's quit game by one player and Say pass by other and look how game ends.
actions.LeaveGame.run(game)
actions.PassAction.run(game)

4. Run auto.

Also you can run auto processing with some pre-definitions of how it should go.

  • Prepare action that would be performed later.
    Make notice for last argument: we can provide exactly on which stage this action will be performed.
huge_bet = actions.PlaceBet.prototype(
    game, misha, 500, stages.BiddingsStage_3
)
  • Create processor that will stop at final stage.
script = processors.AutoProcessor(
    game,
    with_actions=[huge_bet],
    stop_after_stage=stages.OpposingStage,
)
  • Execute our game script.
script.run()

5. How to see results.

  • If you are making game script as Command, run it by this line.
$ python manage.py my_game_script
  • If you are using shell, you'll see log output just afrer every action runs.
  • Also you can specify the way of cards representation in logs. By default it's emoji, but you may not like it. Just add this line in beginning of your script.
Card.Text.repr_method = 'eng_short_suit' or 'classic'

For more details have a look at cards module.

API

See auto-generated documentation for API to get all info about available resources and methods. Make sure that django server is running.

WEB

The most native way to try all application feauteres.

1. Log in.

Go to browser and log in or sign up. It is recomended to use default data described above and make log in as admin user with this authentication credentials:

username: vybornyy
password: vybornyy

Or sign up as new user, if you want.

2. Join games.

Just click join button. Notice that host of the game has to approve your participation. Or you can create new game. In that way you will be host player.

Screenshot 2022-10-23 at 16 49 26

2. Game page. Small hints.

  • Join other players or kick out them (if you are host and only between game rounds).
    Screenshot 2022-10-23 at 16 42 05

  • See your combination detail by clicling on combo name.
    Screenshot 2022-10-23 at 16 45 59

  • And don't hessitate playing alone. If you are logged in as admin user, it is avaliable perform action for another players.
    Screenshot 2022-10-23 at 16 48 33

force is a special button to proceed game further. It makes action by current game performer. Supplied mostly for test purposes.

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch
git checkout -b feature/SomeFeature
  1. Commit your Changes
git commit -m 'add some new features'
  1. Push to the Branch
git push origin feature/SomeFeature
  1. Open a Pull Request

License

Distributed under the GNU General Public License. See LICENSE.txt for more information.

Contact

Misha Vybornyy:

Gmail Badge Telegram Badge

(back to top)

About

Web application for playing in poker with extended rules 🤡

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages