Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions factorion-bot-discord/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "factorion-bot-discord"
version = "2.3.1"
version = "2.4.0"
edition = "2024"
description = "factorion-bot (for factorials and related) on Discord"
license = "MIT"
Expand All @@ -10,7 +10,7 @@ keywords = ["factorial", "termial", "bot", "math", "discord"]
categories = ["mathematics", "web-programming", "parser-implementations"]

[dependencies]
factorion-lib = { path = "../factorion-lib", version = "4.3.1", features = ["serde", "influxdb"] }
factorion-lib = { path = "../factorion-lib", version = "4.4.0", features = ["serde", "influxdb"] }
serenity = { version = "0.12", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "cache"] }
tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread", "time"] }
dotenvy = "^0.15.7"
Expand Down
4 changes: 2 additions & 2 deletions factorion-bot-reddit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "factorion-bot-reddit"
version = "5.4.1"
version = "5.5.0"
edition = "2024"
description = "factorion-bot (for factorials and related) on Reddit"
license = "MIT"
Expand All @@ -10,7 +10,7 @@ keywords = ["factorial", "termial", "bot", "math"]
categories = ["mathematics", "web-programming", "parser-implementations"]

[dependencies]
factorion-lib = {path = "../factorion-lib", version = "4.3.1", features = ["serde", "influxdb"]}
factorion-lib = {path = "../factorion-lib", version = "4.4.0", features = ["serde", "influxdb"]}
reqwest = { version = "0.12.28", features = ["json", "native-tls"], default-features = false }
serde = { version = "1.0.219", default-features = false, features = ["derive"] }
serde_json = "1.0.140"
Expand Down
2 changes: 1 addition & 1 deletion factorion-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "factorion-lib"
version = "4.3.1"
version = "4.4.0"
edition = "2024"
description = "A library used to create bots to recognize and calculate factorials and related concepts"
license = "MIT"
Expand Down
56 changes: 51 additions & 5 deletions factorion-lib/src/calculation_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,31 @@ impl Calculation {
"", "mill", "bill", "trill", "quadrill", "quintill", "sextill", "septill", "octill",
"nonill",
];
const BINDING_T: [[bool; 10]; 4] = [
const TEN_THOUSANDS: [&str; 10] = [
"",
"decill",
"vigintill",
"trigintill",
"quadragintill",
"quinquagintill",
"sexagintill",
"septuagintill",
"octogintill",
"nonagintill",
];
const HUNDRED_THOUSANDS: [&str; 10] = [
"",
"centill",
"ducentill",
"tricentill",
"quadringentill",
"quingentill",
"sescentill",
"septingentill",
"octingentill",
"nongentill",
];
const BINDING_T: [[bool; 10]; 6] = [
// Singles
[
false, false, false, false, false, false, false, false, false, false,
Expand All @@ -448,14 +472,22 @@ impl Calculation {
[
false, false, false, false, false, false, false, false, false, false,
],
// Tenthousands
[
false, false, false, false, false, false, false, false, false, false,
],
// Hundredthousands
[
false, false, false, false, false, false, false, false, false, false,
],
];
if let Some(s) = locale.num_overrides().get(&level) {
return s.as_ref().into();
}
match level {
0 => locale.sub().as_ref().into(),
1 => "{factorial}".into(),
..=9999 if !locale.force_num() => {
..=999999 if !locale.force_num() => {
let singles = if level < 10 { SINGLES_LAST } else { SINGLES };
let mut acc = String::new();
let mut n = level;
Expand All @@ -469,9 +501,15 @@ impl Calculation {
n /= 10;
acc.write_str(HUNDREDS[h as usize]).unwrap();
let th = n % 10;
n /= 10;
acc.write_str(THOUSANDS[th as usize]).unwrap();
let tth = n % 10;
n /= 10;
acc.write_str(TEN_THOUSANDS[tth as usize]).unwrap();
let hth = n % 10;
acc.write_str(HUNDRED_THOUSANDS[hth as usize]).unwrap();
// Check if we need tuple not uple
let last_written = [s, t, h, th]
let last_written = [s, t, h, th, tth, hth]
.iter()
.cloned()
.enumerate()
Expand Down Expand Up @@ -724,8 +762,16 @@ mod tests {
"unvigintricenquadrilluple-{factorial}"
);
assert_eq!(
Calculation::get_factorial_level_string(10000, &en.format()),
"10000-{factorial}"
Calculation::get_factorial_level_string(89342, &en.format()),
"duoquadragintricennonilloctogintilluple-{factorial}"
);
assert_eq!(
Calculation::get_factorial_level_string(654321, &en.format()),
"unvigintricenquadrillquinquagintillsescentilluple-{factorial}"
);
assert_eq!(
Calculation::get_factorial_level_string(1000000, &en.format()),
"1000000-{factorial}"
);
let de = locale::get_de();
assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions factorion-lib/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ fn test_get_reply_for_high_multifactorial() {
meta: (),
calculation_list: vec![Calculation {
value: 10.into(),
steps: vec![(12345, false)],
steps: vec![(1234567, false)],
result: CalculationResult::Exact(Integer::from(10)),
}],
notify: None,
Expand All @@ -1056,7 +1056,7 @@ fn test_get_reply_for_high_multifactorial() {
let reply = comment.get_reply(&consts);
assert_eq!(
reply,
"12345-factorial of 10 is 10 \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*"
"1234567-factorial of 10 is 10 \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*"
);
}

Expand Down