Skip to content

RSginer/idle-capitalist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Idle Capitalist

alt text

Features

  • ✅ Buy Business.
  • ✅ Multiple Business to choose
  • ✅ Upgrade Business.
  • ✅ Manage orders.
  • ✅ Hire Managers.
  • ✅ Managers automatically manage orders.
  • ✅ Your businesses make money for you while you are out, even if the server is down or the websocket is disconnected.
  • ✅ Websocket reconnection.

Getting Started 🎉

  • Clone the repository.
git clone https://github.com/RSginer/idle-capitalist.git

Docker

  • Build images.
cd idle-capitalist
docker-compose build
  • Run the containers.
docker-compose up

npm

  • This option needs Node.js v12.16.1 installed and a MongoDB instance running on your localhost

Start Server

  • Install dependencies
cd idle-capitalist/server
npm install
  • Start the server
npm run start
  • Start the server in development mode
npm run start:dev

Start Client

  • Install dependencies
cd idle-capitalist/client
npm install
  • Start Webapp
npm run start

👨‍💻 Technical things

This game uses two compatible architecture patterns, a common onion architecture with a simplified version of CQRS pattern.

Workflow: Web browser -> React Component -> Dispatch Redux Action -> Redux Saga Catch -> Websocket Emmit -> Server Websocket -> Controller -> CQRS Exec Command -> Service -> Repository -> Database.

Initial game state is fetched from an REST API GET /api/v1/game/initialGameState.

Client and server communicates their commands throght a websocket.

Client

Client is a React-Redux webapp, with Redux-Saga, so is a implementation of the flux pattern. It's also ready to use with Redux-DevTools

Server

Server is a Node.js with Express server.

Database

Server uses a MongoDB database.

Game Model Schema

This Model is used to store the game data.

Game: {
  totalCashAmount: Number,
  businesses: [Business],
  lastEventDateInMs: Number
}

Business Model Schema

This Model is used to store the businesses data for each Game

Business: {
  businessKey: String,
  level: Number,
  manager: Boolean,
  lastOrderStarted: Number
}

Maths

  • Calculating expand business cost.

  • Calculating business revenue per second

  • 👨🏻‍💼 Managers price is fixed depends on the business:

    • Lemonade Stand: $1,000
    • Newspaper Delivery: $15,000
    • Car Wash: $100,000
    • Pizza Delivery: $500,000
    • Donut Shop: $1,200,000
  • Initial values

Maths of Idle capitalist table

About

React Redux Node.js CQRS Websockets Express Idle Capitalist Video Game like Adventure Capitalist - Full Stack JS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published