From 52908484d0da85245b5e93537b051e30f1ef6a46 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Wed, 26 Oct 2022 21:43:21 +0300 Subject: [PATCH] refactor games utils --- .gitignore | 23 ------------- README.md | 2 -- fakeGames.go | 28 ---------------- game/fakeGames.go | 27 +++++++++++++++ game/gamesTypes.go | 19 +++++++++++ game/gamesUtils.go | 71 +++++++++++++++++++++++++++++++++++++++ utils.go | 83 ---------------------------------------------- 7 files changed, 117 insertions(+), 136 deletions(-) delete mode 100644 .gitignore delete mode 100644 README.md delete mode 100644 fakeGames.go create mode 100644 game/fakeGames.go create mode 100644 game/gamesTypes.go create mode 100644 game/gamesUtils.go delete mode 100644 utils.go diff --git a/.gitignore b/.gitignore deleted file mode 100644 index adf8f72..0000000 --- a/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# ---> Go -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - diff --git a/README.md b/README.md deleted file mode 100644 index 59db3e0..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# skirda-go-utils - diff --git a/fakeGames.go b/fakeGames.go deleted file mode 100644 index dc28e24..0000000 --- a/fakeGames.go +++ /dev/null @@ -1,28 +0,0 @@ -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} diff --git a/game/fakeGames.go b/game/fakeGames.go new file mode 100644 index 0000000..8b5e316 --- /dev/null +++ b/game/fakeGames.go @@ -0,0 +1,27 @@ +package game + +var garrysmodGame = SteamGame{ + GameId: "garrysmod", + SteamId: "4000", + Args: []string{}, + Platforms: map[string]bool{"linux": true}, + Assets: GameInterfaceAssets{ + Title: "Garry's Mod", + Image: "gmod.png", + Description: "", + }, +} + +var openarena = SteamGame{ + GameId: "openarena", + SteamId: "", + //Executable: "/usr/games/openarena", + Args: []string{}, + Assets: GameInterfaceAssets{ + Title: "Open Arena", + Image: "openarena.jpg", + Description: "asdadasd", + }, +} + +var FakeGamesList = []SteamGame{garrysmodGame, openarena} diff --git a/game/gamesTypes.go b/game/gamesTypes.go new file mode 100644 index 0000000..6e33f63 --- /dev/null +++ b/game/gamesTypes.go @@ -0,0 +1,19 @@ +package gamestypes + +type SteamGame struct { + GameId string + SteamId string + Args []string + Assets GameInterfaceAssets + Platforms map[string]bool +} + +type GameInterfaceAssets struct { + Title string + Image string + Description string +} + +type Games struct { + SteamGames []SteamGame +} diff --git a/game/gamesUtils.go b/game/gamesUtils.go new file mode 100644 index 0000000..d4d97c8 --- /dev/null +++ b/game/gamesUtils.go @@ -0,0 +1,71 @@ +package game + +// type SteamGame struct { +// GameId string +// SteamId string +// Args []string +// Assets GameInterfaceAssets +// Platforms map[string]bool +// } + +// type Games struct { +// SteamGames []SteamGame +// } + +// type GameInterfaceAssets struct { +// Title string +// Image string +// Description string +// } + +// type JSGameInterface struct { +// GameID string `json:"gameId"` +// Title string `json:"title"` +// Image string `json:"image"` +// Description string `json:"description"` +// } + +// var GamesList = []SteamGame{garrysmodGame, openarena} + +// func GetJSGameInterface(game SteamGame) JSGameInterface { +// newInterface := JSGameInterface{ +// GameID: game.GameId, +// Title: game.Assets.Title, +// Image: game.Assets.Image, +// Description: game.Assets.Description, +// } + +// return newInterface +// } + +// func findGameByID(id string) SteamGame { +// for _, game := range GamesList { +// 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 FindGameByID() {} + +func GetJSGameInterface(game SteamGame) JSGameInterface { + newInterface := JSGameInterface{ + GameID: game.GameId, + Title: game.Assets.Title, + Image: game.Assets.Image, + Description: game.Assets.Description, + } + return newInterface +} diff --git a/utils.go b/utils.go deleted file mode 100644 index 1d3bf62..0000000 --- a/utils.go +++ /dev/null @@ -1,83 +0,0 @@ -package skirdaGoUtils - -type Game struct { - 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 { - - gamesInterfacesList = append(gamesInterfacesList, GetJSGameInterface(Game)) - } - - return gamesInterfacesList -} - -func GetJSGameInterface(game Game) JSGameInterface { - newInterface := JSGameInterface{ - //Id: game.Id, - GameID: game.GameId, - Title: game.Assets.Title, - Image: game.Assets.Image, - Description: game.Assets.Description, - } - - return newInterface -} - -func findGameByID(id string) Game { - for _, game := range GamesList { - if game.GameId == id { - return 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", -// }, -// }