update btw
This commit is contained in:
parent
fa7f748392
commit
427edc6786
3 changed files with 46 additions and 3 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -5,3 +5,19 @@ version = 3
|
|||
[[package]]
|
||||
name = "anydice-rust"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"indexed_string",
|
||||
"scanrs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexed_string"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e14068693e4d4f9c0ab8186f3ecf92f2481847c6569b941a3f826ca410cda059"
|
||||
|
||||
[[package]]
|
||||
name = "scanrs"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff90aa1fb53a5fef7e7d4214413109e9c96670ce8a6fead5045cfe7dcae98b0e"
|
||||
|
|
|
@ -4,3 +4,5 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
indexed_string = "0.1.0"
|
||||
scanrs = "0.3.0"
|
||||
|
|
31
src/main.rs
31
src/main.rs
|
@ -1,18 +1,27 @@
|
|||
use std::collections::BTreeMap;
|
||||
use std::collections::btree_map::Entry;
|
||||
use std::iter;
|
||||
use std::process::exit;
|
||||
use std::io;
|
||||
use std::io::{read_to_string, stdin};
|
||||
use scanrs;
|
||||
use indexed_string::indexed_string::IndexedString;
|
||||
|
||||
|
||||
fn main() {
|
||||
let dice = [6, 6, 6, 6, 7];
|
||||
|
||||
firstinstruction();
|
||||
inputdie();
|
||||
exit(0); // comment this out once i'm done with the other stuff
|
||||
// i need 2 otherwise the for loops below break
|
||||
let comb = combinations(&dice);
|
||||
let comb1 = comb.clone();
|
||||
let comb2 = comb.clone();
|
||||
|
||||
// below code gets total for all values
|
||||
let mut total = 0;
|
||||
|
||||
|
||||
for i in comb {
|
||||
for i in comb1 {
|
||||
total += i.1;
|
||||
}
|
||||
for i in comb2 {
|
||||
|
@ -48,4 +57,20 @@ fn recursive(dice: &[u32], out: &mut BTreeMap<u32, u32>, cur: &[u32]) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn firstinstruction() {
|
||||
println!("\
|
||||
input your dice.
|
||||
e.g. If you want 2x d6 run 2d6. use \"d6\" for single line.
|
||||
You can input one dice instruction per line.
|
||||
When you are done inputting dice, press enter with a blank line to stop input and calculate.");
|
||||
}
|
||||
fn inputdie() {
|
||||
loop {
|
||||
io::stdin();
|
||||
let mut tempinput: String = scanrs::scanln();
|
||||
let mut t2 = IndexedString::from(tempinput);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue