2023-01-24 13:46:17 +00:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/skirdasession"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SkirdaDomain struct {
|
|
|
|
DomainId string
|
2023-02-12 16:43:44 +00:00
|
|
|
SkirdaGames
|
2023-01-24 13:46:17 +00:00
|
|
|
skirdasession.SkirdaSessions
|
|
|
|
}
|
|
|
|
|
2023-02-12 16:43:44 +00:00
|
|
|
func (domain SkirdaDomain) BuildDomain(newGames []SkirdaGame, newSessions []skirdasession.SkirdaSession) {
|
2023-01-24 13:46:17 +00:00
|
|
|
domain.AddGames(newGames)
|
|
|
|
domain.AddSessions(newSessions)
|
|
|
|
}
|
|
|
|
|
|
|
|
type Domains []SkirdaDomain
|
|
|
|
|
|
|
|
func (domains Domains) Set(newDomains []SkirdaDomain) {
|
|
|
|
domains = append([]SkirdaDomain{}, newDomains...)
|
|
|
|
}
|
|
|
|
|
2023-02-12 16:43:44 +00:00
|
|
|
func (domains Domains) FindGameByID(gameId string) (SkirdaGame, error) {
|
2023-01-24 13:46:17 +00:00
|
|
|
for _, domain := range domains {
|
|
|
|
game, _ := domain.FindGameByID(gameId)
|
|
|
|
if game.GetSkirdaGameId() == gameId {
|
|
|
|
return game, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, errors.New("")
|
|
|
|
}
|
|
|
|
|
2023-02-12 16:43:44 +00:00
|
|
|
func (domains Domains) GetGames() SkirdaGames {
|
|
|
|
allGames := SkirdaGames{}
|
2023-01-24 13:46:17 +00:00
|
|
|
for _, domain := range domains {
|
|
|
|
allGames = append(allGames, domain.SkirdaGames...)
|
|
|
|
}
|
|
|
|
return allGames
|
|
|
|
}
|
|
|
|
|
|
|
|
func (domains Domains) GetSessions() skirdasession.SkirdaSessions {
|
|
|
|
plainSessions := skirdasession.SkirdaSessions{}
|
|
|
|
for _, domain := range domains {
|
|
|
|
plainSessions = append(plainSessions, domain.SkirdaSessions...)
|
|
|
|
}
|
|
|
|
return plainSessions
|
|
|
|
}
|
|
|
|
|
|
|
|
func (domains Domains) FindDomain(domainId string) (SkirdaDomain, error) {
|
|
|
|
for _, domain := range domains {
|
|
|
|
if domain.DomainId == domainId {
|
|
|
|
return domain, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return SkirdaDomain{}, errors.New("not any domain founded")
|
|
|
|
}
|