diff --git a/spawnclients.html b/spawnclients.html
index e60f27c..5d6f386 100644
--- a/spawnclients.html
+++ b/spawnclients.html
@@ -2,15 +2,31 @@
Cards For Humanity Test Clients
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/api.rs b/src/api.rs
index c702adb..2fd8cd9 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -1,5 +1,5 @@
use crate::AppState;
-use crate::CAHd_game::*;
+use crate::gamemaster::*;
use axum::{
extract::{
ws::{Message, WebSocket, WebSocketUpgrade},
@@ -61,7 +61,14 @@ pub async fn websocket(stream: WebSocket, state: Arc) {
if let Ok(new_game) = serde_json::from_str::(&text) {
tracing::debug!("{:#?}", &new_game);
- state.games.lock().unwrap().push(CAHGame::new(new_game).expect("error creating game"));
+ // create game
+ if let Ok(new_game_object) = CAHGame::new(new_game) {
+ state.games.lock().unwrap().push(new_game_object);
+ } else {
+ let _res = sender
+ .send(Message::Text(format!("error creating game")))
+ .await;
+ }
} else {
// just echo
let _res = sender.send(Message::Text(text)).await;
diff --git a/src/CAHd_game.rs b/src/gamemaster.rs
similarity index 92%
rename from src/CAHd_game.rs
rename to src/gamemaster.rs
index f07d2c0..69cd1c7 100644
--- a/src/CAHd_game.rs
+++ b/src/gamemaster.rs
@@ -105,7 +105,7 @@ impl CAHGame {
let mut game = CAHGame {
..Default::default()
};
- println!("Creating game {}", &request.name);
+ tracing::debug!("Creating game {}", &request.name);
game.name = request.name;
// game.build_decks(request.packs)?;
@@ -120,7 +120,7 @@ impl CAHGame {
/// Log counts of current drawable cards
/// For testing
pub fn deck_counts(&self) {
- println!(
+ tracing::debug!(
"Deck Counts:\n {} White cards\n {} Black cards",
self.white.len(),
self.black.len()
@@ -167,13 +167,13 @@ impl CAHGame {
/// Create a new player and add them to the game.
pub fn create_player(&mut self, mut player: CAHPlayer) -> Result<()> {
- println!("Creating player {} as {:?}", &player.name, &player.role);
+ tracing::debug!("Creating player {} as {:?}", &player.name, &player.role);
let mut hand_buf = vec![];
for _ in 0..10 {
hand_buf.push(self.draw_one_white()?);
}
- println!("Dealing hand for {}", &player.name);
+ tracing::debug!("Dealing hand to {}", &player.name);
player.white.extend(hand_buf);
self.players.push(player);
@@ -183,12 +183,12 @@ impl CAHGame {
pub fn game_start(&mut self) -> Result<()> {
self.game_active = true;
- println!("Game Active!");
+ tracing::debug!("Game Active!");
if let Some(black) = &self.current_black {
- println!("{}", black.text);
+ tracing::debug!("{}", black.text);
} else {
- println!("YOU DONE FUCKED UP (no current black card)");
+ tracing::debug!("YOU DONE FUCKED UP (no current black card)");
}
Ok(())
diff --git a/src/main.rs b/src/main.rs
index 03656d5..82a0c6a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,9 +7,8 @@ use std::{error::Error, fs, result::Result};
use tokio::sync::broadcast;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
-#[allow(non_snake_case)]
-pub mod CAHd_game;
-use crate::CAHd_game::*;
+pub mod gamemaster;
+use crate::gamemaster::*;
pub mod api;
use crate::api::*;
diff --git a/test_client.html b/test_client.html
index 9c863a3..c0c0b57 100644
--- a/test_client.html
+++ b/test_client.html
@@ -6,12 +6,17 @@