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

peristanceBDD
Thomas Chazot 3 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"; $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();
$i=0;
foreach($res as $row){ foreach($res as $row){
$tabkey=[]; $tabKey=[];
$tabValue=[]; $tabValue=[];
$arg=array(':id'=>array($row['PK_ID'], PDO::PARAM_INT)); $arg=array(':id'=>array($row['PK_ID'], PDO::PARAM_INT));
$this->connection->execQuery($mapQuery,$arg); $this->connection->execQuery($mapQuery,$arg);
@ -40,8 +41,7 @@ class GameGateway{
$row['GAM_NB_PLAYER_MIN'], $row['GAM_NB_PLAYER_MIN'],
$row['GAM_NB_PLAYER_MAX'], $row['GAM_NB_PLAYER_MAX'],
$tabKey, $tabKey,
$tabValue); $tabValue);
} }
return $tabGames; return $tabGames;
} }

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

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

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

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

Loading…
Cancel
Save