text_based_rpg 0.1.0

A text-based RPG game
Documentation
use crate::entity::{monsters, Enemy};
use crate::items::Item;
use crate::weapons::Weapon;
pub mod loot;


pub struct Location {
    pub name: String,
    pub load_entities: fn() -> Vec<Enemy>,
    pub load_loot: fn() -> Vec<Weapon>,
}

pub fn load_locations() -> Vec<Location> {
    let mut locations = Vec::new();
    let greater_taiga: Location = Location {
        name: String::from("Greater Taiga"),
        load_entities: monsters::greater_taiga::get_greater_taiga_entities,
        load_loot: loot::get_greater_taiga_weapons,
    };

    locations.push(greater_taiga);

    return locations;
}

mod tests {
    use super::Location;
    use crate::entity::{monsters::greater_taiga, Enemy};

    #[test]
    fn load_greater_taiga_entities() {
        let greater_taiga = Location {
            name: "Greater Taiga".to_string(),
            load_entities: greater_taiga::get_greater_taiga_entities,
            load_loot: || vec![],
        };

        let entities = (greater_taiga.load_entities)();

        assert!(!entities.is_empty(), "No entities loaded for Greater Taiga");
    }
}