Pusher Contest Idea: JavaScript Game (3)
Tags: pushercontest, javascript
Published: 2018-05-05 12:28:16

---
title: Pusher Contest Idea: JavaScript Game (3)
published: true
description: 
tags: pushercontest, javascript
series: [pusher contest]
---

[In my last post](https://dev.to/kayis/pusher-contest-idea-javascript-game-2-228d) I lined out my idea and had a small discussion with [Mikk](https://dev.to/mikkpr) about it.

I re-evaluated the game design and while it is far from perfect, I have to start or I won't meet the deadline.

Ha, doing stuff is the worst!

## Game Design

A mix of the __clicker__ and the __battle royal__ genre.

I'd give it the code name __Startup Clix__

The rough out-line:

- a __game__ consist of multiple __rounds__
  - a __round__ take about __10 seconds__
- there are about 20 __players__ per game
- every __player__ has a __startup__
  - every __startup__ starts with some __money__
- there is a __burn-rate__
- at the end of every __round__ the __burn-rate__ reduces the __capital__ 
- every __round__ every __player__ needs to build a __product__
  - a __product__ is build with __clicks__
- at the end of every __round__ the __products__ are valued and sold
- every __startup__ gets the money value of their __product__
- if the __money__ of one __startup__ is gone, its __player__ loses the __game__
- the last __player__ left wins the game

An example game could look like this:

So you basically join a game, when it's full, the game starts.

You start clicking for 10 seconds to build your product and can submit it when you think it's good enough.

The faster you submit and the more clicks you put in, the more money you get at the end of the round.

After the round is done, you get your product money and lose money according to the burn rate.

If you got money left you can play the next round, if not you are out.

If you are the last player with money, you win.

## Technical Considerations

Pushers [Presence Channels](https://pusher.com/docs/client_api_guide/client_presence_channels) to keep track of the online players, every game will be a new channel.

AWS Lambda & API Gateway to join a game and to submit a finished product.

Pushers [Webhooks](https://pusher.com/docs/webhooks) can call Lambda functions via API Gateway to keep the user count up to date on the AWS side of things.

[AWS Step Functions](https://aws.amazon.com/de/step-functions/) to model games with state-machines. A state-machine is a definition of possible game states. Every game is an execution of a state-machine. Step Functions can pipe data from state to state (-> channel name, active players, money, etc.) , it can transition states with timeouts (-> rounds) and external events (-> player joins/leaves) and last but not least it can __execute Lambda functions__ that can call the Pusher API to update all players.

Pusher and Step Functions are the core of the application, without Pusher there wouldn't be a way to get state-updates back to the clients.

I'll probably build the back-end with [AWS SAM](https://github.com/awslabs/serverless-application-model), to get the infrastructure as code benefit. I guess the Pusher side will be a few clicks to setup and can be controlled entirely via AWS Lambda.

For the front-end I'd use either [React](https://reactjs.org/) or [Preact](https://preactjs.com/), because I don't know any better and I don't have much time to waste. [GitHub](https://pages.github.com/) pages is probably the fastest way to get it deployed just put an `index.html` in the repo root. I could version the whole thing in one repo.