sharedutils/gameUtils/gameUtils.go
2022-10-28 18:23:04 +03:00

42 lines
827 B
Go

package gameUtils
import (
"encoding/json"
)
func FindGameByID(id string, list Games) SteamGame {
for _, game := range list.SteamGames {
if game.GameId == id {
return game
}
}
var temp SteamGame = SteamGame{}
return temp
}
// func findSteamGameByID(id string) SteamGame {
// for _, game := range localGames.St {
// if game.GameId == id {
// return game
// }
// }
// var game SteamGame = SteamGame{}
// return game
// }
func GetJSGameInterface(game SteamGame) JSGameInterface {
newInterface := JSGameInterface{
GameID: game.GameId,
Title: game.Assets.Title,
Icon: game.Assets.Icon,
Description: game.Assets.Description,
}
return newInterface
}
func ConvertServerGamesToJSON(g Games) []byte {
g_json, err := json.Marshal(g)
_ = err //TODO: Check Errors
return g_json
}