From 119a3d314aea30d0990f9e4e476ba76230c5ff45 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Sun, 14 Jan 2024 13:31:40 +0100 Subject: [PATCH] clean up some warnings --- src/dungeon_slayer.rs | 3 +++ src/level.rs | 5 ----- src/level_generator.rs | 3 +-- src/monster.rs | 6 +++--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/dungeon_slayer.rs b/src/dungeon_slayer.rs index 7a364bf..e245020 100644 --- a/src/dungeon_slayer.rs +++ b/src/dungeon_slayer.rs @@ -1,5 +1,6 @@ use rand::Rng; + pub fn do_challenge(stat: u8) -> (bool, u8) { if stat <= 20 { let mut rng = rand::thread_rng(); @@ -19,6 +20,7 @@ pub fn do_challenge(stat: u8) -> (bool, u8) { (false, 0) } +#[allow(dead_code)] pub struct PlayerStats { // dungeon slayer attributes pub(crate) body: u8, @@ -93,6 +95,7 @@ impl PlayerStats { } } +#[allow(dead_code)] pub struct MonsterStats { // dungeon slayer attributes pub(crate) body: u8, diff --git a/src/level.rs b/src/level.rs index 05fb81e..3f07f95 100644 --- a/src/level.rs +++ b/src/level.rs @@ -1,8 +1,5 @@ use std::cmp::{max, min}; -use rand::Rng; -use rand::rngs::ThreadRng; - #[cfg(test)] use crate::artifacts::{Chest, Potion}; use crate::artifacts::Artifact; @@ -38,7 +35,6 @@ pub struct Level { pub(crate) start: (usize, usize), /// the position of the end in the level (either stair down or end point) pub(crate) end: (usize, usize), - pub(crate) rng: ThreadRng, } impl Level { @@ -210,7 +206,6 @@ impl Level { artifacts: Vec::with_capacity(10), start: (0, 0), end: (0, 0), - rng: rand::thread_rng(), } } #[cfg(test)] diff --git a/src/level_generator.rs b/src/level_generator.rs index 19ffa2e..1fa12c3 100644 --- a/src/level_generator.rs +++ b/src/level_generator.rs @@ -11,7 +11,7 @@ use rand::rngs::ThreadRng; use crate::artifacts::{Artifact, Chest, Potion}; use crate::level::{Level, StructureElement}; -use crate::monster::{LowerDaemon, Monster, Orc, Rat}; +use crate::monster::{LowerDaemon, Monster, Rat}; use crate::position::Position; const ROOMS_VERTICAL: usize = 7; @@ -344,7 +344,6 @@ impl LevelGenerator { artifacts, start: (start_x, start_y), end: (end_x, end_y), - rng: rand::thread_rng(), } } } diff --git a/src/monster.rs b/src/monster.rs index 0313186..eba28bc 100644 --- a/src/monster.rs +++ b/src/monster.rs @@ -98,7 +98,7 @@ impl crate::monster::LowerDaemon { } } - fn calc_move(&self, level: &Level, player_pos: &Position) -> (i16, i16) { + fn calc_move(&self, _level: &Level, player_pos: &Position) -> (i16, i16) { let d = self.position.distance(player_pos); if d == 1 { return self.position.get_direction(player_pos); @@ -160,7 +160,7 @@ impl Rat { monster_stats, } } - fn calc_move(&self, level: &Level, player_pos: &Position) -> (i16, i16) { + fn calc_move(&self, _level: &Level, _player_pos: &Position) -> (i16, i16) { match rand::thread_rng().gen_range(0..5) { 1 => { (1, 0) } 2 => { (-1, 0) } @@ -218,7 +218,7 @@ impl Orc { monster_stats, } } - fn calc_move(&self, level: &Level, player_pos: &Position) -> (i16, i16) { + fn calc_move(&self, _level: &Level, _player_pos: &Position) -> (i16, i16) { match rand::thread_rng().gen_range(0..5) { 1 => { (1, 0) } 2 => { (-1, 0) }