A browser-based Ricochet Robots client written in Elm, to be paired with a backend written in Elixir. Includes chat, scorekeeping, and democratically-driven game management!
- keys :
Keys
. List of booleans representing active keyboard input - user :
User
. Information about the current user. - users :
List
ofUser
s. Information about all users, including scores. - chat :
List
ofChatline
s. A list of lines of text/usernames. - messageInProgress :
String
. Current chat input text. - nameInProgress :
String
. Current name-change input text. - colorInProgress :
String
. Current color-change input selection. - boundaryBoard :
Grid
ofInt
s. 16-by-16 array of arrays of integers, where the value determines how to print the board. - goal :
GoalSymbol
. Active goal symbol. - goalList :
List
ofGoal
s. List of all goals, including their symbols and positions. - toggleStates :
{
settings:String
, activePoll:String
, pollOptions:String
, emoticons:String
, countdown:String}
. States for all toggle-able UI elements. - countdown :
Int
. 60s countdown timer that begins when one solution has been found. - currentTimer :
Int
. Count-up timer that restarts for each puzzle. - robots :
List
ofRobot
s. List of robots including color (ID), position, and legal (unblocked) moves. - activeRobot :
Maybe Robot
. Current selected robot for UI purposes. - movesQueue :
List
ofMove
s. Current stack of moves.
"action" | "content" | Description |
---|---|---|
connect_to_server |
"" |
Server has connected. Respond with a request to create a user. |
Tick | Not implemented, so timers are not currently synchronized between frontend and backend. | |
update_board |
[ [ 147, ... ], ... ] |
Reset board layout with a boundaryBoard sent from the server. Payload contains a 16x16 array of integer corresponding to a graphical representation of the board. |
update_robots |
[ "pos": {"x": 1, "y": 2}, "color": "red", "moves": [ "up", "left" ] ] |
Update robots positions and sets of legal moves |
update_goals |
[ "pos": {"x": 1, "y": 2}, "symbol": "RedMoon", "active": true ] |
Reset goalList positions and set the active goal |
switch_to_countdown |
"timer": 25, "countdown": 60 |
Switch clock mode to countdown (e.g. solution found) |
switch_to_timer |
"timer": 0, "countdown": 60 |
Switch clock mode to timer (e.g. new game) |
clear_moves_queue |
"" |
Force movesQueue to clear, e.g. upon a new game. |
update_scoreboard |
[ {"username": "User", "color": "#faefa0", "score": 5, "is_admin": true, "is_muted": false} ] |
Update users names, colors, scores and all (for example, after each round is scored). |
update_user |
{"username": "User", "color": "#faefa0", "score": 5, "is_admin": true, "is_muted": false} |
Update current user name, color, etc. |
update_chat |
{"user": <User>, "msg": "Hello!", "kind": 0} |
Update chat |
"action" | "content" | Description |
---|---|---|
submit_movelist |
[ {"color": "Color", "direction": "Direction"} ] |
Submit list of moves |
create_user |
"" |
Add user |
update_user |
{"username": "User", "color": "#faefa0", "score": 5, "is_admin": true, "is_muted": false} |
Update user |
update_chat |
{"user": <User>, "msg": "Hello!", "kind": 0} |
Send (user) message |
new_game |
"" |
Immediately initialize a new game (only available to admin users). |
ping |
"ping" |
Send "ping" every 50 seconds to maintain the connection. |
1 or R : Select red robot
2 or G : Select green robot
3 or B : Select blue robot
4 or Y : Select yellow robot
5 or S : Select silver robot
←, ↑, →, or ↓ : Attempt to queue a move for the selected robot in the corresponding direction.
Esc : Clear queue of moves
Backspace : Remove (undo) last move from queue
Administration is performed through the use of /poll <option> [param1, param2]
and /set <option> [param1, param2]
commands entered through chat. A poll must succeed with more Yes votes than No votes to change settings. Only an owner can unilaterally change settings with /set
. Available option/parameters:
owner <UID>
: Grant owner status to userdemote <UID>
: Remove owner status from usermute <UID>
: Set mute status for user (no chat or polls)unmute <UID>
: Remove mute status from userkick <UID>
: Kick user from game.set_score <UID> <# points>
: Set score of user to integer value.reset_scores
: Immediately reset all scores to 0.reset_board
: Immediately reset board, robots, and goal.new_game
: Immediately choose new goal.poll_time <# sec>
: Time before poll expires. Default is 120 seconds. Minimum is 30 seconds.countdown_time <# sec>
: Time to find better solutions. Default is 60 seconds.puzzles_before_new_board <# puzzles>
: Number of puzzles before a new board is generated. Default is 10.min_moves <# moves>
: A single-robot solution below this number will not increment the scoreboard. Default is 0.
Compile javascript from root directory: elm make ./src/Robots.elm --output=./assets/js/main.js
Start project server at http://localhost:8000
with elm reactor
. Navigate to http://localhost:8000/index.html
to see the project. Note that you will need a functional backend running to play the game.