sharedutils/gameUtils/gameUtils.go

42 lines
827 B
Go
Raw Permalink Normal View History

2022-10-27 20:31:39 +00:00
package gameUtils
2022-10-27 18:05:45 +00:00
2022-10-28 12:27:57 +00:00
import (
"encoding/json"
)
2022-10-27 20:31:39 +00:00
func FindGameByID(id string, list Games) SteamGame {
for _, game := range list.SteamGames {
if game.GameId == id {
return game
}
}
var temp SteamGame = SteamGame{}
return temp
}
2022-10-27 18:05:45 +00:00
// 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,
2022-10-28 15:23:04 +00:00
Icon: game.Assets.Icon,
2022-10-27 18:05:45 +00:00
Description: game.Assets.Description,
}
return newInterface
}
2022-10-28 12:27:57 +00:00
func ConvertServerGamesToJSON(g Games) []byte {
g_json, err := json.Marshal(g)
_ = err //TODO: Check Errors
return g_json
}