From fb34d0d9651fc28788a1024f18ab3b51ef9359b6 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Fri, 27 Dec 2024 14:05:41 -0500 Subject: [PATCH] Move the database into a more complex sub-module --- .../src/{database.rs => database/mod.rs} | 46 ------------------- 1 file changed, 46 deletions(-) rename visions/server/src/{database.rs => database/mod.rs} (88%) diff --git a/visions/server/src/database.rs b/visions/server/src/database/mod.rs similarity index 88% rename from visions/server/src/database.rs rename to visions/server/src/database/mod.rs index a741594..8e27f4b 100644 --- a/visions/server/src/database.rs +++ b/visions/server/src/database/mod.rs @@ -251,52 +251,6 @@ pub struct DiskDb { conn: Connection, } -/* -fn setup_test_database(conn: &Connection) -> Result<(), FatalError> { - let mut gamecount_stmt = conn.prepare("SELECT count(*) FROM games").unwrap(); - let mut count = gamecount_stmt.query([]).unwrap(); - if count.next().unwrap().unwrap().get::(0) == Ok(0) { - let admin_id = format!("{}", Uuid::new_v4()); - let user_id = format!("{}", Uuid::new_v4()); - let game_id = format!("{}", Uuid::new_v4()); - let char_id = CharacterId::new(); - - let mut user_stmt = conn - .prepare("INSERT INTO users VALUES (?, ?, ?, ?, ?)") - .map_err(|err| FatalError::ConstructQueryFailure(format!("{}", err)))?; - user_stmt - .execute((admin_id.clone(), "admin", "abcdefg", true, true)) - .unwrap(); - user_stmt - .execute((user_id.clone(), "savanni", "abcdefg", false, true)) - .unwrap(); - - let mut game_stmt = conn - .prepare("INSERT INTO games VALUES (?, ?)") - .map_err(|err| FatalError::ConstructQueryFailure(format!("{}", err)))?; - game_stmt - .execute((game_id.clone(), "Circle of Bluest Sky")) - .unwrap(); - - let mut role_stmt = conn - .prepare("INSERT INTO roles VALUES (?, ?, ?)") - .map_err(|err| FatalError::ConstructQueryFailure(format!("{}", err)))?; - role_stmt - .execute((user_id.clone(), game_id.clone(), "gm")) - .unwrap(); - - let mut sheet_stmt = conn - .prepare("INSERT INTO characters VALUES (?, ?, ?)") - .map_err(|err| FatalError::ConstructQueryFailure(format!("{}", err)))?; - - sheet_stmt.execute((char_id.as_str(), game_id, r#"{ "type_": "Candela", "name": "Soren Jensen", "pronouns": "he/him", "circle": "Circle of the Bluest Sky", "style": "dapper gentleman", "catalyst": "a cursed book", "question": "What were the contents of that book?", "nerve": { "type_": "nerve", "drives": { "current": 1, "max": 2 }, "resistances": { "current": 0, "max": 3 }, "move": { "gilded": false, "score": 2 }, "strike": { "gilded": false, "score": 1 }, "control": { "gilded": true, "score": 0 } }, "cunning": { "type_": "cunning", "drives": { "current": 1, "max": 1 }, "resistances": { "current": 0, "max": 3 }, "sway": { "gilded": false, "score": 0 }, "read": { "gilded": false, "score": 0 }, "hide": { "gilded": false, "score": 0 } }, "intuition": { "type_": "intuition", "drives": { "current": 0, "max": 0 }, "resistances": { "current": 0, "max": 3 }, "survey": { "gilded": false, "score": 0 }, "focus": { "gilded": false, "score": 0 }, "sense": { "gilded": false, "score": 0 } }, "role": "Slink", "role_abilities": [ "Scout: If you have time to observe a location, you can spend 1 Intuition to ask a question: What do I notice here that others do not see? What in this place might be of use to us? What path should we follow?" ], "specialty": "Detective", "specialty_abilities": [ "Mind Palace: When you want to figure out how two clues might relate or what path they should point you towards, burn 1 Intution resistance. The GM will give you the information you have deduced." ] }"#)) - .unwrap(); - } - - Ok(()) -} -*/ - impl DiskDb { pub fn new

(path: Option

) -> Result where