Skip to content

eurano/CaSino50

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CASINO50

Description:

This is my project for CS50 course. Tools used: Python + Flask, Javascript, AJAX, sqlite3 (cs50 library).

Idea
I wanted to create a virtual interactive casino in the climate of CS50. The croupier is a cute duck and informs player of game stages and results.

Explaining the project
Program is composed of two parts: app.py wich contains Flask routes and helpers.py where functions are stored. Application allows user to play three simple casino games including roulette, craps and blackjack. The games are simplified. First the user has to create an account and login to the website. Accounts are stored in the users table inside casino databese. The index page displays current available cash because bets are placed in dollars not chips. When player place bet the information is stored inside bets table and money are blocked and cant be used unless game ends either with win or loose (roulette game is excluded from this rule because result is allways instant). To achieve this I used Flask session to store craps and blackjack game stage so if in the middle of the game player decides to log out or for any reason didn't finish the game he is allowed to do it later.
Details about unfinished game stage are stored either in the blackjackgames or crapsgames table. If result is known instantly for example if deal in blackjack gives player score 21 the game doesnt start and player is informed that he already won (blackjack-result.html is rendered instead of blackjack.html. Same rule applies for craps game. Flask backend has 4 'routes' (what I mean by that is algorithm routes not Flask routes )for blackjack and craps: new game, unfinished game, instant result, AJAX call from the game (for example player draws new card). The reason for this is security reasons. API calls and score calculations are processed only in the Python backend so even if user will try to modify javascript he wont be able to pass any malicious data to server side. In summary client side of the program is only capable of displaying result not change them. The games results are stored in database. User is allowed to see hes last 5 games details and top scores for each game in the index.html page. Application is mobile devices friendly and should display correctly on any screen size.

Rules
Each user gain 10000 dollars for free when he makes new account just because its fun.

Roulette:
Roulette is a common casino game where players can place bets on either a single number, various groupings of numbers, the colors red or black, whether the number is odd or even, or if the numbers are high (19–36) or low (1–18).

Bets and Payouts
REST Roulette API used for my project supports the following bets:

Odd/Even: 1 to 1
Low/High: 1 to 1
Red/Black: 1 to 1
Green: 35 to 1
Number: 36 to 1

Craps:
Pass line

If the come-out roll is 7 or 11, the bet wins.
If the come-out roll is 2, 3 or 12, the bet loses (known as "crapping out").
If the roll is any other value, it establishes a point.
If, with a point established, that point is rolled again before a 7, the bet wins.
If, with a point established, a 7 is rolled before the point is rolled again ("seven out"), the bet loses.
The Pass line bet pays even money.

Don't Pass
A Don't Pass bet is a bet for the shooter to lose ("seven out, line away") and is almost the opposite of the Pass line bet.

If the come-out roll is 2 or 3, the bet wins.
If the come-out roll is 7 or 11, the bet loses.
If the come-out roll is 12, the bet is a push (neither won nor lost).
If the roll is any other value, it establishes a point.
If, with a point established, a 7 is rolled before the point is rolled again ("seven out"), the bet wins.
If, with a point established, that point is rolled again before a 7, the bet loses.
The Don't Pass bet pays even money.

Blackjack:
Game starts with deal of 4 cards - two for player and two for croupier. User play against casino but crupier is not allowed to draw more cards. One of the croupier cards is faced down so the player doesnt know he's score. Play can either draw new card or stand. Player wins when he achieve 21 points or decide to stand and beat croupier score. If he exceed 21 points or stand and has lower score than croupier he lost the game. Blackjack pays 3:2.

API
https://www.roulette.rip/
https://www.deckofcardsapi.com/
https://en.dejete.com/api-lancer-des
https://http.cat/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published