Merge branch 'Persistance' of https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY into Persistance
continuous-integration/drone/push Build is failing Details

Persistance
Mathilde JEAN 2 years ago
commit 9d23ade7a2

@ -7,8 +7,10 @@ import { useFonts } from 'expo-font';
export default function App() { export default function App() {
const [fontsLoaded] = useFonts({ const [fontsLoaded] = useFonts({
'Helvetica': require('./assets/fonts/Helvetica.ttf'), 'Helvetica': require('./assets/fonts/Helvetica.ttf'),
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1009 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 KiB

@ -1,11 +0,0 @@
import React from 'react'
import App from './App'
// export for others scripts to use
export default function Index(){
return(
<App/>
)
}

@ -0,0 +1,8 @@
const { io } = require("socket.io-client");
export default socket = io("http://localhost:3000");

@ -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');
});

@ -8,6 +8,7 @@ import {
Image, Image,
TouchableHighlight, TouchableHighlight,
Alert, Alert,
ImageBackground,
} from 'react-native' } from 'react-native'
import { MANAGER_MATCH, MANAGER_USER } from '../../../appManagers'; import { MANAGER_MATCH, MANAGER_USER } from '../../../appManagers';
import { useMatchStore } from '../../context/matchContext'; import { useMatchStore } from '../../context/matchContext';
@ -16,12 +17,12 @@ import { Match } from '../../core/Match/match';
import { User } from '../../core/User/user'; 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 { navigation } = props
const GAMING_TIME=120; const GAMING_TIME = 120;
const setUser = useUserStore((state) => state.setUser); const setUser = useUserStore((state) => state.setUser);
@ -39,56 +40,56 @@ function CookieClicker(props: { navigation: any}){
const [timer, setTimer] = useState(GAMING_TIME); const [timer, setTimer] = useState(GAMING_TIME);
function onPressCookie(){ function onPressCookie() {
setMoney(money+clickSpeed); setMoney(money + clickSpeed);
setCount(count+clickSpeed); setCount(count + clickSpeed);
points=count+clickSpeed; points = count + clickSpeed;
} }
function onPressGrandma(){ function onPressGrandma() {
if (money>=grandmaCost){ if (money >= grandmaCost) {
setMoney(money-grandmaCost); setMoney(money - grandmaCost);
setClickSpeed(clickSpeed+1); setClickSpeed(clickSpeed + 1);
setGrandmaCost(grandmaCost+10); setGrandmaCost(grandmaCost + 10);
} }
} }
function onPressFarm(){ function onPressFarm() {
if (money>=farmCost){ if (money >= farmCost) {
setMoney(money-farmCost); setMoney(money - farmCost);
setClickSpeed(clickSpeed+25); setClickSpeed(clickSpeed + 25);
setFarmCost(farmCost+250); setFarmCost(farmCost + 250);
} }
} }
function onPressFactory(){ function onPressFactory() {
if (money>=factoryCost){ if (money >= factoryCost) {
setMoney(money-factoryCost); setMoney(money - factoryCost);
setClickSpeed(clickSpeed+200); setClickSpeed(clickSpeed + 200);
setFactoryCost(factoryCost+2000); setFactoryCost(factoryCost + 2000);
} }
} }
function onPressWizard(){ function onPressWizard() {
if (money>=wizardCost){ if (money >= wizardCost) {
setMoney(money-wizardCost); setMoney(money - wizardCost);
setClickSpeed(clickSpeed+2500); setClickSpeed(clickSpeed + 2500);
setWizardCost(wizardCost+25000); setWizardCost(wizardCost + 25000);
} }
} }
function onPressPortal(){ function onPressPortal() {
if (money>=portalCost){ if (money >= portalCost) {
setMoney(money-portalCost); setMoney(money - portalCost);
setClickSpeed(clickSpeed+20000); setClickSpeed(clickSpeed + 20000);
setPortalCost(portalCost+200000); setPortalCost(portalCost + 200000);
} }
} }
function endGame(){ function endGame() {
const tmp=MANAGER_USER.getCurrentUser(); const tmp = MANAGER_USER.getCurrentUser();
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);
setUser(tmp); setUser(tmp);
} }
@ -97,90 +98,96 @@ function CookieClicker(props: { navigation: any}){
} }
useEffect(() => { useEffect(() => {
let counter=GAMING_TIME; let counter = GAMING_TIME;
var oneSecInterval = setInterval(() => { var oneSecInterval = setInterval(() => {
setTimer(timer => timer - 1); setTimer(timer => timer - 1);
counter --; counter--;
if (counter == 0) { if (counter == 0) {
clearInterval(oneSecInterval); clearInterval(oneSecInterval);
endGame(); endGame();
Alert.alert("fin du jeu"); Alert.alert("fin du jeu");
navigation.navigate('Home'); navigation.navigate('Home');
} }
}, 1000); }, 1000);
},[]); }, []);
return (
<View style={styles.container}>
<ImageBackground source={{ uri: "https://i0.wp.com/lesfoliesdejenny.fr/wp-content/uploads/2021/12/5.png?w=1080&ssl=1" }} resizeMode="cover" style={styles.image}>
<View style={styles.containerTop}>
<Text style={styles.cout}>
Timer: {timer}
</Text>
<TouchableHighlight onPress={onPressCookie} >
<Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasCookie.png' }} />
</TouchableHighlight>
<Text style={styles.cout}>
Argent {money}
</Text>
<Text style={styles.cout}>
Points {count}
</Text>
<View style={styles.containerRight}>
<TouchableHighlight onPress={onPressGrandma}>
<Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasGrandma.png' }} />
</TouchableHighlight>
<View>
<Text style={styles.cout}>
Cost {grandmaCost}
</Text>
</View>
return ( <TouchableHighlight onPress={onPressFarm} style={styles.photo}>
<View style={styles.container}> <Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFarm.png' }} />
<View > </TouchableHighlight>
<Text> <View>
Timer: {timer} <Text style={styles.cout}>
Cost {farmCost}
</Text> </Text>
<TouchableHighlight onPress={onPressCookie} > </View>
<Image style={styles.photo} source={{uri: 'https://cdn-icons-png.flaticon.com/512/614/614131.png'}}/>
</TouchableHighlight> <TouchableHighlight onPress={onPressFactory}>
<Text> <Image style={styles.photo} source={{ uri: 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/Persistance/bob_party/assets/ImagesJeux/CookieClicker/ChristmasFactory.png' }} />
Argent {money} </TouchableHighlight>
<View>
<Text style={styles.cout}>
Cost {factoryCost}
</Text> </Text>
<Text> </View>
Points {count}
<TouchableHighlight onPress={onPressWizard}>
<Image style={styles.photo} source={{ uri: 'https://www.clasher.us/images/coc/units/Wizard_Tower7.png' }} />
</TouchableHighlight>
<View>
<Text style={styles.cout}>
Cost {wizardCost}
</Text> </Text>
</View> </View>
<View style={styles.containerRight}>
<TouchableHighlight onPress={onPressGrandma}>
<Image style={styles.photo} source={{uri: 'https://www.pngall.com/wp-content/uploads/12/Grandma-Happy-PNG-Photo.png'}}/>
</TouchableHighlight>
<View>
<Text style={styles.cout}>
Cost {grandmaCost}
</Text>
</View>
<TouchableHighlight onPress={onPressFarm} style={styles.photo}>
<Image style={styles.photo} source={{uri: 'https://www.pngall.com/wp-content/uploads/8/Farming-PNG-Picture.png'}}/>
</TouchableHighlight>
<View>
<Text style={styles.cout}>
Cost {farmCost}
</Text>
</View>
<TouchableHighlight onPress={onPressFactory}>
<Image style={styles.photo} source={{uri: 'https://cdn.pixabay.com/photo/2018/04/16/09/12/factory-3323977_960_720.png'}}/>
</TouchableHighlight>
<View>
<Text style={styles.cout}>
Cost {factoryCost}
</Text>
</View>
<TouchableHighlight onPress={onPressWizard}>
<Image style={styles.photo} source={{uri: 'https://www.clasher.us/images/coc/units/Wizard_Tower7.png'}}/>
</TouchableHighlight>
<View>
<Text style={styles.cout}>
Cost {wizardCost}
</Text>
</View>
<TouchableHighlight onPress={onPressPortal}>
<Image style={styles.photo} source={{uri: 'https://i.pinimg.com/originals/98/29/21/9829215db6f9210c0ae4e318e854cb1f.png'}}/>
</TouchableHighlight>
<View>
<Text style={styles.cout}>
Cost {portalCost}
</Text>
</View>
<TouchableHighlight onPress={onPressPortal}>
<Image style={styles.photo} source={{ uri: 'https://i.pinimg.com/originals/98/29/21/9829215db6f9210c0ae4e318e854cb1f.png' }} />
</TouchableHighlight>
<View>
<Text style={styles.cout}>
Cost {portalCost}
</Text>
</View>
</View> </View>
</View> </View>
) </ImageBackground>
} </View>
)
}
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1,
},
containerTop:{
top: 75, top: 75,
margin: 10, margin: 10,
flex: 1, flex: 1,
@ -190,7 +197,6 @@ const styles = StyleSheet.create({
containerRight: { containerRight: {
flex: 1, flex: 1,
flexWrap: "wrap", flexWrap: "wrap",
top: 100,
marginBottom: 20, marginBottom: 20,
left: 100, left: 100,
}, },
@ -208,12 +214,18 @@ const styles = StyleSheet.create({
marginBottom: 10 marginBottom: 10
}, },
photo: { photo: {
width: 50, width: 75,
height: 50 height: 75
}, },
cout: { cout: {
marginBottom: 20 marginBottom: 20,
} color: "white",
fontSize: 15
},
image: {
flex: 1,
justifyContent: "center"
},
}) })

