A full-stack rust implementation of Connect-4 and TOOT-and-OTTO.
- Navigate to the
client/
directory.
cd client/
- Install
Trunk
, a WASM web application bundler forRust
. This may take a couple minutes.
cargo install trunk wasm-bindgen-cli
- Run the application. This should automatically spawn a web browser. If this is not the case, open up a browser and navigate to
localhost:<PORT>
or127.0.0.1:<PORT>
.
trunk serve # port 8080
# or specify the port number
trunk serve --port 3000
- Navigate to server/ directory
cd server/
- Switch to
Rust Nightly
rustup update
cargo update
rustup override set nightly
- Setup the
MongoDB
server
mongod
- In a new terminal, open the mongo shell
mongo
- In the mongo shell, Initialize the users and scores collections with index for username on both of them
use 421ServerDB
db.createCollection("users")
db.users.createIndex({"username": 1}, {unique: true})
db.createCollection("scores")
db.scores.createIndex({"username": 1}, {unique: true})
- Exit the mongo shell
exit
- Run the
Rust Rocket
project
cargo run
Returns the game scores of a user
Login Request
JSON Request Format
{
"username": "username",
"password": "password"
}
Sign up Request
JSON Request Format
{
"username": "username",
"password": "password"
}
Update game stats
JSON Request Format
{
"username": "username",
"game": 0, // Connect 4: 0, TootnOtto: 1
"win": 0 // loss: 0, win: 1, tie: 2
}
Gets game stats
JSON Request Return Format
{
"username": "username",
"xo_wins": 0, // connect 4 wins
"xo_loss": 0, // connect 4 losses
"xo_ties": 0, // connect 4 ties
"to_wins": 0, // tootnotto wins
"to_loss": 0, // tootnotto losses
"to_ties": 0 // tootnotto ties
}