mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 04:52:03 +00:00
feat: add ranked season window policy
This commit is contained in:
@@ -14,6 +14,7 @@ const (
|
||||
GlickoInitialRating = 1500.0
|
||||
GlickoInitialRD = 350.0
|
||||
GlickoInitialVolatility = 0.06
|
||||
RankedSeasonLength = 12 * 7 * 24 * time.Hour
|
||||
)
|
||||
|
||||
type Rating struct {
|
||||
@@ -64,6 +65,24 @@ type RankedProfile struct {
|
||||
SeasonHistory []string
|
||||
}
|
||||
|
||||
type RankedSeason struct {
|
||||
SeasonID string
|
||||
StartsAt time.Time
|
||||
EndsAt time.Time
|
||||
RolledOverAt time.Time
|
||||
}
|
||||
|
||||
func NewRankedSeason(seasonID string, startsAt time.Time) (RankedSeason, error) {
|
||||
if seasonID == "" || startsAt.IsZero() {
|
||||
return RankedSeason{}, fmt.Errorf("invalid ranked season")
|
||||
}
|
||||
return RankedSeason{SeasonID: seasonID, StartsAt: startsAt, EndsAt: startsAt.Add(RankedSeasonLength)}, nil
|
||||
}
|
||||
|
||||
func SeasonRolloverDue(season RankedSeason, now time.Time) bool {
|
||||
return season.SeasonID != "" && !season.EndsAt.IsZero() && !now.Before(season.EndsAt) && season.RolledOverAt.IsZero()
|
||||
}
|
||||
|
||||
func RankedIsProvisional(profile RankedProfile) bool { return profile.RankedGames < 10 }
|
||||
|
||||
// ApplySeasonRollover is idempotent by season ID. It intentionally accepts a
|
||||
|
||||
Reference in New Issue
Block a user