made bot in four hours
can run roll and random
This commit is contained in:
@@ -0,0 +1 @@
|
||||
trait Die {}
|
||||
@@ -0,0 +1,34 @@
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum DieType {
|
||||
DieFour,
|
||||
DieSix,
|
||||
DieEight,
|
||||
DieTen,
|
||||
DieTwelve,
|
||||
DieTwenty,
|
||||
}
|
||||
|
||||
impl DieType {
|
||||
pub fn from_sides(sides: i32) -> Option<DieType> {
|
||||
match sides {
|
||||
4 => Some(DieType::DieFour),
|
||||
6 => Some(DieType::DieSix),
|
||||
8 => Some(DieType::DieEight),
|
||||
10 => Some(DieType::DieTen),
|
||||
12 => Some(DieType::DieTwelve),
|
||||
20 => Some(DieType::DieTwenty),
|
||||
_ => None, // Return None for values that don't map to a die
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_sides(&self) -> i32 {
|
||||
match self {
|
||||
DieType::DieFour => 4,
|
||||
DieType::DieSix => 6,
|
||||
DieType::DieEight => 8,
|
||||
DieType::DieTen => 10,
|
||||
DieType::DieTwelve => 12,
|
||||
DieType::DieTwenty => 20,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
pub mod die;
|
||||
pub mod dietype;
|
||||
Reference in New Issue
Block a user