Skip to main content

kingslayer/
lib.rs

1//! Kingslayer is a text-based dungeon crawler adventure game and game engine
2
3pub use cli::Cli;
4pub use entity::{
5    item::{Armor, Container, Gold, Thing, Weapon},
6    Element, Enemy, Item,
7};
8pub use input::{CmdTokens, Lexer};
9pub use types::EnemyStatus;
10
11/// A command line interface for controlling interactions between objects in a game
12mod cli;
13
14/// Various different kinds of repetitive entities that make up a World
15mod entity;
16
17/// Methods for reading, lexing, and parsing user input
18mod input;
19
20/// A Player's inventory
21mod inventory;
22
23/// An abstraction of the player's interactions with the World
24mod player;
25
26/// Useful types used throughout the crate
27mod types;
28
29/// Manages the map of Rooms
30mod world;
31
32use rand::Rng;
33
34fn dice_roll(num_rolls: u32, num_sides: u32) -> u32 {
35    (0..num_rolls).fold(0, |sum, _| {
36        sum + rand::thread_rng().gen_range(1..=num_sides)
37    })
38}