diff options
author | Guillaume Pasquet <dev@etenil.net> | 2019-11-18 05:57:17 +0000 |
---|---|---|
committer | Guillaume Pasquet <dev@etenil.net> | 2019-11-18 05:57:17 +0000 |
commit | 057ca8bf3485b1d3b4d41e186780b9ee4d689f3c (patch) | |
tree | 3a0dee1daca3b5ab5bfb309477674e5cc652bec6 | |
parent | dab25fd352aaf46ec098e1c77494a36b2638ed07 (diff) |
Fix formatting
-rw-r--r-- | src/main.rs | 22 | ||||
-rw-r--r-- | src/state.rs | 18 | ||||
-rw-r--r-- | src/world.rs | 6 |
3 files changed, 22 insertions, 24 deletions
diff --git a/src/main.rs b/src/main.rs index fcab47b..8488a2e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,15 +7,15 @@ mod state; mod tiling; mod world; +use crossterm::cursor; +use crossterm::input::{input, InputEvent, KeyEvent}; +use crossterm::screen::{EnterAlternateScreen, LeaveAlternateScreen, RawScreen}; +use crossterm::terminal; +use crossterm::{execute, Output}; use entities::{Entity, Player}; use state::State; use std::env; use std::io::{stdout, Write}; -use crossterm::{execute, Output}; -use crossterm::cursor; -use crossterm::screen::{EnterAlternateScreen, LeaveAlternateScreen, RawScreen}; -use crossterm::input::{input, InputEvent, KeyEvent}; -use crossterm::terminal; use world::{Dungeon, DOWN, LEFT, RIGHT, UP}; fn get_player_name() -> String { @@ -30,11 +30,7 @@ fn main() { let mut state = State::new( Player::new(get_player_name(), String::from("Warrior"), 30, 10, 10, 20), - Dungeon::new( - term_size.0 as usize, - (term_size.1 - 2) as usize, - 5, - ), + Dungeon::new(term_size.0 as usize, (term_size.1 - 2) as usize, 5), ); state.init(); @@ -58,12 +54,14 @@ fn main() { if let Some(event) = reader.next() { match event { InputEvent::Keyboard(KeyEvent::Char('q')) => break, - InputEvent::Keyboard(KeyEvent::Char('?')) => execute!(stdout(), Output("q: quit")).unwrap(), + InputEvent::Keyboard(KeyEvent::Char('?')) => { + execute!(stdout(), Output("q: quit")).unwrap() + } InputEvent::Keyboard(KeyEvent::Char('j')) => state.player.move_by(DOWN).unwrap(), InputEvent::Keyboard(KeyEvent::Char('k')) => state.player.move_by(UP).unwrap(), InputEvent::Keyboard(KeyEvent::Char('h')) => state.player.move_by(LEFT).unwrap(), InputEvent::Keyboard(KeyEvent::Char('l')) => state.player.move_by(RIGHT).unwrap(), - _ => () + _ => (), } } // actors actions (normally attack / interact if on same location as the character) diff --git a/src/state.rs b/src/state.rs index 038f46f..3cc7c05 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,6 +1,6 @@ -use std::io::{stdout, Write}; +use crossterm::cursor::MoveTo; use crossterm::{queue, Output}; -use crossterm::cursor::{MoveTo}; +use std::io::{stdout, Write}; use crate::entities::{Character, Entity}; use crate::tiling::{tile_to_str, TileGrid}; @@ -43,11 +43,7 @@ impl State { for chr in linestr { linestr2.push_str(chr); } - queue!( - sout, - Output(linestr2), - MoveTo(0, linenum as u16) - ).unwrap(); + queue!(sout, Output(linestr2), MoveTo(0, linenum as u16)).unwrap(); sout.flush().unwrap(); } } @@ -63,9 +59,13 @@ impl State { sout, MoveTo(dirt.0 as u16, dirt.1 as u16), Output(tile_to_str(background)), - MoveTo(entity.get_location().0 as u16, entity.get_location().1 as u16), + MoveTo( + entity.get_location().0 as u16, + entity.get_location().1 as u16 + ), Output(tile_to_str(entity.get_tiletype())) - ).unwrap(); + ) + .unwrap(); sout.flush().unwrap(); } diff --git a/src/world.rs b/src/world.rs index 96c928d..369fd59 100644 --- a/src/world.rs +++ b/src/world.rs @@ -471,16 +471,16 @@ mod tests { let exp_horz = vec![ Corridor::new((0, 0), 5, CorridorType::Horizontal), - Corridor::new((5, 0), 5, CorridorType::Vertical) + Corridor::new((5, 0), 5, CorridorType::Vertical), ]; let exp_vert = vec![ Corridor::new((0, 0), 5, CorridorType::Vertical), - Corridor::new((0, 5), 5, CorridorType::Horizontal) + Corridor::new((0, 5), 5, CorridorType::Horizontal), ]; match cor[0].direction { CorridorType::Horizontal => assert_eq!(cor, exp_horz), - CorridorType::Vertical => assert_eq!(cor, exp_vert) + CorridorType::Vertical => assert_eq!(cor, exp_vert), }; } |