mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-10 17:26:17 +00:00
New structure
This commit is contained in:
26
src/util/state/MobileRetryTracker.ts
Normal file
26
src/util/state/MobileRetryTracker.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export class MobileRetryTracker {
|
||||
private attempts = 0
|
||||
private readonly maxRetries: number
|
||||
|
||||
constructor(maxRetries: number) {
|
||||
const normalized = Number.isFinite(maxRetries) ? Math.floor(maxRetries) : 0
|
||||
this.maxRetries = Math.max(0, normalized)
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an incomplete mobile search attempt.
|
||||
* @returns true when another retry should be attempted, false when the retry budget is exhausted.
|
||||
*/
|
||||
registerFailure(): boolean {
|
||||
this.attempts += 1
|
||||
return this.attempts <= this.maxRetries
|
||||
}
|
||||
|
||||
hasExceeded(): boolean {
|
||||
return this.attempts > this.maxRetries
|
||||
}
|
||||
|
||||
getAttemptCount(): number {
|
||||
return this.attempts
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user