Bläddra i källkod

Start working on classes

main
Noëlle 3 år sedan
förälder
incheckning
67ba11811a
2 ändrade filer med 30 tillägg och 6 borttagningar
  1. 2
    1
      Cargo.toml
  2. 28
    5
      src/main.rs

+ 2
- 1
Cargo.toml Visa fil

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


[dependencies] [dependencies]
rand = "0.8.3"
rand = "0.8.3"
dict = "0.1.5"

+ 28
- 5
src/main.rs Visa fil

use rand::{ distributions:: {Distribution, Standard},
Rng
};
use rand::{ distributions:: {Distribution, Standard}, Rng };
//use dict::{ Dict, DictIface };
//use std::collections::HashMap;


#[derive(Debug)]
#[derive(Debug, Hash)]
enum Cls { enum Cls {
Artificer,
Artificer = 0,
Barbarian, Barbarian,
Bard, Bard,
Cleric, Cleric,
Wizard Wizard
} }


impl PartialEq for Cls {
fn eq(&self, other: &Self) -> bool {
self == other
}
}

impl Default for Cls { impl Default for Cls {
fn default() -> Self { Cls::Fighter } fn default() -> Self { Cls::Fighter }
} }
self.class = rand::random(); self.class = rand::random();
} }
fn gen_stats(&mut self) { fn gen_stats(&mut self) {
let associated_stats = vec![
[3,1,2,5,4,0],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
];
// println!("{:?}", associated_stats);
self.strength = roll_stat(); self.strength = roll_stat();
self.dexterity = roll_stat(); self.dexterity = roll_stat();
self.constitution = roll_stat(); self.constitution = roll_stat();
chr.pick_class(); chr.pick_class();
chr.gen_stats(); chr.gen_stats();
println!("{:?}", chr); println!("{:?}", chr);
println!("{:?}", chr.class as u32);
} }

Laddar…
Avbryt
Spara