This commit is contained in:
cyber-dream 2022-10-20 01:00:43 +03:00
parent a23089a463
commit 52d3bef12c
2 changed files with 86 additions and 0 deletions

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module example.com/skirdagoutils
go 1.18

83
utils.go Normal file
View File

@ -0,0 +1,83 @@
package skirdagoutils
type Game struct {
Id int
GameId string
Title string
GameType string
Executable string
Args []string
Assets GameInterfaceAssets
}
type GameInterfaceAssets struct {
Image string
Description string
}
func GetGamesListInterface() []JSGameInterface {
var gamesInterfacesList = []JSGameInterface{}
for _, Game := range GamesList {
gamesInterfacesList = append(gamesInterfacesList, GetJSGameInterface(Game))
}
return gamesInterfacesList
}
var GamesList = []Game{garrysmodGame, openarena}
var garrysmodGame = Game{
Id: 0,
GameId: "garrysmod",
GameType: "steam",
Title: "Garry's Mod",
Executable: "steam",
Args: []string{"steam://rungameid/4000"},
Assets: GameInterfaceAssets{
Image: "gmod.png",
Description: "",
},
}
var openarena = Game{
GameId: "openarena",
GameType: "file",
Title: "Open Arena",
Executable: "/usr/games/openarena",
Args: []string{},
Assets: GameInterfaceAssets{
Image: "openarena.jpg",
Description: "asdadasd",
},
}
func GetJSGameInterface(game Game) JSGameInterface {
newInterface := JSGameInterface{
Id: game.Id,
GameID: game.GameId,
Title: game.Title,
Image: game.Assets.Image,
Description: game.Assets.Description,
}
return newInterface
}
type JSGameInterface struct {
Id int `json:"id"`
GameID string `json:"gameId"`
Title string `json:"title"`
Image string `json:"image"`
Description string `json:"description"`
}
func findGameByID(id string) Game {
for _, game := range GamesList {
if game.GameId == id {
return game
}
}
var temp Game = Game{}
return temp
}