Giter Club home page Giter Club logo

online-crash-gambling-simulator's Introduction

Crash Gambling Simulator

A recreation of the popular online casino game "crash" with accurate casino odds.

showcase

Technologies Used

  • React.js - JS framework used to create the frontend.
  • Express.js - The backend server environment and serves as an API.
  • Node.js - JS environment that executes JS outside of the browser.
  • Socket.io - Allows communication between the server and client in real time.
  • MongoDB - NoSQL database used to store all user and server information.
  • Passport.js - Middleware used to authenticate and authorize users. Handles logins and registrations.
  • bcrypt.js - Secures user passwords by hashing all passwords before storing in database.
  • Chart.js - Create visualizations of data through charts and graphs like line graphs.
  • HTML
  • CSS

Features

  • Login system - Users must log in or create an account to place bets.
  • Betting system - Users wager their balance before the round begins. A multiplier counts up from 1.00 and users can cash out at any time, multiplying their bet amount by the current multiplier. The multiplier will stop, or crash, at a randomly generated value, and users who have not cashed out yet will lose their entire bet.
  • Accurate Gambling Odds - Every crash value is generated using the same algorithms real casinos use, including a 3% house edge.
  • Live Bet Tracker - Users can see other users betting live. When a user places a bet, their username and bet amount are added to a live table. When the user cashes out, their cash out multiplier and profit are also added.
  • Game History - Displays the crash values of the last 25 games played along with the streak of games with crash values above or below 2.00.
  • Chat - Users who are logged in can send messages to other users through chat
  • Live Line Graph - Visualization of the current multiplier with respect to time.

Installation

// Clone the repository
$ git clone https://github.com/wbrandon25/Online-Crash-Gambling-Simulator

// Navigate to directory
$ cd ./Online-Crash-Gambling-Simulator

Setup and Run Client

// Navigate to client directory 
$ cd ./client

// install packages
$ npm i 

// start client (localhost:3000)
$ npm start

// For running in production
$ npm run build
$ npm start

Setup and Run Server

// Navigate to server directory 
$ cd ./backend

// install packages
$ npm i 

// install nodemon for development
$ npm i -D nodemon

// start node server (localhost:4000) and socket.io server (localhost:3001) 
$ npm start 

Environment Variables

  • MONGOOSE_DB_LINK - URL to MongoDB server
  • PASSPORT_SECRET - Secret for Passport.js authorization and authentication

online-crash-gambling-simulator's People

Contributors

wbrandon25 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

online-crash-gambling-simulator's Issues

Slowness and response

The game is quite slow and it's not that responsive when it comes to staking and opening account

FIXED - Cannot read properties of null (reading 'previous_crashes')

FIXED
I got the game running. I solved the issue this way.

1. At server.js add the following code after the MongoDB connection line:

const crashSchema = new mongoose.Schema(
{ round_number: Number,
active_player_id_list: [String],
multiplier_crash: Number,
b_betting_phase: Boolean,
b_game_phase: Boolean,
b_cashout_phase: Boolean,
time_now: Number,
previous_crashes: [Number],
round_id_list: [Number],
chat_messages_list: []
}
);

const Crash = mongoose.model(
'Crash', crashSchema
);

Crash.create({
round_number: 1,
active_player_id_list: [],
multiplier_crash: 0,
b_betting_phase: false,
b_game_phase: false,
b_cashout_phase: false,
time_now: -1,
previous_crashes: [],
round_id_list: 0,
chat_messages_list: []
})
.then(result => {
console.log(result)
});

Save it and run the server. It will now automatically generate the documents.
NOTE: The server will crash thats OK!

2. Now, copy the ID of the document and paste it in server.js at GAME_LOOP_ID.
3. Go to /models/game_loop.js and change:
const game_loop = new mongoose.Schema => const crashSchema = new mongoose.Schema
mongoose.model("game_loop", game_loop); => mongoose.model("Crash", crashSchema);

4. In the root folder, create an .evn file with the following line:
PASSPORT_SECRET = "YOURPASSWORDHERE"

5. Go back to server.js and delete or comment out the code you added in step 1.
6. Restart the server and enjoy. This is how it worked for me.

Original message:
Noticed the other issues claiming the same but without a clear answer still.. App does connect to my mongodb, i can see it in the connections list, however.. schema's arent generated even though the app has permission. Adding the game_loop schema manually also not solves the problem

App crashes

I'm having a problem with npm start in backend. What might cause this?
Example2

app keeps crashing

i installed all the files and then put them in replit and i run all the commands for the backend server and when i do npm start it says the app crashes

help

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:69:19)
at Object.createHash (node:crypto:133:10)
at module.exports (C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\webpack\lib\NormalModule.js:471:10)
at C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\webpack\lib\NormalModule.js:503:5
at C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\webpack\lib\NormalModule.js:358:12
at C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\react-scripts\scripts\start.js:19
throw err;
^

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:69:19)
at Object.createHash (node:crypto:133:10)
at module.exports (C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\webpack\lib\NormalModule.js:417:16)
at C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\webpack\lib\NormalModule.js:452:10
at C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\webpack\lib\NormalModule.js:323:13
at C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\loader-runner\lib\LoaderRunner.js:367:11
at C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\loader-runner\lib\LoaderRunner.js:233:18
at context.callback (C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at C:\Users\DELL\Desktop\Nowy folder\Online-Crash-Gambling-Simulator\client\node_modules\babel-loader\lib\index.js:59:103 {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'

Game History not showing

The last 25 crash history is not showing. Any ideas? I check db and it is empty. Probably issue saving to MongoDB

Register and Login

What did I not do that would prevent Register and Login from working?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.