Skip to content

Commit eea05ff

Browse files
committed
chore: simplify shiny rate logic
1 parent 276ba48 commit eea05ff

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

server/src/models/Pokemon.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -612,28 +612,16 @@ class Pokemon extends Model {
612612
}
613613

614614
const statsMap = new Map()
615-
const today = new Date()
616-
today.setHours(0, 0, 0, 0)
617-
const cutoff = new Date(today)
618-
cutoff.setDate(cutoff.getDate() - 1)
619-
const cutoffStr = cutoff.toISOString().slice(0, 10)
620-
621615
grouped.forEach((entries, key) => {
622616
let shinySum = 0
623617
let checkSum = 0
624618
let sinceDate = null
625-
for (let i = 0; i < entries.length; i += 1) {
619+
// 20000 checks would give >99% of distinguishing even 1/512 from 1/256
620+
for (let i = 0; i < entries.length && checkSum < 20000; i++) {
626621
const { shiny, checks, date } = entries[i]
627-
const includeRecent = date >= cutoffStr
628-
// 20000 checks would give >99% of distinguishing even 1/512 from 1/256
629-
if (!includeRecent && checkSum >= 20000) {
630-
break
631-
}
632622
shinySum += shiny
633623
checkSum += checks
634-
if (!sinceDate || date < sinceDate) {
635-
sinceDate = date
636-
}
624+
sinceDate = date
637625
}
638626
statsMap.set(key, {
639627
shiny_seen: shinySum,

0 commit comments

Comments
 (0)