diff --git a/Cargo.lock b/Cargo.lock index 50759bf..97f87dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -399,7 +399,7 @@ dependencies = [ [[package]] name = "factorion-bot-discord" -version = "2.3.1" +version = "2.4.0" dependencies = [ "anyhow", "dotenvy", @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "factorion-bot-reddit" -version = "5.4.1" +version = "5.5.0" dependencies = [ "anyhow", "base64 0.22.1", @@ -434,7 +434,7 @@ dependencies = [ [[package]] name = "factorion-lib" -version = "4.3.1" +version = "4.4.0" dependencies = [ "arbtest", "chrono", diff --git a/factorion-bot-discord/Cargo.toml b/factorion-bot-discord/Cargo.toml index be47566..dc3805d 100644 --- a/factorion-bot-discord/Cargo.toml +++ b/factorion-bot-discord/Cargo.toml @@ -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" @@ -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" diff --git a/factorion-bot-reddit/Cargo.toml b/factorion-bot-reddit/Cargo.toml index 452f00b..e9e7f72 100644 --- a/factorion-bot-reddit/Cargo.toml +++ b/factorion-bot-reddit/Cargo.toml @@ -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" @@ -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" diff --git a/factorion-lib/Cargo.toml b/factorion-lib/Cargo.toml index 199a304..f40cb22 100644 --- a/factorion-lib/Cargo.toml +++ b/factorion-lib/Cargo.toml @@ -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" diff --git a/factorion-lib/src/calculation_results.rs b/factorion-lib/src/calculation_results.rs index ea4400f..6b35044 100644 --- a/factorion-lib/src/calculation_results.rs +++ b/factorion-lib/src/calculation_results.rs @@ -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, @@ -448,6 +472,14 @@ 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(); @@ -455,7 +487,7 @@ impl Calculation { 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; @@ -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() @@ -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!( diff --git a/factorion-lib/tests/integration.rs b/factorion-lib/tests/integration.rs index 768c42d..0300b0c 100644 --- a/factorion-lib/tests/integration.rs +++ b/factorion-lib/tests/integration.rs @@ -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, @@ -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))*" ); }