diff --git a/Cargo.lock b/Cargo.lock index 3fc26bb..74ef4c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,6 +38,12 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + [[package]] name = "cassowary" version = "0.3.0" @@ -89,6 +95,7 @@ dependencies = [ "petgraph", "rand", "ratatui", + "whoami", ] [[package]] @@ -155,6 +162,15 @@ dependencies = [ "either", ] +[[package]] +name = "js-sys" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "libc" version = "0.2.149" @@ -435,6 +451,80 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" + +[[package]] +name = "web-sys" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "whoami" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 5caa701..0515c19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,4 @@ ratatui = "0.24.0" crossterm = "0.27.0" rand = "0.8.5" petgraph = "0.6.4" +whoami = "1.4.1" \ No newline at end of file diff --git a/src/level_generator.rs b/src/level_generator.rs index 6beb9fa..d9ee502 100644 --- a/src/level_generator.rs +++ b/src/level_generator.rs @@ -1,11 +1,12 @@ use std::cmp::{max, min}; use std::ops::Range; + +use petgraph::algo::min_spanning_tree; +use petgraph::data::*; +use petgraph::graph::Graph; +use petgraph::graph::UnGraph; use rand::prelude::SliceRandom; use rand::Rng; -use petgraph::graph::UnGraph; -use petgraph::graph::Graph; -use petgraph::data::*; -use petgraph::algo::min_spanning_tree; use rand::rngs::ThreadRng; use crate::level::{Level, LevelElement, RoomType}; diff --git a/src/main.rs b/src/main.rs index 1e43eb1..e0ff4eb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,21 +1,23 @@ +use std::io::{Result, stdout}; + use crossterm::{ event::{self, KeyCode, KeyEventKind}, - terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, ExecutableCommand, + terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; use ratatui::{ prelude::{CrosstermBackend, Stylize, Terminal}, widgets::Paragraph, }; -use std::io::{stdout, Result}; use ratatui::prelude::*; use ratatui::widgets::Block; +use whoami::realname; use crate::game::Game; use crate::level::Level; +use crate::level_generator::LevelGenerator; use crate::level_widget::LevelWidget; use crate::player::Player; -use crate::level_generator::LevelGenerator; mod game; mod player; @@ -30,7 +32,7 @@ fn main() -> Result<()> { levels[l] = LevelGenerator::generate(l).render(); } let mut g = Game { - player: Player::new("Teddy Tester", 10), + player: Player::new(realname().as_str(), 10), levels, }; diff --git a/src/player.rs b/src/player.rs index 5e68c55..957a635 100644 --- a/src/player.rs +++ b/src/player.rs @@ -1,4 +1,5 @@ use std::cmp::{max, min}; + use crate::position::Position; pub struct Player {