This commit is contained in:
cyber-dream 2022-10-25 23:07:25 +03:00
parent 57cf56234a
commit d132e4a6be
3 changed files with 69 additions and 43 deletions

28
fakeGames.go Normal file
View File

@ -0,0 +1,28 @@
package skirdaGoUtils
var garrysmodGame = Game{
GameId: "garrysmod",
SteamId: "",
Executable: "",
Args: []string{"steam://rungameid/4000"},
Platforms: map[string]bool{"linux": true},
Assets: GameInterfaceAssets{
Title: "Garry's Mod",
Image: "gmod.png",
Description: "",
},
}
var openarena = Game{
GameId: "openarena",
SteamId: "",
Executable: "/usr/games/openarena",
Args: []string{},
Assets: GameInterfaceAssets{
Title: "Open Arena",
Image: "openarena.jpg",
Description: "asdadasd",
},
}
var FakeGamesList = []Game{garrysmodGame, openarena}

3
go.mod
View File

@ -1,3 +0,0 @@
module git.gregbrzezinski.com/Skirda/skirdaGoUtils
go 1.18

View File

@ -1,19 +1,31 @@
package skirdaGoUtils
type Game struct {
GameId string
Title string
GameType string
GameId string
SteamId string
//GameType string
Executable string
Args []string
Assets GameInterfaceAssets
Platforms map[string]bool
}
type GameInterfaceAssets struct {
Title string
Image string
Description string
}
type JSGameInterface struct {
Id int `json:"id"`
GameID string `json:"gameId"`
Title string `json:"title"`
Image string `json:"image"`
Description string `json:"description"`
}
var GamesList = []Game{garrysmodGame, openarena}
func GetGamesListInterface() []JSGameInterface {
var gamesInterfacesList = []JSGameInterface{}
for _, Game := range GamesList {
@ -24,38 +36,11 @@ func GetGamesListInterface() []JSGameInterface {
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,
//Id: game.Id,
GameID: game.GameId,
Title: game.Title,
Title: game.Assets.Title,
Image: game.Assets.Image,
Description: game.Assets.Description,
}
@ -63,14 +48,6 @@ func GetJSGameInterface(game Game) JSGameInterface {
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 {
@ -80,3 +57,27 @@ func findGameByID(id string) Game {
var temp Game = Game{}
return temp
}
// var garrysmodGame = Game{
// 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",
// },
// }