From 52d3bef12cbde5dd6586d99c77308c620509814d Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Thu, 20 Oct 2022 01:00:43 +0300 Subject: [PATCH] init --- go.mod | 3 ++ utils.go | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 go.mod create mode 100644 utils.go diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..bb52ab6 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module example.com/skirdagoutils + +go 1.18 diff --git a/utils.go b/utils.go new file mode 100644 index 0000000..ce12129 --- /dev/null +++ b/utils.go @@ -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 +}