inexplicably, this runs right now
All checks were successful
Continuous Releases / build (windows) (push) Successful in 6s

This commit is contained in:
Lauren Kaviak
2026-03-22 01:01:27 -05:00
parent d37c4fdb4b
commit 7e41aecd56

View File

@@ -1,3 +1,5 @@
use rand::prelude::*;
pub enum StandardSkills { pub enum StandardSkills {
Acrobatics, Acrobatics,
AnimalHandling, AnimalHandling,
@@ -78,11 +80,133 @@ pub trait Skill {
fn is_save(&self) -> bool; fn is_save(&self) -> bool;
} }
// pub trait SkillSet { pub struct DieRoll {
// fn get_skill() { sides: u8,
count: u8
}
// } pub struct RollCalculation {
// } rolls: Vec<DieRoll>,
modifier: i8
}
pub struct RollResult {
total: i32,
calculation: RollCalculation
}
pub trait Rollable {
fn calculation(&self) -> RollCalculation;
fn roll(&self) -> i32 {
let calculation = self.calculation();
let mut total : i32 = calculation.modifier as i32;
let mut _rng = rand::rng();
for die in calculation.rolls {
for _ in 0..die.count {
total += (rand::random::<u8>() % die.sides + 1) as i32;
}
}
return total;
}
}
impl Rollable for DieRoll {
fn calculation(&self) -> RollCalculation {
return RollCalculation {
rolls: vec![DieRoll { sides: self.sides, count: self.count }],
modifier: 0
}
}
}
pub trait ShortRestRecovery {
fn on_short_rest(&mut self);
}
pub trait LongRestRecovery {
fn on_long_rest(&mut self);
}
pub trait LevelAndHitDieManagement {
fn get_hit_die() -> u8;
fn max_hit_die(&self) -> DieRoll {
return DieRoll {
sides: Self::get_hit_die(),
count: self.get_total_levels()
}
}
fn expended_hit_die(&self) -> u8;
fn get_total_levels(&self) -> u8;
fn single_hit_die(&self) -> DieRoll {
return DieRoll {
sides: Self::get_hit_die(),
count: 1
}
}
fn available_hit_die(&self) -> DieRoll {
let max = self.max_hit_die();
let expended = self.expended_hit_die();
return DieRoll {
sides: max.sides,
count: max.count - expended
}
}
fn get_historical_hit_die(&self) -> &Vec<RollResult>;
fn get_total_hp(&self) -> i32 {
let mut max_hp = 0;
let historical_hp_rolls = self.get_historical_hit_die();
for roll in historical_hp_rolls {
max_hp += roll.total;
}
return max_hp;
}
fn level_up(&mut self);
}
pub struct UniversalClass {
levels: u8,
// reset to 0 on long rest
expended_hit_die: u8,
// historical, each should be immutable.
hit_die_history: Vec<RollResult>
}
impl LongRestRecovery for UniversalClass {
fn on_long_rest(&mut self) {
self.expended_hit_die = 0;
}
}
impl LevelAndHitDieManagement for UniversalClass {
fn get_hit_die() -> u8 {
return 6;
}
fn get_total_levels(&self) -> u8 {
return self.levels;
}
fn expended_hit_die(&self) -> u8 {
return self.expended_hit_die;
}
fn get_historical_hit_die(&self) -> &Vec<RollResult> {
return &self.hit_die_history;
}
fn level_up(&mut self) {
self.levels += 1;
let new_hit_die = self.single_hit_die();
self.hit_die_history.push(RollResult {
total: new_hit_die.roll(),
calculation: new_hit_die.calculation()
});
}
}
impl Stat for u8 { impl Stat for u8 {
fn score(&self) -> u8 { fn score(&self) -> u8 {