diff --git a/Cargo.toml b/Cargo.toml index f81d2fe..cfb6b28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,4 @@ colored = "2.2.0" termion = "4.0.3" serde = { version = "1.0.127", features = ["derive"] } serde_json = "1.0" +lazy_static = "1.4" diff --git a/data/save.json b/data/save.json index e62d000..94e67e3 100644 --- a/data/save.json +++ b/data/save.json @@ -5,8 +5,8 @@ "mining": 0 }, "coordinates": { - "x": 100, - "z": 29, + "x": 85, + "z": 17, "map": "world" }, "inventory": [ diff --git a/data/world_ground.map b/data/world.map similarity index 65% rename from data/world_ground.map rename to data/world.map index 2164b41..c956113 100644 --- a/data/world_ground.map +++ b/data/world.map @@ -1,66 +1,66 @@ -''''''''''''####'''''''''''''''''''''''''''''''''''####''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''#;;#'''''''''''''''''''''''''''''''''''#;;#''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''#;;;###################################;;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''##;;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;;##''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#;;#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#;;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#;;###################%%%%##########;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#########;##########;;;;;;;##########;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#%%%%%%%#;#%%%%%%%%#;;;;;;;#%%%%%%%%#;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#%%%%%%%#;#%%%%%%%%#;;;;;;;#%%%%%%%%#;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#######%#;####%%%%%#;;;;;;;#%%%%%%%%#;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#;;;;;;;;;;;;#%%%%%#;;;;;;;#####%####;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''''#;;;#######;;#%%%%%#;;;;;;;;;;;;;;;;;;#''''''''''''''''''''''''''''''''''''''';;;;;;;;;'''''''''''''''[[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''###;;##%%%%%#;;###%%##;;;;;;;;####%###;####''''''''''''''''''''''''''''''''';;;;;;'''''';;;;;;;;'''''''''[[[[[[[[[[[[[[[[[[[[[[[[ -''''''''''''#;;;;#%%%%%%%;;;;;;;;;;;;;;;;;#%%%%%%#;;;;#'''''''''''''''''''''''''';;;;;;;'''''''''''''''''';;;;;''''''''';;;;[[[[[[[[[[[[[[[[[ -''''''''''''#;;###################;;;;;;;###########;;#'''''''''''''''''''''';;;;;;''''''''''''''''''''''''''';;;;;;;;;;;;;;[[[[[[[[[[[[[[[[[ -''''''''''''####'''''''''''''''''';;;;;;;''''''''''####''''''''''''';;;;;;;;;;'''''''''''''''''''''''''''''''''''''''';;;;;;''[[[[[[[[[[[[[[[ -'''''''''''''''''''''''''''''''''';;;;;;;''''''''''''''''''''''''';;;''''''''''''''''''''''''''''''''''''''''''''''''''';;;''''''''[[[[[[[[[[ -''''''''''''''''''''''''''''''''''';;;;;;;;''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''[[[ +''''''''''''####'''''''''''''''''''''''''''''''''''####''''''''''''''''''''''''''''''''''''''''''''''^^^^^^^^^^^^^^^^^^^^^^^^^^^[^^^^^^^^^^^^ +''''''''''''#;;#'''''''''''''''''''''''''''''''''''#;;#''''''''''''''''''''''''''''''''''''''''''''''''''''^^^^^^^^^^^^^^^^^^[[[[[^^^^^^^^^^^ +''''''''''''#;;;###################################;;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''^^^^^^^^^[[[[[[[[^^^^^^^^^^^^ +''''''''''''##;;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;;##''''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[^^^^^^^^^^^ +''''''''''''''#;;#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#;;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''^^[[[[[[[[[[[[[[[[[[[[^^^^^^^^^^ +''''''''''''''#;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[[[[[[[[[^^^^^^ +''''''''''''''#;;#%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%#;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[[[[[[[[[^^^^^^ +''''''''''''''#;;###################%%%%##########;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''^^[[[[[[[[[[[[[[[[[[[[[[[[[[^^^^^ +''''''''''''''#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[[[[[[[[[[^^^ +''''''''''''''#########;##########;;;;;;;##########;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''^^[[[[[[[[[[[[[[[[[[[[[[[[^^^^ +''''''''''''''#%%%%%%%#;#%%%%%%%%#;;;;;;;#%%%%%%%%#;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[[[[[^^^^^ +''''''''''''''#%%%%%%%#;#%%%%%%%%#;;;;;;;#%%%%%%%%#;#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''^^[[[[[[[[[[[[[[[[[[[[[[^^^^ +''''''''''''''#######%#;####%%%%%#;;;;;;;#%%%%%%%%#;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''^[[[[[[[[[[[[[[[[[[[[[^^^^^ +''''''''''''''#;;;;;;;;;;;;#%%%%%#;;;;;;;#####%####;#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''^^[[[[[[[[[[[[[[[[[[[^^^^^^ +''''''''''''''#;;;#######;;#%%%%%#;;;;;;;;;;;;;;;;;;#''''''''''''''''''''''''''''''''''''''';;;;;;;;;'''''''''''''''^^[[[[[[[[[[[[[[[[[^^^^^^ +''''''''''''###;;##%%%%%#;;###%%##;;;;;;;;####%###;####''''''''''''''''''''''''''''''''';;;;;;'''''';;;;;;;;'''''''''^^^^[[[[[[[[[[[[^^^^^^^^ +''''''''''''#;;;;#%%%%%%%;;;;;;;;;;;;;;;;;#%%%%%%#;;;;#'''''''''''''''''''''''''';;;;;;;'''''''''''''''''';;;;;''''''''';;;;^^[[[[[[^^^^^^^^^ +''''''''''''#;;###################;;;;;;;###########;;#'''''''''''''''''''''';;;;;;''''''''''''''''''''''''''';;;;;;;;;;;;;;^^^^^^^^^^^^^^^^^ +''''''''''''####'''''''''''''''''';;;;;;;''''''''''####''''''''''''';;;;;;;;;;'''''''''''''''''''''''''''''''''''''''';;;;;;''^^^^^^^^^^^^^^^ +'''''''''''''''''''''''''''''''''';;;;;;;''''''''''''''''''''''''';;;'''''''''''''''''''''''''♣''''''''''''''''''''''''';;;''''''''^^^^^^^^^^ +''''''''''''''''''''''''''''''''''';;;;;;;;''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''^^^ '''''''''''''''''''''''''''''''''''';;;;;;;''''''''''''''''''';;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''''' -'''''''''''''''''''''''''''''''''''';;;;;;;;;;''''''''''''''';;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''''' +'''''''''''''''''''''''''''''''''''';;;;;;;;;;''''''''''''''';;;''''''''''''''''''''''''''''''''''♣'''''''''''''''''''''';;'''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''';;;;;;;''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;'''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''';;;;;;'''''';;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';'''''''''''''''''''' -'''''''''''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';'''''''''''''''''''' -''''''''''''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''''''' +'''''''''''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;'''''''''''''''''''''''''''♣''''''''''''''''''''''''''''''''''';'''''''''''''''''''' +''''''''''''''''''''''''''''''''''''''''♣'''';;;;;;;;;;;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;;'''''''''''''''''''''''''''''''''''''''''''''''''''''';;;''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;;'''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''''''''''' -'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''''''''''' +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;;'''''''♣''''''''''''''''''''''♣''''''''''''''''''''';;'''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''''''''''''''''''''''''''''''''''''''';;'''''''''''''''''''''''' ''''''''''''''''~''''''''''''''''''''''''''''''''''''''''''~';;'''''''''''''''~'''''''''''''''''''''''''''''''''''';;'''''''''''''''''''''''' ''''''''''''''''~~~~~~~~'''''''''''''''''''''''''''''''''''~';;''''''''''''''~~''''''''''''''''''''''''''''''''''';;''''''''''''''''''''''''' -'''''''''''''''''''''''~~~~~'''''''''''''''''''''''''''''''~';;''''''''''''~~~~'''''''''''''''''''''''''''''''''';''''''''''''''''''''''''''' +'''''''''''''''''''''''~~~~~'''''''''''''''''''''''''''''''~';;''''''''''''~~~~''''''''''''''''''♣''''''''''''''';''''''''''''''''''''''''''' ''''''''''''''''''''''''''~~~'''''''''''''''''''''''''''''~~';;'''''''''~~~~'''''''''''''''''''''''''''''''''''';;''''''''''''''''''''''''''' -'''''''''''''''''''''''''''~~'''''''''''''''''''''''''''''~~';;'''''''''~~~'''''''''''''''''''''''''''''''''''';;'''''''''''''''''''''''''''' +'''''''''''''''''''''''''''~~'''''''''''''''''''''''''♣'''~~';;'''''''''~~~'''''''''''''''''''''''''''''''''''';;'''''''''''''''''''''''''''' '''''''''''''''''''''''''''~~''''''''''''''''''''''''''''~~'';;;'''''''~~~'''''''''''''''''''''''''''''''''''';;;'''''''''''''''''''''''''''' -'''''''''''''''''''''''''''~~''''''''''''''''''''''''''''~~'''';;'''''~~'''''''''''''''''''''''''''''''''''';;;'''''''''''''''''''''''''''''' -'''''''''''''''''''''''''''~~~'''''''''''''''''''''''''''~~''''';'''~~~''''''''''''''''''''''''''''''''''';;;;''''''''''''''''''''''''''''''' +'''''''''''''''''''''''''''~~''''''''''''''''''''''''''''~~'''';;'''''~~'''''''''''♣'''''''''''''''''''''''';;;'''''''''''''''''''''''''''''' +'''''''''''''''''''''''''''~~~'''''''''''''''''''''''''''~~''♣'';'''~~~''''''''''''''''''''''''''''''''''';;;;''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''~~~'''~~~''''''''''''''''''''~~'''''';;'~~~''''''''''''''''''''''''''''''''''';;;''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''~~''~~~~~'''''''''''''''''''~~'~~~~~%%~~~''''''''''''''''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''' -''''''''''''''''''''''''''''~~~~~~~~~~'''''''''''''''''~~~~~~~~~~%%~'''''''''''''''''''''''''''''''''''';;;'''''''''''''''''''''''''''''''''' +''''''''''''''''''''''''''''~~~~~~~~~~'''''''♣'''''''''~~~~~~~~~~%%~'''♣'''''''''''♣'''''''''''''''''''';;;'''''''''''''''''''''''''''''''''' ::''''''''''''''''''''''''''~~~~~'''''~~~~~''''''''''''~~~~~''''';;'''''''''''''''''''''''''''''''''''';;;;;;;;;;;;;;;''''''''''''''''''''''' :::::::'''''''''''''''''''''~~~~''''''''~~~~''''''''~~~~~~~'''''';;'''''''''''''''''''''''''''''''''';;;;;'''''''''''';;;'''''''''''''''''''' ::::::::::::'''''''''''''::::~~~'''''''''''~~~~~'''~~~~'''''''''';;;;''''''''''''''''''''''''''''''';;;''''''''''''''''';;;;''''''''''''''''' -::::::::::::::::::'''':::::~~~~~''''''''''''~~~~~~~~~~~'''''''''''';;;;''''''''''''''''''''''''''';;;'''''''''''''''''''''';;;;'''''''''''''' -:::::::::::::::::::::::::~~~~~:''''''''''''''''~~~~~''''''''''''''''';;''''''''''''''''''';;;;;;;;;;;;%%%'''''''''''''''''''''';;;;;''''''''' -:::::::::::::::::::::::~~~~~:::''''''''''''''''''''''''''''''''''''''';;;'''''''''''''';;;;;''''';;;;;%"%%%%''''''''''''''''''''''';;;;'''''' -:::::::::::::::::::::::~~~~::::'''''''''''''''''''''''''''''''''''''''';;'''''''''''';;;'''''''%%%;;;;%%%""%%%%%%%%%%''''''''''''''''';;;;;'' -~:::::::::::::::::::::~~~~~:::::''''''''''''''''''''''''''''''''''''''';;;'''''''''';;;'''''''%%"%""""""""""""""""""%%%%''''''''''''''''';;;; -~~~~~~:::::::::::::::~~~~~:::::::'''''''''''''''''''''''''''''''''''''''';''''''''';;;'''''''%"%%%""""""""""%%%%%%"""""%%'''''''''''''''''';; -~~~~~~~~~~:::::::~~~~~~~~:::::::::'''''''''''''''''''''''''''''''''''''''';;;;;;;;;;'''''''%%%"""""""""""""%"""""%%%""""%'''''''''''''''''''' -~~~~~~~~~~~~~~:::~~~~~~~~:::::::::::''''''''''''''''''''''''''''''''''''''''';;;;'''''''''%%"""""""""""""""%"""""""%""""%'''''''''''''''''''' -~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::''''''''''''''''''''''''''''''''''';;;;''''''''''''%"""%%%%""%%""""""""""""%%""""%'''''''''''''''''''' -~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::::::::'''''''''''''''''''''''''''''';;;;;''''''''''''''%"""%""""""%"""""%%%%%%%""""""%'''''''''''''''''''' -~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::::::::::'''''''''''''''''''''''';;;;;;'''''''''''''''''%"""%""""""%""""""""""""""""""%''''''''''''''''''~~ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::::'''''''''''';;;;;;;;;;;;''''''''''''''''''''''%"""%%"""""%""""%""%%%""""""""%''''''''''''''''''~~ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::'''''''';;;''''''''''''''''''''''''''''''''''%%""""%%%%%""""%""""""%%%"""""%''''''''''''''''''~~ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::'''';;;'''''''''''''''''''''''''''''''''''''%%%"""""""""""%""""""""%%""""%''''''''''''''''''~~ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::''';;''''''''''''''''''''''''''''''''''''''''%%%""""""""""%%%%%%%%%""""%%''''''''''''''''''~~ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::';;''''''''''''''''''''''''''''''''''''''''''%%%%%%%%%%%%%""""""""%%%%'''''''''''''''''''~~ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::::::;;:::'''''''''''''''''''''''''''''''''''''''''''''''''''''%%%%%%%%%%''''''''''''''''''''''~~ +::::::::::::::::::'''':::::~~~~~''''''''''''~~~~~~~~~~~'''''''♣'''';;;;'''''♣''''''''''''''''''''';;;'''''''''''''''''''''';;;;'''''''''''''' +:::::::::::::::::::::::::~~~~~:''''''''''''''''~~~~~''''''''''''''''';;''''''''''''''''''';;;;;;;;;;;;==='''''''''''''''''''''';;;;;''''''''' +:::::::::::::::::::::::~~~~~:::''''''''''''''''''''''''''''''''''''''';;;'''''''''''''';;;;;''''';;;;;="====''''''''''''''''''''''';;;;'''''' +:::::::::::::::::::::::~~~~::::'''''''''''''''''''''''''''''''''''''''';;'''''''''''';;;'''''''===;;;;===""==========''''''''''''''''';;;;;'' +~:::::::::::::::::::::~~~~~:::::''''''''''''''''''''''''''''''''''''''';;;''''''''♣';;;'''''''=="=""""""""""""""""""====''''''''''''''''';;;; +~~~~~~:::::::::::::::~~~~~:::::::''''''''''''''''''''''''''♣''''''''''''';''''''''';;;'''''''="===""""""""""======"""""=='''''''''''''''''';; +~~~~~~~~~~:::::::~~~~~~~~:::::::::'''''''''''''''''''''''''''''''''''''''';;;;;;;;;;'''''''==="""""""""""""="""""===""""='''''''''''''''''''' +~~~~~~~~~~~~~~:::~~~~~~~~:::::::::::''''''''''''''''''''''''''''''''''''''''';;;;'''''''''=="""""""""""""""="""""""=""""='''''''''''''''''''' +~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::''''''''''''''''''''''''''''''''''';;;;''''''''''''="""====""==""""""""""""==""""='''''''''''''''''''' +~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::::::::'''''''''''''''''''''''''''''';;;;;''''''''''''''="""=""""""="""""=======""""""='''''''''''''''''''' +~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::::::::::'''''''''''''''''''''''';;;;;;'''''''''''''''''="""=""""""=""""""""""""""""""=''''''''''''''''''~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::::'''''''''''';;;;;;;;;;;;''''''''''''''''''''''="""=="""""=""""=""===""""""""=''''''''''''''''''~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::::'''''''';;;''''''''''''''''''''''''''''''''''==""""=====""""=""""""==="""""=''''''''''''''''''~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::::'''';;;'''''''''''''''''''''''''''''''''''''==="""""""""""=""""""""==""""=''''''''''''''''''~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::::::::::''';;''''''''''''''''''''''''''''''''''''''''===""""""""""=========""""==''''''''''''''''''~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~::::::::::';;''''''''''''''''''''''''''''''''''''''''''=============""""""""===='''''''''''''''''''~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::::::;;:::'''''''''''''''''''''''''''''''''''''''''''''''''''''==========''''''''''''''''''''''~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:::;;;;;:::::::'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;;;:::::::::::::''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;;;~~~~:::::::::::::''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' diff --git a/resources/alphabet.info b/resources/alphabet.info new file mode 100644 index 0000000..de3018e --- /dev/null +++ b/resources/alphabet.info @@ -0,0 +1,8 @@ +a b c d e f g h i j k l m n o p q r s t u v w x y z sh th(this) th(thing) ch 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ! ? " " sus/odd +∪ Ь s d ∪ ⫮ g \ : i ʎ l ʍ ∩ ∪ ρ ٩ / s + ∪ V w ks ᒍ ʃ 6(reversed) O Ј 0 | z 3 X S 6 ) 8 9 a u c ↋ e ٩ ¡! ¿? <<>> ඞ + +hello how are you? -> ¿\∪ll∪ \∪w ∪/ ᒍ∪w? + +fuck off, wanker! -> ⫮∪ʎ ∪⫮ w∪∩ʎ∪! + + diff --git a/images/fullmap.png b/resources/fullmap.png similarity index 100% rename from images/fullmap.png rename to resources/fullmap.png diff --git a/images/newmap.png b/resources/newmap.png similarity index 100% rename from images/newmap.png rename to resources/newmap.png diff --git a/images/wraithfate.png b/resources/wraithfate.png similarity index 100% rename from images/wraithfate.png rename to resources/wraithfate.png diff --git a/src/blocks.rs b/src/blocks.rs new file mode 100644 index 0000000..d511b5e --- /dev/null +++ b/src/blocks.rs @@ -0,0 +1,24 @@ +use crate::HashMap; +// key = block character +// element = color (array), collision (bool), pretty name (&str) +lazy_static! { + pub static ref BLOCKS: HashMap> = { + let mut map = HashMap::new(); + map.insert('X', vec![([255, 0, 0], false, "Null")]); + map.insert('\'', vec![([0, 255, 0], false, "Grass")]); + map.insert('"', vec![([153, 102, 0], false, "Dirt")]); + map.insert(';', vec![([128, 128, 128], false, "Cobbles")]); + map.insert('~', vec![([0, 0, 255], true, "Water")]); + map.insert('D', vec![([0, 128, 128], true, "Diamond Ore")]); + map.insert('C', vec![([0, 0, 0], true, "Coal")]); + map.insert('i', vec![([138, 74, 24], true, "Iron Ore")]); + map.insert('%', vec![([195, 162, 103], false, "Wooden Planks")]); + map.insert('=', vec![([190, 170, 100], true, "Wooden Wall")]); + map.insert(':', vec![([195, 162, 103], false, "Sand")]); + map.insert('[', vec![([196, 196, 196], false, "Rock")]); + map.insert('^', vec![([196, 128, 196], true, "Mountain")]); + map.insert('#', vec![([255, 196, 196], true, "Stone Bricks")]); + map.insert('♣', vec![([0, 153, 51], true, "Oak Tree")]); + map + }; +} diff --git a/src/function.rs b/src/function.rs index 035f38d..5af9a3a 100644 --- a/src/function.rs +++ b/src/function.rs @@ -23,18 +23,3 @@ pub fn clear_screen() .expect("Failed to clear screen"); } -pub fn read_element_from_map(vector: &Vec>, index1: usize, index2: usize) -> Result -{ - if vector.len() <= index1 - { - Err(()) - } - else if vector[index1].len() <= index2 - { - Err(()) - } - else - { - Ok(vector[index1][index2]) - } -} diff --git a/src/initialise.rs b/src/initialise.rs index f73e2fe..8398b7f 100644 --- a/src/initialise.rs +++ b/src/initialise.rs @@ -24,7 +24,7 @@ pub fn initialise() -> Player inventory: vec! { ("axe".to_string(), 1), - ("vape".to_string(), 1) + ("morphine pill".to_string(), 1) } }; return player; diff --git a/src/main.rs b/src/main.rs index 7fe8240..f6972e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use std::fs; use std::process::{Command}; use serde::{Serialize, Deserialize}; +use std::collections::HashMap; // Declare the modules from these files mod parse_map; // parse_map.rs @@ -10,6 +11,10 @@ mod initialise; // initialise.rs, creates a new character mod function; // function.rs, for misc functions mod process_input; // process_input.rs +#[macro_use] +extern crate lazy_static; +mod blocks; + pub enum GameAction { Continue, Exit, @@ -36,10 +41,10 @@ struct Player { inventory: Vec<(String, u64)>, } -const DEBUG_MODE: bool = false; +const DEBUG_MODE: bool = true; fn main() -{ +{ let save_file_path: &str = "data/save.json"; let player: Player; @@ -51,7 +56,7 @@ fn main() { println!("{:?}", player); } - if let Ok((ground_map, above_map)) = parse_map::parse_map(&player.coordinates) // Call the parse map function from parse_map.rs + if let Ok(map) = parse_map::parse_map(&player.coordinates) // Call the parse map function from parse_map.rs { // Parse the map file into a vector if DEBUG_MODE == false { @@ -59,8 +64,8 @@ fn main() } output_map::output_map // Call output_map fuctino from output_map.rs ( - &ground_map, - &above_map, + &map, + &blocks::BLOCKS, &player.coordinates, ); // Output the map 'game_loop: loop @@ -71,8 +76,8 @@ fn main() ( user_input, &mut player, - &ground_map, - &above_map, + &map, + &blocks::BLOCKS, ); if let Err(e) = save::save(&save_file_path, &player) diff --git a/src/output_map.rs b/src/output_map.rs index adcd969..229d1e2 100644 --- a/src/output_map.rs +++ b/src/output_map.rs @@ -3,59 +3,70 @@ use std::collections::HashMap; use crate::Coordinates; use crate::DEBUG_MODE; -use crate::function; // Output the map based on map vector pub fn output_map( - ground_map: &Vec>, - above_map: &Vec>, + map: &Vec>, + blocks: &HashMap>, player_coordinates: &Coordinates, ) { let (screen_width, screen_height) = termion::terminal_size().unwrap(); - let distance_you_can_see: [i16; 2] = + let mut distance_you_can_see: [[i16; 2]; 2] = [ - (screen_width as f32 / 2.0) as i16, - (screen_height as f32 / 2.0) as i16 + [ + (player_coordinates.x as f32 - (screen_width as f32 / 2.0)) as i16, + (player_coordinates.x as f32 + (screen_width as f32 / 2.0)) as i16, + ], + [ + (player_coordinates.z as f32 - (screen_height as f32 / 2.0)) as i16, + (player_coordinates.z as f32 + (screen_height as f32 / 2.0)) as i16, + ], ]; + + // Dynamic sizing of output, I forgot how this works, don't change pls + // X + if distance_you_can_see[0][0] < 0 + { + distance_you_can_see[0][1] -= distance_you_can_see[0][0]; + distance_you_can_see[0][0] = 0; + } + if distance_you_can_see[0][1] > map[player_coordinates.z as usize].len() as i16 + { + distance_you_can_see[0][0] -= map[player_coordinates.z as usize].len() as i16 - distance_you_can_see[0][1]; + distance_you_can_see[0][1] = map[player_coordinates.z as usize].len() as i16; + } + // Z + if distance_you_can_see[1][0] < 0 + { + distance_you_can_see[1][1] -= distance_you_can_see[1][0]; + distance_you_can_see[1][0] = 0; + } + if distance_you_can_see[1][1] > map.len() as i16 + { + distance_you_can_see[1][0] -= map.len() as i16 - distance_you_can_see[1][1]; + distance_you_can_see[1][1] = map.len() as i16; + } + + // Output debug info if DEBUG_MODE == true { + println!("{:?}", player_coordinates); println!("Screen Width: {}, Screen Height: {}", screen_width, screen_height); + println!("{:?}", distance_you_can_see); } - let blocks: HashMap = - [ - ('X', [255,0, 0]), // Null - ('\'', [0, 255,0]), // Grass - ('"', [153,102,0]), // Dirt - (';', [128,128,128]), // Cobbles - ('~', [0, 0, 255]), // Water/sea - ('D', [0, 128,128]), // Diamond - ('C', [0, 0, 0]), // Coal - ('i', [138,74 ,24]), // Iron - ('%', [195,162,103]), // Wood planks - (':', [195,162,103]), // Sand - ('[', [196,196,196]), // Stone - ('^', [196,128,196]), // Mountain - ('#', [255,196,196]), // Stone bricks - ('♣', [0, 153,51]), // Oak tree - ] - .iter().cloned().collect(); + // Loop over array and print each block - for z in player_coordinates.z - distance_you_can_see[1]..player_coordinates.z + distance_you_can_see[1] + for z in distance_you_can_see[1][0]..distance_you_can_see[1][1] { - if z >= 0 && z < ground_map.len() as i16 + if z >= 0 && z < map.len() as i16 { - for x in player_coordinates.x - distance_you_can_see[0]..player_coordinates.x+distance_you_can_see[0] + for x in distance_you_can_see[0][0]..distance_you_can_see[0][1] { - if x >= 0 && x < ground_map[z as usize].len() as i16 + if x >= 0 && x < map[z as usize].len() as i16 { - let character: char = ground_map[z as usize][x as usize]; - let mut above_character: char = ' '; - if let Ok(above_element) = function::read_element_from_map(&above_map, z as usize, x as usize) - { - above_character = above_element; - } + let character: char = map[z as usize][x as usize]; // Check if the character is at the current coordinates if z == player_coordinates.z && x == player_coordinates.x { @@ -67,21 +78,6 @@ pub fn output_map( .truecolor(0,0,0) ) } - // Else check if there's something on the above y level - else if blocks.contains_key(&above_character) && above_character != ' ' - { - print! - ( - "{}", - above_character // Output's the current block - .to_string() - .truecolor( - blocks.get(&above_character).unwrap()[0], - blocks.get(&above_character).unwrap()[1], - blocks.get(&above_character).unwrap()[2] - ) - ) - } // Else print what is below (the ground) else if blocks.contains_key(&character) { @@ -91,9 +87,9 @@ pub fn output_map( character // Output's the current block .to_string() .truecolor( - blocks.get(&character).unwrap()[0], - blocks.get(&character).unwrap()[1], - blocks.get(&character).unwrap()[2] + blocks.get(&character).unwrap()[0].0[0], + blocks.get(&character).unwrap()[0].0[1], + blocks.get(&character).unwrap()[0].0[2] ) ) } @@ -106,9 +102,9 @@ pub fn output_map( "X" .to_string() .truecolor( - blocks.get(&'X').unwrap()[0], - blocks.get(&'X').unwrap()[1], - blocks.get(&'X').unwrap()[2] + blocks.get(&'X').unwrap()[0].0[0], + blocks.get(&'X').unwrap()[0].0[1], + blocks.get(&'X').unwrap()[0].0[2] ) ) } diff --git a/src/parse_map.rs b/src/parse_map.rs index b4b4fca..14fcf14 100644 --- a/src/parse_map.rs +++ b/src/parse_map.rs @@ -3,51 +3,30 @@ use crate::Coordinates; // This function reads the map file and puts it into a 2d vector of integers, each integer // Refers to a block (see top comment) and the function returns this vector -pub fn parse_map(player_coordinates: &Coordinates) -> Result<(Vec>, Vec>), u8> +pub fn parse_map(player_coordinates: &Coordinates) -> Result>, u8> { - let mut ground_map: Vec> = Vec::new(); // Initialises the Ground map vector - let mut above_map: Vec> = Vec::new(); // Initialises the Above Ground map vector - let ground_file = format!("data/{}_ground.map",player_coordinates.map); - let above_file = format!("data/{}_above.map",player_coordinates.map); + let mut map: Vec> = Vec::new(); // Initialises the Ground map vector + let map_file = format!("data/{}.map",player_coordinates.map); // Read the ground map file - if let Ok(parsed_ground_file_contents) = fs::read_to_string(&ground_file) + if let Ok(parsed_map_file_contents) = fs::read_to_string(&map_file) { - let ground_file_contents = parsed_ground_file_contents; - let ground_rows = ground_file_contents.split("\n").collect::>(); // Split the file contents into rows + let map_file_contents = parsed_map_file_contents; + let map_rows = map_file_contents.split("\n").collect::>(); // Split the file contents into rows // Loop over each row to parse each column of it - for row in 0..ground_rows.len() + for row in 0..map_rows.len() { // Turn each column into an integer and collect it into a row vector - let current_row = ground_rows[row].chars().collect(); - ground_map.push(current_row); // Then push this vector to the full map vector + let current_row = map_rows[row].chars().collect(); + map.push(current_row); // Then push this vector to the full map vector } } else { - eprintln!("Error: Could not read file: {}", ground_file); - return Err(1) - } - // Read the above ground map file - if let Ok(parsed_above_file_contents) = fs::read_to_string(&above_file) - { - let above_file_contents = parsed_above_file_contents; - let above_rows = above_file_contents.split("\n").collect::>(); // Split the file contents into rows - - // Loop over each row to parse each column of it - for row in 0..above_rows.len() - { - // Turn each column into an integer and collect it into a row vector - let current_row = above_rows[row].chars().collect(); - above_map.push(current_row); // Then push this vector to the full map vector - } - } - else - { - eprintln!("Error: Could not read file: {}", ground_file); + eprintln!("Error: Could not read file: {}", map_file); return Err(1) } - return Ok((ground_map, above_map)) + return Ok(map) } diff --git a/src/process_input.rs b/src/process_input.rs index 05cbe06..dcacc03 100644 --- a/src/process_input.rs +++ b/src/process_input.rs @@ -1,4 +1,6 @@ use std::fs; +use std::collections::HashMap; + use crate::GameAction; use crate::Player; use crate::DEBUG_MODE; @@ -9,8 +11,8 @@ pub fn process_input ( user_input: String, player: &mut Player, - ground_map: &Vec>, - above_map: &Vec>, + map: &Vec>, + blocks: &HashMap>, ) -> GameAction { // Split commands up, so "help && travel 5" > [["help"], ["travel", "5]] @@ -42,21 +44,21 @@ pub fn process_input { match command[0].to_lowercase().as_str() { - "help"|"h" => + "help"|"h"|":h" => if let Ok(help_text) = fs::read_to_string("data/help.txt") // Output text from help file { println!("\n{}", help_text); }, - "exit"|"quit"|"q" => + "exit"|"quit"|"q"|":q"|":wq" => { return GameAction::Exit; }, - "map"|"world" => + "map"|"world"|"m" => { output_map::output_map // Call output_map fuctino from output_map.rs ( - &ground_map, - &above_map, + &map, + &blocks, &player.coordinates, ); // Output the map }, @@ -64,6 +66,25 @@ pub fn process_input { function::clear_screen(); }, + "player" => + { + println!("{:?}", player); + }, + /* + "cut"|"chop"|"mine"|"pick"|"axe"|"destroy" => + { + let vector: &str = command[1]; + + match vector + { + "north"|"n"|"up" |"u" => player.coordinates.z -= 1, + "east" |"e"|"right"|"r" => player.coordinates.x += 1, + "south"|"s"|"down" |"d" => player.coordinates.z += 1, + "west" |"w"|"left" |"l" => player.coordinates.x -= 1, + _ => {println!("Invalid travel direction"); break;}, + } + }, + */ "travel"|"move"|"go" => { let mut magnitude: usize = 1; @@ -96,6 +117,7 @@ pub fn process_input } for _block in 0..magnitude { + // Movement match vector { "north"|"n"|"up" |"u" => player.coordinates.z -= 1, @@ -104,7 +126,10 @@ pub fn process_input "west" |"w"|"left" |"l" => player.coordinates.x -= 1, _ => {println!("Invalid travel direction"); break;}, } - if above_map[player.coordinates.z as usize][player.coordinates.x as usize] != ' ' + + // Collision + let character: char = map[player.coordinates.z as usize][player.coordinates.x as usize]; + if blocks.get(&character).unwrap()[0].1 == true { println!("Bumped into something!"); match vector diff --git a/src/save.rs b/src/save.rs index 8f23d0a..87a857b 100644 --- a/src/save.rs +++ b/src/save.rs @@ -1,4 +1,3 @@ -use serde::{Serialize, Deserialize}; use std::io::{self, Write}; use std::fs::File;