aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorIago Garrido <iago086@gmail.com>2019-11-12 16:53:13 +0100
committerIago Garrido <iago086@gmail.com>2019-11-12 16:53:13 +0100
commitc20f1310fb3417cb1b0bf41e2d31db373751e392 (patch)
tree7b35746e4f8ea7ee0ff0d0c56a7ff2734f12ed80 /src/main.rs
parentefbf0f17da4d6d237712b1559e9877746859697a (diff)
get player name from env
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index b59d587..ab93eb5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,16 +16,23 @@ use pancurses::{
Input,
noecho
};
+use std::env;
use state::State;
use world::{Dungeon};
+fn get_player_name() -> String {
+ match env::var_os("USER") {
+ Some(val) => val.into_string().unwrap(),
+ None => String::from("Kshar")
+ }
+}
fn main() {
let window = initscr();
let mut state = State::new(
Player::new(
- "Kshar".to_string(),
+ get_player_name(),
"Warrior".to_string(),
30,
10,