sorry - swapping from rustfmt to prettier-rust
This commit is contained in:
parent
281396f9ce
commit
c2c7e0bd52
93 changed files with 2797 additions and 2021 deletions
|
|
@ -1,9 +1,9 @@
|
|||
use super::{Map, TileType};
|
||||
use crate::{gamelog, map_builders, OtherLevelPosition, Position, Telepath, Viewshed};
|
||||
use super::{ Map, TileType };
|
||||
use crate::{ gamelog, map_builders, OtherLevelPosition, Position, Telepath, Viewshed };
|
||||
use rltk::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{ Deserialize, Serialize };
|
||||
use specs::prelude::*;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{ HashMap, HashSet };
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||
pub struct MasterDungeonMap {
|
||||
|
|
@ -108,18 +108,42 @@ fn make_scroll_name(rng: &mut RandomNumberGenerator) -> String {
|
|||
}
|
||||
|
||||
const POTION_COLOURS: &[&str] = &[
|
||||
"red", "orange", "yellow", "green", "blue", "indigo", "violet", "black", "white", "silver", "gold", "rainbow",
|
||||
"blood", "purple", "cyan", "brown", "grey", "octarine",
|
||||
"red",
|
||||
"orange",
|
||||
"yellow",
|
||||
"green",
|
||||
"blue",
|
||||
"indigo",
|
||||
"violet",
|
||||
"black",
|
||||
"white",
|
||||
"silver",
|
||||
"gold",
|
||||
"rainbow",
|
||||
"blood",
|
||||
"purple",
|
||||
"cyan",
|
||||
"brown",
|
||||
"grey",
|
||||
"octarine",
|
||||
];
|
||||
const POTION_ADJECTIVES: &[&str] = &[
|
||||
"swirling",
|
||||
"viscous",
|
||||
"effervescent",
|
||||
"slimy",
|
||||
"oily",
|
||||
"metallic",
|
||||
"prismatic",
|
||||
"goopy",
|
||||
];
|
||||
const POTION_ADJECTIVES: &[&str] =
|
||||
&["swirling", "viscous", "effervescent", "slimy", "oily", "metallic", "prismatic", "goopy"];
|
||||
|
||||
fn make_potion_name(rng: &mut RandomNumberGenerator, used_names: &mut HashSet<String>) -> String {
|
||||
loop {
|
||||
let mut name: String =
|
||||
POTION_ADJECTIVES[rng.roll_dice(1, POTION_ADJECTIVES.len() as i32) as usize - 1].to_string();
|
||||
POTION_ADJECTIVES[(rng.roll_dice(1, POTION_ADJECTIVES.len() as i32) as usize) - 1].to_string();
|
||||
name += " ";
|
||||
name += POTION_COLOURS[rng.roll_dice(1, POTION_COLOURS.len() as i32) as usize - 1];
|
||||
name += POTION_COLOURS[(rng.roll_dice(1, POTION_COLOURS.len() as i32) as usize) - 1];
|
||||
name += " potion";
|
||||
|
||||
if !used_names.contains(&name) {
|
||||
|
|
@ -153,7 +177,7 @@ const WAND_TYPES: &[&str] = &[
|
|||
|
||||
fn make_wand_name(rng: &mut RandomNumberGenerator, used_names: &mut HashSet<String>) -> String {
|
||||
loop {
|
||||
let mut name: String = WAND_TYPES[rng.roll_dice(1, WAND_TYPES.len() as i32) as usize - 1].to_string();
|
||||
let mut name: String = WAND_TYPES[(rng.roll_dice(1, WAND_TYPES.len() as i32) as usize) - 1].to_string();
|
||||
name += " wand";
|
||||
|
||||
if !used_names.contains(&name) {
|
||||
|
|
@ -189,12 +213,12 @@ fn transition_to_existing_map(ecs: &mut World, new_id: i32, offset: i32) {
|
|||
for (idx, tt) in map.tiles.iter().enumerate() {
|
||||
if *tt == stair_type {
|
||||
let mut player_position = ecs.write_resource::<Point>();
|
||||
*player_position = Point::new(idx as i32 % w, idx as i32 / w);
|
||||
*player_position = Point::new((idx as i32) % w, (idx as i32) / w);
|
||||
let mut position_components = ecs.write_storage::<Position>();
|
||||
let player_pos_component = position_components.get_mut(*player_entity);
|
||||
if let Some(player_pos_component) = player_pos_component {
|
||||
player_pos_component.x = idx as i32 % w;
|
||||
player_pos_component.y = idx as i32 / w;
|
||||
player_pos_component.x = (idx as i32) % w;
|
||||
player_pos_component.y = (idx as i32) / w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{gamelog, raws, spawner, Clock, Map, RandomNumberGenerator, TakingTurn, LOG_SPAWNING};
|
||||
use crate::{ gamelog, raws, spawner, Clock, Map, RandomNumberGenerator, TakingTurn, LOG_SPAWNING };
|
||||
use specs::prelude::*;
|
||||
|
||||
const TRY_SPAWN_CHANCE: i32 = 70;
|
||||
|
|
@ -48,7 +48,7 @@ fn spawn_random_mob_in_free_nonvisible_tile(ecs: &mut World) {
|
|||
let roll = raws::get_mob_spawn_amount(&mut rng, &spawn_type, player_level);
|
||||
for _i in 0..roll {
|
||||
let idx = get_random_idx_from_tiles(&mut rng, &mut available_tiles);
|
||||
spawn_locations.push((idx as i32 % map.width, idx as i32 / map.width));
|
||||
spawn_locations.push(((idx as i32) % map.width, (idx as i32) / map.width));
|
||||
}
|
||||
// Dropping resources for borrow-checker.
|
||||
std::mem::drop(map);
|
||||
|
|
@ -64,7 +64,7 @@ fn spawn_random_mob_in_free_nonvisible_tile(ecs: &mut World) {
|
|||
&key,
|
||||
None,
|
||||
raws::SpawnType::AtPosition { x: idx.0, y: idx.1 },
|
||||
difficulty,
|
||||
difficulty
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
use rltk::{Algorithm2D, BaseMap, Point};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use rltk::{ Algorithm2D, BaseMap, Point };
|
||||
use serde::{ Deserialize, Serialize };
|
||||
use std::collections::HashSet;
|
||||
pub mod colours;
|
||||
mod glyphs;
|
||||
mod tiletype;
|
||||
pub use tiletype::{tile_cost, tile_opaque, tile_walkable, TileType};
|
||||
pub use tiletype::{ tile_cost, tile_opaque, tile_walkable, TileType };
|
||||
mod interval_spawning_system;
|
||||
pub use interval_spawning_system::try_spawn_interval;
|
||||
pub mod dungeon;
|
||||
pub use dungeon::{level_transition, MasterDungeonMap};
|
||||
pub use dungeon::{ level_transition, MasterDungeonMap };
|
||||
pub mod themes;
|
||||
pub use colours::NON_VISIBLE_MULTIPLIER;
|
||||
|
||||
|
|
@ -65,9 +65,9 @@ impl Map {
|
|||
let mut rng = rltk::RandomNumberGenerator::new();
|
||||
|
||||
for idx in 0..map.colour_offset.len() {
|
||||
let red_roll: f32 = (rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - OFFSET_PERCENT) as f32 / 100f32 + 1.0;
|
||||
let green_roll: f32 = (rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - OFFSET_PERCENT) as f32 / 100f32 + 1.0;
|
||||
let blue_roll: f32 = (rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - OFFSET_PERCENT) as f32 / 100f32 + 1.0;
|
||||
let red_roll: f32 = ((rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - OFFSET_PERCENT) as f32) / 100f32 + 1.0;
|
||||
let green_roll: f32 = ((rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - OFFSET_PERCENT) as f32) / 100f32 + 1.0;
|
||||
let blue_roll: f32 = ((rng.roll_dice(1, TWICE_OFFSET - 1) + 1 - OFFSET_PERCENT) as f32) / 100f32 + 1.0;
|
||||
map.colour_offset[idx] = (red_roll, green_roll, blue_roll);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use super::{colours::*, glyphs::*, Map, Point, TileType};
|
||||
use super::{ colours::*, glyphs::*, Map, Point, TileType };
|
||||
use rltk::prelude::*;
|
||||
use std::ops::{Add, Mul};
|
||||
use std::ops::{ Add, Mul };
|
||||
|
||||
const DARKEN_TILES_BY_DISTANCE: bool = true;
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ pub fn get_tile_renderables_for_id(idx: usize, map: &Map, other_pos: Option<Poin
|
|||
|
||||
// If one of the colours was left blank, make them the same.
|
||||
if fg == RGB::new() {
|
||||
fg = bg
|
||||
fg = bg;
|
||||
} else if bg == RGB::new() {
|
||||
bg = fg;
|
||||
}
|
||||
|
|
@ -22,8 +22,10 @@ pub fn get_tile_renderables_for_id(idx: usize, map: &Map, other_pos: Option<Poin
|
|||
bg = apply_bloodstain_if_necessary(bg, map, idx);
|
||||
(fg, bg) = darken_if_not_visible(fg, bg, map, idx);
|
||||
if other_pos.is_some() && DARKEN_TILES_BY_DISTANCE {
|
||||
let distance =
|
||||
darken_by_distance(Point::new(idx as i32 % map.width, idx as i32 / map.width), other_pos.unwrap());
|
||||
let distance = darken_by_distance(
|
||||
Point::new((idx as i32) % map.width, (idx as i32) / map.width),
|
||||
other_pos.unwrap()
|
||||
);
|
||||
(fg, bg) = (fg.mul(distance), bg.mul(distance));
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +85,7 @@ fn is_revealed_and_wall(map: &Map, x: i32, y: i32) -> bool {
|
|||
}
|
||||
|
||||
fn wall_glyph(map: &Map, x: i32, y: i32) -> rltk::FontCharType {
|
||||
if x < 1 || x > map.width - 2 || y < 1 || y > map.height - 2 as i32 {
|
||||
if x < 1 || x > map.width - 2 || y < 1 || y > map.height - (2 as i32) {
|
||||
return 35;
|
||||
}
|
||||
let mut mask: u8 = 0;
|
||||
|
|
@ -126,16 +128,16 @@ fn wall_glyph(map: &Map, x: i32, y: i32) -> rltk::FontCharType {
|
|||
}
|
||||
|
||||
match mask {
|
||||
0 => 254, // ■ (254) square pillar; but maybe ○ (9) looks better
|
||||
1 => 186, // Wall only to the north
|
||||
2 => 186, // Wall only to the south
|
||||
3 => 186, // Wall to the north and south
|
||||
4 => 205, // Wall only to the west
|
||||
5 => 188, // Wall to the north and west
|
||||
6 => 187, // Wall to the south and west
|
||||
7 => 185, // Wall to the north, south and west
|
||||
8 => 205, // Wall only to the east
|
||||
9 => 200, // Wall to the north and east
|
||||
0 => 254, // ■ (254) square pillar; but maybe ○ (9) looks better
|
||||
1 => 186, // Wall only to the north
|
||||
2 => 186, // Wall only to the south
|
||||
3 => 186, // Wall to the north and south
|
||||
4 => 205, // Wall only to the west
|
||||
5 => 188, // Wall to the north and west
|
||||
6 => 187, // Wall to the south and west
|
||||
7 => 185, // Wall to the north, south and west
|
||||
8 => 205, // Wall only to the east
|
||||
9 => 200, // Wall to the north and east
|
||||
10 => 201, // Wall to the south and east
|
||||
11 => 204, // Wall to the north, south and east
|
||||
12 => 205, // Wall to the east and west
|
||||
|
|
@ -194,7 +196,7 @@ fn wall_glyph(map: &Map, x: i32, y: i32) -> rltk::FontCharType {
|
|||
205 => 202,
|
||||
175 => 204,
|
||||
203 => 204,
|
||||
61 => 205, // NEW cases
|
||||
61 => 205, // NEW cases
|
||||
125 => 205, // NEW cases
|
||||
189 => 205, // NEW cases
|
||||
206 => 205,
|
||||
|
|
@ -204,7 +206,7 @@ fn wall_glyph(map: &Map, x: i32, y: i32) -> rltk::FontCharType {
|
|||
253 => 205,
|
||||
254 => 205,
|
||||
167 => 186, // NSW, NW, SW
|
||||
91 => 186, // NSE, NE, SE
|
||||
91 => 186, // NSE, NE, SE
|
||||
183 => 186, // NSW, NW, SW, NE
|
||||
123 => 186, // NSE, NE, SE, NW
|
||||
231 => 186, // NSW, NW, SW, SE
|
||||
|
|
@ -215,7 +217,7 @@ fn wall_glyph(map: &Map, x: i32, y: i32) -> rltk::FontCharType {
|
|||
191 => 201, // Everything except NW
|
||||
223 => 188, // Everything except SE
|
||||
239 => 200, // Everything except SW
|
||||
_ => 35, // We missed one?
|
||||
_ => 35, // We missed one?
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -251,8 +253,9 @@ pub fn multiply_by_float(rgb: rltk::RGB, offsets: (f32, f32, f32)) -> RGB {
|
|||
|
||||
fn darken_by_distance(pos: Point, other_pos: Point) -> f32 {
|
||||
let distance = DistanceAlg::Pythagoras.distance2d(pos, other_pos) as f32; // Get distance in tiles.
|
||||
let interp_factor = (distance - START_DARKEN_AT_N_TILES)
|
||||
/ (MAX_DARKEN_AT_N_TILES * crate::config::entity::DEFAULT_VIEWSHED_STANDARD as f32 - START_DARKEN_AT_N_TILES);
|
||||
let interp_factor =
|
||||
(distance - START_DARKEN_AT_N_TILES) /
|
||||
(MAX_DARKEN_AT_N_TILES * (crate::config::entity::DEFAULT_VIEWSHED_STANDARD as f32) - START_DARKEN_AT_N_TILES);
|
||||
let interp_factor = interp_factor.max(0.0).min(1.0); // Clamp [0-1]
|
||||
return 1.0 - interp_factor * (1.0 - MAX_DARKENING);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use serde::{ Deserialize, Serialize };
|
||||
|
||||
#[derive(PartialEq, Eq, Hash, Copy, Clone, Serialize, Deserialize)]
|
||||
pub enum TileType {
|
||||
|
|
@ -26,7 +26,7 @@ pub enum TileType {
|
|||
|
||||
pub fn tile_walkable(tt: TileType) -> bool {
|
||||
match tt {
|
||||
TileType::Floor
|
||||
| TileType::Floor
|
||||
| TileType::WoodFloor
|
||||
| TileType::Gravel
|
||||
| TileType::Road
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue