UPDATE: Correction de bugs
continuous-integration/drone/push Build is passing Details

peristanceBDD
Thomas Chazot 2 years ago
parent 0057d8ecca
commit 2267eaa529

@ -20,14 +20,28 @@ class GameGateway{
public function getGames():?array{ public function getGames():?array{
$tabGames=null; $tabGames=null;
$gamesQuery="SELECT * FROM T_E_GAME_GAM"; $gamesQuery="SELECT * FROM T_E_GAME_GAM";
$mapQuery="SELECT * FROM T_J_GAME_MAP_GMP WHERE FK_GAME=:id ORDER BY GMP_KEY";
$this->connection->execQuery($gamesQuery,[]); $this->connection->execQuery($gamesQuery,[]);
$res = $this->connection->getRes(); $res = $this->connection->getRes();
foreach($res as $row){ foreach($res as $row){
$tabkey=[];
$tabValue=[];
$arg=array(':id'=>array($row['PK_ID'], PDO::PARAM_INT));
$this->connection->execQuery($mapQuery,$arg);
$resMap = $this->connection->getRes();
foreach($resMap as $rowMap){
$tabKey[]=$rowMap['GMP_KEY'];
$tabValue[]=$rowMap['GMP_VALUE'];
}
$tabGames[]= new Game($row['PK_ID'], $tabGames[]= new Game($row['PK_ID'],
$row['GAM_NAME'], $row['GAM_NAME'],
$row['GAM_IMAGE'], $row['GAM_IMAGE'],
$row['GAM_TYPE'],
$row['GAM_NB_PLAYER_MIN'], $row['GAM_NB_PLAYER_MIN'],
$row['GAM_NB_PLAYER_MAX']); $row['GAM_NB_PLAYER_MAX'],
$tabKey,
$tabValue);
} }
return $tabGames; return $tabGames;
} }

@ -4,12 +4,21 @@ class Game{
public int $id; public int $id;
public string $name; public string $name;
public string $image; public string $image;
public string $type;
public int $nbPlayerMin;
public int $nbPlayerMax;
public array $keys;
public array $values;
public function __construct(int $_id, string $_name, string $_image, string $_type, $_nbPlayerMin, $_nbPlayerMax, array $_keys, array $_values){
public function __construct(int $_id, string $_name, string $_image){
$this->id=$_id; $this->id=$_id;
$this->name=$_name; $this->name=$_name;
$this->image=$_image; $this->image=$_image;
$this->type=$_type;
$this->nbPlayerMin=$_nbPlayerMin;
$this->nbPlayerMax=$_nbPlayerMax;
$this->keys=$_keys;
$this->values=$_values;
} }
} }