@ -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(
<View style={styles.container}>
<Text>TIC TAC TOE</Text>
<ImageBackground style={styles.grid} source={{uri:"https://upload.wikimedia.org/wikipedia/commons/6/64/Tic-tac-toe.png"}} >
<View style={styles.map}>
{map.map((row)=>(
<View style={styles.row}>
{row.map((cell)=> (
<View style={styles.cell}>
{cell === "o" && <View style={styles.circle}/>}
{cell === "x" &&(
<View style={styles.cross}>
<View style={styles.crossLine}/>
<View style={[styles.crossLine, styles.crossLineReversed]}/>
</View>
)}
</View>
))}
</View>
))}
</View>
</ImageBackground>
</View>
);
}
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
}
})

@ -15,6 +15,7 @@ import SignUp from '../screens/SignUp'
import LobbySolo from '../screens/LobbySolo' import LobbySolo from '../screens/LobbySolo'
import CookieClicker from '../Games/CookieClicker/cookieClicker' import CookieClicker from '../Games/CookieClicker/cookieClicker'
import MatchMaking from '../screens/MatchMaking' import MatchMaking from '../screens/MatchMaking'
import TicTacToe from '../Games/Tic-Tac-Toe/tic-tac-toe'
const HomeStack = createStackNavigator(); const HomeStack = createStackNavigator();
@ -96,6 +97,7 @@ function GameSoloStackScreen() {
<GameSoloStack.Navigator screenOptions={{headerShown: false}}> <GameSoloStack.Navigator screenOptions={{headerShown: false}}>
<GameSoloStack.Screen name='MatchMaking' component={MatchMaking} options={{animationEnabled: false,}}/> <GameSoloStack.Screen name='MatchMaking' component={MatchMaking} options={{animationEnabled: false,}}/>
<GameSoloStack.Screen name='CookieClicker' component={CookieClicker} /> <GameSoloStack.Screen name='CookieClicker' component={CookieClicker} />
<GameSoloStack.Screen name='TicTacToe' component={TicTacToe} />
</GameSoloStack.Navigator> </GameSoloStack.Navigator>
); );
} }

