Init commit
This commit is contained in:
+63
@@ -0,0 +1,63 @@
|
||||
use std::env;
|
||||
mod models {
|
||||
pub mod board;
|
||||
pub mod piece;
|
||||
pub mod networking;
|
||||
}
|
||||
|
||||
fn print_help() {
|
||||
println!("Ey fam, hmu with dat '--serve' or '--join <address>'")
|
||||
}
|
||||
|
||||
fn start_game() {
|
||||
println!("OK");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if (args.len() == 2) && ((args[1] == "--serve") | (args[1] == "serve")) {
|
||||
|
||||
//Start game server
|
||||
println!("Serving!");
|
||||
start_game();
|
||||
|
||||
} else if (args.len() == 3) && ((args[1] == "--join") | (args[1] == "join")) {
|
||||
|
||||
//Join game server
|
||||
println!("Joining!");
|
||||
start_game();
|
||||
|
||||
} else if (args.len() == 2) && (args[1] == "--help") {
|
||||
|
||||
print_help();
|
||||
|
||||
} else {
|
||||
|
||||
println!("What do you mean with {:?}\n", args);
|
||||
print_help();
|
||||
|
||||
}
|
||||
|
||||
println!("{}", serialize_move(models::networking::Action::Rotate {
|
||||
from: (2, 2),
|
||||
rot: models::networking::RotationDirection::Positive
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn serialize_move(action: models::networking::Action) -> str {
|
||||
let serialized = serde_json::to_string(&action);
|
||||
match serialized {
|
||||
Ok(s) => {
|
||||
println!("OK: {}", s);
|
||||
return &s;
|
||||
},
|
||||
Err(_e) => {
|
||||
println!("Couldn't serialize...");
|
||||
return ("");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user