mirror of
https://git.kittycat.homes/zoe/reversi.git
synced 2024-08-15 03:27:19 +00:00
Compare commits
No commits in common. "ab7785ed0051a35360f6d0d76e067753d5763601" and "f77033ef8a9781fb36e300a3e72e9238762a9a9d" have entirely different histories.
ab7785ed00
...
f77033ef8a
3 changed files with 6 additions and 44 deletions
36
src/main.rs
36
src/main.rs
|
|
@ -17,17 +17,12 @@ lazy_static! {
|
||||||
static ref ROOMS: Mutex<HashMap<String, rooms::Room>> = Mutex::new(HashMap::new());
|
static ref ROOMS: Mutex<HashMap<String, rooms::Room>> = Mutex::new(HashMap::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Config options
|
|
||||||
*/
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[clap(about, version, author)]
|
#[clap(about, version, author)]
|
||||||
struct Args {
|
struct Args {
|
||||||
// Port number for server
|
// Port number for server
|
||||||
#[clap(short, long, default_value_t = 8000)]
|
#[clap(short, long, default_value_t = 8000)]
|
||||||
port: u16,
|
port: u16,
|
||||||
// this is here so that it shows up in help, it's actually used in templates.rs
|
|
||||||
// sucks
|
|
||||||
#[clap(short, long, default_value = "http://127.0.0.1:8000")]
|
#[clap(short, long, default_value = "http://127.0.0.1:8000")]
|
||||||
base_url: String,
|
base_url: String,
|
||||||
}
|
}
|
||||||
|
|
@ -42,9 +37,6 @@ fn rocket() -> _ {
|
||||||
.mount("/", routes![index, room])
|
.mount("/", routes![index, room])
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* handles creating rooms, player counts and
|
|
||||||
*/
|
|
||||||
#[get("/?<roomname>")]
|
#[get("/?<roomname>")]
|
||||||
async fn index(mut roomname: String) -> Template {
|
async fn index(mut roomname: String) -> Template {
|
||||||
// remove whitespace from roomname
|
// remove whitespace from roomname
|
||||||
|
|
@ -80,31 +72,7 @@ async fn index(mut roomname: String) -> Template {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* handles requests for joining rooms and returns the real room page if token and room combination
|
|
||||||
* is correct
|
|
||||||
*/
|
|
||||||
#[get("/room?<roomname>&<token>&<player1>")]
|
#[get("/room?<roomname>&<token>&<player1>")]
|
||||||
async fn room(roomname: &str, token: usize, player1: bool) -> Template {
|
async fn room(roomname: &str, token: usize, player1: bool) -> String{
|
||||||
// lock room list mutex, don't forget to drop again
|
"hey gamer".to_string()
|
||||||
let rooms = ROOMS.lock().unwrap();
|
|
||||||
if rooms.contains_key(roomname) {
|
|
||||||
let room = rooms.get(roomname).unwrap();
|
|
||||||
// the room is real and the token is correct
|
|
||||||
if room.token == token {
|
|
||||||
drop(rooms);
|
|
||||||
//TODO: placeholder
|
|
||||||
templates::get_back_to_home("cool!")
|
|
||||||
}
|
|
||||||
// the room is real but the token is incorrect
|
|
||||||
else {
|
|
||||||
drop(rooms);
|
|
||||||
templates::get_back_to_home("illegalroom")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// the room doesn't exist
|
|
||||||
else {
|
|
||||||
drop(rooms);
|
|
||||||
templates::get_back_to_home("illegalroom")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
body,
|
body,
|
||||||
html {
|
html {
|
||||||
|
|
@ -67,15 +67,14 @@ footer {
|
||||||
align-self: center;
|
align-self: center;
|
||||||
min-height: 90%;
|
min-height: 90%;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 90%;
|
width: 100%;
|
||||||
max-width: 900px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
button,
|
button,
|
||||||
.contentdiv *,
|
.contentdiv *,
|
||||||
a,
|
a,
|
||||||
p {
|
p {
|
||||||
line-height: 48pt;
|
line-height: 1.84em;
|
||||||
border-radius: 0.48em;
|
border-radius: 0.48em;
|
||||||
font-size: 24pt;
|
font-size: 24pt;
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
|
|
@ -94,11 +93,6 @@ input {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
form {
|
|
||||||
width: 100%;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
input {
|
||||||
cursor: text;
|
cursor: text;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
class="{{hide_url_button}}"
|
class="{{hide_url_button}}"
|
||||||
href="{{url_button_url}}"
|
href="{{url_button_url}}"
|
||||||
type="button"
|
type="button"
|
||||||
>copy url</a>
|
>{{url_button_url}}</a>
|
||||||
<a href={{link_url}}>{{link}}</a>
|
<a href={{link_url}}>{{link}}</a>
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue