new domain, games, sessions
This commit is contained in:
parent
8a16a26b35
commit
b2c1867430
61
domain/domain.go
Normal file
61
domain/domain.go
Normal file
@ -0,0 +1,61 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/games/skirdagame"
|
||||
"git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/skirdasession"
|
||||
)
|
||||
|
||||
type SkirdaDomain struct {
|
||||
DomainId string
|
||||
skirdagame.SkirdaGames
|
||||
skirdasession.SkirdaSessions
|
||||
}
|
||||
|
||||
func (domain SkirdaDomain) BuildDomain(newGames []skirdagame.SkirdaGame, newSessions []skirdasession.SkirdaSession) {
|
||||
domain.AddGames(newGames)
|
||||
domain.AddSessions(newSessions)
|
||||
}
|
||||
|
||||
type Domains []SkirdaDomain
|
||||
|
||||
func (domains Domains) Set(newDomains []SkirdaDomain) {
|
||||
domains = append([]SkirdaDomain{}, newDomains...)
|
||||
}
|
||||
|
||||
func (domains Domains) FindGameByID(gameId string) (skirdagame.SkirdaGame, error) {
|
||||
for _, domain := range domains {
|
||||
game, _ := domain.FindGameByID(gameId)
|
||||
if game.GetSkirdaGameId() == gameId {
|
||||
return game, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("")
|
||||
}
|
||||
|
||||
func (domains Domains) GetGames() skirdagame.SkirdaGames {
|
||||
allGames := skirdagame.SkirdaGames{}
|
||||
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")
|
||||
}
|
27
games/minecraftgame/minecraftgame.go
Normal file
27
games/minecraftgame/minecraftgame.go
Normal file
@ -0,0 +1,27 @@
|
||||
package minecraftgame
|
||||
|
||||
import "git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/games/skirdagame"
|
||||
|
||||
const gameType = "minecraft"
|
||||
|
||||
type MinecraftGame struct {
|
||||
SkirdaGameId string
|
||||
Assets skirdagame.GameUIAssets
|
||||
// CurrentVersion string
|
||||
}
|
||||
|
||||
func (game MinecraftGame) GetSkirdaGameId() string {
|
||||
return game.SkirdaGameId
|
||||
}
|
||||
|
||||
func (game MinecraftGame) GetInterfaceAsset() skirdagame.GameUIAssets {
|
||||
return game.Assets
|
||||
}
|
||||
|
||||
func (game MinecraftGame) GetLaunchArgs() []string {
|
||||
return []string{"", ""}
|
||||
}
|
||||
|
||||
func (game MinecraftGame) GetType() string {
|
||||
return gameType
|
||||
}
|
32
games/skirdagame/skirdagame.go
Normal file
32
games/skirdagame/skirdagame.go
Normal file
@ -0,0 +1,32 @@
|
||||
package skirdagame
|
||||
|
||||
import "errors"
|
||||
|
||||
type SkirdaGame interface {
|
||||
GetSkirdaGameId() string
|
||||
GetInterfaceAsset() GameUIAssets
|
||||
GetLaunchArgs() []string
|
||||
GetType() string
|
||||
}
|
||||
|
||||
type GameUIAssets struct {
|
||||
// GameID string `json:"gameId"`
|
||||
Title string `json:"title"`
|
||||
Icon string `json:"icon"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type SkirdaGames []SkirdaGame
|
||||
|
||||
func (games SkirdaGames) AddGames(game []SkirdaGame) {
|
||||
games = append(games, game...)
|
||||
}
|
||||
|
||||
func (games SkirdaGames) FindGameByID(gameId string) (SkirdaGame, error) {
|
||||
for _, game := range games {
|
||||
if game.GetSkirdaGameId() == gameId {
|
||||
return game, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.New("")
|
||||
}
|
28
games/steamgame/steamgame.go
Normal file
28
games/steamgame/steamgame.go
Normal file
@ -0,0 +1,28 @@
|
||||
package steamgame
|
||||
|
||||
import "git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/games/skirdagame"
|
||||
|
||||
const gameType = "steam"
|
||||
|
||||
type SteamGame struct {
|
||||
SkirdaGameId string
|
||||
SteamId string
|
||||
Assets skirdagame.GameUIAssets
|
||||
// CurrentVersion string
|
||||
}
|
||||
|
||||
func (game SteamGame) GetSkirdaGameId() string {
|
||||
return game.SkirdaGameId
|
||||
}
|
||||
|
||||
func (game SteamGame) GetInterfaceAsset() skirdagame.GameUIAssets {
|
||||
return game.Assets
|
||||
}
|
||||
|
||||
func (game SteamGame) GetLaunchArgs() []string {
|
||||
return []string{"", ""}
|
||||
}
|
||||
|
||||
func (game SteamGame) GetType() string {
|
||||
return gameType
|
||||
}
|
37
sharedauth/sharedauth.go
Normal file
37
sharedauth/sharedauth.go
Normal file
@ -0,0 +1,37 @@
|
||||
package sharedauth
|
||||
|
||||
import "time"
|
||||
|
||||
type InstallIdRegisterReq struct {
|
||||
InstallId InstallId
|
||||
}
|
||||
|
||||
type InstallId string
|
||||
|
||||
func (id InstallId) Validate() bool {
|
||||
//TODO: More checks
|
||||
return id != ""
|
||||
}
|
||||
|
||||
type RedirResp struct {
|
||||
RedirectUrl string
|
||||
}
|
||||
|
||||
type LauncherSession struct {
|
||||
// Username string
|
||||
// DiscordId string
|
||||
SessionToken string
|
||||
InstallId string
|
||||
Expiry time.Time
|
||||
}
|
||||
|
||||
type ProfileResp struct {
|
||||
Username string
|
||||
}
|
||||
|
||||
type ValidateReq struct {
|
||||
LauncherToken string
|
||||
}
|
||||
|
||||
type ValidateResp struct {
|
||||
}
|
103
skirdasession/skirdasession.go
Normal file
103
skirdasession/skirdasession.go
Normal file
@ -0,0 +1,103 @@
|
||||
package skirdasession
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type SkirdaSession interface {
|
||||
GetSessionId() string
|
||||
GetGameId() string
|
||||
GetUIAssets() SessionUIAssets
|
||||
GetGameType() string
|
||||
GetSessionData() string
|
||||
}
|
||||
|
||||
// type SkirdaSession struct {
|
||||
// SkirdaSessionId string
|
||||
// SkirdaGameId string
|
||||
// Assets SessionUIAssets
|
||||
// }
|
||||
|
||||
type SkirdaSessions []SkirdaSession
|
||||
|
||||
type SessionUIAssets struct {
|
||||
// GameID string `json:"gameId"`
|
||||
Title string `json:"title"`
|
||||
Icon string `json:"icon"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
func (sessions SkirdaSessions) FindSessionById(sessionId string) (SkirdaSession, error) {
|
||||
for _, session := range sessions {
|
||||
if session.GetSessionId() == sessionId {
|
||||
return session, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.New("no any sessions founded")
|
||||
}
|
||||
|
||||
func (sessions SkirdaSessions) AddSessions(newSessions []SkirdaSession) {
|
||||
sessions = append(sessions, newSessions...)
|
||||
}
|
||||
|
||||
type MinecraftSession struct {
|
||||
SkirdaSessionId string
|
||||
SkirdaGameId string
|
||||
Assets SessionUIAssets
|
||||
Version string
|
||||
}
|
||||
|
||||
func (session MinecraftSession) GetSessionId() string {
|
||||
return session.SkirdaSessionId
|
||||
}
|
||||
|
||||
func (session MinecraftSession) GetUIAssets() SessionUIAssets {
|
||||
return session.Assets
|
||||
}
|
||||
|
||||
func (session MinecraftSession) GetGameId() string {
|
||||
return session.SkirdaGameId
|
||||
}
|
||||
|
||||
func (session MinecraftSession) GetMinecraftVersion() string {
|
||||
return session.SkirdaGameId
|
||||
}
|
||||
|
||||
func (session MinecraftSession) GetGameType() string {
|
||||
return "minecraft"
|
||||
}
|
||||
|
||||
func (session MinecraftSession) GetSessionData() string {
|
||||
return session.Version
|
||||
}
|
||||
|
||||
type SteamSession struct {
|
||||
SkirdaSessionId string
|
||||
SkirdaGameId string
|
||||
Assets SessionUIAssets
|
||||
// Data SteamSessionData
|
||||
}
|
||||
|
||||
type SteamSessionData struct {
|
||||
kke string
|
||||
}
|
||||
|
||||
func (session SteamSession) GetSessionId() string {
|
||||
return session.SkirdaSessionId
|
||||
}
|
||||
|
||||
func (session SteamSession) GetUIAssets() SessionUIAssets {
|
||||
return session.Assets
|
||||
}
|
||||
|
||||
func (session SteamSession) GetGameId() string {
|
||||
return session.SkirdaGameId
|
||||
}
|
||||
|
||||
func (session SteamSession) GetGameType() string {
|
||||
return "steam"
|
||||
}
|
||||
|
||||
func (session SteamSession) GetSessionData() string {
|
||||
return ""
|
||||
}
|
Loading…
Reference in New Issue
Block a user