Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rsginer/idle-capitalist

React Redux Node.js CQRS Websockets Express Idle Capitalist Video Game like Adventure Capitalist - Full Stack JS
https://github.com/rsginer/idle-capitalist

cqrs express idle-capitalist idle-game mongodb nodejs react-redux reactjs redux-saga videogame websocket

Last synced: 23 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# Idle Capitalist

![alt text](https://raw.githubusercontent.com/RSginer/idle-capitalist/master/screenshot.gif "Idle Capitalist")

### 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.
```bash
git clone https://github.com/RSginer/idle-capitalist.git
```
### Docker
* Build images.
```bash
cd idle-capitalist
docker-compose build
```

* Run the containers.
```bash
docker-compose up
```

* Go to http://localhost:3000 🤘
### npm
* This option needs Node.js v12.16.1 installed and a MongoDB instance running on your localhost
#### Start Server

* Install dependencies
```bash
cd idle-capitalist/server
npm install
```

* Start the server
```bash
npm run start
```

* Start the server in development mode
```bash
npm run start:dev
```
#### Start Client
* Install dependencies
```bash
cd idle-capitalist/client
npm install
```

* Start Webapp
```bash
npm run start
```

* Go to http://localhost:3000 🤘

## 👨‍💻 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](https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en)**

### 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.
```js
Game: {
totalCashAmount: Number,
businesses: [Business],
lastEventDateInMs: Number
}
```

#### Business Model Schema
This Model is used to store the businesses data for each `Game`
```js
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

* 👨🏻‍🎓📚 **Bibliography**: https://blog.kongregate.com/the-math-of-idle-games-part-i/