Persistance
Lucie Bedouret 2 years ago
commit ba54ed12df

@ -1,6 +1,34 @@
import React from 'react'
import MainTabNavigator from './src/navigation/AppNavigator' import MainTabNavigator from './src/navigation/AppNavigator'
import store from './src/redux/store'
import { Provider } from 'react-redux'
import LoaderUserApi from './src/services/userServices/loaderUserApi'
import ManagerUser from './src/services/userServices/managerUser'
import FakeSaverUser from './src/services/userServices/fakeSaverUser'
import React, { useCallback } from 'react';
import { useUserStore } from './src/context/userContext';
import ManagerConversation from './src/services/conversationService/managerConversation'
import { LoaderConversationApi } from './src/services/conversationService/loaderConversationApi'
import { FakeSaverConversation } from './src/services/conversationService/fakeSaverConversation'
import ManagerMatch from './src/services/matchServices/managerMatch'
import LoaderMatchApi from './src/services/matchServices/loaderMatchApi'
import SaverMatchApi from './src/services/matchServices/saverMatchApi'
import LoaderGameApi from './src/services/gameService/loaderGameApi'
import ManagerGame from './src/services/gameService/managerGame'
export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new FakeSaverUser);
export const MANAGER_CONVERSATION = new ManagerConversation(new LoaderConversationApi, new FakeSaverConversation);
export const MANAGER_MATCH = new ManagerMatch(new LoaderMatchApi, new SaverMatchApi);
export const MANAGER_GAME = new ManagerGame(new LoaderGameApi);
export default function App() {
return (
<Provider store={store}>
<MainTabNavigator/>
</Provider>
);
}
export default function App() {
return <MainTabNavigator/>
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

@ -1,6 +1,13 @@
module.exports = function(api) { module.exports = function(api) {
api.cache(true); api.cache(true);
return { return {
presets: ['babel-preset-expo'], presets: [
['babel-preset-expo'],
'@babel/preset-typescript',
],
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript', '@babel/preset-react'
],
}; };
}; };

@ -2,11 +2,17 @@ import React from 'react'
import App from './App' import App from './App'
import store from './src/redux/store' import store from './src/redux/store'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
// export for others scripts to use
export default function Index(){ export default function Index(){
return( return(
<App/>
/*
<Provider store={store}> <Provider store={store}>
<App /> <App />
</Provider> </Provider>
*/
) )
} }

@ -0,0 +1,6 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ["**/__tests__/**/*.ts?(x)", "**/?(*.)+(test).ts?(x)"],
transformIgnorePatterns: ['/node_modules/(?!(foo|bar)/)', '/bar/'],
};

File diff suppressed because it is too large Load Diff

@ -6,37 +6,55 @@
"start": "expo start", "start": "expo start",
"android": "expo start --android", "android": "expo start --android",
"ios": "expo start --ios", "ios": "expo start --ios",
"web": "expo start --web" "web": "expo start --web",
"test": "jest"
}, },
"dependencies": { "dependencies": {
"@react-native-picker/picker": "^2.4.8", "@babel/runtime": "^7.20.6",
"@react-native-community/datetimepicker": "6.2.0",
"@react-native-picker/picker": "2.4.2",
"@react-navigation/bottom-tabs": "^6.4.0", "@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13", "@react-navigation/native": "^6.0.13",
"@react-navigation/stack": "^6.3.2", "@react-navigation/stack": "^6.3.2",
"@reduxjs/toolkit": "^1.8.6", "@reduxjs/toolkit": "^1.8.6",
"expo": "^46.0.15", "axios": "^1.1.3",
"babel-core": "^6.26.3",
"babel-jest": "^29.3.1",
"babel-preset-env": "^1.7.0",
"babel-preset-typescript": "^7.0.0-alpha.19",
"babel-test": "^0.2.4",
"expo": "^46.0.17",
"expo-status-bar": "~1.4.0", "expo-status-bar": "~1.4.0",
"jest": "^26.6.3", "jest": "^29.3.1",
"jquery": "^3.6.1",
"node": "^18.10.0", "node": "^18.10.0",
"react": "18.0.0", "react": "18.0.0",
"react-dom": "18.0.0", "react-dom": "18.0.0",
"react-native": "^0.69.6", "react-native": "^0.69.6",
"react-native-date-picker": "^4.2.5",
"react-native-dialog": "^9.2.2", "react-native-dialog": "^9.2.2",
"react-native-dialog-input": "^1.0.8", "react-native-dialog-input": "^1.0.8",
"react-native-gesture-handler": "~2.5.0", "react-native-gesture-handler": "~2.5.0",
"react-native-picker-select": "^8.0.4", "react-native-picker-select": "^8.0.4",
"react-native-safe-area-context": "4.3.1", "react-native-safe-area-context": "4.3.1",
"react-native-web": "~0.18.7", "react-native-web": "~0.18.7",
"react-redux": "^8.0.4" "react-redux": "^8.0.4",
"ts-node": "^10.9.1",
"typescript-jest": "^0.0.0",
"zustand": "^4.1.4"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.9", "@babel/core": "^7.12.9",
"@types/jest": "^29.1.2", "@babel/preset-typescript": "^7.18.6",
"@jest/globals": "^29.3.1",
"@types/jest": "^29.2.3",
"@types/jquery": "^3.5.14",
"@types/mocha": "^10.0.0", "@types/mocha": "^10.0.0",
"@types/node": "^18.8.4", "@types/node": "^18.8.4",
"@types/react": "~18.0.14", "@types/react": "~18.0.14",
"@types/react-native": "~0.69.1", "@types/react-native": "~0.69.1",
"typescript": "~4.3.5" "ts-jest": "^29.0.3",
"typescript": "^4.9.3"
}, },
"private": true "private": true
} }

