Secret-Hitler-Online-Server/planning.txt

157 lines
No EOL
4.8 KiB
Text

OnConnect
- Client connects to the server, this is just an information log event
OnDisconnect
- Client disconnects from the server, this is just an information log event
HostGame
- Client wants to start a new game, create a basic room with the basic
information included in the object.
- May want to save currently active rooms to disk to prevent data being
lost in case of a server/computer crash.
- On success:
- Emit `GameCreated` event w/ necessary data
- On error:
- Emit `GenericError` event w/ more info
JoinGame
- Client wants to join an already existing game
- Check if a room exists:
- If no:
- Emit `InvalidRoom` event
- Check if the username is taken:
- If yes:
- Does the user have the same token as the person in the game already
- If yes:
- Allow the player to connect with that name
- Emit `GameRejoined`
- If no:
- Emit `UsernameTaken`
- If no:
- Emit `GameJoined` to joining client
- Emit `UserJoined` to all existing clients
StartGame
- This is triggered the host user triggers the start of the game.
- Server decides who all is fascist/liberal then picks one fascist to be Hitler
- Store this data, send each player only the data is relevant to that player:
- Liberals:
- Party affiliation
- Fascists (not Hitler):
- Party affiliation
- Other fascist's identity
- Hitler's identity
- Hitler:
- Party affiliation
- "Oh hey, you're Hitler"
- If 5-6 players:
- Send other fascist's identity
- If 7+ players:
- No one else's identity
- Start the main game loop. (emit `PresidentNominate` to the players, with
list of eligible players, only the president can send a response to
this event, any other events in this state will be ignored.)
ChancellorNomination
- The president's nomination of player to elect as chancellor
- Emit `ChancellorVote` to all alive
- Wait until we get a `Vote` event from each client.
Vote
- Sent from a client that has voted, this will be in a binary yes/no format
- Only alive players send vote events, so only wait for that many events
- Once all players have voted:
- If majority vote "no" or tied:
- Add one to election counter
- Check if election counter is == 3
- If yes:
- Enact top policy from the policy deck, do not take any
executive actions
- Check win conditions of the boards
- Reset election counter
- If no:
- Go to next president
- If majority vote "yes":
- Check enacted policies to see if there are >= 3 fascist policies
in play
- if yes:
- Is the chancellor Hitler?
- If yes:
- Emit `GameEnd`, fascists won
- If no:
- Take 3 policies from the top of the deck, send them to president
PresidentPolicies
- Client sends the two policies that the president wants to give the chancellor.
- Server discards the third, not chosen policy
- Server sends chancellor the two chosen policies
VetoRequest
- Chancellor is requesting a discard of both policies
- Send a confirmation to the president
VetoConfirm
- President's choice for the veto vote, this handles both the president
denying the veto and accepting it.
- If president allows veto:
- Discard the two policies
- Add one to election counter
- Check if election counter is == 3
- If yes:
- Enact top policy from the policy deck, do not take any
executive actions
- Check win conditions of the boards
- Reset election counter
- If no:
- Go to next president
ChancellorPolicy
- Client sends the policy that the chancellor chose
- Server discards other policy
- Did the policy cover an executive action?
- If yes:
- Take according action
- If no:
- Continue
- Then:
- Check win conditions
- Reset election counter
- Go to next president
---
# Special Actions:
Execution:
- Server initiates process
- Send president list of alive players
- Receive `ExecutePlayer`
- Is the chosen player Hitler?
- If yes:
- Liberals win the game
- If no:
- Chosen player is marked as dead so we don't wait for their
votes, and skip over them in the presidential cycle
- Then:
- Stop processing the action, go back to main game loop
Special Election:
- President receives list of all non-dead players
- Receive `NextPresident`:
- Put the chosen player at the front of the queue
- Stop processing the action, go back to main game loop
View top 3 policies:
- Send copies of the top three policies to the president (not does not
modify policy deck)
- Receive `ExecutiveConfirmation`:
- Stop processing action, go back to main game loop
Investigate loyalty:
- President receives list of players that have not been investigated
- Receive `InvestigateAffiliation`:
- Server sends the client the player's party affiliation
- Mark player has having been investigated
- Receive `ExecutiveConfirmation`:
- Stop processing action, go back to main game loop