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/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 2a45cfa..0000000 --- a/bob_party/index.js +++ /dev/null @@ -1,40 +0,0 @@ -const express = require("express"); -const app = express(); -const PORT = 4000; - - -app.use(express.urlencoded({ extended: true })); -app.use(express.json()); - -const http = require("http").Server(app); -const cors = require("cors"); - -const socketIO = require('socket.io')(http, { - cors: { - origin: "" - } -}); - -//👇🏻 Add this before the app.get() block -socketIO.on('connection', (socket) => { - console.log(`⚡: ${socket.id} user just connected!`); - - socket.on("singIn", (test) => { - console.log(test); - }); - - socket.on('disconnect', () => { - socket.disconnect() - console.log('🔥: A user disconnected'); - }); -}); - -app.get("/api", (req, res) => { - res.json({ - message: "Hello world", - }); -}); - -app.listen(PORT, () => { - console.log(`Server listening on ${PORT}`); -}); \ 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 d995a2e..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: 100 + width: 75, + height: 75 }, cout: { - marginBottom: 20 - } + marginBottom: 20, + color: "white", + fontSize: 15 + }, + image: { + flex: 1, + justifyContent: "center" + }, })