use std::io::*;
use rand::rngs::ThreadRng;
use rand::{Rng, rng};
use rand::distr::{Distribution, Uniform};
const ARRAY_SIZE: u64 = 100;
//ADD THESE TO MAIN LATER
static mut selections:bool = false;
static mut endRolls:bool = false;
static mut roll:bool = false;
#[derive(Debug)]
struct DiceCollection{
DiceName: &'static str,
DiceNum: &'static [i32],
size: u64
}
struct DiceRolling{
DiceName: String,
DiceNum: u64,
next: Option<Box<DiceRolling>>
}
const diceCol: [DiceCollection; 7] = [
DiceCollection { DiceName: "D4", DiceNum: &[1,2,3,4] , size: 4},
DiceCollection { DiceName: "D6", DiceNum: &[1,2,3,4,5,6] , size: 6},
DiceCollection { DiceName: "D8", DiceNum: &[1,2,3,4,5,6,7,8] , size: 8},
DiceCollection { DiceName: "D10", DiceNum: &[1,2,3,4,5,6,7,8,9,10] , size: 10},
DiceCollection { DiceName: "D12", DiceNum: &[1,2,3,4,5,6,7,8,9,10,11,12] , size: 12},
DiceCollection { DiceName: "D20", DiceNum: &[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] , size: 20},
DiceCollection { DiceName: "D10", DiceNum: &[10,20,30,40,50,60,70,80,90,100] , size: 10},
];
fn main() {
//Allows me to check global variables will change later on
unsafe{
while !selections{
println!("select between dice or docuement");
println!("please input your option?");
let mut selection: String = String::new();
std::io::stdin()
.read_line(&mut selection) // Read the line and append it to the string
.expect("Failed to read line"); // Handle potential errors
if selection.trim() == "dice"{
RollDie();
}else if selection.trim() == "document"{
Document();
}
else if selection.trim() == "exit"{
selections = true;
}
else{
println!("invalid selection, please choose dice or docuement");
}
}
}
}
fn RollDie(){
println!("Test");
println!("Username: {:?}", diceCol.get(0).unwrap().DiceNum[1]);
unsafe{
while !endRolls{
let selection: String;
let mut counter: i32 = 0;
let mut selectionInt: i32;
//Set Dicea head as a null equivalent
let DiceHead: DiceRolling= DiceRolling{
DiceName: String::from(""),
DiceNum: 0,
next: None
};
while !roll && !endRolls{
println!("Choose a Die(1-7), type *end* to end rolls, type roll to keep rolling: ");
let mut selection: String = String::new();
//Collects user input
std::io::stdin()
.read_line(&mut selection) // Read the line and append it to the string
.expect("Failed to read line"); // Handle potential errors
//user option to roll or not
if selection.trim() == "end"{
endRolls = true;
} else if selection.trim() == "roll"{
roll = true;
}else{//allows the roll associated with a numbber
selectionInt = selection.trim().parse::<i32>().expect("failed to parse");
selectionInt = selectionInt -1;
}
counter+= 1;
let mut rng: ThreadRng = rng();
let mut dev1: i32 = rng.gen();
}
}
}
}
fn Document(){
println!("Test2");
}