Skip to content

Web based party game. Take the best picture and get on the front page!

License

Notifications You must be signed in to change notification settings

VVill-ga/newsie

Repository files navigation

By Will Garrison, Joshua Brown, Sankalp Patil, and Bradley Rule

Using fonts by Omnibus-Type

Hosting your own:

Optional Configuration

  • By default, this program expects to be located in /var/www/newsie. To run the program elsewhere, modify WorkingDirectory in newsie.service or run without Systemd.
  • By default, this program will run on port 3000. To choose a different port, modify the PORT variable in server.js.

Required Configuration

  • Change variables WSaddr and HTaddr at the top of public/pregame.js to point to your own domain or IP address.
  • Copy newsie.service to /usr/lib/systemd/system/newsie.service or other directory scanned by Systemd.
  • Run systemctl daemon-reload to make Systemd discover the new service file.
  • Run sudo systemctl enable newsie and then sudo systemctl start newsie to begin your newsie server.

To run without Systemd for testing or otherwise, simply run node server.js.

Enjoy!

How it Works:

Game State

There are 5 states a game can be in at any time. A game is created once a user has hit the Create Game button and entered a nickname. The game states are as follows (With a screenshot attached in the dropdown):

Lobby
Submission
Voting
RoundEnd
GameEnd

Hypertext Messages:

GET

  • /subtitle

    • Returns a random line from subtitles.txt

    • Status 200

  • *

    • Handled by Express.js

POST

  • ?game&name

    • Joins game if exists, as user name if available.

    • Status 201 if successful, 400 if not.

  • ?game

    • Checks to see if game exists.

    • Status 200 if found, 404 if not found.

  • ?name

    • Creates new game as user name.

    • Status 201 including the newly created game code.


Websocket Messages:

FROM CLIENT

  • Game Creation or Join Game
GameCode + NickName //(ex. "ABC123John Doe")

Server: Game manager searches the GameCode's user map for the user NickName, and replaces the index with the websocket id. (ex, Users[WebSocket] = Users["John Doe"])

  • Game Owner Starts Game
"Start Game"
  • Submit an Image
image: String //Image Base64 Data URL
  • Submit Votes
votes: [Int] //Array of original indexes rearranged according to vote order
  • Game Owner Next Round
"Next Round"

FROM SERVER

  • Anytime: Error Message
id: "error"
state: String
level: Int //ErrorLevel, as described in Error Handling below
message: String
  • Lobby: Update users on join
id: "lobby"
usernames: [String]
gameowner: String
  • Submission: Send out prompt
id: "round"
headline: String
roundStart: Int //Timestamp
roundEnd: Int //Timestamp
roundNumber: Int
  • Voting: Send out images to vote on
id: "images"
images: [{
    user: User,
    image: String, //Image Base64 Data URL
    votes: Int
}]
voteStart: Int //Timestamp
voteEnd: Int //Timestamp
roundNumber: Int
  • Round End: Send out round results
id: "results"
winner: String
winningImage: String //Image Base64 Data URL
currentPoints: Int //Clients total points
pointsEarned: Int //Points client earned this round
roundNumber: Int
  • Game End: Send out winner
id: "end"
winner: String //Nickname of winner

Error Handling

Server Error Levels:

  1. Game Crashed, Go back to start and do not collect $200
  2. Error processing input. Resubmit entry/votes.
  3. Unknown websocket. Resend "GameCode + Nickname" message