kuroswhattoplay/KurosWhatToPlay/Controller/IGDB.cs

49 lines
1.7 KiB
C#
Raw Normal View History

2025-03-18 16:51:50 +00:00
using IGDB;
using IGDB.Models;
namespace KurosWhatToPlay.Controller {
public class IGDB {
IGDBClient igdb;
internal IGDB() {
igdb = new IGDBClient("ngtj0oyeb9fz4713uv0nxij7nrnh01", "fjzked4kg1d3a7u1lpw6qsp1a5823u");
}
internal async void getGame(string id) {
Game[] games = await igdb.QueryAsync<Game>(IGDBClient.Endpoints.Games, query: "fields *; where id = " + id + ";");
Game game = games.First();
Console.WriteLine(game.Name); // Thief
}
internal async void GetGameNames(long last, long amount, DataGridView gameList) {
long value = last + amount;
string request = "(";
for (long i = last; i <= value; i++) {
request += i + ",";
}
request = request.Remove(request.Length - 1);
request = request + ")";
Game[] games = await igdb.QueryAsync<Game>(IGDBClient.Endpoints.Games, query: "fields id,name; where id = " + request + "; limit " + amount + ";");
foreach (Game game in games) {
if (game.Id != null && game.Id.HasValue) {
gameList.Rows.Add(game.Id.Value, game.Name);
}
}
}
internal async void GetConsoleNames(ComboBox consoleCbx) {
Platform[] gameEngines = await igdb.QueryAsync<Platform>(IGDBClient.Endpoints.Platforms, query: "fields id,name; limit 200;");
foreach (Platform engine in gameEngines) {
if (engine.Id != null && engine.Id.HasValue) {
consoleCbx.Items.Add(engine.Name);
}
}
}
}
}