@ -5,10 +5,6 @@ import stylesScreen from './style/screens.style';
import styles from './style/Settings.style'; import styles from './style/Settings.style';
import { TopBar } from '../components/TopBar'; import { TopBar } from '../components/TopBar';
import { ButtonGreySmall } from '../components/ButtonGreySmall'; 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 { PickerGreySmall } from '../components/PickerGreySmall';
import { useUserStore } from '../context/userContext'; import { useUserStore } from '../context/userContext';
import DialogInput from 'react-native-dialog-input'; import DialogInput from 'react-native-dialog-input';
@ -17,6 +13,7 @@ import { MANAGER_USER } from '../../appManagers';
function Settings(props: { navigation: any; }) { function Settings(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
const setUser = useUserStore((state) => state.setUser); const setUser = useUserStore((state) => state.setUser);
@ -29,26 +26,45 @@ function Settings(props: { navigation: any; }) {
async function changeUsername(username:string){ async function changeUsername(username:string){
const m = new UserModificationManager(); let userManager = new UserModificationManager();
const tmp=MANAGER_USER.getCurrentUser(); let tmp=MANAGER_USER.getCurrentUser();
if (tmp!==null){ if (tmp!=null){
await m.changeUsername(tmp, username); await userManager.changeUsername(tmp, username);
setUser(tmp); setUser(tmp);
MANAGER_USER.setCurrentUser(tmp); MANAGER_USER.setCurrentUser(tmp);
} }
} }
async function changePassword(password:string){ async function changePassword(password:string){
const m = new UserModificationManager(); let userManager = new UserModificationManager();
const tmp=MANAGER_USER.getCurrentUser(); let tmp=MANAGER_USER.getCurrentUser();
if (tmp!==null){ if (tmp!=null){
await m.changePassword(tmp, password); 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); setUser(tmp);
MANAGER_USER.setCurrentUser(tmp); MANAGER_USER.setCurrentUser(tmp);
} }
} }
const dispatch=useDispatch();
return ( return (
<View style={stylesScreen.container}> <View style={stylesScreen.container}>
@ -72,11 +88,11 @@ function Settings(props: { navigation: any; }) {
</View> </View>
<View> <View>
<Text style={styles.text}>Nationalité: {useUserStore().user?.getNationality()}</Text> <Text style={styles.text}>Nationalité: {useUserStore().user?.getNationality()}</Text>
<PickerGreySmall title='Changer la nationalité' valueChange={(value:string) => setSelectedNationality(value)} donePress={() => dispatch(updateNationality(selectedNationality))} values={["Francais", "Anglais"]} /> <PickerGreySmall title='Selectionner un pays' valueChange={(value:string) => 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)' }, ]}/>
</View> </View>
<View> <View>
<Text style={styles.text}>Sexe: {useUserStore().user?.getSexe()}</Text> <Text style={styles.text}>Sexe: {useUserStore().user?.getSexe()}</Text>
<PickerGreySmall title='Changer le sexe' valueChange={(value:string) => setSelectedSex(value)} donePress={() => dispatch(updateSex(selectedSex))} values={["Homme", "Femme", "Autre"]} /> <PickerGreySmall title='Selectionner le sexe' valueChange={(value:string) => setSelectedSex(value)} donePress={() => changeSexe(selectedSex)} values={[ { label: 'Homme', value: 'Homme' }, { label: 'Femme', value: 'Femme' }, {label: 'Autre', value: 'Autre' } ]} />
</View> </View>
</View> </View>
<Text style={styles.textID}>ID: {useUserStore().user?.getId()}</Text> <Text style={styles.textID}>ID: {useUserStore().user?.getId()}</Text>

@ -24,7 +24,9 @@ export default class LoaderGameApi implements ILoaderGame{
map.set(300,150); map.set(300,150);
map.set(450,1000); 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); 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; return tab;

@ -9,4 +9,5 @@ let myMap = new Map<number, number>([
let game=new GameSolo(1, "bo jeu", "", "super jeu", 1, 1, myMap); let game=new GameSolo(1, "bo jeu", "", "super jeu", 1, 1, myMap);
export default game; export default game;
Loading…
Cancel
Save