Correction du problème lors du load des jeux
continuous-integration/drone/push Build is passing Details

peristanceBDD
Thomas Chazot 2 years ago
parent 5a43d53b3c
commit e2fb286b00

@ -23,8 +23,9 @@ class GameGateway{
$mapQuery="SELECT * FROM T_J_GAME_MAP_GMP WHERE FK_GAME=:id ORDER BY GMP_KEY";
$this->connection->execQuery($gamesQuery,[]);
$res = $this->connection->getRes();
$i=0;
foreach($res as $row){
$tabkey=[];
$tabKey=[];
$tabValue=[];
$arg=array(':id'=>array($row['PK_ID'], PDO::PARAM_INT));
$this->connection->execQuery($mapQuery,$arg);
@ -41,7 +42,6 @@ class GameGateway{
$row['GAM_NB_PLAYER_MAX'],
$tabKey,
$tabValue);
}
return $tabGames;
}

@ -91,6 +91,7 @@ function CookieClicker(props: { navigation: any }) {
if (tmp !== null) {
if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)) {
MANAGER_MATCH.getCurrentMatch()?.updatePostMatch(tmp, points);
MANAGER_USER.setCurrentUser(tmp);
setUser(tmp);
}
}

@ -5,9 +5,16 @@ import { useMatchStore } from "../../context/matchContext";
import { current } from "@reduxjs/toolkit";
import { ScreenIndicator } from "../../components/ScreenIndicator";
import { TopBar } from "../../components/TopBar";
import { MANAGER_MATCH, MANAGER_USER } from "../../../appManagers";
import { useUserStore } from "../../context/userContext";
export default function TicTacToe(props: { navigation: any}){
const setUser = useUserStore((state) => state.setUser);
const resetMatch = useMatchStore((state) => state.resetMatch);
const [map,setMap]=useState([
['','',''],
['','',''],
@ -46,12 +53,12 @@ export default function TicTacToe(props: { navigation: any}){
const isRowOWinning = map[i] .every((cell)=>cell==="o");
if(isRowXWinning==true){
Alert.alert("X won !");
navigation.goBack();
endGame();
return true;
}
else if(isRowOWinning==true){
Alert.alert("O won !");
navigation.goBack();
endGame();
return true;
}
}
@ -70,12 +77,12 @@ export default function TicTacToe(props: { navigation: any}){
}
if (isColumnXWinning == true){
Alert.alert("X won !");
navigation.goBack();
endGame();
return true;
}
if(isColumnOWinning==true){
Alert.alert("O won !");
navigation.goBack();
endGame();
return true;
}
@ -101,12 +108,12 @@ export default function TicTacToe(props: { navigation: any}){
}
if(isDiag1OWinning==true || isDiag2OWinning==true){
Alert.alert("O won !");
navigation.goBack();
endGame();
return true;
}
if(isDiag1XWinning==true || isDiag2XWinning==true){
Alert.alert("X won !");
navigation.goBack();
endGame();
return true;
}
};
@ -117,11 +124,25 @@ export default function TicTacToe(props: { navigation: any}){
const isRow2Full = map[2] .every((cell)=>cell!=="");
if(isRow0Full==true && isRow1Full==true && isRow2Full==true){
Alert.alert("Draw !");
navigation.goBack();
endGame();
return false;
}
};
function endGame() {
const tmp = MANAGER_USER.getCurrentUser();
if (tmp !== null) {
if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)) {
MANAGER_MATCH.getCurrentMatch()?.updatePostMatch(tmp, 0);
MANAGER_USER.setCurrentUser(tmp);
setUser(tmp);
}
}
navigation.goBack();
resetMatch();
}
return(
<View style={styles.container}>
<TopBar nav={navigation} state={"game"}/>

@ -1,5 +1,5 @@
import { StatusBar } from 'expo-status-bar'
import {View} from 'react-native'
import {Pressable, View, Image} from 'react-native'
import React, { useCallback } from 'react';
import stylesScreen from './style/screens.style';
import { TopBar } from '../components/TopBar';
@ -11,9 +11,12 @@ import { io } from 'socket.io-client';
import { socket } from '../../socketConfig';
import { MANAGER_CONVERSATION, MANAGER_USER } from '../../appManagers';
import { Message } from '../core/message';
import styles from '../components/style/TopBar.style';
function Chat(props: { navigation: any; }) {
const { navigation } = props
const cross = require('../../assets/Icons/UnSelected/Cross.png');
return (
<View style={stylesScreen.container}>
@ -27,6 +30,9 @@ function Chat(props: { navigation: any; }) {
renderItem={({item}) => <ConversationPreviewComponent conv={item} navigation={navigation}/>}
/>
</View>
<Pressable onPress={() => navigation.navigate('Settings')}>
<Image source={cross} style={styles.icon}/>
</Pressable>
<BotBar
nav={navigation}

@ -25,19 +25,20 @@ export default class LoaderGameApi implements ILoaderGame{
case "GameSolo":
let mapSolo = new Map();
for (let i=0; i<game.keys.length; i++){
console.log(game.keys[i], game.name);
mapSolo.set(new Number(game.keys[i]), new Number(game.values[i]))
}
tab.push(new GameSolo(game.id, game.name, game.image, game.nmbPlayerMin, game.nbPlayerMax, mapSolo));
tab.push(new GameSolo(game.id, game.name, game.image, game.nbPlayerMin, game.nbPlayerMax, mapSolo));
break;
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));
tab.push(new GameMulti(game.id, game.name, game.image, game.nbPlayerMin, game.nbPlayerMax, mapMulti));
break;
case "GameCasino":
tab.push(new GameCasino(game.id, game.name, game.image, game.nmbPlayerMin, game.nbPlayerMax));
tab.push(new GameCasino(game.id, game.name, game.image, game.nbPlayerMin, game.nbPlayerMax));
break;
}
});

Loading…
Cancel
Save