Merge branch 'hyper-refactoring'
This commit is contained in:
commit
a101fb122b
5
auth/auth.go
Normal file
5
auth/auth.go
Normal file
@ -0,0 +1,5 @@
|
||||
package sharedauth
|
||||
|
||||
type InstallId struct {
|
||||
InstallId string
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package distribution
|
||||
|
||||
type Distributiuon struct {
|
||||
Domains []Domain
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package distribution
|
||||
|
||||
type Domain struct {
|
||||
DiscordGroupID string
|
||||
Games Games
|
||||
Sessions Sessions
|
||||
}
|
||||
|
||||
type Domains struct {
|
||||
Domains []Domain
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package distribution
|
||||
|
||||
var fakeDomains = Domains{ //TODO: Move to back
|
||||
Domains: []Domain{defaultDomain},
|
||||
}
|
||||
|
||||
var defaultDomain = Domain{
|
||||
DiscordGroupID: "0",
|
||||
Games: Games{
|
||||
SteamGames: SteamFakeGamesList,
|
||||
},
|
||||
Sessions: FakeSessions,
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package distribution
|
||||
|
||||
var garrysmodGame = SteamGame{ //TODO: Move to front
|
||||
GameId: "garrysmod",
|
||||
SteamId: "4000",
|
||||
Args: []Argument{},
|
||||
Platforms: map[string]bool{
|
||||
"linux": true,
|
||||
"windows": true,
|
||||
},
|
||||
Assets: GameInterfaceAssets{
|
||||
Title: "Garry's Mod",
|
||||
Icon: "icon.png",
|
||||
Description: "",
|
||||
},
|
||||
}
|
||||
|
||||
var openarena = SteamGame{
|
||||
GameId: "half-life-1",
|
||||
SteamId: "70",
|
||||
Args: []Argument{},
|
||||
Assets: GameInterfaceAssets{
|
||||
Title: "Half Life",
|
||||
Icon: "icon.png",
|
||||
Description: "asdadasd",
|
||||
},
|
||||
}
|
||||
|
||||
var SteamFakeGamesList = []SteamGame{garrysmodGame, openarena}
|
@ -1,37 +0,0 @@
|
||||
package distribution
|
||||
|
||||
type SteamGame struct {
|
||||
GameId string
|
||||
SteamId string
|
||||
Args []Argument
|
||||
OptionalArgs []Argument
|
||||
Assets GameInterfaceAssets
|
||||
Platforms map[string]bool
|
||||
}
|
||||
|
||||
type GameInterfaceAssets struct {
|
||||
Title string
|
||||
Icon string
|
||||
Description string
|
||||
Backgrounds []GameInterfaceBackground
|
||||
}
|
||||
|
||||
type GameInterfaceBackground struct {
|
||||
File string
|
||||
}
|
||||
|
||||
type Games struct {
|
||||
SteamGames []SteamGame
|
||||
}
|
||||
|
||||
type JSGameInterface struct {
|
||||
GameID string `json:"gameId"`
|
||||
Title string `json:"title"`
|
||||
Icon string `json:"icon"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type Argument struct {
|
||||
Body string
|
||||
Value string
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package distribution
|
||||
|
||||
func FindGameByID(id string, list Games) SteamGame {
|
||||
for _, game := range list.SteamGames {
|
||||
if game.GameId == id {
|
||||
return game
|
||||
}
|
||||
}
|
||||
var temp SteamGame = SteamGame{}
|
||||
return temp
|
||||
}
|
||||
|
||||
// func findSteamGameByID(id string) SteamGame {
|
||||
// for _, game := range localGames.St {
|
||||
// if game.GameId == id {
|
||||
// return game
|
||||
// }
|
||||
// }
|
||||
// var game SteamGame = SteamGame{}
|
||||
// return game
|
||||
// }
|
||||
|
||||
func GetJSGameInterface(game SteamGame) JSGameInterface {
|
||||
newInterface := JSGameInterface{
|
||||
GameID: game.GameId,
|
||||
Title: game.Assets.Title,
|
||||
Icon: game.Assets.Icon,
|
||||
Description: game.Assets.Description,
|
||||
}
|
||||
return newInterface
|
||||
}
|
||||
|
||||
func ArgToStr(a Argument) string {
|
||||
return a.Body + " " + a.Value
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package distribution
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Session struct {
|
||||
SessionId string
|
||||
GameId string
|
||||
Assets GameInterfaceAssets
|
||||
Expires time.Time
|
||||
Arguments []Argument
|
||||
}
|
||||
|
||||
type Sessions struct {
|
||||
Sessions []Session
|
||||
}
|
||||
|
||||
type JSSessionInterface struct {
|
||||
GameID string `json:"gameId"`
|
||||
SessionId string `json:"sessionId"`
|
||||
Expires time.Time `json:"expires"`
|
||||
Title string `json:"title"`
|
||||
Icon string `json:"icon"`
|
||||
Description string `json:"description"`
|
||||
Backgrounds []string `json:"backgrounds"`
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package distribution
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ConvertServerSessionsToJSON(s Session) []byte {
|
||||
s_json, err := json.Marshal(s)
|
||||
_ = err //TODO: Check Errors
|
||||
return s_json
|
||||
}
|
||||
|
||||
func FindSessionByID(sessionId string, sessions []Session) Session {
|
||||
for _, session := range sessions {
|
||||
if session.SessionId == sessionId {
|
||||
return session
|
||||
}
|
||||
}
|
||||
return Session{ //TODO: Return Errors
|
||||
SessionId: sessionId,
|
||||
GameId: "",
|
||||
Assets: GameInterfaceAssets{},
|
||||
Expires: time.Time{},
|
||||
Arguments: []Argument{},
|
||||
}
|
||||
}
|
||||
|
||||
func GetJSSessionInterface(s Session) JSSessionInterface {
|
||||
newInterface := JSSessionInterface{ //TODO: If session icon empty - use game icon
|
||||
GameID: s.GameId,
|
||||
SessionId: s.SessionId,
|
||||
Expires: time.Time{},
|
||||
Title: s.Assets.Title,
|
||||
Icon: s.Assets.Icon,
|
||||
Description: s.Assets.Description,
|
||||
Backgrounds: []string{}, //TODO: Complete
|
||||
}
|
||||
return newInterface
|
||||
}
|
||||
|
||||
var FakeSessions = Sessions{ //TODO: Move to front
|
||||
Sessions: []Session{
|
||||
{
|
||||
GameId: "garrysmod",
|
||||
SessionId: "gmod-test",
|
||||
// Icon: "",
|
||||
// Title: "Regular Skirda Gmod server",
|
||||
// Status: "Super fake session",
|
||||
// Version: "",
|
||||
Expires: time.Time{},
|
||||
Arguments: []Argument{
|
||||
{
|
||||
Body: "+connect",
|
||||
Value: "127.0.0.1:27015",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// GameId: "half-lide-1",
|
||||
// Title: "Half-Life 1 МЯСО",
|
||||
// Status: "Retro shit",
|
||||
Expires: time.Time{},
|
||||
},
|
||||
{
|
||||
GameId: "minecraft",
|
||||
// Title: "Test 3",
|
||||
// Status: "Testing session",
|
||||
// Version: "1.54.7",
|
||||
Expires: time.Time{},
|
||||
},
|
||||
},
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package jsonutils
|
||||
|
||||
//TODO: Rename package
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
)
|
||||
|
||||
func ConvertToJSON(g interface{}) []byte {
|
||||
g_json, err := json.Marshal(g)
|
||||
_ = err //TODO: Check Errors
|
||||
return g_json
|
||||
}
|
||||
|
||||
func ConvertResponseFromJSON(body io.ReadCloser, inter interface{}) {
|
||||
json_err := json.NewDecoder(body).Decode(&inter)
|
||||
_ = json_err //TODO work with errors
|
||||
}
|
158
sharedDistribution/games.go
Normal file
158
sharedDistribution/games.go
Normal file
@ -0,0 +1,158 @@
|
||||
package sharedDistribution
|
||||
|
||||
type SkirdaGame interface {
|
||||
// SkirdaGameId string
|
||||
GetSkirdaGameId() string
|
||||
GetInterfaceAsset(gameId string) JSGameInterface
|
||||
GetLaunchArgs() []string
|
||||
// Launch(gameId string) error
|
||||
}
|
||||
|
||||
type SkirdaGames struct {
|
||||
Steam []SteamGame
|
||||
Minecraft MinecraftGame //TODO: To slice
|
||||
}
|
||||
|
||||
func (games SkirdaGames) GetGameTypeById(skirdaGameId string) (string, error) {
|
||||
if games.Minecraft.GetSkirdaGameId() == skirdaGameId {
|
||||
return "minecraft", nil
|
||||
}
|
||||
|
||||
for _, game := range games.Steam {
|
||||
if game.GetSkirdaGameId() == skirdaGameId {
|
||||
return "steam", nil
|
||||
}
|
||||
}
|
||||
return "", nil //TODO: Right error return
|
||||
}
|
||||
|
||||
func (games SkirdaGames) Test(skirdaGameId string) (interface{}, error) {
|
||||
return games.Minecraft, nil
|
||||
}
|
||||
|
||||
func (games SkirdaGames) GetInterfaceAssets() []JSGameInterface {
|
||||
assets := []JSGameInterface{}
|
||||
|
||||
assets = append(assets, games.Minecraft.GetInterfaceAsset())
|
||||
for _, game := range games.Steam {
|
||||
assets = append(assets, game.GetInterfaceAsset())
|
||||
}
|
||||
return assets
|
||||
}
|
||||
|
||||
func (games SteamGame) Test(skirdaGameId string) (interface{}, error) {
|
||||
return SteamGame{}, nil
|
||||
}
|
||||
|
||||
func (game SteamGame) GetSkirdaGameId() string {
|
||||
return game.SkirdaGameId
|
||||
}
|
||||
|
||||
func (game MinecraftGame) GetSkirdaGameId() string {
|
||||
return game.SkirdaGameId
|
||||
}
|
||||
|
||||
func (game MinecraftGame) GetMinecraftVersion() string {
|
||||
return game.CurrentVersion
|
||||
}
|
||||
|
||||
func (games SkirdaGames) GetLaunchCmd(skirdaGameId string, os string) (string, []string, error) {
|
||||
gameType, err := games.GetGameTypeById(skirdaGameId)
|
||||
if err != nil {
|
||||
return "", nil, nil
|
||||
}
|
||||
|
||||
switch gameType {
|
||||
case "minecraft":
|
||||
switch os {
|
||||
case "windows":
|
||||
|
||||
return "notepad", []string{""}, nil
|
||||
default:
|
||||
return "", []string{}, nil
|
||||
}
|
||||
default:
|
||||
return "", nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
// func (games SkirdaGames) FindGameByID(gameId string) (SkirdaGame, error) {
|
||||
// for _, game := range games {
|
||||
// if game.GetSkirdaGameId() == gameId {
|
||||
// return game, nil
|
||||
// }
|
||||
// }
|
||||
// kek := SkirdaGame
|
||||
// return game, nil //TODO: Right error return
|
||||
// }
|
||||
|
||||
// func (game MinecraftGame) GetLaunchArgs() (string, []string, error) {
|
||||
// switch os := runtime.GOOS; os {
|
||||
// case "windows":
|
||||
// return "java", []string{"-version"}, nil
|
||||
// default:
|
||||
// return "", []string{}, nil
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
func (game SteamGame) GetInterfaceAsset() JSGameInterface {
|
||||
return JSGameInterface{
|
||||
GameID: game.SkirdaGameId,
|
||||
Title: game.Assets.Title,
|
||||
Icon: game.Assets.Icon,
|
||||
Description: game.Assets.Description,
|
||||
}
|
||||
}
|
||||
|
||||
func (game MinecraftGame) GetInterfaceAsset() JSGameInterface {
|
||||
return JSGameInterface{
|
||||
GameID: game.SkirdaGameId,
|
||||
Title: game.Assets.Title,
|
||||
Icon: game.Assets.Icon,
|
||||
Description: game.Assets.Description,
|
||||
}
|
||||
}
|
||||
|
||||
type MinecraftGame struct {
|
||||
SkirdaGameId string
|
||||
Assets GameInterfaceAssets
|
||||
CurrentVersion string
|
||||
}
|
||||
|
||||
type SteamGame struct {
|
||||
SkirdaGameId string
|
||||
SteamId string
|
||||
Args []Argument
|
||||
OptionalArgs []Argument
|
||||
//TODO: Settings??
|
||||
Assets GameInterfaceAssets
|
||||
Platforms map[string]bool
|
||||
}
|
||||
|
||||
type LocalGame struct {
|
||||
GameId string
|
||||
}
|
||||
|
||||
type GameInterfaceAssets struct {
|
||||
Title string
|
||||
Icon string
|
||||
Description string
|
||||
Backgrounds []GameInterfaceBackground
|
||||
}
|
||||
|
||||
type GameInterfaceBackground struct {
|
||||
File string
|
||||
}
|
||||
|
||||
type JSGameInterface struct {
|
||||
GameID string `json:"gameId"`
|
||||
Title string `json:"title"`
|
||||
Icon string `json:"icon"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type Argument struct {
|
||||
Body string
|
||||
Value string
|
||||
}
|
63
sharedDistribution/sessions.go
Normal file
63
sharedDistribution/sessions.go
Normal file
@ -0,0 +1,63 @@
|
||||
package sharedUtils
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type SkirdaSessions []SkirdaSession
|
||||
|
||||
func (sessions SkirdaSessions) FindSessionById(sessionId string) (SkirdaSession, error) {
|
||||
for _, session := range sessions {
|
||||
if session.GetSessionId() == sessionId {
|
||||
return session, nil
|
||||
}
|
||||
}
|
||||
return sessions[0], nil //TODO: Temp error return
|
||||
}
|
||||
|
||||
func (sessions SkirdaSessions) GetInterfaceAssets() []JSSessionInterface {
|
||||
assets := []JSSessionInterface{}
|
||||
|
||||
for _, session := range sessions {
|
||||
assets = append(assets, session.GetInterfaceAsset())
|
||||
}
|
||||
return assets
|
||||
}
|
||||
|
||||
type SkirdaSession struct {
|
||||
SkirdaSessionId string
|
||||
SkirdaGameId string
|
||||
Args []string
|
||||
NegativeArgs []string
|
||||
}
|
||||
|
||||
type JSSessionInterface struct {
|
||||
GameID string `json:"gameId"`
|
||||
SessionId string `json:"sessionId"`
|
||||
Expires time.Time `json:"expires"`
|
||||
Title string `json:"title"`
|
||||
Icon string `json:"icon"`
|
||||
Description string `json:"description"`
|
||||
Backgrounds []string `json:"backgrounds"`
|
||||
}
|
||||
|
||||
func (session SkirdaSession) GetSessionId() string {
|
||||
return session.SkirdaSessionId
|
||||
}
|
||||
|
||||
func (session SkirdaSession) GetGameId() string {
|
||||
return session.SkirdaGameId
|
||||
}
|
||||
|
||||
func (session SkirdaSession) GetInterfaceAsset() JSSessionInterface {
|
||||
// gameId := SkirdaGame.GetSkirdaGameId()
|
||||
return JSSessionInterface{
|
||||
GameID: "",
|
||||
SessionId: "",
|
||||
Expires: time.Time{},
|
||||
Title: "Test Session",
|
||||
Icon: "",
|
||||
Description: "",
|
||||
Backgrounds: []string{},
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package updateutils
|
||||
|
||||
type LastVersion struct { //Rename to Version
|
||||
Epic int
|
||||
Sprint int
|
||||
Build int
|
||||
}
|
Loading…
Reference in New Issue
Block a user