init
This commit is contained in:
parent
a23089a463
commit
52d3bef12c
83
utils.go
Normal file
83
utils.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user