mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-14 13:52:04 +00:00
feat: enforce ranked admission policy
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package domain
|
||||
|
||||
import "fmt"
|
||||
|
||||
type RankedParticipant struct {
|
||||
PlayerID string
|
||||
SteamID string
|
||||
PartyID string
|
||||
IsBot bool
|
||||
IsBackfill bool
|
||||
}
|
||||
|
||||
type RankedArena struct {
|
||||
RandomEnabled bool
|
||||
ElevatedGoals bool
|
||||
}
|
||||
|
||||
func ValidateRankedAdmission(participants []RankedParticipant, arena RankedArena) error {
|
||||
if len(participants) != 6 || !arena.RandomEnabled || arena.ElevatedGoals {
|
||||
return fmt.Errorf("ranked admission requirements not met")
|
||||
}
|
||||
seenPlayers := make(map[string]bool, len(participants))
|
||||
seenSteam := make(map[string]bool, len(participants))
|
||||
for _, participant := range participants {
|
||||
if participant.PlayerID == "" || participant.SteamID == "" || participant.PartyID != "" || participant.IsBot || participant.IsBackfill || seenPlayers[participant.PlayerID] || seenSteam[participant.SteamID] {
|
||||
return fmt.Errorf("ranked requires six unique verified solo humans")
|
||||
}
|
||||
seenPlayers[participant.PlayerID] = true
|
||||
seenSteam[participant.SteamID] = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user