From d844b6271374578e5aba5de689bd7a80b1f6012b Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 28 Feb 2024 21:49:09 +0800 Subject: [PATCH] lv1 debug --- Cargo.lock | 435 ---------------------------------------------------- Cargo.toml | 6 +- src/name.rs | 249 ++++++++++++++++-------------- 3 files changed, 135 insertions(+), 555 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6bd77f3..12db1e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,60 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" - -[[package]] -name = "cc" -version = "1.0.88" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" - [[package]] name = "cfg-if" version = "1.0.0" @@ -71,40 +17,6 @@ dependencies = [ "powerfmt", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "hermit-abi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60" - -[[package]] -name = "indexmap" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "itoa" version = "1.0.10" @@ -117,61 +29,16 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "libc" -version = "0.2.153" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" -[[package]] -name = "memchr" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" - -[[package]] -name = "miniz_oxide" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "namerena-rs" version = "0.1.0" dependencies = [ - "serde", - "tokio", - "toml", "tracing", "tracing-subscriber", ] @@ -192,25 +59,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -223,29 +71,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.48.5", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -276,27 +101,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "serde" version = "1.0.197" @@ -317,15 +121,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_spanned" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" -dependencies = [ - "serde", -] - [[package]] name = "sharded-slab" version = "0.1.7" @@ -335,31 +130,12 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - [[package]] name = "smallvec" version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" -[[package]] -name = "socket2" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "syn" version = "2.0.51" @@ -412,70 +188,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tokio" -version = "1.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "toml" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - [[package]] name = "tracing" version = "0.1.40" @@ -546,12 +258,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "winapi" version = "0.3.9" @@ -573,144 +279,3 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.3", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.52.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" -dependencies = [ - "windows_aarch64_gnullvm 0.52.3", - "windows_aarch64_msvc 0.52.3", - "windows_i686_gnu 0.52.3", - "windows_i686_msvc 0.52.3", - "windows_x86_64_gnu 0.52.3", - "windows_x86_64_gnullvm 0.52.3", - "windows_x86_64_msvc 0.52.3", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" - -[[package]] -name = "winnow" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4191c47f15cc3ec71fcb4913cb83d58def65dd3787610213c649283b5ce178" -dependencies = [ - "memchr", -] diff --git a/Cargo.toml b/Cargo.toml index 0ffa299..0199fc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,11 +6,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -tokio = { version = "1.35.1", features = ["full"] } +# tokio = { version = "1.35.1", features = ["full"] } -serde = { version = "1.0", features = ["derive"] } +# serde = { version = "1.0", features = ["derive"] } # md-5 = "0.10.6" -toml = "0.8.10" +# toml = "0.8.10" tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["time"] } diff --git a/src/name.rs b/src/name.rs index fda8fa4..918755f 100644 --- a/src/name.rs +++ b/src/name.rs @@ -1,134 +1,149 @@ +use tracing::warn; + +use crate::name; + pub fn median(x: u8, y: u8, z: u8) -> u8 { // std::max(std::min(x, y), std::min(std::max(x, y), z)) x.max(y).max(x.min(y).min(z)) } -/* -function Poly(x) { - var xp = new Array() - for (let y = 0; y < 1034; y++) { - var l = 44 - var i = 0, p = 0, q = 0, r = 0 - var j = y - for (let k = 0; k < 45; k++) { - i++; - if (i > 2) p++; - q = j; - j = j - l + p; - if (j < 0) break; - } - if (i == 1) r = x[q] - if (i > 1) { - r = x[p] * x[p + q] - } - xp[y] = r - } - return xp +#[derive(Debug, Clone)] +pub struct Namer { + pub name: String, + pub team: String, + pub val: [u8; 256], + pub name_base: [u8; 128], + pub name_bytes: [u8; 256], + pub team_bytes: [u8; 256], + pub name_prop: [u8; 8], + pub skl_id: [u8; 40], + pub skl_freq: [u8; 40], } -function onStart() { - var tmp1 = document.getElementById("input").value.trim() - var names = Array.prototype.slice.call(tmp1.split('\n')); - var output = document.getElementById("output") - var dis = document.getElementById("dis") - output.value = '' +impl Namer { + pub fn new(raw_name: &String) -> Option { + let mut val = [0_u8; 256]; + for i in 0..256 { + val[i] = i as u8; + } + let mut name_base = [0_u8; 128]; + let mut name_prop = [0_u8; 8]; + let mut skl_id = [0_u8; 40]; + let mut skl_freq = [0_u8; 40]; - var tmpsize = parseInt(document.getElementById("tmpsize").value.trim()) - var lim = parseInt(document.getElementById("lim").value.trim()) - if (isNaN(lim)) lim = 0 + // name@team + // name + let (name, team) = raw_name.split_once('@').unwrap_or((raw_name, "")); + // len < 256 + if name.len() > 255 { + warn!("Name too long({}): {}", name.len(), name); + return None; + } + let name_len = name.len(); + if team.len() > 255 { + warn!("Team too long({}): {}", team.len(), team); + return None; + } + let team_len = team.len(); - var x = new Array(43) - var name = new Name() - var s = 0, tmp2 = 0, tmp3 = '' - var length = names.length - var Loop = setInterval(function () { - tmp3 = '' - for (let ii = 0; ii < tmpsize; ii++) { - s = tmp2 + ii - var nametmp = Array.prototype.slice.call(names[s].split('@')); - if (nametmp.length < 2) nametmp[1] = nametmp[0] - name.load_team(nametmp[1]) - name.load_name(nametmp[0]) - if (nametmp[1] == "!") name.TV() - var props = name.calc_props() - name.calc_skills() - for (let j = 0; j < 7; j++)props[j] += 36; - x = new Array(44) + let name_bytes = name.as_bytes(); + let team_bytes = team.as_bytes(); + // 转到 256 长度 的 u8 数组 + let name_bytes = { + let mut bytes = [0_u8; 256]; + for i in 0..name_len { + bytes[i] = name_bytes[i]; + } + bytes + }; + let team_bytes = { + let mut bytes = [0_u8; 256]; + for i in 0..team_len { + bytes[i] = team_bytes[i]; + } + bytes + }; - x[0] = props[7] - for (let i = 0; i < 7; i++) { - x[i + 1] = props[i] - } - for (let i = 0; i < 35; i++) { - var cf = 0; - for (let k = 0; k < 16; k++) { - if (name.skill[k] == i) { - x[i + 8] = name.freq[k] - cf = 1; - } - } - if (cf == 0) { - x[i + 8] = 0 - } - } - if (x[32] > 0) {//x[32]>48 - name.load_name(nametmp[0] + '?shadow') - props = name.calc_props() - var shadow_sum = props[7] / 3 - for (let j = 0; j < 7; j++)shadow_sum += props[j] + let mut s = 0_u32; + for i in 0..256 { + s += name_bytes[i] as u32 + val[i] as u32; + s %= 256; + let tmp = val[i]; + val[i] = val[s as usize]; + val[s as usize] = tmp; + } + for _ in 0..2 { + s = 0; + for j in 0..256 { + s += name_bytes[j % name_len] as u32 + val[j] as u32; + s %= 256; + let tmp = val[j]; + val[j] = val[s as usize]; + val[s as usize] = tmp; + } + } + s = 0; + for i in 0..256 { + let m = ((val[i] as u32 * 181 + 160) % 256) as u8; + if m >= 89 && m < 217 { + name_base[s as usize] = m & 63; + } + } - //更新部分 - shadow_sum -= props[6] * 3 - var shadowi = shadow_sum - 210 + let mut prop_cnt = 0; + let mut r = name_base[0..32].to_vec(); + for i in (10..31).step_by(3) { + r[i..i + 3].sort(); + name_prop[prop_cnt] = r[i + 1]; + prop_cnt += 1; + } + r[0..10].sort(); + name_prop[prop_cnt] = 154; + prop_cnt += 1; + for i in 3..7 { + name_prop[prop_cnt - 1] += r[i]; + } + for i in 0..7 { + name_prop[i] += 36; + } - //更新部分 - shadowi = shadowi * x[32] / 100 - x[43] = shadowi.toFixed(3) - } else { - x[43] = 0 - } - if (x[42] > 0) x[42] += 20 + Some(Self { + name: name.to_string(), + team: team.to_string(), + val, + name_base, + name_bytes, + team_bytes, + name_prop, + skl_id, + skl_freq, + }) + } - var xp = Poly(x) - var score = model[0] - var scoreQD = modelQD[0] - for (let i = 0; i < 1034; i++) { - score += xp[i] * model[i + 1] - } - for (let i = 0; i < 1034; i++) { - scoreQD += xp[i] * modelQD[i + 1] - } + pub fn name_len(&self) -> usize { self.name.len() + 1 } - if (score >= lim && x[32] > 48) { - tmp3 += names[s] + ' ' + parseInt(score) + ' ' + parseInt(scoreQD) + ' !幻术\n' - } else if (score >= lim && x[26] > 48) { - tmp3 += names[s] + ' ' + parseInt(score) + ' ' + parseInt(scoreQD) + ' !铁壁\n' - } else if (score >= lim && x[29] > 48) { - tmp3 += names[s] + ' ' + parseInt(score) + ' ' + parseInt(scoreQD) + ' !背刺\n' - } else if (score >= lim && x[11] > 48) { - tmp3 += names[s] + ' ' + parseInt(score) + ' ' + parseInt(scoreQD) + ' !地裂\n' - } else if (score >= lim && x[20] > 48) { - tmp3 += names[s] + ' ' + parseInt(score) + ' ' + parseInt(scoreQD) + ' !加速\n' - } else if (score >= lim) { tmp3 += names[s] + ' ' + parseInt(score) + ' ' + parseInt(scoreQD) + '\n' } - - names[s] = null - s++ - if (ii == tmpsize - 1 || s == length) { - dis.innerText = (s) + ' / ' + length - output.value += tmp3 - } - if (s == length) { - dis.innerText = "测试完成" - clearInterval(Loop) - break - } - } - tmp2 += tmpsize - }, 0) + pub fn team_len(&self) -> usize { self.team.len() + 1 } } -function LoadVersion() { - var dis = document.getElementById("dis") - dis.innerText = "模型版本: " + version + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn basic_new_test() { + let namer = Namer::new(&"x@x".to_string()); + assert!(namer.is_some()); + let namer = namer.unwrap(); + // println!("{:#?}", namer); + assert_eq!(namer.name, "x"); + assert_eq!(namer.team, "x"); + println!("val: {:?}", namer.val); + println!("name_base: {:?}", namer.name_base); + println!("name_bytes: {:?}", namer.name_bytes); + println!("team_bytes: {:?}", namer.team_bytes); + println!("name_prop: {:?}", namer.name_prop); + println!("skl_id: {:?}", namer.skl_id); + println!("skl_freq: {:?}", namer.skl_freq); + } } - */ \ No newline at end of file