diff --git a/backend/games.ini b/backend/games.ini deleted file mode 100644 index 814de4e..0000000 --- a/backend/games.ini +++ /dev/null @@ -1,111 +0,0 @@ -path=static/games/ - -[Alisha Lara.json] -name=Alisha Lara -turns=143 -players= "SimpleBot 2 (check if python is correct before executing)" "mybot2" - -[Andre Head.json] -name=Andre Head -turns=1229 -players= "mybot2" "SimpleBot 2 (check if python is correct before executing)" "mybot" - -[Angela Sims.json] -name=Angela Sims -turns=221 -players= "SimpleBot 2 (check if python is correct before executing)" "mybot2" - -[Buford Humphrey.json] -name=Buford Humphrey -turns=174 -players= "Subutai" "SimpleBot 1 (check if python is correct before executing)" "SimpleBot 2 (check if python is correct before executing)" - -[Catalina Grant.json] -name=Catalina Grant -turns=202 -players= "mybot" "SimpleBot 1 (check if python is correct before executing)" "SimpleBot 2 (check if python is correct before executing)" - -[Cesar Jordan.json] -name=Cesar Jordan -turns=214 -players= "Subutai" "SimpleBot 1 (check if python is correct before executing)" - -[Chandra Garrett.json] -name=Chandra Garrett -turns=202 -players= "SimpleBot 1 (check if python is correct before executing)" "SimpleBot 2 (check if python is correct before executing)" - -[Cory Mooney.json] -name=Cory Mooney -turns=45 -players= "SimpleBot 2 (check if python is correct before executing)" "SimpleBot 1 (check if python is correct before executing)" - -[Deana Bishop.json] -name=Deana Bishop -turns=302 -players= "mybot" "mybot2" - -[game2.json] -name=game2 -turns=110 -players="bot_auto_player_full_rand" "adversary_auto_player_link_rand" - -[Georgina Wiley.json] -name=Georgina Wiley -turns=302 -players= "mybot2" "mybot" - -[hungergames.json] -name=hungergames -turns=119 -players= - -[Jeannie Swanson.json] -name=Jeannie Swanson -turns=251 -players= "SimpleBot 1 (check if python is correct before executing)" "SimpleBot 2 (check if python is correct before executing)" "mybot2" "mybot" - -[Joanne Blair.json] -name=Joanne Blair -turns=202 -players= "mybot2" "mybot" "SimpleBot 1 (check if python is correct before executing)" "SimpleBot 2 (check if python is correct before executing)" - -[large.json] -name=large -turns=1166 -players= - -[Lester Berg.json] -name=Lester Berg -turns=1132 -players= "mybot" "mybot2" "SimpleBot 2 (check if python is correct before executing)" - -[Lindsey Farrell.json] -name=Lindsey Farrell -turns=461 -players= "jens" "SimpleBot 2 (check if python is correct before executing)" "dinkske" "SimpleBot 1 (check if python is correct before executing)" - -[Pansy Le.json] -name=Pansy Le -turns=417 -players= "Subutai" "SimpleBot 1 (check if python is correct before executing)" "SammyBot" - -[pietmap.json] -name=pietmap -turns=2788 -players= - -[Randell Wolfe.json] -name=Randell Wolfe -turns=300 -players= "mybot" "SimpleBot 2 (check if python is correct before executing)" - -[spiral2.json] -name=spiral2 -turns=537 -players= - -[standard_game.json] -name=standard_game -turns=82 -players="bot_auto_player_full_rand" "adversary_auto_player_orfirst_rand" diff --git a/backend/src/planetwars/mod.rs b/backend/src/planetwars/mod.rs index 184db66..45de3e6 100644 --- a/backend/src/planetwars/mod.rs +++ b/backend/src/planetwars/mod.rs @@ -5,7 +5,7 @@ use serde_json; use std::collections::HashMap; use std::convert::TryInto; -use std::fs::File; +use std::fs::{File, create_dir}; use std::io::Write; mod pw_config; @@ -33,6 +33,11 @@ impl PlanetWarsGame { .iter() .map(|p| (p.name.clone(), p.id)) .collect(); + + if let Err(_) = create_dir("static/games") { + println!("'static/games' already exists"); + } + let file = File::create(format!("static/games/{}", location)).unwrap(); Self { diff --git a/backend/templates/debug.html.tera b/backend/templates/debug.html.tera index 2d30e65..389cbfa 100644 --- a/backend/templates/debug.html.tera +++ b/backend/templates/debug.html.tera @@ -91,7 +91,7 @@ const network = new vis.Network(container, data, options); - var ws = new WebSocket('ws://127.0.0.1:3012'); + var ws = new WebSocket(`ws://${window.location.hostname}:3012`); ws.onmessage = function (event) { handle_event(JSON.parse(event.data)); };