conjure-os/frontend/src/services/game-service.ts

131 lines
5.4 KiB
TypeScript

import {LoadGames} from "../../wailsjs/go/main/App";
import {models} from "../../wailsjs/go/models";
import Metadata = models.Metadata;
import Game = models.Game;
import Developer = models.Developer;
const localGames: Game[] = [
new Game({
id: "ddf1ab0c-d86e-442f-8fd8-cfe8a0dc0a52",
title: "Soul Shaper",
version: "2.0.0",
description: "Laissez votre imagination prendre forme en maniant le pouvoir de la création contre la seule chose qui vous sépare du paradis. Manipulez l'espace et le temps contre votre adversaire dans Soul Shaper!",
players: "1-1",
release: "2023-12-15",
modification: "2023-12-15",
executable: "game\\Soul Shaper.exe",
public_repository_link: "https://github.com/PFE033-ConjureOS/ConjureOS-SoulShaper",
genres: "action",
developers: [
new Developer({
name: "William Gingras"
}),
new Developer({
name: "Yussef Shehadeh"
}),
new Developer({
name: "Leah Fortin"
}),
new Developer({
name: "Cameron Lamoureux"
}),
],
thumbnail_path: "https://img.itch.zone/aW1hZ2UvMTkwMzc5MS8xMTgzNzY0Ny5wbmc=/original/r7iVIj.png",
itch_link: "https://craftelia.itch.io/gamelab2023-blood-god",
media_paths: [
"https://img.itch.zone/aW1hZ2UvMTkwMzc5MS8xMTgyMjc0Ni5wbmc=/original/65c%2FQT.png",
"https://img.itch.zone/aW1hZ2UvMTkwMzc5MS8xMTgyMjc0Ny5wbmc=/original/4FiVFR.png",
"https://img.itch.zone/aW1hZ2UvMTkwMzc5MS8xMTgyMjc0OC5wbmc=/original/IkUG5I.png",
"https://img.itch.zone/aW1hZ2UvMTkwMzc5MS8xMTgzNzY1My5wbmc=/original/jtOMly.png"
],
logo_path: "https://img.itch.zone/aW1nLzExODI4OTQyLnBuZw==/original/0MBnt3.png",
backgroundImagePath: "https://img.itch.zone/aW1nLzExODIyNzg4LnBuZw==/original/QVGL4L.png",
collections: "Ubi Gamelab",
color_scheme: {
primary: "#66258a",
secondary: "#80f071",
ternary: "#ffffff"
},
}),
new Game({
id: "random-id",
title: "Froggin' Around",
version: "2.0.0",
description: "Incarnez deux grenouilles s'échappant d'un atelier magique. Travaillez ensemble et utilisez vos langues élastiques et rebondissantes pour progresser et résoudre des énigmes.",
players: "2-2",
release: "2025-04-13",
modification: "2023-05-05",
executable: "game\\FrogginAround.exe",
genres: "action, adventure, puzzle",
developers: [
new Developer({
name: "Jeanne Castonguay",
role: "Designer"
}),
new Developer({
name: "Mathieu Vézina",
role: "Developer",
link: "https://www.linkedin.com/in/mathieu-vezina/",
picture: "https://media.licdn.com/dms/image/v2/C4E03AQElTJL0iSscHg/profile-displayphoto-shrink_400_400/profile-displayphoto-shrink_400_400/0/1637863156486?e=1757548800&v=beta&t=oJQ1GfgqFx6dBgtIxS6GpsPp_eOYRGhVpAzmO1_ygr0"
}),
new Developer({
name: "Loïc Cyr",
role: "Developer"
}),
new Developer({
name: "Céline",
role: "Art"
}),
],
thumbnail_path: "https://img.itch.zone/aW1nLzIwNzAwNDg1LnBuZw==/original/qGDxOj.png",
itch_link: "https://jeanne444.itch.io/froggin-around",
media_paths: [
"https://img.itch.zone/aW1hZ2UvMzQ2ODYzOS8yMDcxMDI1Mi5wbmc=/original/owXY2q.png",
"https://img.itch.zone/aW1hZ2UvMzQ2ODYzOS8yMDcwMDgwOC5wbmc=/original/PTa96E.png",
"https://img.itch.zone/aW1hZ2UvMzQ2ODYzOS8yMDcwMDgwNy5wbmc=/original/PXw75v.png",
"https://img.itch.zone/aW1hZ2UvMzQ2ODYzOS8yMDcwMDY2OC5wbmc=/original/MwyNjV.png",
"https://img.itch.zone/aW1hZ2UvMzQ2ODYzOS8yMDcwMDgwOS5wbmc=/original/FYGa9e.png",
"https://img.itch.zone/aW1hZ2UvMzQ2ODYzOS8yMDcyNDg1Mi5naWY=/original/%2BLoLem.gif"
],
logo_path: "https://img.itch.zone/aW1hZ2UvMzQ2ODYzOS8yMDg2MDc1OC5wbmc=/original/tgccKa.png",
collections: "Ubi Gamelab",
color_scheme: {
primary: "#cf2d30",
secondary: "#b3cf43",
ternary: "#ffffff"
},
})
];
export async function fetchGames(): Promise<Game[]> {
const source = localStorage.getItem('dataSource') || 'local';
if (source === 'local') return localGames;
const games = await LoadGames();
for (const game of games) {
console.log(game)
}
return games.map(convertToNewFormat);
}
function convertToNewFormat(metadata: Metadata): Game {
return new Game({
id: metadata.Id,
title: metadata.Game,
description: metadata.Description,
collections: metadata.Collection,
thumbnail_path: metadata.ThumbnailPath,
media_paths: [metadata.ImagePath],
genres: metadata.Genres,
executable: metadata.Files,
release: metadata.Release,
modification: metadata.Modification,
version: metadata.Version,
players: metadata.Players,
public_repository_link: metadata.PublicRepositoryLink,
developers: metadata.Developers.split(",").map((dev) => new Developer({
name: dev
})),
});
}