Merge branch 'Persistance' of https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY into Persistance
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
commit
ada683e922
@ -0,0 +1,23 @@
|
||||
import React from "react";
|
||||
import create from "zustand";
|
||||
import { MANAGER_USER } from "../../App";
|
||||
import tabSkinApp from "../constSkin";
|
||||
import { Game } from "../core/game";
|
||||
import { Skin } from "../core/Skin";
|
||||
import { User } from "../core/User/user";
|
||||
|
||||
|
||||
// Define store types
|
||||
interface GameState {
|
||||
tabGame: Game[] | undefined;
|
||||
setTabGame: (tabGame: Game[]) => void;
|
||||
resetTabGame: () => void;
|
||||
}
|
||||
|
||||
// Define store data and methods
|
||||
export const useGameStore = create<GameState>()((set, get) => ({
|
||||
tabGame: undefined,
|
||||
setTabGame: (tabGame) => set((state) => ({ tabGame: tabGame })),
|
||||
resetTabGame: () => set((state) => ({ tabGame: undefined })),
|
||||
}));
|
||||
|
@ -0,0 +1,17 @@
|
||||
import { Game } from "../../core/game";
|
||||
|
||||
export default interface ILoaderGame{
|
||||
|
||||
/**
|
||||
* loadAllGame methode that load every Game from the data management system
|
||||
* return an array of Game
|
||||
*/
|
||||
loadAllGame(): Promise<Game[]>;
|
||||
|
||||
/**
|
||||
* loadByID methode that load a match from the data management system by its id
|
||||
* id the id we want to search
|
||||
* return a Game if found, if not null
|
||||
*/
|
||||
loadByID(id:string): Promise<Game | null>;
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
import { Game } from "../../core/game";
|
||||
import { GameSolo } from "../../core/gameSolo";
|
||||
import ILoaderGame from "./ILoaderGame";
|
||||
|
||||
export default class LoaderGameApi implements ILoaderGame{
|
||||
|
||||
private axios = require('axios').default;
|
||||
|
||||
|
||||
async loadAllGame(): Promise<Game[]> {
|
||||
let tab: Game[]=[];
|
||||
await this.axios({
|
||||
method: 'get',
|
||||
url: 'https://jsonplaceholder.typicode.com/todos/1',
|
||||
params: {
|
||||
name: "getAllUser",
|
||||
//Les params genre nom de la fonction en php
|
||||
}
|
||||
})
|
||||
.then(function (response: any) {
|
||||
const map = new Map();
|
||||
map.set(0,0);
|
||||
map.set(100,50);
|
||||
map.set(300,150);
|
||||
map.set(450,1000);
|
||||
const cookieClicker= new GameSolo(1, "Cookie Clicker", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/Pong.png", "/Games/CookieClicker/cookieClicker.tsx", 1, 1, map);
|
||||
const test= new GameSolo(1, "Test", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/Pendu.jpg", "/Games/CookieClicker/cookieClicker.tsx", 1, 1, map);
|
||||
tab=[cookieClicker, test];
|
||||
console.log(tab);
|
||||
});
|
||||
return tab;
|
||||
|
||||
}
|
||||
async loadByID(id: string): Promise<Game | null> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
import { Game } from "../../core/game";
|
||||
import ILoaderGame from "./ILoaderGame";
|
||||
|
||||
export default class ManagerGame{
|
||||
|
||||
private tabGame: Game[] | null=null;
|
||||
|
||||
private loaderGame: ILoaderGame;
|
||||
|
||||
constructor(loader:ILoaderGame){
|
||||
this.loaderGame=loader;
|
||||
}
|
||||
|
||||
getTabGame(){
|
||||
return this.tabGame;
|
||||
}
|
||||
|
||||
setTabGame(g:Game[] | null){
|
||||
this.tabGame=g;
|
||||
}
|
||||
|
||||
getLoaderGame(){
|
||||
return this.loaderGame;
|
||||
}
|
||||
|
||||
setLoaderGame(l:ILoaderGame){
|
||||
this.loaderGame=l;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue