mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 20:33:44 +00:00
33 lines
997 B
Go
33 lines
997 B
Go
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
|
|
}
|