mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
54 lines
1.8 KiB
Go
54 lines
1.8 KiB
Go
package domain
|
|
|
|
import "fmt"
|
|
|
|
type RankedParticipant struct {
|
|
PlayerID string
|
|
SteamID string
|
|
PartyID string
|
|
IsBot bool
|
|
IsBackfill bool
|
|
}
|
|
|
|
type RankedArena struct {
|
|
ID string
|
|
}
|
|
|
|
// rankedArenas is the server-owned eligibility registry for launch ranked
|
|
// matches. It mirrors the floor-goal ArenaRegistry entries in the Godot
|
|
// project, but deliberately excludes every elevated-goal variant until a
|
|
// policy trained for that geometry is promoted.
|
|
var rankedArenas = map[string]RankedArena{
|
|
"arena_01": {ID: "arena_01"},
|
|
"arena_02": {ID: "arena_02"},
|
|
"arena_03": {ID: "arena_03"},
|
|
}
|
|
|
|
// DefaultRankedArena supplies a safe server-owned eligibility decision while
|
|
// the allocator-to-Godot match configuration channel is being completed. A
|
|
// ranked proposal is never admitted based on a mutable command-line boolean.
|
|
func DefaultRankedArena() RankedArena {
|
|
return rankedArenas["arena_01"]
|
|
}
|
|
|
|
func ValidateRankedAdmission(participants []RankedParticipant, arena RankedArena) error {
|
|
if len(participants) != 6 || !validRankedArena(arena) {
|
|
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
|
|
}
|
|
|
|
func validRankedArena(arena RankedArena) bool {
|
|
registered, ok := rankedArenas[arena.ID]
|
|
return ok && registered == arena
|
|
}
|