@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/ -- https://www.phpmyadmin.net/
-- --
-- Hôte : localhost:8889 -- Hôte : localhost:8889
-- Généré le : ven. 30 déc. 2022 à 14:14 -- Généré le : mar. 03 jan. 2023 à 15:37
-- Version du serveur : 5.7.34 -- Version du serveur : 5.7.34
-- Version de PHP : 7.4.21 -- Version de PHP : 7.4.21
@ -30,11 +30,22 @@ SET time_zone = "+00:00";
CREATE TABLE `T_E_GAME_GAM` ( CREATE TABLE `T_E_GAME_GAM` (
`PK_ID` int(11) NOT NULL, `PK_ID` int(11) NOT NULL,
`GAM_NAME` varchar(50) DEFAULT NULL, `GAM_NAME` varchar(50) DEFAULT NULL,
`GAM_IMAGE` varchar(50) DEFAULT NULL, `GAM_IMAGE` varchar(200) DEFAULT NULL,
`GAM_NB_PLAYER_MIN` int(11) DEFAULT NULL, `GAM_NB_PLAYER_MIN` int(11) DEFAULT NULL,
`GAM_NB_PLAYER_MAX` int(11) DEFAULT NULL `GAM_NB_PLAYER_MAX` int(11) DEFAULT NULL,
`GAM_TYPE` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_E_GAME_GAM`
--
INSERT INTO `T_E_GAME_GAM` (`PK_ID`, `GAM_NAME`, `GAM_IMAGE`, `GAM_NB_PLAYER_MIN`, `GAM_NB_PLAYER_MAX`, `GAM_TYPE`) VALUES
(1, 'Cookie Clicker', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/Pong.png', 1, 1, 'GameSolo'),
(2, 'TicTacToe', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 1, 1, 'GameSolo'),
(3, 'TicTacToe Online', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 2, 2, 'GameMulti'),
(4, 'BlackJack', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/peristanceBDD/bob_party/assets/ImagesJeux/blackjack.jpg', 1, 1, 'GameCasino');
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -182,6 +193,33 @@ INSERT INTO `T_J_DISCUSS_DIS` (`FK_USER`, `FK_CONVERSATION`) VALUES
-- -------------------------------------------------------- -- --------------------------------------------------------
--
-- Structure de la table `T_J_GAME_MAP_GMP`
--
CREATE TABLE `T_J_GAME_MAP_GMP` (
`FK_GAME` int(11) NOT NULL,
`GMP_KEY` int(11) NOT NULL,
`GMP_VALUE` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_J_GAME_MAP_GMP`
--
INSERT INTO `T_J_GAME_MAP_GMP` (`FK_GAME`, `GMP_KEY`, `GMP_VALUE`) VALUES
(1, 0, 0),
(1, 100, 25),
(1, 1000, 30),
(1, 10000, 40),
(1, 100000, 50),
(1, 1000000, 75),
(3, 0, 0),
(3, 1, 25),
(3, 2, 50);
-- --------------------------------------------------------
-- --
-- Structure de la table `T_J_OWN_SKIN_OWN` -- Structure de la table `T_J_OWN_SKIN_OWN`
-- --
@ -205,7 +243,8 @@ INSERT INTO `T_J_OWN_SKIN_OWN` (`FK_USER`, `FK_SKIN`) VALUES
(7, 1), (7, 1),
(8, 1), (8, 1),
(10, 1), (10, 1),
(11, 1); (11, 1),
(12, 1);
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -242,14 +281,15 @@ CREATE TABLE `T_S_USER_USR` (
-- --
INSERT INTO `T_S_USER_USR` (`PK_ID`, `USR_USERNAME`, `USR_PASSWORD`, `USR_NATIONALITY`, `USR_SEX`, `USR_DATE_OF_BIRTH`, `USR_CURRENT_NB_COINS`, `USR_TOTAL_NB_COINS`, `USR_NB_GAMES_PLAYED`, `FK_CURRENT_SKIN`) VALUES INSERT INTO `T_S_USER_USR` (`PK_ID`, `USR_USERNAME`, `USR_PASSWORD`, `USR_NATIONALITY`, `USR_SEX`, `USR_DATE_OF_BIRTH`, `USR_CURRENT_NB_COINS`, `USR_TOTAL_NB_COINS`, `USR_NB_GAMES_PLAYED`, `FK_CURRENT_SKIN`) VALUES
(1, 'tom', 't', 'Anglais(e)', 'M', '2003-07-01', 100, 600, 12, 2), (1, 'tom', 't', 'Anglais(e)', 'M', '2003-07-01', 0, 225, 12, 2),
(2, 'leilla20', 'l', 'France', 'F', '2003-11-22', 0, 0, 0, 1), (2, 'leilla20', 'l', 'France', 'F', '2003-11-22', 0, 0, 0, 1),
(3, 'test', 't', 'Français(e)', 'H', '1999-12-27', 0, 0, 0, 1), (3, 'test', 't', 'Français(e)', 'H', '1999-12-27', 0, 0, 0, 1),
(6, 'LEBg', 'belleBite63*', 'Espagnol(e)', 'Autre', '2001-12-27', 0, 0, 0, 1), (6, 'LEBg', 'belleBite63*', 'Espagnol(e)', 'Autre', '2001-12-27', 0, 0, 0, 1),
(7, 'DYLAN', 'argGR65**', 'Anglais(e)', 'Autre', '2002-12-27', 0, 0, 0, 1), (7, 'DYLAN', 'argGR65**', 'Anglais(e)', 'Autre', '2002-12-27', 0, 0, 0, 1),
(8, 'Marche', 'je45tE**', 'Anglais(e)', 'Femme', '1999-12-27', 0, 0, 0, 1), (8, 'Marche', 'je45tE**', 'Anglais(e)', 'Femme', '1999-12-27', 0, 0, 0, 1),
(10, 'dsqdz', 'AEZQzze1*', 'Francais(e)', 'null', '2005-12-27', 0, 0, 0, 1), (10, 'dsqdz', 'AEZQzze1*', 'Francais(e)', 'null', '2005-12-27', 0, 0, 0, 1),
(11, 'qdsqdz', 'dqzA12****', 'Francais(e)', 'Homme', '2002-12-27', 0, 0, 0, 1); (11, 'qdsqdz', 'dqzA12****', 'Francais(e)', 'Homme', '2002-12-27', 0, 0, 0, 1),
(12, 'thilde', 'coucoulesnazes*M0', 'Francais(e)', 'Femme', '2004-11-02', 0, 0, 0, 1);
-- --
-- Déclencheurs `T_S_USER_USR` -- Déclencheurs `T_S_USER_USR`
@ -268,7 +308,7 @@ DELIMITER ;
-- --
ALTER TABLE `T_E_GAME_GAM` ALTER TABLE `T_E_GAME_GAM`
ADD PRIMARY KEY (`PK_ID`), ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `GAM_NAME` (`GAM_NAME`,`GAM_IMAGE`); ADD UNIQUE KEY `GAM_NAME` (`GAM_NAME`) USING BTREE;
-- --
-- Index pour la table `T_E_MATCH_MTC` -- Index pour la table `T_E_MATCH_MTC`
@ -312,6 +352,12 @@ ALTER TABLE `T_J_DISCUSS_DIS`
ADD PRIMARY KEY (`FK_USER`,`FK_CONVERSATION`), ADD PRIMARY KEY (`FK_USER`,`FK_CONVERSATION`),
ADD KEY `FK_CONVERSATION` (`FK_CONVERSATION`); ADD KEY `FK_CONVERSATION` (`FK_CONVERSATION`);
--
-- Index pour la table `T_J_GAME_MAP_GMP`
--
ALTER TABLE `T_J_GAME_MAP_GMP`
ADD PRIMARY KEY (`FK_GAME`,`GMP_KEY`,`GMP_VALUE`) USING BTREE;
-- --
-- Index pour la table `T_J_OWN_SKIN_OWN` -- Index pour la table `T_J_OWN_SKIN_OWN`
-- --
@ -342,7 +388,7 @@ ALTER TABLE `T_S_USER_USR`
-- AUTO_INCREMENT pour la table `T_E_GAME_GAM` -- AUTO_INCREMENT pour la table `T_E_GAME_GAM`
-- --
ALTER TABLE `T_E_GAME_GAM` ALTER TABLE `T_E_GAME_GAM`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT; MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
-- --
-- AUTO_INCREMENT pour la table `T_E_MATCH_MTC` -- AUTO_INCREMENT pour la table `T_E_MATCH_MTC`
@ -354,7 +400,7 @@ ALTER TABLE `T_E_MATCH_MTC`
-- AUTO_INCREMENT pour la table `T_H_CONVERSATION_COV` -- AUTO_INCREMENT pour la table `T_H_CONVERSATION_COV`
-- --
ALTER TABLE `T_H_CONVERSATION_COV` ALTER TABLE `T_H_CONVERSATION_COV`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=47; MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=33;
-- --
-- AUTO_INCREMENT pour la table `T_H_MESSAGE_MSG` -- AUTO_INCREMENT pour la table `T_H_MESSAGE_MSG`
@ -372,7 +418,7 @@ ALTER TABLE `T_H_SKIN_SKI`
-- AUTO_INCREMENT pour la table `T_S_USER_USR` -- AUTO_INCREMENT pour la table `T_S_USER_USR`
-- --
ALTER TABLE `T_S_USER_USR` ALTER TABLE `T_S_USER_USR`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12; MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
-- --
-- Contraintes pour les tables déchargées -- Contraintes pour les tables déchargées
@ -404,6 +450,12 @@ ALTER TABLE `T_J_DISCUSS_DIS`
ADD CONSTRAINT `t_j_discuss_dis_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE, ADD CONSTRAINT `t_j_discuss_dis_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_discuss_dis_ibfk_2` FOREIGN KEY (`FK_CONVERSATION`) REFERENCES `T_H_CONVERSATION_COV` (`PK_ID`) ON DELETE CASCADE; ADD CONSTRAINT `t_j_discuss_dis_ibfk_2` FOREIGN KEY (`FK_CONVERSATION`) REFERENCES `T_H_CONVERSATION_COV` (`PK_ID`) ON DELETE CASCADE;
--
-- Contraintes pour la table `T_J_GAME_MAP_GMP`
--
ALTER TABLE `T_J_GAME_MAP_GMP`
ADD CONSTRAINT `t_j_game_map_gmp_ibfk_1` FOREIGN KEY (`FK_GAME`) REFERENCES `T_E_GAME_GAM` (`PK_ID`);
-- --
-- Contraintes pour la table `T_J_OWN_SKIN_OWN` -- Contraintes pour la table `T_J_OWN_SKIN_OWN`
-- --

@ -176,11 +176,6 @@ export default function BlackJack(){
setGameover(true); setGameover(true);
setGameMessage("You Win $ "+ betValue); setGameMessage("You Win $ "+ betValue);
}else if(dealerPoints > 21 && playerPoints < 22){
await modifAmount(amount+betValue);
setTotalBet(0);
setGameover(true);
setGameMessage("You Win $ "+ betValue);
} }
else if(playerPoints > 21 && dealerPoints <= 21){ else if(playerPoints > 21 && dealerPoints <= 21){
await modifAmount(amount); await modifAmount(amount);
@ -196,8 +191,8 @@ export default function BlackJack(){
setGameover(true); setGameover(true);
setGameMessage("Push!"); setGameMessage("Push!");
}else{ }else{
await modifAmount(amount+totalBet);
await modifAmount(amount);
setTotalBet(0); setTotalBet(0);
setGameover(true); setGameover(true);
setGameMessage("Dealer Wins, You Lost"); setGameMessage("Dealer Wins, You Lost");

@ -2,16 +2,14 @@ export abstract class Game{
readonly id:number; readonly id:number;
private name:string; private name:string;
private imageSource:string; private imageSource:string;
private gameSource:string;
private nbPlayerMin: number; private nbPlayerMin: number;
private nbPlayerMax:number; private nbPlayerMax:number;
/* Constructor of the class */ /* Constructor of the class */
constructor (id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){ constructor (id:number, name:string, imageSource:string, nbPlayerMin:number, nbPlayerMax:number){
this.id=id; this.id=id;
this.name=name; this.name=name;
this.imageSource=imageSource; this.imageSource=imageSource;
this.gameSource=gameSource;
this.nbPlayerMin=nbPlayerMin; this.nbPlayerMin=nbPlayerMin;
this.nbPlayerMax=nbPlayerMax; this.nbPlayerMax=nbPlayerMax;
} }
@ -41,16 +39,6 @@ export abstract class Game{
this.imageSource=imageSource; this.imageSource=imageSource;
} }
/* Brief : Function getting the source of a game */
getGameSource(){
return this.gameSource;
}
/* Brief : Function setting the source of a game */
setGameSource(gameSource:string){
this.gameSource=gameSource;
}
/* Brief : Function getting the number of player */ /* Brief : Function getting the number of player */
getNbPlayerMin(){ getNbPlayerMin(){
return this.nbPlayerMin; return this.nbPlayerMin;

@ -5,8 +5,10 @@ export class UserCoinsModifier{
async addCoins(u:User, coins:number){ async addCoins(u:User, coins:number){
u.setCurrentCoins(u.getCurrentCoins()+coins); const newCoins: number=coins+u.getCurrentCoins();
u.setTotalCoins(u.getTotalCoins()+coins); const newTotalCoins: number=coins+u.getTotalCoins();
u.setCurrentCoins(newCoins);
u.setTotalCoins(newTotalCoins);
await MANAGER_USER.getsaverUser().updateUser(u); await MANAGER_USER.getsaverUser().updateUser(u);
MANAGER_USER.setCurrentUser(u); MANAGER_USER.setCurrentUser(u);
} }

@ -2,8 +2,8 @@ import { Game } from './game'
export class GameCasino extends Game{ export class GameCasino extends Game{
constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){ constructor(id:number, name:string, imageSource:string, nbPlayerMin:number, nbPlayerMax:number){
super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax); super(id, name, imageSource, nbPlayerMin, nbPlayerMax);
} }
coinsCalculator(points: number): number { coinsCalculator(points: number): number {

@ -3,8 +3,8 @@ import { Game } from './game'
export class GameMulti extends Game{ export class GameMulti extends Game{
readonly rankToCoins:Map<number,number> readonly rankToCoins:Map<number,number>
constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map<number,number>){ constructor(id:number, name:string, imageSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map<number,number>){
super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax); super(id, name, imageSource, nbPlayerMin, nbPlayerMax);
this.rankToCoins=rankToCoins; this.rankToCoins=rankToCoins;
} }

@ -3,8 +3,8 @@ import { Game } from './game'
export class GameSolo extends Game{ export class GameSolo extends Game{
readonly ptsToCoins:Map<number,number> readonly ptsToCoins:Map<number,number>
constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map<number,number>){ constructor(id:number, name:string, imageSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map<number,number>){
super(id, name, imageSource, gameSource, nbPlayerMin,nbPlayerMax); super(id, name, imageSource, nbPlayerMin,nbPlayerMax);
this.ptsToCoins=ptsToCoins; this.ptsToCoins=ptsToCoins;
} }
@ -19,9 +19,11 @@ export class GameSolo extends Game{
let test; let test;
for (let key of this.ptsToCoins.keys()){ for (let key of this.ptsToCoins.keys()){
test = this.ptsToCoins.get(key); test = this.ptsToCoins.get(key);
coins=key; if (test != undefined){
if (test != undefined && test>=points){ coins=test;
return coins; if (test>=points){
return coins;
}
} }
} }
return coins; return coins;

@ -4,7 +4,7 @@ import { GameCasino } from '../GameCasino';
// Instances // Instances
const img = ""; const img = "";
let game = new GameCasino(1, "bo jeu", img, "super jeu", 1, 5); let game = new GameCasino(1, "bo jeu", img, 1, 5);
// Get tests // Get tests

@ -9,7 +9,7 @@ let myMap = new Map<number, number>([
[2, 5], [2, 5],
[1, 10] [1, 10]
]); ]);
let game = new GameMulti(1, "bo jeu", img, "super jeu", 1, 5, myMap); let game = new GameMulti(1, "bo jeu", img, 1, 5, myMap);
// Get tests // Get tests

@ -8,7 +8,7 @@ let myMap = new Map<number, number>([
[100, 5], [100, 5],
[150, 6] [150, 6]
]); ]);
let game=new GameSolo(1, "bo jeu", img, "super jeu", 1, 1, myMap); let game=new GameSolo(1, "bo jeu", img, 1, 1, myMap);
// Get tests // Get tests

@ -21,8 +21,8 @@ let myMap = new Map<number, number>([
[150, 6] [150, 6]
]); ]);
let tabU2:User[] = []; let tabU2:User[] = [];
let game=new GameSolo(1, "bo jeu", img, "super jeu", 1, 1, myMap); let game=new GameSolo(1, "bo jeu", img, 1, 1, myMap);
let game2 = new GameSolo(2, "jeu magnifique", img, "wow jeu", 1, 1, myMap) let game2 = new GameSolo(2, "jeu magnifique", img, 1, 1, myMap)
let match = new MatchSolo(1, false, tabU, game); let match = new MatchSolo(1, false, tabU, game);
let match2 = new MatchSolo(1, false, tabU2, game2); let match2 = new MatchSolo(1, false, tabU2, game2);
let match3 = new MatchSolo(1, false, tabU, game); let match3 = new MatchSolo(1, false, tabU, game);

@ -107,7 +107,7 @@ function SignIn(props: { navigation: any; }) {
} }
async function handleGameLoad(){ async function handleGameLoad(){
MANAGER_GAME.setTabGame(await MANAGER_GAME.getLoaderGame().loadAllGame()); MANAGER_GAME.setTabGame(await MANAGER_GAME.getLoaderGame().loadAllGames());
MANAGER_GAME.getTabGame().forEach(game => { MANAGER_GAME.getTabGame().forEach(game => {
if (game.getNbPlayerMin()>1){ if (game.getNbPlayerMin()>1){
MANAGER_GAME.getTabGameMulti().push(game); MANAGER_GAME.getTabGameMulti().push(game);
@ -119,7 +119,6 @@ function SignIn(props: { navigation: any; }) {
setTabGame(MANAGER_GAME.getTabGame()); setTabGame(MANAGER_GAME.getTabGame());
setTabGameMulti(MANAGER_GAME.getTabGameMulti()) setTabGameMulti(MANAGER_GAME.getTabGameMulti())
setTabGameSolo(MANAGER_GAME.getTabGameSolo()); setTabGameSolo(MANAGER_GAME.getTabGameSolo());
} }

@ -6,7 +6,7 @@ export default interface ILoaderGame{
* loadAllGame methode that load every Game from the data management system * loadAllGame methode that load every Game from the data management system
* return an array of Game * return an array of Game
*/ */
loadAllGame(): Promise<Game[]>; loadAllGames(): Promise<Game[]>;
/** /**
* loadByID methode that load a match from the data management system by its id * loadByID methode that load a match from the data management system by its id

@ -1,4 +1,5 @@
import { Game } from "../../core/game"; import { Game } from "../../core/game";
import { GameCasino } from "../../core/gameCasino";
import { GameMulti } from "../../core/gameMulti"; import { GameMulti } from "../../core/gameMulti";
import { GameSolo } from "../../core/gameSolo"; import { GameSolo } from "../../core/gameSolo";
import ILoaderGame from "./ILoaderGame"; import ILoaderGame from "./ILoaderGame";
@ -8,28 +9,37 @@ export default class LoaderGameApi implements ILoaderGame{
private axios = require('axios').default; private axios = require('axios').default;
async loadAllGame(): Promise<Game[]> { async loadAllGames(): Promise<Game[]> {
let tab: Game[]=[]; let tab: Game[]=[];
const url="http://localhost:8888/api-rest/index.php/getGames";
await this.axios({ await this.axios({
method: 'get', method: 'get',
url: 'https://jsonplaceholder.typicode.com/todos/1', url: url,
params: {
name: "getAllUser",
//Les params genre nom de la fonction en php
}
}) })
.then(function (response: any) { .then(function (response: any) {
const map = new Map(); response.data.forEach(game => {
map.set(0,0); switch(game.type){
map.set(100,50); case "GameSolo":
map.set(300,150); let mapSolo = new Map();
map.set(450,1000); for (let i=0; i<game.keys.length; i++){
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", "./src/Games/CookieClicker/cookieClicker.tsx", 1, 1, map); mapSolo.set(new Number(game.keys[i]), new Number(game.values[i]))
const ticTacToe= new GameSolo(2,"TicTacToe", "https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg", "./src/Games/Tic-Tac-Toe/tic_tac_toe.tsx", 1, 1, map); }
const ticTacToeOnline= new GameSolo(3,"TicTacToeOnline", "https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg", "./src/Games/Tic-Tac-Toe/tic_tac_toe_online.tsx", 2, 2, map); tab.push(new GameSolo(game.id, game.name, game.image, game.nmbPlayerMin, game.nbPlayerMax, mapSolo));
const blackjack = new GameMulti(4, "BlackJack", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/peristanceBDD/bob_party/assets/ImagesJeux/blackjack.jpg", "./src/Games/BlackJack/blackJack", 1, 1, map) break;
tab=[cookieClicker,ticTacToe, ticTacToeOnline, blackjack]; case "GameMulti":
const mapMulti = new Map();
for (let i=0; i<game.keys.length; i++){
mapMulti.set(new Number(game.keys[i]), new Number(game.values[i]));
}
tab.push(new GameMulti(game.id, game.name, game.image, game.nmbPlayerMin, game.nbPlayerMax, mapMulti));
break;
case "GameCasino":
tab.push(new GameCasino(game.id, game.name, game.image, game.nmbPlayerMin, game.nbPlayerMax));
break;
}
});
}); });
return tab; return tab;

@ -24,7 +24,7 @@ export default class StubUser implements ILoaderUser{
[150, 6] [150, 6]
]); ]);
game:GameSolo = new GameSolo(1, 'SuperJeu', "", 'source', 1, 1, this.map); game:GameSolo = new GameSolo(1, 'SuperJeu', "", 1, 1, this.map);
match:Match = new MatchSolo(1, false, this.tabUS, this.game); match:Match = new MatchSolo(1, false, this.tabUS, this.game);

@ -7,7 +7,7 @@ let myMap = new Map<number, number>([
[150, 6] [150, 6]
]); ]);
let game=new GameSolo(1, "bo jeu", "", "super jeu", 1, 1, myMap); let game=new GameSolo(1, "bo jeu", "", 1, 1, myMap);
export default game; export default game;
Loading…
Cancel
Save