going to bed soon
This commit is contained in:
parent
b0318ab4da
commit
8b8d493df2
@ -6,17 +6,17 @@
|
||||
},
|
||||
"coordinates": {
|
||||
"x": 85,
|
||||
"z": 17,
|
||||
"z": 25,
|
||||
"map": "world"
|
||||
},
|
||||
"inventory": [
|
||||
[
|
||||
"axe",
|
||||
"Steel Axe",
|
||||
1
|
||||
],
|
||||
[
|
||||
"vape",
|
||||
1
|
||||
"Morphine",
|
||||
2
|
||||
]
|
||||
]
|
||||
}
|
@ -21,4 +21,12 @@ lazy_static! {
|
||||
map.insert('♣', vec![([0, 153, 51], true, "Oak Tree")]);
|
||||
map
|
||||
};
|
||||
pub static ref SKILLABLE: HashMap<char, Vec<(&'static str, u64, Vec<&'static str>)>> = {
|
||||
let mut map = HashMap::new();
|
||||
map.insert('D', vec![("mining", 15, vec!["Steel Pickaxe"])]);
|
||||
map.insert('C', vec![("mining", 5, vec!["Bronze Pickaxe", "Steel Pickaxe"])]);
|
||||
map.insert('i', vec![("mining", 10, vec!["Bronze Pickaxe", "Steel Pickaxe"])]);
|
||||
map.insert('♣', vec![("woodcutting", 5, vec!["Bronze Axe", "Steel Axe"])]);
|
||||
map
|
||||
};
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
use std::io::{stdin,stdout,Write};
|
||||
use crate::Command;
|
||||
use crate::data;
|
||||
use crate::Player;
|
||||
|
||||
pub fn input() -> String{
|
||||
let mut s=String::new();
|
||||
@ -23,3 +25,44 @@ pub fn clear_screen()
|
||||
.expect("Failed to clear screen");
|
||||
}
|
||||
|
||||
pub fn skill_item
|
||||
(
|
||||
direction: char,
|
||||
player: &Player,
|
||||
map: &Vec<Vec<char>>,
|
||||
)
|
||||
{
|
||||
let mut block: char = 'X';
|
||||
if direction == 'n'
|
||||
{
|
||||
block = map[(player.coordinates.z - 1) as usize][player.coordinates.x as usize];
|
||||
}
|
||||
else if direction == 'e'
|
||||
{
|
||||
block = map[player.coordinates.z as usize][(player.coordinates.x + 1) as usize];
|
||||
}
|
||||
else if direction == 's'
|
||||
{
|
||||
block = map[(player.coordinates.z + 1) as usize][player.coordinates.x as usize];
|
||||
}
|
||||
else if direction == 'w'
|
||||
{
|
||||
block = map[player.coordinates.z as usize][(player.coordinates.x - 1) as usize];
|
||||
}
|
||||
else
|
||||
{
|
||||
println!("Invalid Direction");
|
||||
}
|
||||
/*
|
||||
if blocks::SKILLABLE.contains_key(&block)
|
||||
{
|
||||
println!("Skilling {} to the {}.", blocks::BLOCKS.get(&block).unwrap()[0].2, direction);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
println!("Block: {} to the {} is not skillable.", blocks::BLOCKS.get(&block).unwrap()[0].2, direction);
|
||||
return ();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
27
src/main.rs
27
src/main.rs
@ -13,28 +13,33 @@ mod process_input; // process_input.rs
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
mod blocks;
|
||||
mod data;
|
||||
|
||||
pub enum GameAction {
|
||||
pub enum GameAction
|
||||
{
|
||||
Continue,
|
||||
Exit,
|
||||
Error,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Coordinates {
|
||||
struct Skills
|
||||
{
|
||||
woodcutting: u64,
|
||||
mining: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Coordinates
|
||||
{
|
||||
x: i16,
|
||||
z: i16,
|
||||
map: String,
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Skills {
|
||||
woodcutting: u8,
|
||||
mining: u8,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Player {
|
||||
struct Player
|
||||
{
|
||||
name: String,
|
||||
skills: Skills,
|
||||
coordinates: Coordinates,
|
||||
@ -65,7 +70,7 @@ fn main()
|
||||
output_map::output_map // Call output_map fuctino from output_map.rs
|
||||
(
|
||||
&map,
|
||||
&blocks::BLOCKS,
|
||||
&data::BLOCKS,
|
||||
&player.coordinates,
|
||||
); // Output the map
|
||||
'game_loop: loop
|
||||
@ -77,7 +82,7 @@ fn main()
|
||||
user_input,
|
||||
&mut player,
|
||||
&map,
|
||||
&blocks::BLOCKS,
|
||||
&data::BLOCKS,
|
||||
);
|
||||
|
||||
if let Err(e) = save::save(&save_file_path, &player)
|
||||
|
@ -70,21 +70,19 @@ pub fn process_input
|
||||
{
|
||||
println!("{:?}", player);
|
||||
},
|
||||
/*
|
||||
"cut"|"chop"|"mine"|"pick"|"axe"|"destroy" =>
|
||||
"cut"|"chop"|"mine"|"pick"|"axe"|"destroy"|"skill" =>
|
||||
{
|
||||
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;},
|
||||
"north"|"n"|"up" |"u" => function::skill_item('n', &player, &map),
|
||||
"east" |"e"|"right"|"r" => function::skill_item('e', &player, &map),
|
||||
"south"|"s"|"down" |"d" => function::skill_item('s', &player, &map),
|
||||
"west" |"w"|"left" |"l" => function::skill_item('w', &player, &map),
|
||||
_ => {println!("Invalid direction"); break;},
|
||||
}
|
||||
},
|
||||
*/
|
||||
"travel"|"move"|"go" =>
|
||||
{
|
||||
let mut magnitude: usize = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user