Struct data::GameData

source ·
pub struct GameData {
    pub monster_data: Info,
    pub breed_formulae: Vec<Formula>,
    pub skills: HashMap<String, Skill>,
}
Expand description

All DWM2 game data. This is the entry point of the whole library.

Fields§

§monster_data: Info

Data about monsters

§breed_formulae: Vec<Formula>

All breed formulae

§skills: HashMap<String, Skill>

All skills

Implementations§

source§

impl GameData

source

pub fn fromXML(x: &[u8]) -> Result<Self, Error>

Create a GameData from XML.

source

pub fn family(&self, name: &str) -> Option<&Family>

Find familiy by name.

source

pub fn monster(&self, name: &str) -> Option<&Monster>

Find monster by name.

source

pub fn skill(&self, name: &str) -> Option<&Skill>

Find skill by name.

source

pub fn monstersWithSkill<'a>( &'a self, skill_name: &'a str ) -> impl Iterator<Item = &Monster> + 'a

Find all monsters having a skill natrually.

source

pub fn monstersInFamily<'a>( &'a self, family: &'a Family ) -> impl Iterator<Item = &Monster> + 'a

Find all monsters in a family.

source

pub fn usedInFormulae<'a>( &'a self, parent: &'a Parent ) -> impl Iterator<Item = &Formula> + 'a

Find all the formulae a monster or a family is used in.

source

pub fn breedFromFormulae<'a>( &'a self, offspring: &'a str ) -> impl Iterator<Item = &Formula> + 'a

Find all the formulae that produces a specific monster.

source

pub fn skillUpgradePath<'a>(&'a self, skill: &'a Skill) -> Vec<&'a Skill>

Return the skill update path the skill is in. The result is arranged from weak to strong. Exmaple:

let content = include_bytes!("../../monster-data.xml");
let data = GameData::fromXML(content).unwrap();
let upgrade_path = data.skillUpgradePath(
    data.skill("Infermore").unwrap());
assert_eq!(upgrade_path.iter().map(|s| &s.name).collect::<Vec<&String>>(),
           vec!["Infernos", "Infermore", "Infermost"]);
source

pub fn skillCombinesInto<'a>( &'a self, skill: &'a Skill ) -> impl Iterator<Item = &Skill> + 'a

Return all the skills that skill and its upgrades combines into.

Trait Implementations§

source§

impl Clone for GameData

source§

fn clone(&self) -> GameData

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for GameData

source§

fn default() -> GameData

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.