Compare commits

..

2 Commits

Author SHA1 Message Date
2fa9396049 separate to different packages 2023-01-05 06:31:53 +03:00
19790ea5c5 separate to different packages 2023-01-05 06:31:30 +03:00
13 changed files with 90 additions and 48 deletions

View File

@ -1,5 +1,9 @@
package distribution
import (
domainModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/domain"
)
type Distributiuon struct {
Domains []Domain
Domains []domainModels.Domain
}

View File

@ -1,11 +0,0 @@
package distribution
type Domain struct {
DiscordGroupID string
Games Games
Sessions Sessions
}
type Domains struct {
Domains []Domain
}

View File

@ -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,
}

View File

@ -0,0 +1,16 @@
package distributionModels
import (
gamesModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/games"
sessionsModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/sessions"
)
type Domain struct {
DiscordGroupID string
Games gamesModels.Games
Sessions sessionsModels.Sessions
}
type Domains struct {
Domains []Domain
}

View File

@ -1,4 +1,4 @@
package distribution
package gamesModels
var garrysmodGame = SteamGame{ //TODO: Move to front
GameId: "garrysmod",

View File

@ -1,7 +1,7 @@
package distribution
package gamesModels
type SteamGame struct {
GameId string
GameId string //TODO: To UUID
SteamId string
Args []Argument
OptionalArgs []Argument
@ -9,6 +9,10 @@ type SteamGame struct {
Platforms map[string]bool
}
type LocalGame struct {
GameId string
}
type GameInterfaceAssets struct {
Title string
Icon string

View File

@ -0,0 +1,16 @@
package sessionsModels
import (
"time"
gamesModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/games"
)
var fakeSession1 = Session{
SessionId: "FakeSession1",
GameId: "fakegameid1",
Assets: gamesModels.GameInterfaceAssets{},
Expires: time.Time{},
Arguments: []gamesModels.Argument{},
}
var FakeSessions = []Session{fakeSession1}

View File

@ -1,15 +1,17 @@
package distribution
package sessionsModels
import (
"time"
gamesModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/games"
)
type Session struct {
SessionId string
GameId string
Assets GameInterfaceAssets
Assets gamesModels.GameInterfaceAssets
Expires time.Time
Arguments []Argument
Arguments []gamesModels.Argument
}
type Sessions struct {

View File

@ -0,0 +1,19 @@
package domainUtils
import (
domainModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/domain"
gamesModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/games"
// sessionsModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/sessions"
)
var fakeDomains = domainModels.Domains{ //TODO: Move to back
Domains: []domainModels.Domain{defaultDomain},
}
var defaultDomain = domainModels.Domain{
DiscordGroupID: "0",
Games: gamesModels.Games{
SteamGames: gamesModels.SteamFakeGamesList,
},
// Sessions: sessionsModels.FakeSessions,
}

View File

@ -1,12 +1,14 @@
package distribution
package gameUtils
func FindGameByID(id string, list Games) SteamGame {
import gamesModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/games"
func FindGameByID(id string, list gamesModels.Games) gamesModels.SteamGame {
for _, game := range list.SteamGames {
if game.GameId == id {
return game
}
}
var temp SteamGame = SteamGame{}
var temp gamesModels.SteamGame = gamesModels.SteamGame{}
return temp
}
@ -20,8 +22,8 @@ func FindGameByID(id string, list Games) SteamGame {
// return game
// }
func GetJSGameInterface(game SteamGame) JSGameInterface {
newInterface := JSGameInterface{
func GetJSGameInterface(game gamesModels.SteamGame) gamesModels.JSGameInterface {
newInterface := gamesModels.JSGameInterface{
GameID: game.GameId,
Title: game.Assets.Title,
Icon: game.Assets.Icon,
@ -30,6 +32,6 @@ func GetJSGameInterface(game SteamGame) JSGameInterface {
return newInterface
}
func ArgToStr(a Argument) string {
func ArgToStr(a gamesModels.Argument) string {
return a.Body + " " + a.Value
}

View File

@ -1,33 +1,36 @@
package distribution
package sessionUtils
import (
"encoding/json"
"time"
gamesModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/games"
sessionsModels "git.gregbrzezinski.com/Skirda/skirdagoutils/models/sessions"
)
func ConvertServerSessionsToJSON(s Session) []byte {
func ConvertServerSessionsToJSON(s sessionsModels.Session) []byte {
s_json, err := json.Marshal(s)
_ = err //TODO: Check Errors
return s_json
}
func FindSessionByID(sessionId string, sessions []Session) Session {
func FindSessionByID(sessionId string, sessions []sessionsModels.Session) sessionsModels.Session {
for _, session := range sessions {
if session.SessionId == sessionId {
return session
}
}
return Session{ //TODO: Return Errors
return sessionsModels.Session{ //TODO: Return Errors
SessionId: sessionId,
GameId: "",
Assets: GameInterfaceAssets{},
Assets: gamesModels.GameInterfaceAssets{},
Expires: time.Time{},
Arguments: []Argument{},
Arguments: []gamesModels.Argument{},
}
}
func GetJSSessionInterface(s Session) JSSessionInterface {
newInterface := JSSessionInterface{ //TODO: If session icon empty - use game icon
func GetJSSessionInterface(s sessionsModels.Session) sessionsModels.JSSessionInterface {
newInterface := sessionsModels.JSSessionInterface{ //TODO: If session icon empty - use game icon
GameID: s.GameId,
SessionId: s.SessionId,
Expires: time.Time{},
@ -39,8 +42,8 @@ func GetJSSessionInterface(s Session) JSSessionInterface {
return newInterface
}
var FakeSessions = Sessions{ //TODO: Move to front
Sessions: []Session{
var FakeSessions = sessionsModels.Sessions{ //TODO: Move to front
Sessions: []sessionsModels.Session{
{
GameId: "garrysmod",
SessionId: "gmod-test",
@ -49,7 +52,7 @@ var FakeSessions = Sessions{ //TODO: Move to front
// Status: "Super fake session",
// Version: "",
Expires: time.Time{},
Arguments: []Argument{
Arguments: []gamesModels.Argument{
{
Body: "+connect",
Value: "127.0.0.1:27015",