@ -0,0 +1,221 @@
import React, { Component, useCallback, useEffect, useState } from 'react'
import {
StyleSheet,
TouchableOpacity,
Text,
View,
Pressable,
Image,
TouchableHighlight,
Alert,
} from 'react-native'
import { MANAGER_MATCH, MANAGER_USER } from '../../../App';
import { useMatchStore } from '../../context/matchContext';
import { useUserStore } from '../../context/userContext';
import { Match } from '../../core/Match/match';
import { User } from '../../core/User/user';
let points=0;
function CookieClicker(props: { navigation: any}){
const { navigation } = props
const GAMING_TIME=45;
const setUser = useUserStore((state) => state.setUser);
const resetMatch = useMatchStore((state) => state.resetMatch);
const [count, setCount] = useState(0);
const [money, setMoney] = useState(0);
const [clickSpeed, setClickSpeed] = useState(1);
const [grandmaCost, setGrandmaCost] = useState(10);
const [farmCost, setFarmCost] = useState(250);
const [factoryCost, setFactoryCost] = useState(2000);
const [wizardCost, setWizardCost] = useState(25000);
const [portalCost, setPortalCost] = useState(200000);
const [timer, setTimer] = useState(GAMING_TIME);
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 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 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 endGame(){
let tmp: User | null;
tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){
if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)){
MANAGER_MATCH.getCurrentMatch()?.updatePostMatch(tmp, points);
setUser(tmp);
}
}
resetMatch();
}
useEffect(() => {
let counter=GAMING_TIME;
var oneSecInterval = setInterval(() => {
setTimer(timer => timer - 1);
counter --;
if (counter == 0) {
clearInterval(oneSecInterval);
endGame();
Alert.alert("fin du jeu");
navigation.navigate('Home');
}
}, 1000);
},[]);
return (
<View style={styles.container}>
<View >
<Text>
Timer: {timer}
</Text>
<TouchableHighlight onPress={onPressCookie} >
<Image style={styles.photo} source={{uri: 'https://cdn-icons-png.flaticon.com/512/614/614131.png'}}/>
</TouchableHighlight>
<Text>
Argent {money}
</Text>
<Text>
Points {count}
</Text>
</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>
</View>
</View>
)
}
const styles = StyleSheet.create({
container: {
top: 75,
margin: 10,
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
containerRight: {
flex: 1,
flexWrap: "wrap",
top: 100,
marginBottom: 20,
left: 100,
},
button: {
alignItems: 'center',
backgroundColor: '#DDDDDD',
padding: 10,
marginBottom: 10
},
button2: {
alignItems: 'center',
backgroundColor: '#FFDDFF',
padding: 10,
marginBottom: 10
},
photo: {
width: 50,
height: 50
},
cout: {
marginBottom: 20
}
})
export default CookieClicker;

@ -1,4 +1,4 @@
import { FC, ReactNode } from "react" import { FC, ReactNode, useCallback } from "react"
import { Pressable, Image, View} from "react-native" import { Pressable, Image, View} from "react-native"
import React from "react" import React from "react"
@ -6,6 +6,10 @@ import React from "react"
Importing the correct stylesheet Importing the correct stylesheet
*/ */
import styles from './style/BotBar.style'; import styles from './style/BotBar.style';
import { useStoreStore } from "../context/storeContext";
import { MANAGER_CONVERSATION, MANAGER_USER } from "../../App";
import tabSkinApp from "../constSkin";
import { useConversationStore } from "../context/conversationContext";
/* /*
Images that are required to create a bottom bar Images that are required to create a bottom bar
@ -35,6 +39,37 @@ export const BotBar :
FC<{nav: any, state?: String}> = FC<{nav: any, state?: String}> =
({nav, state}) => ({nav, state}) =>
{ {
const setTabSkin = useStoreStore((state) => state.setTabSkin);
const setTabConv = useConversationStore((state) => state.setTabConv);
const handleStoreChange = useCallback(async () => {
let tabSkinStore=[...tabSkinApp];
let tmp=MANAGER_USER.getCurrentUser()?.getTabSkin();
if (tmp!=undefined){
tmp.forEach(skin => {
for (let i=0; i<tabSkinStore.length; i++){
if(skin.isEqual(tabSkinStore[i])){
tabSkinStore.splice(i,1);
}
}
});
setTabSkin(tabSkinStore);
}
}, []);
const handleConversationChange = useCallback(async () => {
let tmp=MANAGER_USER.getCurrentUser();
if (tmp!=undefined){
await MANAGER_CONVERSATION.getLoaderConversation().loadByUser(tmp).then((res) => {
MANAGER_CONVERSATION.setCurrentTabConv(res);
setTabConv(res);
});
}
}, []);
/* /*
By default, all the images are the white ones By default, all the images are the white ones
*/ */
@ -66,7 +101,7 @@ FC<{nav: any, state?: String}> =
*/ */
return ( return (
<View style={styles.footer}> <View style={styles.footer}>
<Pressable onPress={() => nav.navigate('ChatTab')}> <Pressable onPress={() => {handleConversationChange() ;nav.navigate('ChatTab')}}>
<Image <Image
style={styles.icon} style={styles.icon}
source={imgLeft} source={imgLeft}
@ -78,7 +113,7 @@ FC<{nav: any, state?: String}> =
source={imgMid} source={imgMid}
/> />
</Pressable> </Pressable>
<Pressable onPress={() => nav.navigate('StoreTab')}> <Pressable onPress={() => {handleStoreChange(); nav.navigate('StoreTab')}}>
<Image <Image
style={styles.icon} style={styles.icon}
source={imgRight} source={imgRight}

@ -1,4 +1,4 @@
import { FC} from "react" import { FC } from "react"
import { Pressable, Text} from "react-native" import { Pressable, Text} from "react-native"
import React from "react" import React from "react"
/* /*

@ -9,30 +9,34 @@ import { Conversation } from "../core/conversation"
*/ */
import styles from "./style/ConverstationComponent.style" import styles from "./style/ConverstationComponent.style"
import { SkinComponent } from "./Skin" import { SkinComponent } from "./Skin"
import { User } from "../core/User/user"
import { MANAGER_USER } from "../../App"
export const ConversationComponent : export const ConversationComponent :
/* Parameters : /* Parameters :
* skin : Skin to be displayed * skin : Skin to be displayed
* state : Indicates from wich screen the component has been called * state : Indicates from wich screen the component has been called
*/ */
FC<{conv: Conversation, state: String}> = FC<{conv: Conversation, state: String, navigation: any}> =
({conv, state}) => ({conv, state, navigation}) =>
{ {
/* The display of this component depends of the screen from where it has been called: /* The display of this component depends of the screen from where it has been called:
* From the TopBar (icon) : Small image in a circle * From the TopBar (icon) : Small image in a circle
* From the shop (shop) : Image + Name + Price, Pressable => Buy the skin * From the shop (shop) : Image + Name + Price, Pressable => Buy the skin
* From the profile (profile) : Name + Image, Pressable => Change the skin * From the profile (profile) : Name + Image, Pressable => Change the skin
*/ */
switch (state) { switch (state) {
case 'Preview': case 'Preview':
return( return(
<View style={{flexDirection: 'row', height: 70, borderBottomWidth: 2,borderBottomColor: '#2D2C33', paddingLeft: '5%',}}> <View style={{flexDirection: 'row', height: 70, borderBottomWidth: 2,borderBottomColor: '#2D2C33', paddingLeft: '5%',}}>
<View style={{alignSelf: 'center'}}> <View style={{alignSelf: 'center'}}>
<SkinComponent skin={conv.getTabUser()[1].getCurrentSkin()} state='icon'/> <SkinComponent skin={conv.getLastMessage().getMessageSender().getCurrentSkin()} state='icon' nav={navigation}/>
</View> </View>
<View style={{marginLeft: '5%', justifyContent: 'space-evenly'}}> <View style={{marginLeft: '5%', justifyContent: 'space-evenly'}}>
<Text style={styles.textNom}>{conv.getTabUser()[1].getUsername()}</Text> <Text style={styles.textNom}>{conv.getLastMessage().getMessageSender().getUsername()}</Text>
<Text style={styles.textMess}>{conv.getLastMessage()}</Text> <Text style={styles.textMess}>{conv.getLastMessage().getMessageContent()}</Text>
</View> </View>
</View> </View>
) )

@ -1,4 +1,4 @@
import { FC, ReactNode } from "react" import { FC, ReactNode, useCallback } from "react"
import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native" import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native"
import React from "react" import React from "react"
import { trace } from "console" import { trace } from "console"
@ -8,8 +8,14 @@ import { Game } from "../core/game"
Importing the correct stylesheet Importing the correct stylesheet
*/ */
import styles from './style/Game.style'; import styles from './style/Game.style';
import LobbySolo from "../screens/LobbySolo"
import ManagerMatch from "../services/matchServices/managerMatch"
import MatchCreator from "../core/Match/matchCreator"
import { MANAGER_MATCH, MANAGER_USER } from "../../App"
import { useMatchStore } from "../context/matchContext"
export const GameComponent : export const GameComponent :
/* /*
* game : Game that must be displayed * game : Game that must be displayed
* nav : tool needed to allow the navigation between the screens * nav : tool needed to allow the navigation between the screens
@ -17,15 +23,35 @@ export const GameComponent :
FC<{game: Game, nav: any}> = FC<{game: Game, nav: any}> =
({game, nav}) => ({game, nav}) =>
{ {
const setMatch = useMatchStore((state) => state.setMatch);
const createNewMatchSolo = useCallback(async (game : Game, nav: any) => {
const m=new MatchCreator();
let tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){
let match=await m.createMatch(tmp, game);
MANAGER_MATCH.setCurrentMatch(match);
setMatch(match);
nav.navigate("GameSolo");
}
}, []);
return ( return (
<View> <View>
<Pressable onPress={() => Alert.alert("Lancement du jeu")}> <Pressable onPress={() => createNewMatchSolo(game, nav)}>
<Image <Image
style={styles.image} style={styles.image}
source={game.getImageSource()} source={{uri: game.getImageSource()}}
/> />
<Text style={styles.name}>{game.getName()}</Text> <Text style={styles.name}>{game.getName()}</Text>
</Pressable> </Pressable>
</View> </View>
) )
} }

@ -0,0 +1,21 @@
import { FC} from "react"
import { Pressable, Text} from "react-native"
import React from "react"
import styles from "./style/PickerGreySmall"
import RNPickerSelect from "react-native-picker-select";
export const PickerGreySmall:
FC<{ valueChange: any, title: string, donePress?: any, values?: any;}>
=
({valueChange, donePress, title, values}) =>
{
return(
<RNPickerSelect
placeholder={{label:title, value: null}}
onValueChange={valueChange}
onDonePress={donePress}
items={values}
style={styles}
/>
)
}

@ -1,4 +1,4 @@
import { FC, ReactNode } from "react" import { FC, ReactNode, useCallback } from "react"
import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native" import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native"
import React from "react" import React from "react"
import { Skin } from "../core/skin" import { Skin } from "../core/skin"
@ -7,19 +7,93 @@ import { Skin } from "../core/skin"
Importing the correct stylesheet Importing the correct stylesheet
*/ */
import styles from "./style/Skin.style" import styles from "./style/Skin.style"
import { useDispatch } from "react-redux" import { useDispatch, useSelector } from "react-redux"
import { updateSkin } from "../redux/features/currentUserSlice" import { loginUser } from "../redux/features/currentUserSlice"
import { RootState } from "../redux/store"
import { MANAGER_USER } from "../../App"
import { useUserStore } from "../context/userContext"
import { ManagerCoinsUser } from "../core/User/userCoinsModifier"
import ManagerUser from "../services/userServices/managerUser"
import UserSkinModifier from "../core/User/userSkinModifier"
import { useStoreStore } from "../context/storeContext"
import tabSkinApp from "../constSkin"
export const SkinComponent : export const SkinComponent :
/* Parameters : /* Parameters :
* skin : Skin to be displayed * skin : Skin to be displayed
* state : Indicates from wich screen the component has been called * state : Indicates from wich screen the component has been called
*/ */
FC<{skin: Skin, state: String}> = FC<{nav : any, skin: Skin, state: String}> =
({skin, state}) => ({nav, skin, state}) =>
{ {
const navigation = nav;
const dispatch=useDispatch(); const dispatch=useDispatch();
const setUser = useUserStore((state) => state.setUser);
const setTabSkin = useStoreStore((state) => state.setTabSkin);
async function changerSkin(skin:Skin) {
const m=new UserSkinModifier();
const tmp = MANAGER_USER.getCurrentUser();
if (tmp!=null){
await m.changeCurrentSkin(tmp, skin);
setUser(tmp);
MANAGER_USER.setCurrentUser(tmp);
}
}
const handleStoreChange = useCallback(async () => {
let tabSkinStore=[...tabSkinApp];
let tmp=MANAGER_USER.getCurrentUser()?.getTabSkin();
if (tmp!=undefined){
tmp.forEach(skin => {
for (let i=0; i<tabSkinStore.length; i++){
if(skin.isEqual(tabSkinStore[i])){
tabSkinStore.splice(i,1);
}
}
});
setTabSkin(tabSkinStore);
}
}, []);
async function buySkin(skin:Skin) {
const mSkin=new UserSkinModifier();
const mCoins= new ManagerCoinsUser();
const tmp = MANAGER_USER.getCurrentUser();
if (tmp!=null){
await mCoins.removeCoins(tmp,skin.getSkinCost()).then(async (res) => {
if(res==true){
await mSkin.addSkin(tmp, skin);
setUser(tmp);
MANAGER_USER.setCurrentUser(tmp);
Alert.alert("Achat du skin");
handleStoreChange();
}
else{
Alert.alert("Pas assez d'argent pour acheter le skin");
}
});
}
}
/* The display of this component depends of the screen from where it has been called: /* The display of this component depends of the screen from where it has been called:
* From the TopBar (icon) : Small image in a circle * From the TopBar (icon) : Small image in a circle
* From the shop (shop) : Image + Name + Price, Pressable => Buy the skin * From the shop (shop) : Image + Name + Price, Pressable => Buy the skin
@ -29,38 +103,38 @@ FC<{skin: Skin, state: String}> =
case 'icon': case 'icon':
return ( return (
<View> <View>
<Image source={skin.getSkinSource()} style={styles.icon}/> <Image source={{uri: skin.getSkinSource()}} style={styles.icon}/>
</View> </View>
) )
case 'shop': case 'shop':
return( return(
<Pressable onPress={() => Alert.alert("Achat du skin")} style={styles.imageWrapper}> <Pressable onPress={() => buySkin(skin)} style={styles.imageWrapper}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text> <Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image <Image
style={styles.imageSkin} style={styles.imageSkin}
source={skin.getSkinSource()} source={{uri: skin.getSkinSource()}}
/> />
<Text style={styles.nomSkin}>100</Text> <Text style={styles.nomSkin}>100</Text>
</Pressable> </Pressable>
) )
case 'liste': case 'liste':
return( return(
<Pressable onPress={() => dispatch(updateSkin(skin))} style={styles.imageWrapper}> <Pressable onPress={() => {changerSkin(skin); navigation.goBack()}} style={styles.imageWrapper}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text> <Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image <Image
style={styles.imageSkin} style={styles.imageSkin}
source={skin.getSkinSource()} source={{uri: skin.getSkinSource()}}
/> />
</Pressable> </Pressable>
) )
case 'profile': case 'profile':
return( return(
<Pressable onPress={() => Alert.alert("Achat du skin")} style={styles.imageWrapperProfil}> <Pressable onPress={() => Alert.alert("cool")} style={styles.imageWrapperProfil}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text> <Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image <Image
style={styles.imageSkin} style={styles.imageSkin}
source={skin.getSkinSource()} source={{uri: skin.getSkinSource()}}
/> />
</Pressable> </Pressable>
) )
@ -68,7 +142,7 @@ FC<{skin: Skin, state: String}> =
return( return(
<Image <Image
style={styles.imageSkin} style={styles.imageSkin}
source={skin.getSkinSource()} source={{uri: skin.getSkinSource()}}
/> />
) )
} }

@ -11,6 +11,9 @@ import { User } from "../core/User/user"
import styles from './style/TopBar.style'; import styles from './style/TopBar.style';
import { useSelector } from "react-redux" import { useSelector } from "react-redux"
import { RootState } from "../redux/store" import { RootState } from "../redux/store"
import { MANAGER_USER } from "../../App"
import { useUserStore } from "../context/userContext"
import { useMatchStore } from "../context/matchContext"
/* /*
Images required Images required
@ -30,7 +33,8 @@ FC<{nav: any, state?: string}> =
({nav, state}) => ({nav, state}) =>
{ {
const currentUser = useSelector((state: RootState) => state.currentUser.value)[0]; const resetMatch = useMatchStore((state) => state.resetMatch);
/* The display of this component depends of the screen from where it has been called: /* The display of this component depends of the screen from where it has been called:
* From the Settings (icon) : Name of the page + cross button * From the Settings (icon) : Name of the page + cross button
@ -49,11 +53,25 @@ FC<{nav: any, state?: string}> =
</Pressable> </Pressable>
</View> </View>
) )
case 'matchmacking':
return (
<View style={styles.header}>
<Pressable>
<Image source={msc} style={styles.icon}/>
</Pressable>
<Text style={styles.titre}>BOB PARTY</Text>
<Pressable onPress={() => { resetMatch(); nav.goBack()}}>
<Image source={cross} style={styles.icon}/>
</Pressable>
</View>
)
default: default:
return ( return (
<View style={styles.header}> <View style={styles.header}>
<Pressable onPress={() => nav.navigate('ProfileTab', {screen: 'Profile'})}> <Pressable onPress={() => nav.navigate('ProfileTab', {screen: 'Profile'})}>
<SkinComponent skin={currentUser.getCurrentSkin()} state='icon' /> <SkinComponent skin={MANAGER_USER.getCurrentUser().getCurrentSkin()} state='icon' nav={nav} />
</Pressable> </Pressable>
<Text style={styles.titre}>BOB PARTY</Text> <Text style={styles.titre}>BOB PARTY</Text>
<Pressable onPress={() => nav.navigate('Settings')}> <Pressable onPress={() => nav.navigate('Settings')}>

@ -0,0 +1,40 @@
import { StyleSheet } from "react-native";
export default StyleSheet.create(
{inputIOS: {
alignItems: 'center',
justifyContent: 'center',
padding: 3,
marginTop: 5,
borderRadius: 10,
backgroundColor: '#2D2C33',
paddingHorizontal: 10,
fontSize: 16,
fontWeight: 'bold',
letterSpacing: 0.25,
textAlign: 'center',
color: 'white',
},
placeholder: {
color: 'white',
},
},
{inputAndroid: {
alignItems: 'center',
justifyContent: 'center',
padding: 3,
marginTop: 5,
borderRadius: 10,
backgroundColor: '#2D2C33',
paddingHorizontal: 10,
fontSize: 16,
fontWeight: 'bold',
letterSpacing: 0.25,
textAlign: 'center',
color: 'white',
},
placeholder: {
color: 'white',
},
}
)

@ -1,25 +0,0 @@
import { Message } from "./core/message"
import { Conversation } from "./core/conversation"
import tabSkinApp from './constSkin'
import { User } from "./core/User/user";
let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, undefined);
let UserTest:User=new User("48", "Wesh Wesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[5], tabSkinApp, undefined);
let tabMessageTest:Message[]=[
new Message("Salut", UserActu, new Date(2022,12,12,11,30,40)),
new Message("Wesh", UserTest, new Date(2022,12,13,12,20,40)),
new Message("Ca va", UserActu, new Date(2022,12,14, 12, 30, 35)),
new Message("Ouais et toi?", UserTest, new Date(2022,12,14,12,35,0)),
]
let tabUS:User[]=[UserActu, UserTest];
let conv = new Conversation(tabUS, tabMessageTest, "le super nom");
let tabConv:Conversation[]=[conv];
export default tabConv;

@ -1,11 +0,0 @@
const tabNat = [
{ label: "France", value: "Français" },
{ label: "Allemagne", value: "Allemand" },
{ label: "Espagne", value: "Espagnol" },
{ label: "Royaume-Uni", value: "Anglais" },
{ label: "États-Unis", value: "Américain" },
{ label: "Italie", value: "Italien" },
]
export default tabNat;

@ -1,9 +0,0 @@
const tabSex = [
{ label: "Homme", value: "Homme" },
{ label: "Femmme", value: "Femmme" },
{ label: "Non-binaire", value: "Non-binaire" },
{ label: "Autre", value: "Autre" },
]
export default tabSex;

@ -1,13 +1,14 @@
import { Skin } from "./core/skin"; import { Skin } from "./core/skin";
const img = "";
let tabSkinApp:Skin[]=[ let tabSkinApp:Skin[]=[
new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0),
new Skin("S0002", "Bob Blue",require('bob_party/assets/BobsSkins/BobBlue.png'), 100), new Skin(2, "Bob Blue","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBlue.png", 100),
new Skin("S0003", "Bob BW",require('bob_party/assets/BobsSkins/BobBW.png'), 100), new Skin(3, "Bob BW","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBW.png", 100),
new Skin("S0004", "Bob Green",require('bob_party/assets/BobsSkins/BobGreen.png'), 100), new Skin(4, "Bob Green","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobGreen.png", 100),
new Skin("S0005", "Bob P&T",require('bob_party/assets/BobsSkins/BobPinkTurquoise.png'), 100), new Skin(5, "Bob P&T", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobPinkTurquoise.png", 100),
new Skin("S0006", "Bob Red",require('bob_party/assets/BobsSkins/BobRed.png'), 100), new Skin(6, "Bob Red", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobRed.png", 100),
new Skin("S0007", "Bob Cute",require('bob_party/assets/BobsSkins/BobYellowGreenBlueHeart.png'), 100), new Skin(7, "Bob Cute", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobYellowGreenBlueHeart.png", 100),
] ]

@ -1,15 +1,13 @@
import { Message } from "./core/message"
import { Conversation } from "./core/conversation"
import tabSkinApp from './constSkin' import tabSkinApp from './constSkin'
import { User } from "./core/User/user"; import { User } from "./core/User/user";
import tabConv from "./constCov";
let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, undefined); let UserActu:User=new User(14, "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp);
let UserTest:User=new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[2], tabSkinApp, undefined); let Alban:User=new User(17, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, tabSkinApp[1], tabSkinApp);
let Alban:User=new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, tabSkinApp[1], tabSkinApp, tabConv); let Fefe63:User=new User(18, "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp);
let Fefe63:User=new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp, undefined); let UserTest:User=new User(48, "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[2], tabSkinApp);
let tabUS:User[]=[UserActu, UserTest, Alban, Fefe63];
let tabUS:User[]=[UserTest, Alban, UserActu, Fefe63];
export default tabUS; export default tabUS;

@ -0,0 +1,20 @@
import React from "react";
import create from "zustand";
import { MANAGER_USER } from "../../App";
import { Conversation } from "../core/conversation";
// Define store types
interface ConversationState {
tabConv: Conversation[] | undefined;
setTabConv: (tabConv: Conversation[]) => void;
resetTabConv: () => void;
}
// Define store data and methods
export const useConversationStore = create<ConversationState>()((set, get) => ({
tabConv: undefined,
setTabConv: (tabConv) => set((state) => ({ tabConv: tabConv })),
resetTabConv: () => set((state) => ({tabConv: undefined})),
}));

@ -0,0 +1,23 @@
import React from "react";
import create from "zustand";
import { MANAGER_USER } from "../../App";
import tabSkinApp from "../constSkin";
import { Game } from "../core/game";
import { Skin } from "../core/Skin";
import { User } from "../core/User/user";
// Define store types
interface GameState {
tabGame: Game[] | undefined;
setTabGame: (tabGame: Game[]) => void;
resetTabGame: () => void;
}
// Define store data and methods
export const useGameStore = create<GameState>()((set, get) => ({
tabGame: undefined,
setTabGame: (tabGame) => set((state) => ({ tabGame: tabGame })),
resetTabGame: () => set((state) => ({ tabGame: undefined })),
}));

@ -0,0 +1,18 @@
import React from "react";
import create from "zustand";
import { Match } from "../core/Match/match";
// Define store types
interface MatchState {
match: Match | null;
setMatch: (match: Match|null) => void;
resetMatch: () => void;
}
// Define store data and methods
export const useMatchStore = create<MatchState>()((set, get) => ({
match: null,
setMatch: (match) => set((state) => ({ match: match })),
resetMatch: () => set((state) => ({ match: null })),
}));

@ -0,0 +1,22 @@
import React from "react";
import create from "zustand";
import { MANAGER_USER } from "../../App";
import tabSkinApp from "../constSkin";
import { Skin } from "../core/Skin";
import { User } from "../core/User/user";
// Define store types
interface StoreState {
tabSkin: Skin[];
setTabSkin: (tabSkin: Skin[]) => void;
resetTabSkin: () => void;
}
// Define store data and methods
export const useStoreStore = create<StoreState>()((set, get) => ({
tabSkin: tabSkinApp,
setTabSkin: (tabSkin) => set((state) => ({ tabSkin: tabSkin })),
resetTabSkin: () => set((state) => ({ tabSkin: tabSkinApp })),
}));

@ -0,0 +1,18 @@
import React from "react";
import create from "zustand";
import { User } from "../core/User/user";
// Define store types
interface UserState {
user: User | null;
setUser: (user: User|null) => void;
resetUser: () => void;
}
// Define store data and methods
export const useUserStore = create<UserState>()((set, get) => ({
user: null,
setUser: (user) => set((state) => ({ user: user })),
resetUser: () => set((state) => ({ user: null })),
}));

@ -0,0 +1,71 @@
import { loginUser } from '../../redux/features/currentUserSlice';
import tabUS from "../../constUser";
import { User } from '../User/user';
import { updateAlreadyUsedPseudo,updateImpossibleBirthDate,updateUndefinedBirthDate,updateUndefinedNationality,updateTooLongPseudo,updateUndefinedPseudo,updateUndefinedSex, updateTooShortPassword, updateInvalidPassword, updateInvalidPseudo, updateUndefinedPassword } from '../../redux/features/credentialErrorsSlice';
function max(array: User[]){
let max: string = "";
for (let index = 0; index < array.length; index++) {
const element = array[index].getId();
if (element > max) max = element;
}
return max;
}
export const checkNewUserValidity = (login: string, password: string, dateOfBirth: Date, nationality: string, sexe: string, dispatch: any, nav: any) => {
let actualDate : number = Date.now();
let givenDate : number = dateOfBirth.getTime();
let passwordRegex : RegExp = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-])(?!.*?[.\n\\{}[\],]).{8,}$/;
let loginRegex : RegExp = /^[A-Za-z0-9_-]{1,22}$/;
switch(true){
case (login === ''):
dispatch(updateUndefinedPseudo(true));
break;
case (password === ''):
dispatch(updateUndefinedPassword(true));
break;
case (givenDate == null):
dispatch(updateUndefinedBirthDate(true));
break;
case (nationality == ''):
dispatch(updateUndefinedNationality(true))
break;
case (sexe == ''):
dispatch(updateUndefinedSex(true));
break;
case (login.length > 22):
dispatch(updateTooLongPseudo(true));
break;
case (! loginRegex.test(login)):
dispatch(updateInvalidPseudo(true));
break;
//ALREADY USED PSEUDO
case (password.length < 8):
dispatch(updateTooShortPassword(true));
break;
case (! passwordRegex.test(password)):
dispatch(updateInvalidPassword(true));
break;
case ((actualDate-givenDate) < 409968000000):
dispatch(updateImpossibleBirthDate(true));
break;
default:
const newUser : User = new User(0,login,password,nationality,sexe,dateOfBirth);
dispatch(loginUser(newUser));
nav.navigate('HomeTab');
}
};

@ -1,15 +1,14 @@
import { randomBytes } from "crypto";
import { ImageSourcePropType } from "react-native";
export abstract class Game{ export abstract class Game{
readonly id:number;
private name:string; private name:string;
private imageSource:ImageSourcePropType; private imageSource:string;
private gameSource:string; private gameSource:string;
private nbPlayerMin: number; private nbPlayerMin: number;
private nbPlayerMax:number; private nbPlayerMax:number;
/* Constructor of the class */ /* Constructor of the class */
constructor (name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){ constructor (id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){
this.id=id;
this.name=name; this.name=name;
this.imageSource=imageSource; this.imageSource=imageSource;
this.gameSource=gameSource; this.gameSource=gameSource;
@ -17,6 +16,11 @@ export abstract class Game{
this.nbPlayerMax=nbPlayerMax; this.nbPlayerMax=nbPlayerMax;
} }
/* Brief : Function getting the id of a game */
getId(){
return this.id;
}
/* Brief : Function getting the name of a game */ /* Brief : Function getting the name of a game */
getName(){ getName(){
return this.name; return this.name;
@ -33,7 +37,7 @@ export abstract class Game{
} }
/* Brief : Function setting the image of a game */ /* Brief : Function setting the image of a game */
setImageSource(imageSource:ImageSourcePropType){ setImageSource(imageSource:string){
this.imageSource=imageSource; this.imageSource=imageSource;
} }
@ -66,4 +70,6 @@ export abstract class Game{
setNbPlayerMax(nbPlayerMax:number){ setNbPlayerMax(nbPlayerMax:number){
this.nbPlayerMax=nbPlayerMax; this.nbPlayerMax=nbPlayerMax;
} }
abstract coinsCalculator(points: number): number;
} }

@ -0,0 +1,72 @@
import { ImageSourcePropType } from 'react-native';
import { Game } from '../game';
import { User } from "../User/user";
export abstract class Match{
readonly code:number;
private inGame:Boolean=false;
private tabUsers:User[];
private theGame:Game;
constructor(code:number, inGame:Boolean, tabUser:User[], game:Game){
this.code=code;
this.inGame=inGame;
this.tabUsers=[...tabUser];
this.theGame=game;
}
/* Brief : Fuction getting if the match is currently in a game */
getInGame(){
return this.inGame;
}
/* Brief : Fuction setting the boolean inGame */
setInGame(inGame:Boolean){
this.inGame=inGame;
}
/* Brief : Fuction getting the array of User */
getTabUsers(){
return this.tabUsers;
}
/* Brief : Fuction setting the array of User */
setTabUser(tabUser:User[]){
this.tabUsers=[...tabUser];
}
/* Brief : Fuction getting code of a match */
getCode(){
return this.code;
}
/* Brief : Fuction getting the game of a match */
getGame(){
return this.theGame;
}
/* Brief : Fuction setting the game of a match */
setGame(game:Game){
this.theGame=game;
}
abstract updatePostMatch(user:User, points:number):void;
}

@ -0,0 +1,18 @@
import { Match } from "./match";
import { User } from "../User/user";
import { Game } from "../game";
import { GameCasino } from "../gameCasino";
import { ManagerCoinsUser } from "../User/userCoinsModifier";
export default class MatchCasino extends Match{
constructor(code:number, inGame:Boolean, tabUser:User[], game:GameCasino){
super(code, inGame, tabUser, game);
}
updatePostMatch(user:User, points: number): void {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -0,0 +1,12 @@
import { MANAGER_MATCH } from "../../../App";
import ManagerMatch from "../../services/matchServices/managerMatch";
import { Game } from "../game";
import { User } from "../User/user";
import { Match } from "./match";
export default class MatchCreator{
async createMatch(u:User, g:Game): Promise<Match>{
return await MANAGER_MATCH.getsaverMatch().saveMatch(u, g);
}
}

@ -0,0 +1,17 @@
import { Match } from "./match";
import { User } from "../User/user";
import { Game } from "../game";
import { GameMulti } from "../gameMulti";
import { ManagerCoinsUser } from "../User/userCoinsModifier";
export default class MatchMulti extends Match{
constructor(code:number, inGame:Boolean, tabUser:User[], game:GameMulti){
super(code, inGame, tabUser, game);
}
updatePostMatch(user:User, points: number): void {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -0,0 +1,17 @@
import { Match } from "./match";
import { GameSolo } from "../gameSolo";
import { User } from "../User/user";
import { Game } from "../game";
import { ManagerCoinsUser } from "../User/userCoinsModifier";
export default class MatchSolo extends Match{
constructor(code:number, inGame:Boolean, tabUser:User[], game:GameSolo){
super(code, inGame, tabUser, game);
}
updatePostMatch(user:User, points: number): void {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -1,14 +0,0 @@
import { User } from "./user";
import { Skin } from "../Skin";
import { ManagerCoinsUser } from "./managerCoinsUser";
//import ManagerCoinsUser
export class SkinBuyer{
buy(u:User, s:Skin){
const manage=new ManagerCoinsUser();
u.getTabSkin().push(s);
manage.removeCoins(u, s.getSkinCost());
}
}

@ -1,16 +0,0 @@
import { User } from "./user";
export class ManagerCoinsUser{
addCoins(u:User, coins:number){
u.setCurrentCoins(u.getCurrentCoins()+coins);
u.setTotalCoins(u.getTotalCoins()+coins);
}
removeCoins(u:User, coins:number){
u.setCurrentCoins(u.getCurrentCoins()-coins);
}
changeCurrentCoins(u:User, coins:number){
u.setCurrentCoins(coins);
}
}

@ -1,9 +1,11 @@
import { Skin } from '../Skin' import { Skin } from '../Skin'
import { Conversation } from '../conversation'; import { Conversation } from '../conversation';
import { sign } from 'crypto'; import { sign } from 'crypto';
import { TextBase } from 'react-native';
export class User{ export class User{
readonly id: string;
readonly id: number;
private username: string; private username: string;
private password: string; private password: string;
private nationality: string; private nationality: string;
@ -11,176 +13,145 @@ export class User{
private dateOfBirth: Date; private dateOfBirth: Date;
private currentCoins: number; private currentCoins: number;
private totalCoins: number; private totalCoins: number;
private nbGamePlayed: number; private nbGamesPlayed: number;
private currentSkin: Skin; private currentSkin: Skin;
private tabSkin: Skin[]; private tabSkin: Skin[];
private tabConv?: Conversation[];
/* Consturctor of the class */ /* Consturctor of the class */
constructor(id: string, username: string, password:string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number, constructor(id: number, username: string, password:string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number,
nbGamePlayed:number, currentSkin: Skin, tabSkin: Skin[], tabConv?: Conversation[] ){ nbGamesPlayed:number, currentSkin: Skin, tabSkin: Skin[]){
this.id=id; this.id=id;
this.username=username; this.username=username;
this.password=password; this.password=password;
this.nationality=nationality; this.nationality=nationality;
this.sexe=sexe; this.sexe=sexe;
this.dateOfBirth=dateOfBirth; this.dateOfBirth=dateOfBirth;
this.nbGamePlayed=nbGamePlayed; this.nbGamesPlayed=nbGamesPlayed;
this.currentCoins=currentCoins; this.currentCoins=currentCoins;
this.totalCoins=totalCoins; this.totalCoins=totalCoins;
this.currentSkin=currentSkin; this.currentSkin=currentSkin;
this.tabSkin=[...tabSkin]; this.tabSkin=tabSkin;
if(tabConv!==undefined){
this.tabConv=[...tabConv];
}
else{
this.tabConv=tabConv;
}
} }
/* Brief : Function getting the name of an user */
/* Brief : Function getting the name of a user */
getUsername(){ getUsername(){
return this.username; return this.username;
} }
/* Brief : Function setting the name of an user */ /* Brief : Function setting the name of a user */
setUsername(username: string){ setUsername(username: string){
this.username=username; this.username=username;
} }
/* Brief : Function getting the id of an user */ /* Brief : Function getting the id of a user */
getId(){ getId(){
return this.id; return this.id;
} }
/* Brief : Function getting the password of a user */
getPassword(){ getPassword(){
return this.password; return this.password;
} }
/* Brief : Function setting the password of a user */
setPassword(password:string){ setPassword(password:string){
this.password=password; this.password=password;
} }
/* Brief : Function getting the current number of coins of an user */ /* Brief : Function getting the current number of coins of a user */
getCurrentCoins(){ getCurrentCoins(){
return this.currentCoins; return this.currentCoins;
} }
/* Brief : Function setting the current number of coins of an user */ /* Brief : Function setting the current number of coins of a user */
setCurrentCoins(currentCoins: number){ setCurrentCoins(currentCoins: number){
this.currentCoins=currentCoins; this.currentCoins=currentCoins;
} }
/* Brief : Function getting the sex of an user */ /* Brief : Function getting the sex of a user */
getSexe(){ getSexe(){
return this.sexe; return this.sexe;
} }
/* Brief : Function getting the sex of an user */ /* Brief : Function getting the sex of a user */
setSexe(sexe: string){ setSexe(sexe: string){
this.sexe=sexe; this.sexe=sexe;
} }
/* Brief : Function getting the date of birth of an user */ /* Brief : Function getting the date of birth of a user */
getDateOfBirth(){ getDateOfBirth(){
return this.dateOfBirth; return this.dateOfBirth;
} }
/* Brief : Function setting the date of birth of an user */ /* Brief : Function setting the date of birth of a user */
setDateOfBirth(dateOfBirth: Date){ setDateOfBirth(dateOfBirth: Date){
this.dateOfBirth=dateOfBirth; this.dateOfBirth=dateOfBirth;
} }
/* Brief : Function getting the nationality of an user */ /* Brief : Function getting the nationality of a user */
getNationality(){ getNationality(){
return this.nationality; return this.nationality;
} }
/* Brief : Function setting the nationality of an user */ /* Brief : Function setting the nationality of a user */
setNationality(nationality: string){ setNationality(nationality: string){
this.nationality=nationality; this.nationality=nationality;
} }
/* Brief : Function getting the total number of coins of an user */ /* Brief : Function getting the total number of coins of a user */
getTotalCoins(){ getTotalCoins(){
return this.totalCoins; return this.totalCoins;
} }
/* Brief : Function setting the total number of coins of an user */ /* Brief : Function setting the total number of coins of a user */
setTotalCoins(totalCoins: number){ setTotalCoins(totalCoins: number){
this.totalCoins=totalCoins; this.totalCoins=totalCoins;
} }
/* Brief : Function getting the current number of game played by an user */ /* Brief : Function getting the current number of games played by a user */
getGamePlayed(){ getGamesPlayed(){
return this.nbGamePlayed; return this.nbGamesPlayed;
} }
/* Brief : Function setting the current number of game played by an user */ /* Brief : Function setting the current number of games played by a user */
setGamePlayed(nb: number){ setGamesPlayed(nb: number){
this.nbGamePlayed=nb; this.nbGamesPlayed=nb;
} }
/* Brief : Function getting the current skin of an user */ /* Brief : Function getting the current skin of a user */
getCurrentSkin(){ getCurrentSkin(){
return this.currentSkin; return this.currentSkin;
} }
/* Brief : Function setting the current skin of an user */ /* Brief : Function setting the current skin of a user */
setCurrentSkin(newSkin: Skin){ setCurrentSkin(newSkin: Skin){
this.currentSkin=newSkin; this.currentSkin=newSkin;
} }
/* Brief : Function getting the skins of an user */ /* Brief : Function getting the skins of a user */
getTabSkin(){ getTabSkin(){
return this.tabSkin; return this.tabSkin;
} }
/* Brief : Function setting the skins of an user */ /* Brief : Function setting the skins of a user */
setTabSkin(tabSkin: Skin[]){ setTabSkin(tabSkin: Skin[]){
this.tabSkin=[...tabSkin]; this.tabSkin=[...tabSkin];
} }
/* Brief : Function getting the conversations of an user */ /* Brief : Function adding a skin to a user */
getTabConv(){ addSkin(skin:Skin){
return this.tabConv; this.tabSkin.push(skin);
}
/* Brief : Function setting the conversations of an user */
setTabConv(tabConv?: Conversation[]){
tabConv?.forEach(conv => {
this.tabConv?.push(conv);
});
} }
/* isEqual(u:User){
changeUserCoins(coin:number){ if (u.getId()==this.id){
this.CurrentCoins+=coin; return true;
if (coin>0){
this.TotalCoins+=coin;
}
}
changerCurrentSkin(skin:Skin){
this.CurrentSkin=skin;
}
ajouterSkin(skin:Skin){
this.TabSkin.push(skin);
}
canConnect(username:string, mdp:string){
if (this.Username==username){
return this.Password==mdp;
} }
return false; return false;
} }
usrPasswordEquals(username:string, password:string){
return this.Password==password && this.Username==username;
}
*/
} }

@ -0,0 +1,27 @@
import { MANAGER_USER } from "../../../App";
import ManagerUser from "../../services/userServices/managerUser";
import { User } from "./user";
export class ManagerCoinsUser{
async addCoins(u:User, coins:number){
u.setCurrentCoins(u.getCurrentCoins()+coins);
u.setTotalCoins(u.getTotalCoins()+coins);
await MANAGER_USER.getsaverUser().updateUser(u);
}
async removeCoins(u:User, coins:number): Promise<boolean>{
if (u.getCurrentCoins()>=coins){
u.setCurrentCoins(u.getCurrentCoins()-coins);
await MANAGER_USER.getsaverUser().updateUser(u);
return true;
}
return false;
}
async changeCurrentCoins(u:User, coins:number){
u.setCurrentCoins(coins);
await MANAGER_USER.getsaverUser().updateUser(u);
}
}

@ -0,0 +1,15 @@
import { User } from "./user";
import tabSkinApp from "../../constSkin";
import { Conversation } from "../conversation";
import ManagerUser from "../../services/userServices/managerUser";
import { MANAGER_USER } from "../../../App";
export class UserCreator{
async createUser(username:string, password:string, nationality:string, sexe:string, date:Date){
//Récup l'ID d'après dans la bdd
let u:null|User = await MANAGER_USER.getsaverUser().saveUser(username, password, nationality, sexe, date);
MANAGER_USER.setCurrentUser(u);
return u;
}
}

@ -0,0 +1,25 @@
import { MANAGER_USER } from "../../../App";
import { User } from "./user";
export default class UserModificationManager{
async changePassword(user:User, password:string){
user.setPassword(password);
await MANAGER_USER.getsaverUser().updateUser(user);
}
async changeUsername(user:User, username:string){
user.setUsername(username);
await MANAGER_USER.getsaverUser().updateUser(user);
}
async changeNationality(user:User, nationality:string){
user.setNationality(nationality);
await MANAGER_USER.getsaverUser().updateUser(user);
}
async changeSexe(user:User, sexe:string){
user.setSexe(sexe);
await MANAGER_USER.getsaverUser().updateUser(user);
}
}

@ -0,0 +1,16 @@
import { MANAGER_USER } from '../../../App';
import { Skin } from '../Skin'
import { User } from './user'
export default class UserSkinModifier{
async addSkin(user:User, skin:Skin){
user.addSkin(skin);
await MANAGER_USER.getsaverUser().updateUser(user);
}
async changeCurrentSkin(user:User, skin:Skin){
user.setCurrentSkin(skin);
await MANAGER_USER.getsaverUser().updateUser(user);
}
}

@ -3,12 +3,14 @@ import { User } from "./User/user";
export class Conversation{ export class Conversation{
private id: number;
private tabUser: User[]; private tabUser: User[];
private tabMessage: Message[]; private tabMessage: Message[];
private name: string; private name: string;
/* Constructor of the class */ /* Constructor of the class */
constructor(tabUser: User[], tabMessage:Message[], name:string){ constructor(id: number, tabUser: User[], tabMessage:Message[], name:string){
this.id=id;
this.tabUser=[...tabUser]; this.tabUser=[...tabUser];
this.tabMessage=[...tabMessage]; this.tabMessage=[...tabMessage];
this.name=name; this.name=name;
@ -36,6 +38,11 @@ export class Conversation{
this.sortMessageDesc(); this.sortMessageDesc();
} }
/* Brief : function returning the id of a conversation */
getId(){
return this.id;
}
/* Brief : function returning the name to a conversation */ /* Brief : function returning the name to a conversation */
getName(){ getName(){
return this.name; return this.name;
@ -49,7 +56,7 @@ export class Conversation{
/* Brief : function returning the last message of a conversation */ /* Brief : function returning the last message of a conversation */
getLastMessage(){ getLastMessage(){
this.sortMessageDesc(); this.sortMessageDesc();
return this.tabMessage[0].getMessageContent(); return this.tabMessage[0];
} }
/* Brief : function sorting the messages of a conversation to be in the discussion order */ /* Brief : function sorting the messages of a conversation to be in the discussion order */

@ -1,9 +1,12 @@
import { ImageSourcePropType } from 'react-native';
import { Game } from './game' import { Game } from './game'
export class GameCasino extends Game{ export class GameCasino extends Game{
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){ constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){
super(name, imageSource, gameSource, nbPlayerMin, nbPlayerMax); super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax);
}
coinsCalculator(points: number): number {
return points;
} }
} }

@ -1,11 +1,10 @@
import { ImageSourcePropType } from 'react-native';
import { Game } from './game' import { Game } from './game'
export class GameMulti extends Game{ export class GameMulti extends Game{
readonly rankToCoins:Map<number,number> readonly rankToCoins:Map<number,number>
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map<number,number>){ constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map<number,number>){
super(name, imageSource, gameSource, nbPlayerMin, nbPlayerMax); super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax);
this.rankToCoins=rankToCoins; this.rankToCoins=rankToCoins;
} }
@ -15,11 +14,15 @@ export class GameMulti extends Game{
} }
//Returns the coins gained depending on the rank //Returns the coins gained depending on the rank
CoinsWithRank(rank:number){ coinsCalculator(points:number): number{
let coins; let coins=0;
let test;
for (let key of this.rankToCoins.keys()){ for (let key of this.rankToCoins.keys()){
coins = this.rankToCoins.get(key); test = this.rankToCoins.get(key);
if (rank==key ){ if (test != undefined){
coins=test;
}
if (points==key ){
return coins; return coins;
} }
} }

@ -1,11 +1,10 @@
import { ImageSourcePropType } from 'react-native';
import { Game } from './game' import { Game } from './game'
export class GameSolo extends Game{ export class GameSolo extends Game{
readonly ptsToCoins:Map<number,number> readonly ptsToCoins:Map<number,number>
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map<number,number>){ constructor(id:number, name:string, imageSource:string, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map<number,number>){
super(name, imageSource, gameSource, nbPlayerMin,nbPlayerMax); super(id, name, imageSource, gameSource, nbPlayerMin,nbPlayerMax);
this.ptsToCoins=ptsToCoins; this.ptsToCoins=ptsToCoins;
} }
@ -15,11 +14,13 @@ export class GameSolo extends Game{
} }
//Returns the gain depending on the number of points //Returns the gain depending on the number of points
CoinsWithPoints(nbPoints:number){ coinsCalculator(points:number): number{
let coins; let coins=0;
let test;
for (let key of this.ptsToCoins.keys()){ for (let key of this.ptsToCoins.keys()){
coins = this.ptsToCoins.get(key); test = this.ptsToCoins.get(key);
if (nbPoints<key ){ coins=key;
if (test != undefined && test>=points){
return coins; return coins;
} }
} }

@ -1,56 +0,0 @@
import { ImageSourcePropType } from 'react-native';
import { Game } from './game';
import { GameCasino } from './gameCasino';
import { GameMulti } from './gameMulti';
import { GameSolo } from './gameSolo';
import { User } from "./User/user";
export abstract class Match{
readonly code:string;
private tabUsers:User[];
private theGame:Game;
constructor(code:string, tabUser:User[], game:Game){
this.code=code;
this.tabUsers=[...tabUser];
this.theGame=game;
}
getTabUsers(){
return this.tabUsers;
}
setTabUser(tabUser:User[]){
this.tabUsers=[...tabUser];
}
getCode(){
return this.code;
}
getGame(){
return this.theGame;
}
setGame(game:Game){
this.theGame=game;
}
/*
convertMechanismToCoins(){
if (this.TheGame instanceof GameSolo){
return this.TheGame.CoinsWithPoints(this.GainingMechanism);
}
else if (this.TheGame instanceof GameMulti){
return this.TheGame.CoinsWithRank(this.GainingMechanism);
}
else if (this.TheGame instanceof GameCasino){
return this.TheGame.betToCoins(this.GainingMechanism);
}
return -1;
}
*/
}

@ -1,11 +0,0 @@
import { Match } from "./match";
import { User } from "./User/user";
import { Game } from "./game";
import { GameCasino } from "./gameCasino";
export class MatchMulti extends Match{
constructor(code:string, tabUser:User[], game:GameCasino){
super(code, tabUser, game);
}
}

@ -1,11 +0,0 @@
import { Match } from "./match";
import { User } from "./User/user";
import { Game } from "./game";
import { GameMulti } from "./gameMulti";
export class MatchMulti extends Match{
constructor(code:string, tabUser:User[], game:GameMulti){
super(code, tabUser, game);
}
}

@ -1,11 +0,0 @@
import { Match } from "./match";
import { GameSolo } from "./gameSolo";
import { User } from "./User/user";
import { Game } from "./game";
export class MatchSolo extends Match{
constructor(code:string, tabUser:User[], game:GameSolo){
super(code, tabUser, game);
}
}

@ -2,45 +2,52 @@ import { User } from './User/user'
export class Message{ export class Message{
private Content: string; private id: number;
private Sender: User; private content: string;
private DateEnvoie: Date; private sender: User;
private dateEnvoie: Date;
/* Constructor of the class */ /* Constructor of the class */
constructor(content: string, sender:User, dateEnvoie:Date){ constructor(id: number, content: string, sender:User, dateEnvoie:Date){
this.Content=content; this.id=id;
this.Sender=sender; this.content=content;
this.DateEnvoie=dateEnvoie; this.sender=sender;
this.dateEnvoie=dateEnvoie;
} }
/* Brief : Function setting the content of a message */ /* Brief : Function setting the content of a message */
setMessageContent(content: string){ setMessageContent(content: string){
this.Content=content; this.content=content;
} }
/* Brief : Function setting the sender of a message */ /* Brief : Function setting the sender of a message */
setMessageSender(sender: User){ setMessageSender(sender: User){
this.Sender=sender; this.sender=sender;
} }
/* Brief : Function setting the date of a message */ /* Brief : Function setting the date of a message */
setMessageDate(dateEnvoie: Date){ setMessageDate(dateEnvoie: Date){
this.DateEnvoie=dateEnvoie; this.dateEnvoie=dateEnvoie;
}
/* Brief : Function getting the id of a message */
getMessageId(){
return this.id;
} }
/* Brief : Function getting the content of a message */ /* Brief : Function getting the content of a message */
getMessageContent(){ getMessageContent(){
return this.Content; return this.content;
} }
/* Brief : Function getting the sender of a message */ /* Brief : Function getting the sender of a message */
getMessageSender(){ getMessageSender(){
return this.Sender; return this.sender;
} }
/* Brief : Function getting the date of a message */ /* Brief : Function getting the date of a message */
getMessageDate(){ getMessageDate(){
return this.DateEnvoie; return this.dateEnvoie;
} }

@ -1,13 +1,13 @@
import { ImageSourcePropType } from "react-native"; import { ImageSourcePropType } from "react-native";
export class Skin{ export class Skin{
readonly id: string; readonly id: number;
private name: string; private name: string;
private source: ImageSourcePropType; private source: string;
private cost:number; private cost:number;
/* Constructor of the class */ /* Constructor of the class */
constructor(id:string, name: string, source:ImageSourcePropType, Cost:number){ constructor(id:number, name: string, source:string, Cost:number){
this.id=id; this.id=id;
this.name=name; this.name=name;
this.source=source; this.source=source;
@ -20,7 +20,7 @@ export class Skin{
} }
/* Brief : Fuction setting the source of the image of a skin */ /* Brief : Fuction setting the source of the image of a skin */
setSkinSource(source: ImageSourcePropType){ setSkinSource(source: string){
this.source=source; this.source=source;
} }
@ -48,4 +48,8 @@ export class Skin{
setSkinCost(cost:number){ setSkinCost(cost:number){
this.cost=cost; this.cost=cost;
} }
isEqual(s:Skin){
return this.id==s.id;
}
} }

@ -5,48 +5,59 @@ import { User } from '../User/user';
// Instances // Instances
let conv:Conversation[] = [];
let tab:Skin[] = []; let tab:Skin[] = [];
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0); let classique = new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0);
let dateBirth = new Date(2010,0o3,0o7); let dateBirth = new Date(2010,0o3,0o7);
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv); let usr = new User(1, 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab, conv); let usr2 = new User(2, 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab);
let theDate = new Date(2022,10,14); let theDate = new Date(2022,10,14);
let theDate2 = new Date(2022,10,13); let theDate2 = new Date(2022,10,13);
let theDate3 = new Date(2022,10,15); let theDate3 = new Date(2022,10,15);
let mess = new Message('Bob Party est le meilleur projet', usr, theDate2); let mess = new Message(1, 'Bob Party est le meilleur projet', usr, theDate2);
let tabU:User[] = [usr, usr2]; let tabU = [usr, usr2];
let mess2 = new Message('Oui tout à fait', usr2, theDate); let mess2 = new Message(2, 'Oui tout à fait', usr2, theDate);
let mess3 = new Message('Mais oui trop de ouf', usr, theDate3); let mess3 = new Message(3, 'Mais oui trop de ouf', usr, theDate3);
let tabM:Message[] = [mess, mess2]; let tabM = [mess, mess2];
let convo = new Conversation(tabU, tabM, 'the conv'); let tabM2 = [mess, mess2, mess3];
let usr3 = new User('00003', 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv); let convo = new Conversation(1, tabU, tabM, 'the conv');
let usr3 = new User(4, 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
// Get tests // Get tests
describe('Conversation get tests', () => { describe('Conversation get tests', () => {
it('should return tabU [usr, usr2] (users)', () => { it('should return 1', () => {
expect(convo.getTabUser()).toBe(tabU); expect(convo.getId()).toBe(1);
})
it('should return tabM [mess, mess2] (messages)', () => {
expect(convo.getTabMessage()).toBe(tabM);
}) })
it('should return the conv', () => { it('should return the conv', () => {
expect(convo.getName()).toBe('the conv'); expect(convo.getName()).toBe('the conv');
}) })
it('should return tabU [usr, usr2] (users)', () => {
expect(convo.getTabUser()).toEqual(tabU);
})
it('should return tabM [mess, mess2] (messages)', () => {
expect(convo.getTabMessage()).toEqual(tabM);
})
it('should return Oui tout à fait (mess2)', () => { it('should return Oui tout à fait (mess2)', () => {
expect(convo.getLastMessage()).toBe('Oui tout à fait'); expect(convo.getLastMessage()).toEqual(mess2);
}) })
}) })
// Setting new value // Set tests
convo.setName('THE conv');
// Set test
describe('Conversation set test', () => { describe('Conversation set test', () => {
it('should return THE conv', () => { it('should return THE conv', () => {
expect(convo.setName).toBe('THE conv'); convo.setName('THE conv');
expect(convo.getName()).toBe('THE conv');
})
it('should return tabU [usr, usr2, usr3] (users)', () => {
convo.ajouterUser(usr3);
expect(convo.getTabUser()).toEqual(tabU);
})
it('should return tabM [mess, mess2, mess3] (messages)', () => {
convo.ajouterMessage(mess3);
expect(convo.getTabMessage()).toEqual(tabM2);
})
it('should return Mais oui trop de ouf (mess3)', () => {
expect(convo.getLastMessage()).toEqual(mess3);
}) })
}) })

@ -3,7 +3,8 @@ import { GameCasino } from '../GameCasino';
// Instances // Instances
let game = new GameCasino("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5); const img = "";
let game = new GameCasino(1, "bo jeu", img, "super jeu", 1, 5);
// Get tests // Get tests
@ -11,8 +12,8 @@ describe('GameMuti get tests', () => {
it('should return bo jeu', () => { it('should return bo jeu', () => {
expect(game.getName()).toBe('bo jeu'); expect(game.getName()).toBe('bo jeu');
}) })
it('should return require(blackjack.jpg)', () => { it('should return img ("")', () => {
expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg')); expect(game.getImageSource()).toBe(img);
}) })
it('should return super jeu', () => { it('should return super jeu', () => {
expect(game.getGameSource()).toBe('super jeu'); expect(game.getGameSource()).toBe('super jeu');
@ -26,28 +27,34 @@ describe('GameMuti get tests', () => {
}) })
// Setting new values
game.setGameSource('trop cool le jeu');
game.setImageSource(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
game.setName('beau jeu');
game.setNbPlayerMin(2);
game.setNbPlayerMax(4);
// Set tests // Set tests
describe('GameCasino set tests', () => { describe('GameCasino set tests', () => {
it('should return beau jeu', () => { it('should return beau jeu', () => {
game.setName('beau jeu');
expect(game.getName()).toBe('beau jeu'); expect(game.getName()).toBe('beau jeu');
}) })
it('should return require(JeuDeDame.jpg)', () => { it('should return require(JeuDeDame.jpg)', () => {
expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg')); game.setImageSource(img);
expect(game.getImageSource()).toBe(img);
}) })
it('should return trop cool le jeu', () => { it('should return trop cool le jeu', () => {
game.setGameSource('trop cool le jeu');
expect(game.getGameSource()).toBe('trop cool le jeu'); expect(game.getGameSource()).toBe('trop cool le jeu');
}) })
it('should return trop cool le jeu', () => { it('should return trop cool le jeu', () => {
game.setNbPlayerMin(2);
expect(game.getNbPlayerMin()).toBe(2); expect(game.getNbPlayerMin()).toBe(2);
}) })
it('should return 4', () => { it('should return 4', () => {
expect(game.getNbPlayerMin()).toBe(4); game.setNbPlayerMax(4);
expect(game.getNbPlayerMax()).toBe(4);
}) })
})
// Coins Calculator Tests
describe('GameCasino coins calculator tests', () => {
it('should return 200', () => {
expect(game.coinsCalculator(200)).toBe(200);
})
})

@ -1,23 +1,27 @@
import { GameMulti } from '../gameMulti'; import { GameMulti } from '../GameMulti';
// Instances // Instances
const img = "";
let myMap = new Map<number, number>([ let myMap = new Map<number, number>([
[50, 3], [4, 1],
[75, 4], [3, 3],
[100, 5], [2, 5],
[150, 6] [1, 10]
]); ]);
let game = new GameMulti("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5, myMap); let game = new GameMulti(1, "bo jeu", img, "super jeu", 1, 5, myMap);
// Get tests // Get tests
describe('GameMuti get tests', () => { describe('GameMulti get tests', () => {
it('should return 1', () => {
expect(game.getId()).toBe(1);
})
it('should return bo jeu', () => { it('should return bo jeu', () => {
expect(game.getName()).toBe('bo jeu'); expect(game.getName()).toBe('bo jeu');
}) })
it('should return require(blackjack.jpg)', () => { it('should return require(blackjack.jpg)', () => {
expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg')); expect(game.getImageSource()).toEqual(img);
}) })
it('should return super jeu', () => { it('should return super jeu', () => {
expect(game.getGameSource()).toBe('super jeu'); expect(game.getGameSource()).toBe('super jeu');
@ -29,34 +33,48 @@ describe('GameMuti get tests', () => {
expect(game.getNbPlayerMax()).toBe(5); expect(game.getNbPlayerMax()).toBe(5);
}) })
it('should return myMap', () => { it('should return myMap', () => {
expect(game.getMultiMap()).toBe(myMap); expect(game.getMultiMap()).toEqual(myMap);
}) })
}) })
// Setting new values
game.setGameSource('trop cool le jeu');
game.setImageSource(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
game.setName('beau jeu');
game.setNbPlayerMin(2);
game.setNbPlayerMax(4);
// Set tests // Set tests
describe('GameMulti set tests', () => { describe('GameMulti set tests', () => {
it('should return beau jeu', () => { it('should return beau jeu', () => {
game.setName('beau jeu');
expect(game.getName()).toBe('beau jeu'); expect(game.getName()).toBe('beau jeu');
}) })
it('should return require(JeuDeDame.jpg)', () => { it('should return img ("")', () => {
expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg')); game.setImageSource(img);
expect(game.getImageSource()).toEqual(img);
}) })
it('should return trop cool le jeu', () => { it('should return trop cool le jeu', () => {
game.setGameSource('trop cool le jeu');
expect(game.getGameSource()).toBe('trop cool le jeu'); expect(game.getGameSource()).toBe('trop cool le jeu');
}) })
it('should return trop cool le jeu', () => { it('should return trop cool le jeu', () => {
game.setNbPlayerMin(2);
expect(game.getNbPlayerMin()).toBe(2); expect(game.getNbPlayerMin()).toBe(2);
}) })
it('should return 4', () => { it('should return 4', () => {
expect(game.getNbPlayerMin()).toBe(4); game.setNbPlayerMax(4);
expect(game.getNbPlayerMax()).toBe(4);
})
})
// Coins Calculator tests
describe('GameMulti coins calculator tests', () => {
it('should return 1', () => {
expect(game.coinsCalculator(4)).toBe(1);
})
it('should return 3', () => {
expect(game.coinsCalculator(3)).toBe(3);
})
it('should return 5', () => {
expect(game.coinsCalculator(2)).toBe(5);
})
it('should return 10', () => {
expect(game.coinsCalculator(1)).toBe(10);
}) })
}) })

@ -1,23 +1,26 @@
import { GameSolo } from '../GameSolo'; import { GameSolo } from '../GameSolo';
// Instances // Instances
const img = "";
let myMap = new Map<number, number>([ let myMap = new Map<number, number>([
[50, 3], [50, 3],
[75, 4], [75, 4],
[100, 5], [100, 5],
[150, 6] [150, 6]
]); ]);
let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap); let game=new GameSolo(1, "bo jeu", img, "super jeu", 1, 1, myMap);
// Get tests // Get tests
describe('GameSolo get tests', () => { describe('GameSolo get tests', () => {
it('should return 1', () => {
expect(game.getId()).toBe(1);
})
it('should return bo jeu', () => { it('should return bo jeu', () => {
expect(game.getName()).toBe('bo jeu'); expect(game.getName()).toBe('bo jeu');
}) })
it('should return require(blackjack.jpg)', () => { it('should return blackjack.jpg', () => {
expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg')); expect(game.getImageSource()).toEqual(img);
}) })
it('should return super jeu', () => { it('should return super jeu', () => {
expect(game.getGameSource()).toBe('super jeu'); expect(game.getGameSource()).toBe('super jeu');
@ -29,34 +32,48 @@ describe('GameSolo get tests', () => {
expect(game.getNbPlayerMax()).toBe(1); expect(game.getNbPlayerMax()).toBe(1);
}) })
it('should return myMap', () => { it('should return myMap', () => {
expect(game.getSoloMap()).toBe(myMap); expect(game.getSoloMap()).toEqual(myMap);
}) })
}) })
// Setting new values
game.setGameSource('trop cool le jeu');
game.setImageSource(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
game.setName('beau jeu');
game.setNbPlayerMin(2);
game.setNbPlayerMax(3);
// Set tests // Set tests
describe('GameSolo set tests', () => { describe('GameSolo set tests', () => {
it('should return beau jeu', () => { it('should return beau jeu', () => {
game.setName('beau jeu');
expect(game.getName()).toBe('beau jeu'); expect(game.getName()).toBe('beau jeu');
}) })
it('should return require(JeuDeDame.jpg)', () => { it('should return JeuDeDame.jpg', () => {
expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg')); game.setImageSource(img);
expect(game.getImageSource()).toEqual(img);
}) })
it('should return trop cool le jeu', () => { it('should return trop cool le jeu', () => {
game.setGameSource('trop cool le jeu');
expect(game.getGameSource()).toBe('trop cool le jeu'); expect(game.getGameSource()).toBe('trop cool le jeu');
}) })
it('should return 2', () => { it('should return 2', () => {
game.setNbPlayerMin(2);
expect(game.getNbPlayerMin()).toBe(2); expect(game.getNbPlayerMin()).toBe(2);
}) })
it('should return 3', () => { it('should return 3', () => {
game.setNbPlayerMax(3);
expect(game.getNbPlayerMax()).toBe(3); expect(game.getNbPlayerMax()).toBe(3);
}) })
}) })
// Coins Calculator tests
describe('GameSolo coins calculator tests', () => {
it('should return 3', () => {
expect(game.coinsCalculator(50)).toBe(3);
})
it('should return 4', () => {
expect(game.coinsCalculator(75)).toBe(4);
})
it('should return 5', () => {
expect(game.coinsCalculator(100)).toBe(5);
})
it('should return 6', () => {
expect(game.coinsCalculator(150)).toBe(6);
})
})

@ -1,3 +0,0 @@
import { Match } from '../Match';

@ -1,4 +1,4 @@
import { MatchSolo } from '../MatchSolo'; import MatchSolo from '../Match/matchSolo';
import { Conversation } from '../Conversation'; import { Conversation } from '../Conversation';
import { Skin } from '../Skin'; import { Skin } from '../Skin';
import { User } from '../User/user'; import { User } from '../User/user';
@ -7,12 +7,13 @@ import { GameSolo } from '../GameSolo';
// Instances // Instances
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0); const img = "";
let blue = new Skin("S0002", "Bob Blue", require('bob_party/assets/BobsSkins/BobBlue.png'), 100); let classique = new Skin(1, "Bob", img, 0);
let blue = new Skin(2, "Bob Blue", img, 100);
let tab:Skin[] = [classique, blue]; let tab:Skin[] = [classique, blue];
let dateBirth = new Date(2010,0o3,0o7); let dateBirth = new Date(2010,0o3,0o7);
let conv:Conversation[] = []; let usr = new User(1, 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv); let usr2 = new User(2, 'Rémi', 'pwd', 'Martinique', 'M', dateBirth, 0, 0, 0, classique, tab);
let tabU:User[] = [usr]; let tabU:User[] = [usr];
let myMap = new Map<number, number>([ let myMap = new Map<number, number>([
[50, 3], [50, 3],
@ -20,16 +21,19 @@ let myMap = new Map<number, number>([
[100, 5], [100, 5],
[150, 6] [150, 6]
]); ]);
let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap); let game=new GameSolo(1, "bo jeu", img, "super jeu", 1, 1, myMap);
let match = new MatchSolo("machin", tabU, game); let match = new MatchSolo(1, false, tabU, game);
let tabU2:User[] = []; let tabU2:User[] = [];
let game2 = new GameSolo("jeu magnifique", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "wow jeu", 1, 1, myMap) let game2 = new GameSolo(2, "jeu magnifique", img, "wow jeu", 1, 1, myMap)
// Get tests // Get tests
describe('Match get tests', () => { describe('Match get tests', () => {
it('should return machin', () => { it('should return 1', () => {
expect(match.getCode()).toBe('machin'); expect(match.getCode()).toBe(1);
})
it('should return false', () => {
expect(match.getInGame()).toBe(false);
}) })
it('should return tabU [usr] (users)', () => { it('should return tabU [usr] (users)', () => {
expect(match.getTabUsers()).toBe(tabU); expect(match.getTabUsers()).toBe(tabU);
@ -42,6 +46,7 @@ describe('Match get tests', () => {
// Setting new values // Setting new values
match.setGame(game2); match.setGame(game2);
match.setInGame(true);
match.setTabUser(tabU2); match.setTabUser(tabU2);
@ -50,7 +55,31 @@ describe('Match set tests', () => {
it('should return tabU2 [] (users)', () => { it('should return tabU2 [] (users)', () => {
expect(match.getTabUsers()).toBe(tabU2); expect(match.getTabUsers()).toBe(tabU2);
}) })
it('should return true', () => {
expect(match.getInGame()).toBe(true);
})
it('should return game2', () => { it('should return game2', () => {
expect(match.getGame).toBe(game2); expect(match.getGame).toBe(game2);
}) })
}) })
// Update Post-Match tests
describe('Update post-match tests', () => {
it('should return 3', () => {
match.updatePostMatch(tabU[0],50);
expect(tabU[0].getCurrentCoins()).toBe(3);
})
it('should return 8', () => {
match.updatePostMatch(tabU[0],100);
expect(tabU[0].getCurrentCoins()).toBe(8);
})
it('should return 4', () => {
match.updatePostMatch(usr2,75);
expect(usr2.getCurrentCoins()).toBe(4);
})
it('should return 10', () => {
match.updatePostMatch(usr2,150);
expect(usr2.getCurrentCoins()).toBe(10);
})
})

@ -1,49 +1,47 @@
import { Message } from '../Message'; import { Message } from '../Message';
import { User } from '../User/user'; import { User } from '../User/user';
import { Conversation } from '../Conversation';
import { Skin } from '../Skin'; import { Skin } from '../Skin';
// Instances // Instances
let conv:Conversation[] = []; const img = "";
let tab:Skin[] = []; let classique = new Skin(1, "Bob", img, 0);
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
let dateBirth = new Date(2010,0o3,0o7); let dateBirth = new Date(2010,0o3,0o7);
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv); let usr = new User(1, 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, []);
let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab, conv); let usr2 = new User(2, 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, []);
let theDate = new Date(2022,10,14); let theDate = new Date(2022,10,14);
let theDate2 = new Date(2022,10,13); let theDate2 = new Date(2022,10,13);
let mess = new Message('Bob Party est le meilleur projet', usr, theDate); let mess = new Message(1, 'Bob Party est le meilleur projet', usr, theDate);
// Get tests // Get tests
describe('Message get tests', () => { describe('Message get tests', () => {
it('should return 1', () => {
expect(mess.getMessageId()).toBe(1);
})
it('should return Bob Party est le meilleur projet', () => { it('should return Bob Party est le meilleur projet', () => {
expect(mess.getMessageContent()).toBe('Bob Party est le meilleur projet'); expect(mess.getMessageContent()).toBe('Bob Party est le meilleur projet');
}) })
it('should return usr', () => { it('should return usr', () => {
expect(mess.getMessageSender()).toBe(usr); expect(mess.getMessageSender()).toEqual(usr);
}) })
it('should return wouhou', () => { it('should return theDate', () => {
expect(mess.getMessageDate()).toBe(theDate); expect(mess.getMessageDate()).toEqual(theDate);
}) })
}) })
// Setting new values
mess.setMessageContent('Vive Bob Party');
mess.setMessageSender(usr2);
mess.setMessageDate(theDate2);
// Set tests // Set tests
describe('Message set tests', () => { describe('Message set tests', () => {
it('should return Vive Bob Party', () => { it('should return Vive Bob Party', () => {
mess.setMessageContent('Vive Bob Party');
expect(mess.getMessageContent()).toBe('Vive Bob Party'); expect(mess.getMessageContent()).toBe('Vive Bob Party');
}) })
it('should return usr2', () => { it('should return usr2', () => {
expect(mess.getMessageSender()).toBe(usr2); mess.setMessageSender(usr2);
expect(mess.getMessageSender()).toEqual(usr2);
}) })
it('should return theDate2', () => { it('should return theDate2', () => {
expect(mess.getMessageDate()).toBe(theDate2); mess.setMessageDate(theDate2);
expect(mess.getMessageDate()).toEqual(theDate2);
}) })
}) })

@ -3,22 +3,22 @@ import { Skin } from '../Skin';
// Instance // Instance
const img = "";
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0); let classique = new Skin(1, "Bob", img, 0);
// Get tests // Get tests
describe('Skin get tests', () => { describe('Skin get tests', () => {
it('should return S0001', () => { it('should return 1', () => {
expect(classique.getSkinId()).toBe('S0001'); expect(classique.getSkinId()).toBe(1);
}) })
it('should return Bob', () => { it('should return Bob', () => {
expect(classique.getSkinName()).toBe('Bob'); expect(classique.getSkinName()).toBe('Bob');
}) })
it('should return require(BobClassic.png)', () => { it('should return img ("")', () => {
expect(classique.getSkinSource()).toBe(require('bob_party/assets/BobsSkins/BobClassic.png')); expect(classique.getSkinSource()).toEqual(img);
}) })
it('should return 0', () => { it('should return 0', () => {
expect(classique.getSkinCost()).toBe(0); expect(classique.getSkinCost()).toBe(0);
@ -27,24 +27,19 @@ describe('Skin get tests', () => {
// Setting new values
classique.setSkinName('Bob Blue');
classique.setSkinCost(100);
classique.setSkinSource(require('bob_party/assets/BobsSkins/BobBlue.png'));
// Set tests // Set tests
describe('Skin set tests', () => { describe('Skin set tests', () => {
it('should return The Classique', () => { it('should return The Classique', () => {
expect(classique.getSkinName()).toBe('Bob blue'); classique.setSkinName('Bob Blue');
expect(classique.getSkinName()).toBe('Bob Blue');
}) })
it('should return require(BobBlue.png)', () => { it('should return yo', () => {
expect(classique.getSkinSource()).toBe(require('bob_party/assets/BobsSkins/BobBlue.png')); classique.setSkinSource("yo");
expect(classique.getSkinSource()).toBe('yo');
}) })
it('should return 100', () => { it('should return 100', () => {
expect(classique.getSkinCost()).toBe(0); classique.setSkinCost(100);
expect(classique.getSkinCost()).toBe(100);
}) })
}) })

@ -1,24 +1,22 @@
import { User } from '../User/user'; import { User } from '../User/user';
import { Skin } from '../Skin'; import { Skin } from '../Skin';
import { Conversation } from '../Conversation';
// Instances // Instances
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0); const img = "";
let blue = new Skin("S0002", "Bob Blue", require('bob_party/assets/BobsSkins/BobBlue.png'), 100); let classique = new Skin(1, "Bob", img, 0);
let blue = new Skin(2, "Bob Blue", img, 100);
let tab:Skin[] = []; let tab:Skin[] = [];
let tab2:Skin[] = [classique, blue]; let tab2:Skin[] = [classique, blue];
let dateBirth = new Date(2010,0o3,0o7); let dateBirth = new Date(2010,0o3,0o7);
let dateBirth2 = new Date(2009,0o3,0o7); let dateBirth2 = new Date(2009,0o3,0o7);
let conv:Conversation[] = []; let usr = new User(1, 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
let conv2:Conversation[] = [];
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv);
// Tests des get // Tests des get
describe('User get tests', () => { describe('User get tests', () => {
it('should return 00001', () => { it('should return 1', () => {
expect(usr.getId()).toBe('00001'); expect(usr.getId()).toBe(1);
}) })
it('should return Killyan', () => { it('should return Killyan', () => {
expect(usr.getUsername()).toBe('Killyan'); expect(usr.getUsername()).toBe('Killyan');
@ -33,7 +31,7 @@ describe('User get tests', () => {
expect(usr.getSexe()).toBe('M'); expect(usr.getSexe()).toBe('M');
}) })
it('should return 2010-03-07 (dateBirth)', () => { it('should return 2010-03-07 (dateBirth)', () => {
expect(usr.getDateOfBirth()).toBe(dateBirth); expect(usr.getDateOfBirth()).toEqual(dateBirth);
}) })
it('should return 0', () => { it('should return 0', () => {
expect(usr.getCurrentCoins()).toBe(0); expect(usr.getCurrentCoins()).toBe(0);
@ -42,67 +40,57 @@ describe('User get tests', () => {
expect(usr.getTotalCoins()).toBe(0); expect(usr.getTotalCoins()).toBe(0);
}) })
it('should return 0', () => { it('should return 0', () => {
expect(usr.getGamePlayed()).toBe(0); expect(usr.getGamesPlayed()).toBe(0);
}) })
it('should return classique', () => { it('should return classique', () => {
expect(usr.getCurrentSkin()).toBe(classique); expect(usr.getCurrentSkin()).toEqual(classique);
}) })
it('should return tab', () => { it('should return tab', () => {
expect(usr.getTabSkin()).toBe(tab); expect(usr.getTabSkin()).toEqual(tab);
})
it('should return conv', () => {
expect(usr.getTabConv()).toBe(conv);
}) })
}) })
// Set de nouvelles valeurs
usr.setUsername('BgKillyan');
usr.setPassword('1234');
usr.setNationality('Marseille');
usr.setSexe('F');
usr.setDateOfBirth(dateBirth2);
usr.setCurrentCoins(2);
usr.setTotalCoins(2);
usr.setGamePlayed(4);
usr.setCurrentSkin(blue);
usr.setTabSkin(tab2);
usr.setTabConv(conv2);
// Tests des set // Tests des set
describe('User get tests', () => { describe('User get tests', () => {
it('should return BgKillyan', () => { it('should return BgKillyan', () => {
usr.setUsername('BgKillyan');
expect(usr.getUsername()).toBe('BgKillyan'); expect(usr.getUsername()).toBe('BgKillyan');
}) })
it('should return 1234', () => { it('should return 1234', () => {
usr.setPassword('1234');
expect(usr.getPassword()).toBe('1234'); expect(usr.getPassword()).toBe('1234');
}) })
it('should return Marseille', () => { it('should return Marseille', () => {
usr.setNationality('Marseille');
expect(usr.getNationality()).toBe('Marseille'); expect(usr.getNationality()).toBe('Marseille');
}) })
it('should return F', () => { it('should return F', () => {
usr.setSexe('F');
expect(usr.getSexe()).toBe('F'); expect(usr.getSexe()).toBe('F');
}) })
it('should return 07/03/2009 (dateBirth2)', () => { it('should return 07/03/2009 (dateBirth2)', () => {
expect(usr.getDateOfBirth()).toBe(dateBirth2); usr.setDateOfBirth(dateBirth2);
expect(usr.getDateOfBirth()).toEqual(dateBirth2);
}) })
it('should return 2', () => { it('should return 2', () => {
usr.setCurrentCoins(2);
expect(usr.getCurrentCoins()).toBe(2); expect(usr.getCurrentCoins()).toBe(2);
}) })
it('should return 2', () => { it('should return 2', () => {
usr.setTotalCoins(2);
expect(usr.getTotalCoins()).toBe(2); expect(usr.getTotalCoins()).toBe(2);
}) })
it('should return 4', () => { it('should return 4', () => {
expect(usr.getGamePlayed()).toBe(4); usr.setGamesPlayed(4);
expect(usr.getGamesPlayed()).toBe(4);
}) })
it('should return kikou', () => { it('should return kikou', () => {
expect(usr.getCurrentSkin()).toBe(blue); usr.setCurrentSkin(blue);
expect(usr.getCurrentSkin()).toEqual(blue);
}) })
it('should return tab2', () => { it('should return tab2', () => {
expect(usr.getTabSkin()).toBe(tab2); usr.setTabSkin(tab2);
}) expect(usr.getTabSkin()).toEqual(tab2);
it('should return conv2', () => {
expect(usr.getTabConv()).toBe(conv2);
}) })
}) })

@ -11,8 +11,9 @@ import Profile from '../screens/Profile'
import SkinList from '../screens/SkinList' import SkinList from '../screens/SkinList'
import GameChoice from '../screens/GameChoice' import GameChoice from '../screens/GameChoice'
import SignIn from '../screens/SignIn' import SignIn from '../screens/SignIn'
//import SignUp from '../screens/SignUp' import SignUp from '../screens/SignUp'
import LobbySolo from '../screens/LobbySolo'
import CookieClicker from '../Games/CookieClicker/cookieClicker'
const HomeStack = createStackNavigator(); const HomeStack = createStackNavigator();
@ -25,7 +26,7 @@ function HomeStackScreen() {
<HomeStack.Navigator screenOptions={{ headerShown: false}}> <HomeStack.Navigator screenOptions={{ headerShown: false}}>
<HomeStack.Screen name="Home" component={Home} options={{animationEnabled: false,}}/> <HomeStack.Screen name="Home" component={Home} options={{animationEnabled: false,}}/>
<HomeStack.Screen name="Settings" component={Settings} /> <HomeStack.Screen name="Settings" component={Settings} />
<HomeStack.Screen name='GameChoice' component={GameChoice} options={{animationEnabled: false,}}/> <HomeStack.Screen name='GameChoiceTab' component={GameChoiceStackScreen} options={{animationEnabled: false,}}/>
</HomeStack.Navigator> </HomeStack.Navigator>
); );
} }
@ -70,6 +71,34 @@ function ProfileStackScreen() {
); );
} }
const GameChoiceStack = createStackNavigator();
/*
Stack of screens for the profile and the changement of informations
*/
function GameChoiceStackScreen() {
return (
<GameChoiceStack.Navigator screenOptions={{headerShown: false}}>
<GameChoiceStack.Screen name='GameChoice' component={GameChoice} options={{animationEnabled: false,}}/>
<GameChoiceStack.Screen name='GameSolo' component={GameSoloStackScreen} options={{animationEnabled: false,}}/>
</GameChoiceStack.Navigator>
);
}
const GameSoloStack = createStackNavigator();
/*
Stack of screens for the profile and the changement of informations
*/
function GameSoloStackScreen() {
return (
<GameSoloStack.Navigator screenOptions={{headerShown: false}}>
<GameSoloStack.Screen name='LobbySolo' component={LobbySolo} options={{animationEnabled: false,}}/>
<GameSoloStack.Screen name='CookieClicker' component={CookieClicker} />
</GameSoloStack.Navigator>
);
}
const Tab = createBottomTabNavigator() const Tab = createBottomTabNavigator()
/* /*
Tab navigator to navigate between the stacks Tab navigator to navigate between the stacks
@ -87,6 +116,7 @@ function MainTabNavigator() {
<Tab.Screen name='ChatTab' component={ChatStackScreen} /> <Tab.Screen name='ChatTab' component={ChatStackScreen} />
<Tab.Screen name='ProfileTab' component={ProfileStackScreen} /> <Tab.Screen name='ProfileTab' component={ProfileStackScreen} />
<Tab.Screen name='SignIn' component={SignIn} /> <Tab.Screen name='SignIn' component={SignIn} />
<Tab.Screen name='SignUp' component={SignUp} />
</Tab.Navigator> </Tab.Navigator>
</NavigationContainer> </NavigationContainer>
) )

@ -0,0 +1,174 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit"
var incorrectCredentialsBool : boolean = false;
var tooLongPseudodBool : boolean = false;
var tooShortPasswordBool : boolean = false;
var invalidPseudoBool : boolean = false;
var invalidPasswordBool : boolean = false;
var impossibleBirthDateBool : boolean = false;
var undefinedPseudoBool : boolean = false;
var undefinedPasswordBool : boolean = false;
var undefinedBirthDateBool : boolean = false;
var undefinedNationalityBool : boolean = false;
var undefinedSexBool : boolean = false;
var alreadyUsedPseudoBool : boolean = false;
export const credentialErrorsSlice = createSlice({
name: "credentialErrors",
initialState:{
newUserErrorList : {
tooLongPseudo: tooLongPseudodBool,
tooShortPassword : tooShortPasswordBool,
invalidPseudo: invalidPseudoBool,
invalidPassword: invalidPasswordBool,
impossibleBirthDate: impossibleBirthDateBool,
undefinedPseudo: undefinedPseudoBool,
undefinedPassword: undefinedPasswordBool,
undefinedBirthDate: undefinedBirthDateBool,
undefinedNationality: undefinedNationalityBool,
undefinedSex: undefinedSexBool,
alreadyUsedPseudo: alreadyUsedPseudoBool,
},
loginErrorList : {
incorrectCredentials: incorrectCredentialsBool,
}
},
reducers: {
updateIncorrectCredentials: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
incorrectCredentials: action.payload
}
}
},
updateTooLongPseudo: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
tooShortPseudo: action.payload
}
}
},
updateTooLongPassword: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
tooLongPassword: action.payload
}
}
},
updateTooShortPassword: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
tooShortPassword: action.payload
}
}
},
updateInvalidPseudo: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
invalidPseudo: action.payload
}
}
},
updateInvalidPassword: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
invalidPassword: action.payload
}
}
},
updateImpossibleBirthDate: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
impossibleBirthDate: action.payload
}
}
},
updateUndefinedPseudo: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
undefinedPseudo: action.payload
}
}
},
updateUndefinedPassword: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
undefinedPassword: action.payload
}
}
},
updateUndefinedBirthDate: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
undefinedBirthDate: action.payload
}
}
},
updateUndefinedNationality: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
undefinedNationality: action.payload
}
}
},
updateUndefinedSex: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
undefinedSex: action.payload
}
}
},
updateAlreadyUsedPseudo: (state, action: PayloadAction<boolean>) => {
return {
...state,
newUserErrorList:{
...state.newUserErrorList,
alreadyUsedPseudo: action.payload
}
}
},
},
});
export const { updateIncorrectCredentials } = credentialErrorsSlice.actions
export const { updateTooShortPassword } = credentialErrorsSlice.actions
export const { updateTooLongPseudo } = credentialErrorsSlice.actions
export const { updateTooLongPassword } = credentialErrorsSlice.actions
export const { updateInvalidPseudo } = credentialErrorsSlice.actions
export const { updateInvalidPassword } = credentialErrorsSlice.actions
export const { updateImpossibleBirthDate } = credentialErrorsSlice.actions
export const { updateUndefinedPseudo } = credentialErrorsSlice.actions
export const { updateUndefinedPassword } = credentialErrorsSlice.actions
export const { updateUndefinedBirthDate } = credentialErrorsSlice.actions
export const { updateUndefinedNationality } = credentialErrorsSlice.actions
export const { updateUndefinedSex } = credentialErrorsSlice.actions
export const { updateAlreadyUsedPseudo } = credentialErrorsSlice.actions
export default credentialErrorsSlice.reducer;

@ -2,50 +2,65 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"
import { Skin } from "../../core/Skin"; import { Skin } from "../../core/Skin";
import { User } from "../../core/User/user"; import { User } from "../../core/User/user";
interface currentUserState { const dateNull = new Date();
value: User[]
}
const initialState: currentUserState = { const userNull:User= new User("","","","","",dateNull);
value: [],
} var currentUser:User = userNull;
export const currentUserSlice = createSlice({ export const currentUserSlice = createSlice({
name: "currentUser", name: "currentUserManager",
initialState, initialState : {
currentUser
},
reducers: { reducers: {
loginUser: (state, action: PayloadAction<User>) => { loginUser: (state, action: PayloadAction<User>) => {
state.value.push(action.payload); const newUser : User = new User(action.payload.getId(), action.payload.getUsername(),action.payload.getPassword(),action.payload.getNationality(),action.payload.getSexe(),action.payload.getDateOfBirth(), action.payload.getCurrentCoins(), action.payload.getTotalCoins(),action.payload.getGamePlayed(),action.payload.getCurrentSkin(),action.payload.getTabSkin(), action.payload.getTabConv())
state.currentUser = newUser;
}, },
updateSkin: (state, action: PayloadAction<Skin>) =>{ updateSkin: (state, action: PayloadAction<Skin>) =>{
const newUser = state.value[0]
const newUser : User = new User(currentUser.getId(), currentUser.getUsername(),currentUser.getPassword(),currentUser.getNationality(),currentUser.getSexe(),currentUser.getDateOfBirth(), currentUser.getCurrentCoins(), currentUser.getTotalCoins(),currentUser.getGamePlayed(),currentUser.getCurrentSkin(),currentUser.getTabSkin(), currentUser.getTabConv())
newUser.setCurrentSkin(action.payload); newUser.setCurrentSkin(action.payload);
state.value.pop();
state.value.push(newUser); state.currentUser = newUser;
}, },
updatePseudo: (state, action: PayloadAction<string>) =>{ updatePseudo: (state, action: PayloadAction<string>) =>{
const newUser = state.value[0] const newUser: User = new User(currentUser.getId(), currentUser.getUsername(), currentUser.getPassword(), currentUser.getNationality(), currentUser.getSexe(), currentUser.getDateOfBirth());
console.log(currentUser);
newUser.setUsername(action.payload); newUser.setUsername(action.payload);
state.value.pop(); return {
state.value.push(newUser); ...state,
currentUser: newUser,
}
}, },
updatePassword: (state, action: PayloadAction<string>) =>{ updatePassword: (state, action: PayloadAction<string>) =>{
const newUser = state.value[0] const newUser = state.currentUser;
newUser.setPassword(action.payload); currentUser.setPassword(action.payload)
state.value.pop(); return {
state.value.push(newUser); ...state,
currentUser: newUser,
}
}, },
updateNationality: (state, action: PayloadAction<string>) =>{ updateNationality: (state, action: PayloadAction<string>) =>{
const newUser = state.value[0] const newUser = state.currentUser;
newUser.setNationality(action.payload); currentUser.setNationality(action.payload)
state.value.pop(); return {
state.value.push(newUser); ...state,
currentUser: newUser,
}
}, },
updateSex: (state, action: PayloadAction<string>) =>{ updateSex: (state, action: PayloadAction<string>) =>{
const newUser = state.value[0] const newUser = state.currentUser;
newUser.setSexe(action.payload); currentUser.setSexe(action.payload)
state.value.pop(); return {
state.value.push(newUser); ...state,
currentUser: newUser,
}
} }
}, },
}); });

@ -1,5 +1,5 @@
import { configureStore } from "@reduxjs/toolkit"; import { configureStore } from "@reduxjs/toolkit";
import currentUserReducer from "./features/currentUserSlice"; import credentialErrorsSlice from "./features/credentialErrorsSlice";
import { getDefaultMiddleware } from '@reduxjs/toolkit'; import { getDefaultMiddleware } from '@reduxjs/toolkit';
const customizedMiddleware = getDefaultMiddleware({ const customizedMiddleware = getDefaultMiddleware({
@ -8,7 +8,7 @@ const customizedMiddleware = getDefaultMiddleware({
const store = configureStore({ const store = configureStore({
reducer: { reducer: {
currentUser: currentUserReducer, credentialErrors: credentialErrorsSlice,
}, },
middleware: (getDefaultMiddleware) => customizedMiddleware, middleware: (getDefaultMiddleware) => customizedMiddleware,
}) })

@ -1,28 +1,28 @@
import { StatusBar } from 'expo-status-bar' import { StatusBar } from 'expo-status-bar'
import {View} from 'react-native' import {View} from 'react-native'
import React 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';
import { BotBar } from '../components/BotBar'; import { BotBar } from '../components/BotBar';
import { FlatList } from 'react-native-gesture-handler'; import { FlatList } from 'react-native-gesture-handler';
import { ConversationComponent } from '../components/ConversationComponent'; import { ConversationComponent } from '../components/ConversationComponent';
import { useSelector } from 'react-redux'; import { Conversation } from '../core/conversation';
import { RootState } from '../redux/store'; import { MANAGER_CONVERSATION, MANAGER_USER } from '../../App';
import { useConversationStore } from '../context/conversationContext';
function Chat(props: { navigation: any; }) { function Chat(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
const currentUser = useSelector((state: RootState) => state.currentUser.value[0]);
return ( return (
<View style={stylesScreen.container}> <View style={stylesScreen.container}>
<TopBar <TopBar
nav={navigation} nav={navigation}
/> />
<View style={stylesScreen.bodyStart}> <View style={stylesScreen.bodyStart}>
<FlatList <FlatList
data={currentUser.getTabConv()} data={useConversationStore().tabConv}
renderItem={({item}) => <ConversationComponent conv={item} state='Preview'/>} renderItem={({item}) => <ConversationComponent conv={item} state='Preview' navigation={navigation}/>}
/> />
</View> </View>
<BotBar <BotBar

@ -1,5 +1,5 @@
import { StatusBar } from 'expo-status-bar' import { StatusBar } from 'expo-status-bar'
import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native' import { StyleSheet, View, Text, Alert, Pressable, Image, FlatList} from 'react-native'
import React from 'react'; import React from 'react';
import { Game } from '../core/game'; import { Game } from '../core/game';
import { Skin } from '../core/skin'; import { Skin } from '../core/skin';
@ -10,29 +10,34 @@ import { User } from '../core/User/user';
import tabSkinApp from '../constSkin'; import tabSkinApp from '../constSkin';
import { Conversation } from '../core/conversation'; import { Conversation } from '../core/conversation';
import { GameSolo } from '../core/gameSolo'; import { GameSolo } from '../core/gameSolo';
import { ScreenIndicator } from '../components/ScreenIndicator';
import stylesScreen from './style/screens.style'
import { MANAGER_GAME } from '../../App';
import { useGameStore } from '../context/gameContext';
let tabConv:Conversation[]=[]; let tabConv:Conversation[]=[];
const msc = require('../../assets/Icons/FondGris.png'); function GameChoice(props: { navigation: any}) {
const { navigation} = props
const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv); console.log(MANAGER_GAME.getTabGame());
const jeuTest= new GameSolo("SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin", 1, 1,new Map<number,number>);
function GameChoice(props: { navigation: any; }) {
const { navigation } = props
return ( return (
<View style={styles.container}> <View style={stylesScreen.container}>
<TopBar <TopBar
nav={navigation} nav={navigation}
/> />
<View style={styles.body}> <View style={stylesScreen.bodyStart}>
<GameComponent <ScreenIndicator title='Game Choice'/>
game={jeuTest} <FlatList
nav={navigation} data={MANAGER_GAME.getTabGame()}
/> numColumns={2}
columnWrapperStyle={{ flex: 1, justifyContent: "space-around"}}
keyExtractor={item =>item.getName()}
renderItem={({item}) => <GameComponent game={item} nav={navigation}/>} />
</View> </View>
<BotBar <BotBar
nav={navigation} nav={navigation}
state='Home' state='Store'
/> />
</View> </View>
); );

@ -1,23 +1,37 @@
import { StatusBar } from 'expo-status-bar' import { StatusBar } from 'expo-status-bar'
import { View} from 'react-native' import { View} from 'react-native'
import React 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';
import { BotBar } from '../components/BotBar'; import { BotBar } from '../components/BotBar';
import { Conversation } from '../core/conversation'; import { Conversation } from '../core/conversation';
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice'; import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
import { useSelector } from 'react-redux'; import { MANAGER_GAME } from '../../App';
import { RootState } from '../redux/store'; import { useGameStore } from '../context/gameContext';
//const test= new GameSolo("test", require('bob_party/assets/ImagesJeux/BatailleNavale.jpeg'), "test", );
let tabConv:Conversation[]=[];
let tabConv:Conversation[]=[];
function Home(props: { navigation: any; }) { function Home(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
const currentUser = useSelector((state: RootState) => state.currentUser.value[0]); const setTabGame = useGameStore((state) => state.setTabGame);
const handleGame = useCallback(async () => {
let tmp=MANAGER_GAME.getTabGame();
if (tmp==null){
await MANAGER_GAME.getLoaderGame().loadAllGame().then((res) => {
MANAGER_GAME.setTabGame(res);
setTabGame(res);
navigation.navigate('GameChoiceTab')
});
}
else{
navigation.navigate('GameChoiceTab')
}
}, []);
return ( return (
<View style={stylesScreen.container}> <View style={stylesScreen.container}>
@ -28,11 +42,11 @@ function Home(props: { navigation: any; }) {
<View style={stylesScreen.bodyCenter}> <View style={stylesScreen.bodyCenter}>
<ButtonGameTypeChoice <ButtonGameTypeChoice
title='Jouer Seul' title='Jouer Seul'
onPress={() => navigation.navigate('GameChoice')} onPress={() => {handleGame()}}
/> />
<ButtonGameTypeChoice <ButtonGameTypeChoice
title='Défier mes amis' title='Défier mes amis'
onPress={() => navigation.navigate('GameChoice')} onPress={() => handleGame()}
/> />
</View> </View>
<BotBar <BotBar

@ -0,0 +1,40 @@
import { StatusBar } from 'expo-status-bar'
import { View, Image} from 'react-native'
import React from 'react';
import stylesScreen from './style/screens.style'
import { TopBar } from '../components/TopBar';
import { BotBar } from '../components/BotBar';
import { Conversation } from '../core/conversation';
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
import { MANAGER_MATCH } from '../../App';
import { useMatchStore } from '../context/matchContext';
function LobbySolo(props: { navigation: any; }) {
const { navigation } = props
const match = useMatchStore().match;
return (
<View style={stylesScreen.container}>
<TopBar
nav={navigation}
state='matchmacking'
/>
<View style={stylesScreen.bodyCenter}>
<ButtonGameTypeChoice
title='Lancer la partie'
onPress={() => navigation.navigate(match?.getGame().getName().replace(/\s/g, ''))}
/>
</View>
<Image
style={{width:100, height:100}}
source={{uri: match?.getGame().getImageSource()}}
/>
</View>
);
}
export default LobbySolo

@ -8,8 +8,8 @@ import { BotBar } from '../components/BotBar';
import { SkinComponent } from '../components/Skin'; import { SkinComponent } from '../components/Skin';
import { ButtonGreySmall } from '../components/ButtonGreySmall'; import { ButtonGreySmall } from '../components/ButtonGreySmall';
import { ScreenIndicator } from '../components/ScreenIndicator'; import { ScreenIndicator } from '../components/ScreenIndicator';
import { useSelector } from 'react-redux'; import { MANAGER_USER } from '../../App';
import { RootState } from '../redux/store'; import { useUserStore } from '../context/userContext';
const coin = require('../../assets/Icons/Coin.png') const coin = require('../../assets/Icons/Coin.png')
@ -18,8 +18,6 @@ const coin = require('../../assets/Icons/Coin.png')
function Profile(props: { navigation: any; }) { function Profile(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
const currentUser = useSelector((state: RootState) => state.currentUser.value)[0];
return ( return (
<View style={stylesScreen.container}> <View style={stylesScreen.container}>
<TopBar <TopBar
@ -27,22 +25,23 @@ function Profile(props: { navigation: any; }) {
/> />
<View style={stylesScreen.bodyStart}> <View style={stylesScreen.bodyStart}>
<ScreenIndicator title='Profil'/> <ScreenIndicator title='Profil'/>
<Text style={styles.pseudoText}>{currentUser.getUsername()}</Text> <Text style={styles.pseudoText}>{useUserStore().user?.getUsername()}</Text>
<View style={styles.coinSkinView}> <View style={styles.coinSkinView}>
<View style={styles.coinView}> <View style={styles.coinView}>
<Image <Image
style={styles.coin} style={styles.coin}
source={coin} source={coin}
/> />
<Text style={styles.coinText}>{currentUser.getCurrentCoins()}</Text> <Text style={styles.coinText}>{useUserStore().user?.getCurrentCoins()}</Text>
</View> </View>
<View style={styles.skinView}> <View style={styles.skinView}>
<SkinComponent skin={currentUser.getCurrentSkin()} state='profile' /> <SkinComponent skin={useUserStore().user?.getCurrentSkin()} state='profile' nav={navigation}/>
<ButtonGreySmall onPress={() => navigation.navigate('SkinList')} title='Changer de skin' state='Profile'/> <ButtonGreySmall onPress={() => {navigation.navigate('SkinList');}} title='Changer de skin' state='Profile'/>
</View> </View>
</View> </View>
<View style={styles.infoView}> <View style={styles.infoView}>
<Text style={styles.infoText}>Total de BobCoin gagnés: {currentUser.getTotalCoins()}</Text> <Text style={styles.infoText}>Total de BobCoin gagnés: {useUserStore().user?.getTotalCoins()}</Text>
<Text style={styles.infoText}>Total de BobCoin gagnés: </Text>
</View> </View>
</View> </View>
<BotBar <BotBar

@ -7,26 +7,47 @@ import { TopBar } from '../components/TopBar';
import { ButtonGreySmall } from '../components/ButtonGreySmall'; import { ButtonGreySmall } from '../components/ButtonGreySmall';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { RootState } from '../redux/store'; import { RootState } from '../redux/store';
import DialogInput from "react-native-dialog-input";
import { updatePseudo, updatePassword, updateNationality, updateSex } from "../redux/features/currentUserSlice";
import Dialog from "react-native-dialog" import Dialog from "react-native-dialog"
import RNPickerSelect from "react-native-picker-select"; import RNPickerSelect from "react-native-picker-select";
import tabNat from '../constNat'; import { PickerGreySmall } from '../components/PickerGreySmall';
import tabSex from '../constSex'; import { MANAGER_USER } from '../../App';
import { useUserStore } from '../context/userContext';
import DialogInput from 'react-native-dialog-input';
import UserModificationManager from '../core/User/userModificationManager';
function Settings(props: { navigation: any; }) { function Settings(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
const setUser = useUserStore((state) => state.setUser);
const currentUser = useSelector((state: RootState) => state.currentUser.value)[0];
const [dialogPseudoVisible, setDialogPseudoVisible] = useState(false); const [dialogPseudoVisible, setDialogPseudoVisible] = useState(false);
const [dialogPasswordVisible, setDialogPasswordVisible] = useState(false); const [dialogPasswordVisible, setDialogPasswordVisible] = useState(false);
const [dialogNationalityVisible, setDialogNationalityVisible] = useState(false);
const [dialogSexVisible, setDialogSexVisible] = useState(false);
const [selectedSex, setSelectedSex] = useState(""); const [selectedSex, setSelectedSex] = useState("");
const [selectedNationality, setSelectedNationality] = useState(""); const [selectedNationality, setSelectedNationality] = useState("");
async function changeUsername(username:string){
const m = new UserModificationManager();
let tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){
await m.changeUsername(tmp, username);
setUser(tmp);
MANAGER_USER.setCurrentUser(tmp);
}
}
async function changePassword(password:string){
const m = new UserModificationManager();
let tmp=MANAGER_USER.getCurrentUser();
if (tmp!=null){
await m.changePassword(tmp, password);
setUser(tmp);
MANAGER_USER.setCurrentUser(tmp);
}
}
const dispatch=useDispatch(); const dispatch=useDispatch();
return ( return (
@ -41,23 +62,24 @@ function Settings(props: { navigation: any; }) {
<View style={{flexDirection: 'row', justifyContent: 'space-between',}}> <View style={{flexDirection: 'row', justifyContent: 'space-between',}}>
<View> <View>
<View> <View>
<Text style={styles.text}>Pseudo: {currentUser.getUsername()}</Text> <Text style={styles.text}>Pseudo: {useUserStore().user?.getUsername()}</Text>
<ButtonGreySmall onPress={() => setDialogPseudoVisible(true)} title='Changer le pseudo'/> <ButtonGreySmall onPress={() => {console.log(dialogPseudoVisible);
;setDialogPseudoVisible(true)}} title='Changer le pseudo'/>
</View> </View>
<View> <View>
<Text style={styles.text}>Mot de passe: {currentUser.getPassword()}</Text> <Text style={styles.text}>Mot de passe: {useUserStore().user?.getPassword()}</Text>
<ButtonGreySmall onPress={() => setDialogPasswordVisible(true)} title='Changer le mot de passe'/> <ButtonGreySmall onPress={() => setDialogPasswordVisible(true) } title='Changer le mot de passe'/>
</View> </View>
<View> <View>
<Text style={styles.text}>Nationalité: {currentUser.getNationality()}</Text> <Text style={styles.text}>Nationalité: {useUserStore().user?.getNationality()}</Text>
<ButtonGreySmall onPress={() => setDialogNationalityVisible(true)} title='Changer la nationnalité'/> <PickerGreySmall title='Changer la nationalité' valueChange={(value:string) => setSelectedNationality(value)} donePress={() => dispatch(updateNationality(selectedNationality))} values={["Francais", "Anglais"]} />
</View> </View>
<View> <View>
<Text style={styles.text}>Sexe: {currentUser.getSexe()}</Text> <Text style={styles.text}>Sexe: {useUserStore().user?.getSexe()}</Text>
<ButtonGreySmall onPress={() => setDialogSexVisible(true)} title='Changer le sexe'/> <PickerGreySmall title='Changer le sexe' valueChange={(value:string) => setSelectedSex(value)} donePress={() => dispatch(updateSex(selectedSex))} values={["Homme", "Femme", "Autre"]} />
</View> </View>
</View> </View>
<Text style={styles.textID}>ID: {currentUser.getId()}</Text> <Text style={styles.textID}>ID: {useUserStore().user?.getId()}</Text>
</View> </View>
</View> </View>
</View> </View>
@ -66,7 +88,7 @@ function Settings(props: { navigation: any; }) {
isDialogVisible={dialogPseudoVisible} isDialogVisible={dialogPseudoVisible}
title="Inserer le nouveau pseudo" title="Inserer le nouveau pseudo"
hintInput ="Pseudo" hintInput ="Pseudo"
submitInput={ (inputText: string) => {dispatch(updatePseudo(inputText)); setDialogPseudoVisible(false)} } submitInput={ (inputText: string) => { changeUsername(inputText); setDialogPseudoVisible(false)} }
closeDialog={ () => {setDialogPseudoVisible(false)}}> closeDialog={ () => {setDialogPseudoVisible(false)}}>
</DialogInput> </DialogInput>
@ -74,35 +96,10 @@ function Settings(props: { navigation: any; }) {
isDialogVisible={dialogPasswordVisible} isDialogVisible={dialogPasswordVisible}
title="Inserer le nouveau mot de passe" title="Inserer le nouveau mot de passe"
hintInput ="Mot de passe" hintInput ="Mot de passe"
submitInput={ (inputText: string) => {dispatch(updatePassword(inputText)); setDialogPasswordVisible(false)} } submitInput={ (inputText: string) => { changePassword(inputText); setDialogPasswordVisible(false)} }
closeDialog={ () => {setDialogPasswordVisible(false)}}> closeDialog={ () => {setDialogPasswordVisible(false)}}>
</DialogInput>
<Dialog.Container visible={dialogNationalityVisible}> </DialogInput>
<Dialog.Title>Changer de nationalité</Dialog.Title>
<View style={styles.RNPView}>
<RNPickerSelect
placeholder={{label:"Cliquez pour changer", value: null}}
onValueChange={(value:string) => setSelectedNationality(value)}
items={tabNat}
/>
</View>
<Dialog.Button label="Cancel" onPress={() => setDialogNationalityVisible(false)} />
<Dialog.Button label="Valider" onPress={() => {dispatch(updateNationality(selectedNationality)); setDialogNationalityVisible(false)}} />
</Dialog.Container>
<Dialog.Container visible={dialogSexVisible}>
<Dialog.Title>Changer de sexe</Dialog.Title>
<View style={styles.RNPView}>
<RNPickerSelect
placeholder={{label:"Cliquez pour changer", value: null}}
onValueChange={(value:string) => setSelectedSex(value)}
items={tabSex}
/>
</View>
<Dialog.Button label="Cancel" onPress={() => setDialogSexVisible(false)} />
<Dialog.Button label="Valider" onPress={() => {dispatch(updateSex(selectedSex)); setDialogSexVisible(false)}} />
</Dialog.Container>
</View> </View>
); );

@ -1,48 +1,75 @@
import { StatusBar } from 'expo-status-bar' import { StatusBar } from 'expo-status-bar'
import { View, Pressable, Text} from 'react-native' import { View, Pressable, Text, Alert} from 'react-native'
import React, { useState } from 'react'; import React, { useCallback, useState } from 'react';
import stylesScreen from './style/screens.style' import stylesScreen from './style/screens.style'
import { TextInput } from 'react-native-gesture-handler'; import { TextInput } from 'react-native-gesture-handler';
import tabUS from "../constUser"; import styles from "./style/SignIn.style";
import styles from "./style/SignIn.style" import { useDispatch, useSelector } from 'react-redux';
import { useDispatch, } from 'react-redux';
import { loginUser } from '../redux/features/currentUserSlice'; import { loginUser } from '../redux/features/currentUserSlice';
import { RootState } from '../redux/store';
import { updateIncorrectCredentials } from '../redux/features/credentialErrorsSlice';
import Dialog from "react-native-dialog";
import { MANAGER_USER } from '../../App';
import { useUserStore } from '../context/userContext';
function SignIn(props: { navigation: any; }) { function SignIn(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
const setUser = useUserStore((state) => state.setUser);
const errorList = useSelector((state: RootState) => state.credentialErrors.loginErrorList);
const [pseudo, setPseudo] = useState(''); const [pseudo, setPseudo] = useState('');
const [password, setPassword] = useState(''); const [password, setPassword] = useState('');
const dispatch=useDispatch(); const dispatch=useDispatch();
function userVerif(login: string, password: string, nav: any){ if (errorList.incorrectCredentials){
if((tabUS.map((User) => User.getUsername()).indexOf(login)) !== -1){ Alert.alert("Pseudo ou Mot de passe incorrect");
let id = (tabUS.map((User) => User.getUsername()).indexOf(login)) dispatch(updateIncorrectCredentials(true));
if ((tabUS.map((User) => User.getUsername()).indexOf(login) === id) && ( tabUS[id].getPassword() === password) ){
dispatch(loginUser(tabUS[id]));
nav.navigate('HomeTab');
} }
const handleUserConnect = useCallback(async (pseudo: string, password: string) => {
await MANAGER_USER.getLoaderUser().loadByUsernamePassword(pseudo, password).then((res) => {
if (res!=null){
MANAGER_USER.setCurrentUser(res);
setUser(MANAGER_USER.getCurrentUser());
navigation.navigate('HomeTab');
} }
else{
console.log("wesh c'est null");
} }
});
}, []);
return ( return (
<View style={stylesScreen.container}> <View style={stylesScreen.container}>
<View style={stylesScreen.bodyCenter}> <View style={stylesScreen.bodyCenter}>
<TextInput style={styles.textInput} placeholder='Login' onChangeText={(val) => setPseudo(val)} autoCapitalize='none' /> <TextInput style={styles.textInput} placeholder='Login' onChangeText={(val) => setPseudo(val)} autoCapitalize='none' />
<TextInput style={styles.textInput} placeholder='Password' onChangeText={(val) => setPassword(val)} autoCapitalize='none' /> <TextInput style={styles.textInput} placeholder='Password' onChangeText={(val) => setPassword(val)} autoCapitalize='none' secureTextEntry={true}/>
<Pressable style={styles.button} onPress={() => userVerif(pseudo, password, navigation)}> <Pressable style={styles.button} onPress={() => handleUserConnect(pseudo, password)}>
<Text style={styles.text}>Se connecter</Text> <Text style={styles.text}>Se connecter</Text>
</Pressable> </Pressable>
<Pressable onPress={() => navigation.navigate('SignUp')}> <Pressable onPress={() => navigation.navigate('SignUp')}>
<Text style={styles.signup}>Pas de compte? Inscrivez vous !</Text> <Text style={styles.textLink}>Pas de compte? Inscrivez vous !</Text>
</Pressable> </Pressable>
</View> </View>
{/*
<Dialog.Container visible={false}>
<Dialog.Title>Ce pseudo n'exsite pas</Dialog.Title>
<Dialog.Button label="Fermer" onPress={() => dispatch(updateIncorrectCredentials(false))} />
</Dialog.Container>
<Dialog.Container visible={false}>
<Dialog.Title>Mot de passe incorrect</Dialog.Title>
<Dialog.Button label="Fermer" onPress={() => dispatch(updateIncorrectCredentials(false))} />
</Dialog.Container>
*/}
</View> </View>
); );
} }

@ -1,29 +1,140 @@
// import { StatusBar } from 'expo-status-bar' import { StatusBar } from 'expo-status-bar'
// import { StyleSheet, View, ImageSourcePropType, Pressable, Text} from 'react-native' import { StyleSheet, View, ImageSourcePropType, Pressable, Text, Alert} from 'react-native'
// import React from 'react'; import React, { useState } from 'react';
// import stylesScreen from './style/screens.style' import stylesScreen from './style/screens.style'
// import { TextInput } from 'react-native-gesture-handler'; import { TextInput } from 'react-native-gesture-handler';
// import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice'; import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
import styleScreen from "./style/screens.style";
// import styles from "./style/SignIn.style" import styles from "./style/SignUp.style";
import { useDispatch, useSelector } from 'react-redux';
// function SignUp(props: { navigation: any; }) { import { checkNewUserValidity } from '../core/Auth/newUser';
// const { navigation } = props import DateTimePicker, { DateTimePickerEvent } from '@react-native-community/datetimepicker';
// return ( import RNPickerSelect from "react-native-picker-select";
// <View style={stylesScreen.container}> import { PickerGreySmall } from '../components/PickerGreySmall';
// <View style={stylesScreen.bodyCenter}> import { loginUser } from '../redux/features/currentUserSlice';
// <CustomTextInput placeholder={""} text="Pseudo"/> import { RootState } from '../redux/store';
// <CustomTextInput placeholder={""} text="Mot de passe"/> import { updateImpossibleBirthDate, updateInvalidPassword, updateInvalidPseudo, updateTooLongPseudo, updateTooShortPassword, updateUndefinedBirthDate, updateUndefinedNationality, updateUndefinedPassword, updateUndefinedPseudo, updateUndefinedSex } from '../redux/features/credentialErrorsSlice';
// <CustomTextInput placeholder={""} text="Mot de passe"/> import { getSystemErrorMap } from 'util';
// <CustomTextInput placeholder={""} text="Nationalité"/> import RNDateTimePicker from '@react-native-community/datetimepicker';
// <CustomTextInput placeholder={""} text="Date de naisance"/>
// <CustomTextInput placeholder={""} text="Sexe"/> function SignUp(props: { navigation: any; }) {
// <Pressable style={styles.button} onPress={navigation.navigate('Home')}> const { navigation } = props
// <Text style={styles.text}>S'inscrire</Text>
// </Pressable> const [pseudo, setPseudo] = useState('');
// </View> const [password, setPassword] = useState('');
// </View> const [date, setDate] = useState(new Date())
// );
// }
function onDateSelected(event : DateTimePickerEvent, value : Date | undefined) {
// export default SignUp console.log(value);
if (value != undefined) {
setDate(value);
}
}
const [selectedSex, setSelectedSex] = useState('');
const [selectedNationality, setSelectedNationality] = useState('')
const errorList = useSelector((state: RootState) => state.credentialErrors.newUserErrorList);
const dispatch=useDispatch();
switch(true){
case (errorList.undefinedPseudo):
Alert.alert("Veuillez définir un pseudo");
dispatch(updateUndefinedPseudo(false));
break;
case (errorList.undefinedPassword):
Alert.alert("Veuillez définir un mot de passe");
dispatch(updateUndefinedPassword(false));
break;
case (errorList.undefinedBirthDate):
Alert.alert("Veuillez définir une date de naissance");
dispatch(updateUndefinedBirthDate(false));
break;
case (errorList.undefinedNationality):
Alert.alert("Veuillez définir une nationalité");
dispatch(updateUndefinedNationality(false))
break;
case (errorList.undefinedSex):
Alert.alert("Veuillez définir un sexe");
dispatch(updateUndefinedSex(false));
break;
case (errorList.tooLongPseudo):
Alert.alert("Votre pseudo ne doit pas dépasser 22 caractères");
dispatch(updateTooLongPseudo(false));
break;
case (errorList.invalidPseudo):
Alert.alert("Votre pseudo doit contenir uniquement des lettres des chiffres et des - ou _");
dispatch(updateInvalidPseudo(false));
break;
//ALREADY USED PSEUDO
case (errorList.tooShortPassword):
Alert.alert("Votre mot de passe doit faire au moins 8 caractères");
dispatch(updateTooShortPassword(false));
break;
case (errorList.invalidPassword):
Alert.alert("Votre pseudo doit contenir au moins une majuscule, une majuscule, un chiffre et un caractère spécial (#?!@$%^&*-)");
dispatch(updateInvalidPassword(false));
break;
case (errorList.impossibleBirthDate):
Alert.alert("Vous devez avoir au moins 13 ans");
dispatch(updateImpossibleBirthDate(false));
break;
}
return (
<View style={stylesScreen.container}>
<View style={stylesScreen.bodyCenter}>
<View style={{width: '60%', alignItems: 'center'}}>
<Text style={styles.text}>Login</Text>
<TextInput style={styles.textInput} placeholder='Login' onChangeText={(val) => setPseudo(val)} autoCapitalize='none' />
</View>
<View style={{width: '60%', alignItems: 'center'}}>
<Text style={styles.text}>Password</Text>
<TextInput style={styles.textInput} placeholder='Password' onChangeText={(val) => setPassword(val)} autoCapitalize='none' />
</View>
<View style={{width: '70%', alignItems: 'center'}}>
<Text style={styles.text}>Date de naissance</Text>
<View style={{width: 150, margin: 10}}>
<RNDateTimePicker onChange={(event, value) => onDateSelected(event, value)} mode='date' value={date} themeVariant='dark'/>
</View>
</View>
<View style={{width: '60%', alignItems: 'center'}}>
<Text style={styles.text}>Nationalité</Text>
<PickerGreySmall title='Choisir la Nationalité' valueChange={(value:string) =>
setSelectedNationality(value)} values={["Français", "Anglais"]} />
</View>
<View style={{width: '60%', alignItems: 'center'}}>
<Text style={styles.text}>Sexe</Text>
<PickerGreySmall title='Choisir le sexe' valueChange={(value:string) => setSelectedSex(value)} values={["Homme","Femme", "Autre"]} />
</View>
<Pressable style={styles.button} onPress={() => checkNewUserValidity(pseudo,password,date,selectedNationality,selectedSex, dispatch, navigation)}>
<Text style={styles.text}>S'inscrire</Text>
</Pressable>
<Pressable onPress={() => navigation.navigate('SignIn')}>
<Text style={styles.textLink}>J'ai déjà un compte</Text>
</Pressable>
</View>
</View>
);
}
export default SignUp

@ -8,16 +8,13 @@ import { FlatList } from 'react-native-gesture-handler';
import { SkinComponent } from '../components/Skin'; import { SkinComponent } from '../components/Skin';
import tabSkinApp from '../constSkin'; import tabSkinApp from '../constSkin';
import { ScreenIndicator } from '../components/ScreenIndicator'; import { ScreenIndicator } from '../components/ScreenIndicator';
import { useSelector } from 'react-redux'; import { MANAGER_USER } from '../../App';
import { RootState } from '../redux/store';
function SkinList(props: { navigation: any; }) { function SkinList(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
const currentUser = useSelector((state: RootState) => state.currentUser.value[0]);
return ( return (
<View style={stylesScreen.container}> <View style={stylesScreen.container}>
<TopBar <TopBar
@ -26,11 +23,11 @@ function SkinList(props: { navigation: any; }) {
<View style={stylesScreen.bodyStart}> <View style={stylesScreen.bodyStart}>
<ScreenIndicator title='Mes Skins'/> <ScreenIndicator title='Mes Skins'/>
<FlatList <FlatList
data={tabSkinApp} data={MANAGER_USER.getCurrentUser()?.getTabSkin()}
numColumns={2} numColumns={2}
columnWrapperStyle={{ flex: 1, justifyContent: "space-around"}} columnWrapperStyle={{ flex: 1, justifyContent: "space-around"}}
keyExtractor={item =>item.getSkinName()} keyExtractor={item =>item.getSkinName()}
renderItem={({item}) => <SkinComponent skin={item} state='liste'/>} /> renderItem={({item}) => <SkinComponent skin={item} state='liste' nav={navigation}/>} />
</View> </View>
<BotBar <BotBar
nav={navigation} nav={navigation}

@ -1,6 +1,6 @@
import { StatusBar } from 'expo-status-bar' import { StatusBar } from 'expo-status-bar'
import { View } from 'react-native' import { View } from 'react-native'
import React 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';
import { BotBar } from '../components/BotBar'; import { BotBar } from '../components/BotBar';
@ -9,12 +9,16 @@ import { SkinComponent } from '../components/Skin';
import { ScreenIndicator } from '../components/ScreenIndicator'; import { ScreenIndicator } from '../components/ScreenIndicator';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { RootState } from '../redux/store'; import { RootState } from '../redux/store';
import tabSkinApp from '../constSkin';
import { MANAGER_USER } from '../../App';
import { useUserStore } from '../context/userContext';
import { useStoreStore } from '../context/storeContext';
function Store(props: { navigation: any; }) { function Store(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
const currentUser = useSelector((state: RootState) => state.currentUser.value[0]);
return ( return (
<View style={stylesScreen.container}> <View style={stylesScreen.container}>
<TopBar <TopBar
@ -23,11 +27,11 @@ function Store(props: { navigation: any; }) {
<View style={stylesScreen.bodyStart}> <View style={stylesScreen.bodyStart}>
<ScreenIndicator title='Store'/> <ScreenIndicator title='Store'/>
<FlatList <FlatList
data={currentUser.getTabSkin()} data={useStoreStore().tabSkin}
numColumns={2} numColumns={2}
columnWrapperStyle={{ flex: 1, justifyContent: "space-around"}} columnWrapperStyle={{ flex: 1, justifyContent: "space-around"}}
keyExtractor={item =>item.getSkinName()} keyExtractor={item =>item.getSkinName()}
renderItem={({item}) => <SkinComponent skin={item} state='shop'/>} /> renderItem={({item}) => <SkinComponent skin={item} state='shop' nav={navigation}/>} />
</View> </View>
<BotBar <BotBar
nav={navigation} nav={navigation}

@ -29,8 +29,4 @@ export default StyleSheet.create({
margin: 15, margin: 15,
padding: 15, padding: 15,
}, },
RNPView: {
alignSelf: 'center',
padding: 20,
}
}); });

@ -19,14 +19,16 @@ export default StyleSheet.create({
letterSpacing: 0.25, letterSpacing: 0.25,
color: 'white', color: 'white',
}, },
signup:{ textLink:{
fontSize:15, fontSize:15,
color:'white', color:'white',
textDecorationLine:"underline", textDecorationLine:"underline",
}, },
textInput: { textInput: {
width: '50%', width: '80%',
height: '5%', height: '5%',
backgroundColor: 'white', backgroundColor: 'white',
padding: 10,
marginVertical: 10,
} }
}); });

@ -0,0 +1,35 @@
import { StyleSheet } from "react-native";
export default StyleSheet.create({
textInput: {
width: '100%',
height: '5%',
backgroundColor: 'white',
padding: 10,
marginTop: 10,
},
button: {
alignItems: 'center',
justifyContent: 'center',
height: 50,
width: 225,
margin:'10%',
borderRadius: 10,
elevation: 3,
backgroundColor: '#0085FF',
},
text: {
fontSize: 16,
lineHeight: 21,
fontWeight: 'bold',
letterSpacing: 0.25,
color: 'white',
},
textLink:{
fontSize:15,
color:'white',
textDecorationLine:"underline",
},
})

@ -24,4 +24,8 @@ export default StyleSheet.create({
justifyContent: 'center', justifyContent: 'center',
width: '100%', width: '100%',
}, },
RNPView: {
alignSelf: 'center',
padding: 20,
}
}); });

@ -0,0 +1,25 @@
import { Conversation } from "../../core/conversation";
import { User } from "../../core/User/user";
export default interface ILoaderConversation{
/**
* loadAllConversation methode that load every Conversation in the data management system
* return an array of Conversation
*/
loadAllConversation(): Promise<Conversation[]>;
/**
* loadByID methode that load an array of Conversation from the data management system by its id
* id the id we want to search
* return a Conversation if found, if not null
*/
loadByID(id:string): Promise<Conversation | null>;
/**
* loadByUser methode that load an array of Conversation from the data management system using a user
* u the user we want the conversations of
* return an array of Conversation
*/
loadByUser(u:User): Promise<Conversation[]>;
}

@ -0,0 +1,23 @@
import { Conversation } from "../../core/conversation";
export default interface ISaverConversation{
/**
* saveConversation methode that save a Conversation in the data management system
* c the Conversation we want to save
*/
saveConversation(c:Conversation): Promise<void>;
/**
* deleteConversation methode that delete a Conversation in the data management system
* c the Conversation we want to delete
*/
deleteConversation(c:Conversation): Promise<void>;
/**
* updateConversation methode that update a Conversation in the data management system
* c the Conversation we want to update
*/
updateConversation(c:Conversation): Promise<void>;
}

@ -0,0 +1,14 @@
import { Conversation } from "../../core/conversation";
import ISaverConversation from "./ISaverConversation";
export class FakeSaverConversation implements ISaverConversation{
async saveConversation(c: Conversation): Promise<void> {
return;
}
async deleteConversation(c: Conversation): Promise<void> {
return;
}
async updateConversation(c: Conversation): Promise<void> {
return;
}
}

@ -0,0 +1,39 @@
import { Conversation } from "../../core/conversation";
import { Message } from "../../core/message";
import { Skin } from "../../core/skin";
import { User } from "../../core/User/user";
import ILoaderConversation from "./ILoaderConversation";
export class LoaderConversationApi implements ILoaderConversation{
private axios = require('axios').default;
loadAllConversation(): Promise<Conversation[]> {
throw new Error("Method not implemented.");
}
loadByID(id: string): Promise<Conversation | null> {
throw new Error("Method not implemented.");
}
async loadByUser(u: User): Promise<Conversation[]> {
let tabConv:Conversation[]=[];
await this.axios({
method: 'get',
url: 'https://jsonplaceholder.typicode.com/todos/1',
params: {
name: "getConversationByUser",
//Les params genre nom de la fonction en php
}
})
.then(function (response: any) {
let skin= new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0);
tabConv=[new Conversation(1,
[new User(1, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, skin, [skin]),
new User(3, "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, skin, [skin])],
[new Message(1, "bonjour", new User(1, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, skin, [skin]), new Date(2022,12,12)),
new Message(2, "test", new User(2, "Fefe63", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, skin, [skin]), new Date(2022,12,13))], "leNom")];
});
return tabConv;
}
}

@ -0,0 +1,33 @@
import { Conversation } from "../../core/conversation";
import ILoaderConversation from "./ILoaderConversation";
import ISaverConversation from "./ISaverConversation";
export default class ManagerConversation{
private currentTabConv:Conversation[]=[];
private loaderConversation: ILoaderConversation;
private saverConversation: ISaverConversation;
constructor(loaderConversation:ILoaderConversation, saverConversation:ISaverConversation){
this.loaderConversation=loaderConversation;
this.saverConversation=saverConversation;
}
getCurrentTabConv(){
return this.currentTabConv;
}
setCurrentTabConv(c:Conversation[]){
this.currentTabConv=c;
}
getLoaderConversation(){
return this.loaderConversation;
}
getsaverConversation(){
return this.saverConversation;
}
}

@ -0,0 +1,17 @@
import { Game } from "../../core/game";
export default interface ILoaderGame{
/**
* loadAllGame methode that load every Game from the data management system
* return an array of Game
*/
loadAllGame(): Promise<Game[]>;
/**
* loadByID methode that load a match from the data management system by its id
* id the id we want to search
* return a Game if found, if not null
*/
loadByID(id:string): Promise<Game | null>;
}

@ -0,0 +1,38 @@
import { Game } from "../../core/game";
import { GameSolo } from "../../core/gameSolo";
import ILoaderGame from "./ILoaderGame";
export default class LoaderGameApi implements ILoaderGame{
private axios = require('axios').default;
async loadAllGame(): Promise<Game[]> {
let tab: Game[]=[];
await this.axios({
method: 'get',
url: 'https://jsonplaceholder.typicode.com/todos/1',
params: {
name: "getAllUser",
//Les params genre nom de la fonction en php
}
})
.then(function (response: any) {
const map = new Map();
map.set(0,0);
map.set(100,50);
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);
const test= new GameSolo(1, "Test", "https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/Pendu.jpg", "/Games/CookieClicker/cookieClicker.tsx", 1, 1, map);
tab=[cookieClicker, test];
console.log(tab);
});
return tab;
}
async loadByID(id: string): Promise<Game | null> {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,30 @@
import { Game } from "../../core/game";
import ILoaderGame from "./ILoaderGame";
export default class ManagerGame{
private tabGame: Game[] | null=null;
private loaderGame: ILoaderGame;
constructor(loader:ILoaderGame){
this.loaderGame=loader;
}
getTabGame(){
return this.tabGame;
}
setTabGame(g:Game[] | null){
this.tabGame=g;
}
getLoaderGame(){
return this.loaderGame;
}
setLoaderGame(l:ILoaderGame){
this.loaderGame=l;
}
}

@ -0,0 +1,17 @@
import { Match } from "../../core/Match/match";
export default interface ILoaderMatch{
/**
* loadAllMatch methode that load every Match from the data management system
* return an array of Match
*/
loadAllMatch(): Promise<Match[]>;
/**
* loadByID methode that load a match from the data management system by its id
* id the id we want to search
* return a Match if found, if not null
*/
loadByID(id:string): Promise<Match | null>;
}

@ -0,0 +1,25 @@
import { Game } from "../../core/game";
import { Match } from "../../core/Match/match";
import { User } from "../../core/User/user";
export default interface ISaverMatch{
/**
* saveMatch methode that save a Match in the data management system
* m the Match we want to save
*/
saveMatch(u:User, g:Game): Promise<Match>;
/**
* deleteMatch methode that delete a Match in the data management system
* m the Match we want to delete
*/
deleteMatch(m:Match): Promise<void>;
/**
* updateMatch methode that update a Match in the data management system
* m the Match we want to update
*/
updateMatch(m:Match): Promise<void>;
}

@ -0,0 +1,13 @@
import { Match } from "../../core/Match/match";
import ILoaderMatch from "./ILoaderMatch";
export default class LoaderMatchApi implements ILoaderMatch{
async loadAllMatch(): Promise<Match[]> {
throw new Error("Method not implemented.");
}
async loadByID(id: string): Promise<Match | null> {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,41 @@
import { Match } from "../../core/Match/Match";
import ILoaderMatch from "./ILoaderMatch";
import ISaverMatch from "./ISaverMatch";
export default class ManagerMatch{
private currentMatch: Match | null=null;
private loaderMatch: ILoaderMatch;
private saverMatch: ISaverMatch;
constructor(loader:ILoaderMatch, saver:ISaverMatch){
this.loaderMatch=loader;
this.saverMatch=saver;
}
getCurrentMatch(){
return this.currentMatch;
}
setCurrentMatch(u:Match | null){
this.currentMatch=u;
}
getLoaderMatch(){
return this.loaderMatch;
}
setLoaderMatch(l:ILoaderMatch){
this.loaderMatch=l;
}
getsaverMatch(){
return this.saverMatch;
}
setsaverMatch(s:ISaverMatch){
this.saverMatch=s;
}
}

@ -0,0 +1,32 @@
import { Game } from "../../core/game";
import { Match } from "../../core/Match/match";
import { User } from "../../core/User/user";
import ISaverMatch from "./ISaverMatch";
import { GameSolo } from "../../core/gameSolo";
import { GameMulti } from "../../core/gameMulti";
import MatchSolo from "../../core/Match/matchSolo";
import MatchMulti from "../../core/Match/matchMulti";
import MatchCasino from "../../core/Match/matchCasino";
export default class SaverMatchApi implements ISaverMatch{
async saveMatch(u:User, g:Game): Promise<Match> {
//match = mettre dans bdd
if (g instanceof GameSolo){
return new MatchSolo(12, false, [u], g);
}
else if(g instanceof GameMulti){
return new MatchMulti(12, false, [u], g);
}
return new MatchCasino(12, false, [u], g);
}
async deleteMatch(m: Match): Promise<void> {
throw new Error("Method not implemented.");
}
async updateMatch(m: Match): Promise<void> {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,25 @@
import { Conversation } from "../../core/conversation";
import { Message } from "../../core/message";
export default interface ILoaderMessage{
/**
* loadAllMessage methode that load every Message from the data management system
* return an array of Message
*/
loadAllMessage(): Promise<Message[]>;
/**
* loadByID methode that load a Message from the data management system by its id
* id the id we want to search
* return a Message if found, if not null
*/
loadByID(id:string): Promise<Message | null>;
/**
* loadByUser methode that load an array of Message from the data management system using a Conversation
* c the Conversation we want the Messages of
* return an array of Message
*/
loadByConversation(c:Conversation): Promise<Message[]>;
}

@ -0,0 +1,12 @@
import { Message } from "../../core/message";
export default interface ISaverMessage{
/**
* saveMessage methode that save a Message in the data management system
* m the Message we want to save
*/
saveMessage(m:Message): Promise<void>;
}

@ -0,0 +1,62 @@
import LoaderUserApi from '../userServices/loaderUserApi';
import ILoaderUser from '../userServices/ILoaderUser';
import { Match } from '../../core/Match/match';
import MatchSolo from '../../core/Match/matchSolo';
import { GameSolo } from '../../core/gameSolo';
import tabUS from '../../constUser';
import { Conversation } from '../../core/conversation';
// Instances
const img = "";
let loader:ILoaderUser = new LoaderUserApi();
let map = new Map<number, number>([
[50, 3],
[75, 4],
[100, 5],
[150, 6]
]);
let game:GameSolo = new GameSolo(1, 'SuperJeu', img, 'source', 1, 1, map);
let match:Match = new MatchSolo(1, false, tabUS, game);
let convo:Conversation = new Conversation(1, tabUS, [], 'superConvo');
// Tests
describe('LoaderUserApi tests', () => {
describe('loadById tests', () => {
it('should return UserTest (id: 48)', () => {
expect(loader.loadByID(48)).toEqual(tabUS[0]);
})
it('should return null', () => {
expect(loader.loadByID(99999999999)).toBe(null);
})
})
describe('loadByUserName tests', () => {
it('should return USerTest (name: WeshWesh)', () => {
expect(loader.loadByUsername('WeshWesh')).toEqual(tabUS[0]);
})
it('should return null', () => {
expect(loader.loadByUsername('jExistePas')).toBe(null);
})
})
describe('loadByUserNamePassword tests', () => {
it('should return UserTest (name: WeshWesh, password: MdpDeOuf)', () => {
expect(loader.loadByUsernamePassword('WeshWesh', 'MdpDeOuf')).toEqual(tabUS[0]);
})
it('should return null', () => {
expect(loader.loadByUsernamePassword('jExistePas', 'jExistePas')).toBe(null);
})
})
describe('loadUserByMatch tests', () => {
it('should return tabUS', () => {
expect(loader.loadUserByMatch(match)).toEqual(tabUS);
})
it('should return null', () => {
expect(loader.loadByUsernamePassword('jExistePas', 'jExistePas')).toEqual(null);
})
})
describe('loadUserByConversation tests', () => {
it('should return tabUS', () => {
expect(loader.loadUserByConversation(convo)).toEqual(tabUS);
})
})
})

@ -0,0 +1,21 @@
/*
import LoaderUserApi from '../userServices/loaderUserApi';
import SaverUserApi from '../userServices/saverUserApi';
// Instances
let saver:SaverUserApi = new SaverUserApi();
let loader = new LoaderUserApi();
// Tests
describe('SaverUserApi tests', () => {
describe('saverUser tests', () => {
})
})
*/
it('should return true', () => {
expect(1+1).toBe(2);
})

@ -0,0 +1,78 @@
import StubUser from '../userServices/stub';
import { User } from '../../core/User/user';
import { Skin } from '../../core/skin';
import { GameSolo } from '../../core/gameSolo';
import MatchSolo from '../../core/Match/matchSolo';
import { Match } from '../../core/Match/match';
import { Conversation } from '../../core/conversation';
// Instances
const img = "";
let stub:StubUser = new StubUser();
let map = new Map<number, number>([
[50, 3],
[75, 4],
[100, 5],
[150, 6]
]);
let tabUS:User[] = [
new User(1, "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)]),
new User(2, "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)]),
new User(3, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)],),
new User(4, "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, new Skin(1, "Bob", img, 0), [new Skin(1, "Bob", img, 0)]),
];
let game:GameSolo = new GameSolo(1, 'SuperJeu', img, 'source', 1, 1, map);
let match:Match = new MatchSolo(1, false, tabUS, game);
let convo:Conversation = new Conversation(1, tabUS, [], 'superConvo');
// Tests
describe('StubUser tests', () => {
describe('loadAllUser tests', () => {
it('should return tabUS', () => {
expect(stub.loadAllUser()).toEqual(tabUS);
})
})
describe('loadById tests', () => {
it('should return UserTest (id: 48)', () => {
expect(stub.loadByID(48)).toEqual(tabUS[0]);
})
it('should return null', () => {
expect(stub.loadByID(999999999999)).toBe(null);
})
})
describe('loadByUserName tests', () => {
it('should return USerTest (name: WeshWesh)', () => {
expect(stub.loadByUsername('WeshWesh')).toEqual(tabUS[0]);
})
it('should return null', () => {
expect(stub.loadByUsername('jExistePas')).toBe(null);
})
})
describe('loadByUserNamePassword tests', () => {
it('should return UserTest (name: WeshWesh, password: MdpDeOuf)', () => {
expect(stub.loadByUsernamePassword('WeshWesh', 'MdpDeOuf')).toEqual(tabUS[0]);
})
it('should return null', () => {
expect(stub.loadByUsernamePassword('jExistePas', 'jExistePas')).toBe(null);
})
})
describe('loadUserByMatch tests', () => {
it('should return tabUS', () => {
expect(stub.loadUserByMatch(match)).toEqual(tabUS);
})
it('should return null', () => {
expect(stub.loadByUsernamePassword('jExistePas', 'jExistePas')).toEqual(null);
})
})
describe('loadUserByConversation tests', () => {
it('should return tabUS', () => {
expect(stub.loadUserByConversation(convo)).toEqual(tabUS);
})
})
describe('loadLastId', () => {
it('should return U0005', () => {
expect(stub.loadLastId()).toBe('U0005');
})
})
})

@ -0,0 +1,52 @@
import { Conversation } from "../../core/conversation";
import { Match } from "../../core/Match/match";
import { User } from "../../core/User/user";
export default interface ILoaderUser{
/**
* loadAllUser methode that load every user from the data management system
* return an array of User
*/
loadAllUser(): Promise<User[]>;
/**
* loadByID methode that load a user from the data management system by his id
* id the id we want to search
* return a User if found, if not null
*/
loadByID(id:number): Promise<User | null>;
/**
* loadByUsername methode that load a user from the data management system by his username
* username the username we want to search
* return a User if found, if not null
*/
loadByUsername(username:string): Promise<User | null>;
/**
* loadByUsernamePassword methode that load a user from the data management system by his username and his password
* username the username we want to search
* password the password we want to search
* return a User if found, if not null
*/
loadByUsernamePassword(username:string, password:string): Promise<User | null>;
/**
* loadUserByMatch methode that load every user in a game
* return an array of User
*/
loadUserByMatch(m:Match): Promise<User[]>;
/**
* laodUserByConversation methode that load every user in a Conversation
* return an array of User
*/
loadUserByConversation(c:Conversation): Promise<User[]>;
/**
* loadLastId methode that load the last id used to create a user
* return a String
*/
loadLastId(): Promise<number>;
}

@ -0,0 +1,23 @@
import { User } from "../../core/User/user";
export default interface ISaverUser{
/**
* saveUser methode that save a User in the data management system
* u the user we want to save
*/
saveUser(username:string, password:string, nationality:string, sexe:string, date:Date): Promise<User | null>;
/**
* deleteUser methode that delete a User in the data management system
* u the user we want to delete
*/
deleteUser(u:User | null):Promise<void>;
/**
* updateUser methode that update a User in the data management system
* u the user we want to update
*/
updateUser(u:User | null): Promise<void>;
}

@ -0,0 +1,41 @@
import { User } from "../../core/User/user";
import ILoaderUser from "./ILoaderUser";
import ISaverUser from "./ISaverUser";
export default class ManagerUser{
private currentUser: User | null=null;
private loaderUser: ILoaderUser;
private saverUser: ISaverUser;
constructor(loader:ILoaderUser, saver:ISaverUser){
this.loaderUser=loader;
this.saverUser=saver;
}
getCurrentUser(){
return this.currentUser;
}
setCurrentUser(u:User | null){
this.currentUser=u;
}
getLoaderUser(){
return this.loaderUser;
}
setLoaderUser(l:ILoaderUser){
this.loaderUser=l;
}
getsaverUser(){
return this.saverUser;
}
setsaverUser(s:ISaverUser){
this.saverUser=s;
}
}

@ -0,0 +1,16 @@
import { User } from "../../core/User/user";
import ISaverUser from "./ISaverUser";
export default class FakeSaverUser implements ISaverUser{
async saveUser(username:string, password:string, nationality:string, sexe:string, date:Date): Promise<User | null> {
return null;
}
async deleteUser(u: User): Promise<void> {
return;
}
async updateUser(u: User): Promise<void> {
return;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save