diff --git a/bob_party/App.tsx b/bob_party/App.tsx index 654dfe5..cfa2d69 100644 --- a/bob_party/App.tsx +++ b/bob_party/App.tsx @@ -7,8 +7,10 @@ import { useFonts } from 'expo-font'; + export default function App() { + const [fontsLoaded] = useFonts({ 'Helvetica': require('./assets/fonts/Helvetica.ttf'), }); diff --git a/bob_party/assets/ImagesJeux/CookieClicker/ChristmasCookie.png b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasCookie.png new file mode 100644 index 0000000..05956be Binary files /dev/null and b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasCookie.png differ diff --git a/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFactory.png b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFactory.png new file mode 100644 index 0000000..d018586 Binary files /dev/null and b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFactory.png differ diff --git a/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFarm.png b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFarm.png new file mode 100644 index 0000000..c7243da Binary files /dev/null and b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFarm.png differ diff --git a/bob_party/assets/ImagesJeux/CookieClicker/ChristmasGrandma.png b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasGrandma.png new file mode 100644 index 0000000..2d73fbe Binary files /dev/null and b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasGrandma.png differ diff --git a/bob_party/assets/ImagesJeux/CookieClicker/ChristmasPortal.png b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasPortal.png new file mode 100644 index 0000000..4bfb874 Binary files /dev/null and b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasPortal.png differ diff --git a/bob_party/assets/ImagesJeux/CookieClicker/ChristmasTower.png b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasTower.png new file mode 100644 index 0000000..670b9d0 Binary files /dev/null and b/bob_party/assets/ImagesJeux/CookieClicker/ChristmasTower.png differ diff --git a/bob_party/index.js b/bob_party/index.js deleted file mode 100644 index 925b4d7..0000000 --- a/bob_party/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import React from 'react' -import App from './App' -// export for others scripts to use - - - -export default function Index(){ - return( - - ) -} \ No newline at end of file diff --git a/bob_party/initSocket.js b/bob_party/initSocket.js new file mode 100644 index 0000000..1591c6a --- /dev/null +++ b/bob_party/initSocket.js @@ -0,0 +1,8 @@ +const { io } = require("socket.io-client"); + + + +export default socket = io("http://localhost:3000"); + + + diff --git a/bob_party/server.js b/bob_party/server.js new file mode 100644 index 0000000..a5dc03f --- /dev/null +++ b/bob_party/server.js @@ -0,0 +1,22 @@ +const express = require('express'); +const app = express(); +const http = require('http'); +const server = http.createServer(app); +const { Server } = require("socket.io"); +const io = new Server(server); + +const connectUsers = [] + +io.on('connection', (socket) => { + console.log(socket.id) + + socket.on('joinRoom', ({username}) => { + connectUsers.push(username) + + socket.emit('roomJoined', connectUsers) + }); +}); + +server.listen(3000, () => { + console.log('listening on *:3000'); +}); \ No newline at end of file diff --git a/bob_party/src/Games/CookieClicker/cookieClicker.tsx b/bob_party/src/Games/CookieClicker/cookieClicker.tsx index 7b4b3ec..08a73c7 100644 --- a/bob_party/src/Games/CookieClicker/cookieClicker.tsx +++ b/bob_party/src/Games/CookieClicker/cookieClicker.tsx @@ -8,6 +8,7 @@ import { Image, TouchableHighlight, Alert, + ImageBackground, } from 'react-native' import { MANAGER_MATCH, MANAGER_USER } from '../../../appManagers'; import { useMatchStore } from '../../context/matchContext'; @@ -16,12 +17,12 @@ import { Match } from '../../core/Match/match'; import { User } from '../../core/User/user'; -let points=0; +let points = 0; -function CookieClicker(props: { navigation: any}){ +function CookieClicker(props: { navigation: any }) { const { navigation } = props - const GAMING_TIME=120; + const GAMING_TIME = 120; const setUser = useUserStore((state) => state.setUser); @@ -39,148 +40,154 @@ function CookieClicker(props: { navigation: any}){ const [timer, setTimer] = useState(GAMING_TIME); - function onPressCookie(){ - setMoney(money+clickSpeed); - setCount(count+clickSpeed); - points=count+clickSpeed; + function onPressCookie() { + setMoney(money + clickSpeed); + setCount(count + clickSpeed); + points = count + clickSpeed; } - function onPressGrandma(){ - if (money>=grandmaCost){ - setMoney(money-grandmaCost); - setClickSpeed(clickSpeed+1); - setGrandmaCost(grandmaCost+10); + function onPressGrandma() { + if (money >= grandmaCost) { + setMoney(money - grandmaCost); + setClickSpeed(clickSpeed + 1); + setGrandmaCost(grandmaCost + 10); } } - function onPressFarm(){ - if (money>=farmCost){ - setMoney(money-farmCost); - setClickSpeed(clickSpeed+25); - setFarmCost(farmCost+250); + function onPressFarm() { + if (money >= farmCost) { + setMoney(money - farmCost); + setClickSpeed(clickSpeed + 25); + setFarmCost(farmCost + 250); } } - function onPressFactory(){ - if (money>=factoryCost){ - setMoney(money-factoryCost); - setClickSpeed(clickSpeed+200); - setFactoryCost(factoryCost+2000); + function onPressFactory() { + if (money >= factoryCost) { + setMoney(money - factoryCost); + setClickSpeed(clickSpeed + 200); + setFactoryCost(factoryCost + 2000); } } - function onPressWizard(){ - if (money>=wizardCost){ - setMoney(money-wizardCost); - setClickSpeed(clickSpeed+2500); - setWizardCost(wizardCost+25000); + function onPressWizard() { + if (money >= wizardCost) { + setMoney(money - wizardCost); + setClickSpeed(clickSpeed + 2500); + setWizardCost(wizardCost + 25000); } } - function onPressPortal(){ - if (money>=portalCost){ - setMoney(money-portalCost); - setClickSpeed(clickSpeed+20000); - setPortalCost(portalCost+200000); + function onPressPortal() { + if (money >= portalCost) { + setMoney(money - portalCost); + setClickSpeed(clickSpeed + 20000); + setPortalCost(portalCost + 200000); } } - function endGame(){ - const tmp=MANAGER_USER.getCurrentUser(); - if (tmp!==null){ - if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)){ + function endGame() { + const tmp = MANAGER_USER.getCurrentUser(); + if (tmp !== null) { + if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)) { MANAGER_MATCH.getCurrentMatch()?.updatePostMatch(tmp, points); - setUser(tmp); + setUser(tmp); } } - resetMatch(); + resetMatch(); } useEffect(() => { - let counter=GAMING_TIME; + let counter = GAMING_TIME; var oneSecInterval = setInterval(() => { setTimer(timer => timer - 1); - counter --; + counter--; if (counter == 0) { - clearInterval(oneSecInterval); - endGame(); - Alert.alert("fin du jeu"); - navigation.navigate('Home'); + clearInterval(oneSecInterval); + endGame(); + Alert.alert("fin du jeu"); + navigation.navigate('Home'); } }, 1000); - },[]); - + }, []); + + + return ( + + + + + Timer: {timer} + + + + + + Argent {money} + + + Points {count} + + + + + + + + + Cost {grandmaCost} + + - return ( - - - - Timer: {timer} + + + + + + Cost {farmCost} - - - - - Argent {money} + + + + + + + + Cost {factoryCost} - - Points {count} + + + + + + + + Cost {wizardCost} - - - - - - - Cost {grandmaCost} - - - - - - - - - Cost {farmCost} - - - - - - - - - Cost {factoryCost} - - - - - - - - - Cost {wizardCost} - - - - - - - - - Cost {portalCost} - - + + + + + + Cost {portalCost} + + + - ) - } + + + ) +} const styles = StyleSheet.create({ container: { + flex: 1, + }, + containerTop:{ top: 75, margin: 10, flex: 1, @@ -190,7 +197,6 @@ const styles = StyleSheet.create({ containerRight: { flex: 1, flexWrap: "wrap", - top: 100, marginBottom: 20, left: 100, }, @@ -208,12 +214,18 @@ const styles = StyleSheet.create({ marginBottom: 10 }, photo: { - width: 50, - height: 50 + width: 75, + height: 75 }, cout: { - marginBottom: 20 - } + marginBottom: 20, + color: "white", + fontSize: 15 + }, + image: { + flex: 1, + justifyContent: "center" + }, }) diff --git a/bob_party/src/Games/Tic-Tac-Toe/tic-tac-toe.tsx b/bob_party/src/Games/Tic-Tac-Toe/tic-tac-toe.tsx new file mode 100644 index 0000000..a73cdfc --- /dev/null +++ b/bob_party/src/Games/Tic-Tac-Toe/tic-tac-toe.tsx @@ -0,0 +1,88 @@ +import {ImageBackground, StyleSheet, Text, View } from "react-native"; +import React, {useState} from "react"; + +export default function tic_tac_toe(){ + const [map,setMap]=useState([ + ['o','',''], + ['','x','x'], + ['o','',''], + ]); + + return( + + TIC TAC TOE + + + {map.map((row)=>( + + {row.map((cell)=> ( + + {cell === "o" && } + {cell === "x" &&( + + + + + )} + + ))} + + ))} + + + + + ); +} + +const styles= StyleSheet.create({ + container:{ + flex:1, + backgroundColor:"#45444E", + alignItems:"center", + justifyContent:"center", + }, + grid:{ + width:375, + height:375, + alignItems:"center", + justifyContent:"center", + }, + row:{ + flex:1, + flexDirection:"row", + }, + cell:{ + width:100, + flex:1, + }, + circle:{ + left:15, + top:15, + width:90, + height:90, + backgroundColor:"#0085FF", + borderRadius:50 + }, + cross:{ + width:"100%", + height:"100%", + }, + crossLine:{ + left:52, + top:15, + position:"absolute", + width:15, + height:100, + borderRadius:50, + backgroundColor:"#0085FF", + transform:[{rotate:"45deg"},], + }, + crossLineReversed:{ + transform:[{rotate:"-45deg"},], + }, + map:{ + aspectRatio:1, + padding:5 + } +}) \ No newline at end of file diff --git a/bob_party/src/navigation/AppNavigator.tsx b/bob_party/src/navigation/AppNavigator.tsx index 1f727c4..99af4ce 100644 --- a/bob_party/src/navigation/AppNavigator.tsx +++ b/bob_party/src/navigation/AppNavigator.tsx @@ -15,6 +15,7 @@ import SignUp from '../screens/SignUp' import LobbySolo from '../screens/LobbySolo' import CookieClicker from '../Games/CookieClicker/cookieClicker' import MatchMaking from '../screens/MatchMaking' +import TicTacToe from '../Games/Tic-Tac-Toe/tic-tac-toe' const HomeStack = createStackNavigator(); @@ -96,6 +97,7 @@ function GameSoloStackScreen() { + ); } diff --git a/bob_party/src/screens/Settings.tsx b/bob_party/src/screens/Settings.tsx index bbe1eb4..733f659 100644 --- a/bob_party/src/screens/Settings.tsx +++ b/bob_party/src/screens/Settings.tsx @@ -5,10 +5,6 @@ import stylesScreen from './style/screens.style'; import styles from './style/Settings.style'; import { TopBar } from '../components/TopBar'; import { ButtonGreySmall } from '../components/ButtonGreySmall'; -import { useDispatch, useSelector } from 'react-redux'; -import { RootState } from '../redux/store'; -import Dialog from "react-native-dialog" -import RNPickerSelect from "react-native-picker-select"; import { PickerGreySmall } from '../components/PickerGreySmall'; import { useUserStore } from '../context/userContext'; import DialogInput from 'react-native-dialog-input'; @@ -17,6 +13,7 @@ import { MANAGER_USER } from '../../appManagers'; function Settings(props: { navigation: any; }) { const { navigation } = props + const setUser = useUserStore((state) => state.setUser); @@ -29,26 +26,45 @@ function Settings(props: { navigation: any; }) { async function changeUsername(username:string){ - const m = new UserModificationManager(); - const tmp=MANAGER_USER.getCurrentUser(); - if (tmp!==null){ - await m.changeUsername(tmp, username); + let userManager = new UserModificationManager(); + let tmp=MANAGER_USER.getCurrentUser(); + if (tmp!=null){ + await userManager.changeUsername(tmp, username); setUser(tmp); MANAGER_USER.setCurrentUser(tmp); } } async function changePassword(password:string){ - const m = new UserModificationManager(); - const tmp=MANAGER_USER.getCurrentUser(); - if (tmp!==null){ - await m.changePassword(tmp, password); + let userManager = new UserModificationManager(); + let tmp=MANAGER_USER.getCurrentUser(); + if (tmp!=null){ + await userManager.changePassword(tmp, password); + setUser(tmp); + MANAGER_USER.setCurrentUser(tmp); + } + } + + async function changeSexe(sexe:string){ + let userManager = new UserModificationManager(); + let tmp=MANAGER_USER.getCurrentUser(); + if (tmp!=null && sexe != null){ + await userManager.changeSexe(tmp, sexe); + setUser(tmp); + MANAGER_USER.setCurrentUser(tmp); + } + } + + async function changeNationality(nationality:string){ + let userManager = new UserModificationManager(); + let tmp=MANAGER_USER.getCurrentUser(); + if (tmp!=null && nationality != null){ + await userManager.changeNationality(tmp, nationality); setUser(tmp); MANAGER_USER.setCurrentUser(tmp); } } - const dispatch=useDispatch(); return ( @@ -72,11 +88,11 @@ function Settings(props: { navigation: any; }) { Nationalité: {useUserStore().user?.getNationality()} - setSelectedNationality(value)} donePress={() => dispatch(updateNationality(selectedNationality))} values={["Francais", "Anglais"]} /> + setSelectedNationality(value)} donePress={() => changeNationality(selectedNationality)} values={[ { label: 'France', value: 'Francais(e)' }, { label: 'Royaume-Uni', value: 'Anglais(e)' }, { label: 'Espagne', value: 'Espagnol(e)' }, { label: 'Belgique', value: 'Belge' }, { label: 'Allemagne', value: 'Allemand(e)' }, ]}/> Sexe: {useUserStore().user?.getSexe()} - setSelectedSex(value)} donePress={() => dispatch(updateSex(selectedSex))} values={["Homme", "Femme", "Autre"]} /> + setSelectedSex(value)} donePress={() => changeSexe(selectedSex)} values={[ { label: 'Homme', value: 'Homme' }, { label: 'Femme', value: 'Femme' }, {label: 'Autre', value: 'Autre' } ]} /> ID: {useUserStore().user?.getId()} diff --git a/bob_party/src/services/gameService/loaderGameApi.ts b/bob_party/src/services/gameService/loaderGameApi.ts index 2529784..49d5660 100644 --- a/bob_party/src/services/gameService/loaderGameApi.ts +++ b/bob_party/src/services/gameService/loaderGameApi.ts @@ -24,7 +24,9 @@ export default class LoaderGameApi implements ILoaderGame{ 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); - tab=[cookieClicker]; + 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", "/Games/Tic-Tac-Toe/tic-tac-toe.tsx", 1, 1, map); + tab=[cookieClicker,ticTacToe]; + }); return tab; diff --git a/bob_party/src/testGameSolo.ts b/bob_party/src/testGameSolo.ts index 5121644..c8cfbb3 100644 --- a/bob_party/src/testGameSolo.ts +++ b/bob_party/src/testGameSolo.ts @@ -9,4 +9,5 @@ let myMap = new Map([ let game=new GameSolo(1, "bo jeu", "", "super jeu", 1, 1, myMap); + export default game; \ No newline at end of file