mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-09-13 04:19:08 +00:00
Ported loldle game module with full classic-mode comparison engine: 4 commands (3 public + /loldle_setmax private), 7-attribute comparison (gender/species/range_type/resource/regions/positions/release_date) with exact/multi/year scoring, 172-champion dictionary, and sticker pools by outcome. Fixed winRate display discrepancy: JS uses Math.round but Go was using int(...) truncation. Applied math.Round in both loldle and wordle handlers. Rendered output now matches expected percentages (e.g. 67% instead of 66%). Includes comparison/lookup/flavor/state/render golden tests, keylock fan-out tests, and strict render-alignment validation.
21 lines
601 B
Go
21 lines
601 B
Go
package loldle
|
|
|
|
import "strings"
|
|
|
|
// normalize folds a name into a comparable form: lowercase, alphanumeric only.
|
|
// JS parity with util/normalize-name.js — `String(s).toLowerCase().replace(/[^a-z0-9]/g, "")`.
|
|
//
|
|
// Used for case/space/punctuation-insensitive name lookup so "Kai'Sa",
|
|
// "kaisa", and "KAI SA" all collapse to the same key.
|
|
func normalize(s string) string {
|
|
lower := strings.ToLower(s)
|
|
out := make([]byte, 0, len(lower))
|
|
for i := 0; i < len(lower); i++ {
|
|
c := lower[i]
|
|
if (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') {
|
|
out = append(out, c)
|
|
}
|
|
}
|
|
return string(out)
|
|
}
|