Vérification nombre de joueurs pour match
continuous-integration/drone/push Build is passing Details

peristanceBDD
Thomas Chazot 3 years ago
parent 0235e7d8d9
commit 6fe0efbce2

@ -1,4 +1,4 @@
const { io } = require("socket.io-client");
export const socket = io("http://codefirst.iut.uca.fr/containers/BOB_PARTEAM-server-bobParty:3000");
export const socket = io("https://codefirst.iut.uca.fr/containers/BOB_PARTEAM-server-bobParty/server:3000");

@ -1,5 +1,5 @@
import { FC, useState} from "react"
import { Button, FlatList, Pressable } from "react-native"
import { Alert, Button, FlatList, Pressable } from "react-native"
import React from "react"
import { Game } from "../core/game"
@ -51,7 +51,19 @@ FC<{nav: any}> =
async function launchMatch(){
const tmpMatch=MANAGER_MATCH.getCurrentMatch();
if (tmpMatch!==undefined && tmpMatch!==null){
if (tmpMatch.getGame().getNbPlayerMin()>tmpMatch.getTabUsers().length){
Alert.alert("Wait until there is enough players!");
return;
}
else if(tmpMatch.getGame().getNbPlayerMin()<tmpMatch.getTabUsers().length){
Alert.alert("There is too much players!");
return;
}
}
socket.emit("launchMatch", MANAGER_MATCH.getCurrentMatch());
nav.navigate(MANAGER_MATCH.getCurrentMatch()?.getGame().getName().replace(/\s/g, ''));
}
@ -110,7 +122,7 @@ FC<{nav: any}> =
/>
<Pressable
style={style.pressable}
onPress={() => {socket.emit("launchMatch", MANAGER_MATCH.getCurrentMatch()); nav.navigate(MANAGER_MATCH.getCurrentMatch()?.getGame().getName().replace(/\s/g, ''))}}
onPress={() => {launchMatch()}}
>
<Text style={style.text}>Lancer la partie</Text>
</Pressable>

@ -194,13 +194,11 @@ function SignUp(props: { navigation: any; }) {
function initSocket(){
socket.emit("signIn", MANAGER_USER.getCurrentUser()?.id);
MANAGER_CONVERSATION.getTabConv()?.forEach( conv =>{
socket.emit("inConv", conv);
});
socket.on("messageReceived", async () =>{
await handleConversationLoad();
});
socket.on("addedToConv", async (conv) =>{
console.log("HEY");
socket.emit("inConv", conv);
await handleConversationLoad();
});

Loading…
Cancel
Save