Merge branch 'typescript' of https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY into typescript
continuous-integration/drone/push Build is failing
Details
@ -0,0 +1,23 @@
|
|||||||
|
# database container deployment
|
||||||
|
kind: pipeline
|
||||||
|
name: BD
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: deploy-container-mysql
|
||||||
|
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||||
|
environment:
|
||||||
|
IMAGENAME: mysql
|
||||||
|
CONTAINERNAME: mysql
|
||||||
|
COMMAND: create
|
||||||
|
# OVERWRITE: false
|
||||||
|
PRIVATE: true
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD:
|
||||||
|
from_secret: P@s$w0rd123
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_MYSQL_DATABASE:
|
||||||
|
from_secret: BDBOB
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER:
|
||||||
|
from_secret: bob
|
||||||
|
CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD:
|
||||||
|
from_secret: P@s$w0rd123
|
||||||
|
scripts:
|
||||||
|
- GRANT ALL PRIVILEGES ON *.* TO 'CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER'@'localhost' IDENTIFIED BY 'CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD';
|
@ -0,0 +1,2 @@
|
|||||||
|
{
|
||||||
|
}
|
@ -1,6 +1,12 @@
|
|||||||
import React from 'react'
|
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'
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return <MainTabNavigator/>
|
return(
|
||||||
|
<Provider store={store}>
|
||||||
|
<MainTabNavigator/>
|
||||||
|
</Provider>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 1013 B After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 6.1 KiB |
@ -0,0 +1,17 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import App from './App'
|
||||||
|
import store from './src/redux/store'
|
||||||
|
import { Provider } from 'react-redux'
|
||||||
|
|
||||||
|
|
||||||
|
export default function Index(){
|
||||||
|
|
||||||
|
return(
|
||||||
|
<App/>
|
||||||
|
/*
|
||||||
|
<Provider store={store}>
|
||||||
|
<App />
|
||||||
|
</Provider>
|
||||||
|
*/
|
||||||
|
)
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
import { FC, ReactNode } from "react"
|
||||||
|
import { Pressable, Image, View} from "react-native"
|
||||||
|
import React from "react"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Importing the correct stylesheet
|
||||||
|
*/
|
||||||
|
import styles from './style/BotBar.style';
|
||||||
|
|
||||||
|
/*
|
||||||
|
Images that are required to create a bottom bar
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Icons when the corresponding screen is not displayed (white ones)
|
||||||
|
*/
|
||||||
|
const gamepad = require('../../assets/Icons/UnSelected/Gamepad.png');
|
||||||
|
const message = require('../../assets/Icons/UnSelected/Chat.png');
|
||||||
|
const store = require('../../assets/Icons/UnSelected/Store.png');
|
||||||
|
|
||||||
|
/*
|
||||||
|
Icons when the corresponding screen is displayed (blue ones)
|
||||||
|
*/
|
||||||
|
const sgamepad = require('../../assets/Icons/Selected/SGamepad.png');
|
||||||
|
const smessage = require('../../assets/Icons/Selected/SChat.png');
|
||||||
|
const sstore = require('../../assets/Icons/Selected/SStore.png');
|
||||||
|
|
||||||
|
|
||||||
|
export const BotBar :
|
||||||
|
/* Parameters :
|
||||||
|
* nav : tool needed to allow the navigation between the screens
|
||||||
|
* state : optional parameter that indicates from which screen the component has been called
|
||||||
|
(the string must be the name of the screen)
|
||||||
|
*/
|
||||||
|
FC<{nav: any, state?: String}> =
|
||||||
|
({nav, state}) =>
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
By default, all the images are the white ones
|
||||||
|
*/
|
||||||
|
var imgLeft=message, imgMid=gamepad, imgRight=store
|
||||||
|
|
||||||
|
/*
|
||||||
|
For each screen corresponding to a screen of the bottom bar,
|
||||||
|
we need to change one of the icons to the corresponding blue one
|
||||||
|
(for example, when the chat screen is displayed,
|
||||||
|
the icon of the messages must switch to the blue one)
|
||||||
|
*/
|
||||||
|
switch (state) {
|
||||||
|
case 'Home':
|
||||||
|
imgMid = sgamepad
|
||||||
|
break;
|
||||||
|
case 'Chat':
|
||||||
|
imgLeft = smessage
|
||||||
|
break;
|
||||||
|
case 'Store':
|
||||||
|
imgRight = sstore
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Once the icons are correctly attributed,
|
||||||
|
the function can display the component
|
||||||
|
*/
|
||||||
|
return (
|
||||||
|
<View style={styles.footer}>
|
||||||
|
<Pressable onPress={() => nav.navigate('ChatTab')}>
|
||||||
|
<Image
|
||||||
|
style={styles.icon}
|
||||||
|
source={imgLeft}
|
||||||
|
/>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable onPress={()=> {nav.navigate('HomeTab', {screen: 'Home'})}}>
|
||||||
|
<Image
|
||||||
|
style={styles.icon}
|
||||||
|
source={imgMid}
|
||||||
|
/>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable onPress={() => nav.navigate('StoreTab')}>
|
||||||
|
<Image
|
||||||
|
style={styles.icon}
|
||||||
|
source={imgRight}
|
||||||
|
/>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
import { FC } from "react"
|
||||||
|
import { Pressable, Text} from "react-native"
|
||||||
|
import React from "react"
|
||||||
|
/*
|
||||||
|
Importing the corresponding stylesheet
|
||||||
|
*/
|
||||||
|
import styles from "./style/ButtonGameTypeChoice.style"
|
||||||
|
|
||||||
|
export const ButtonGameTypeChoice:
|
||||||
|
/* Parameters:
|
||||||
|
* onPress : function that must be called when the button has been clicked
|
||||||
|
* title : optional text that would be in the button
|
||||||
|
*/
|
||||||
|
FC<{ onPress: any; title?: any | undefined; }>
|
||||||
|
=
|
||||||
|
({onPress,title}) =>
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<Pressable style={styles.button} onPress={onPress}>
|
||||||
|
<Text style={styles.text}>{title}</Text>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
import { FC} from "react"
|
||||||
|
import { Pressable, Text} from "react-native"
|
||||||
|
import React from "react"
|
||||||
|
import styles from "./style/ButtonGreySmall"
|
||||||
|
|
||||||
|
export const ButtonGreySmall:
|
||||||
|
FC<{ onPress: any, title: String, state?: String;}>
|
||||||
|
=
|
||||||
|
({onPress, title, state}) =>
|
||||||
|
{
|
||||||
|
switch (state) {
|
||||||
|
case 'Profile':
|
||||||
|
return(
|
||||||
|
<Pressable style={styles.buttonProfile} onPress={onPress}>
|
||||||
|
<Text style={styles.text}>{title}</Text>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return(
|
||||||
|
<Pressable style={styles.button} onPress={onPress}>
|
||||||
|
<Text style={styles.text}>{title}</Text>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
import { FC, ReactNode } from "react"
|
||||||
|
import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native"
|
||||||
|
import React from "react"
|
||||||
|
import { Skin } from "../core/skin"
|
||||||
|
import { Conversation } from "../core/conversation"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Importing the correct stylesheet
|
||||||
|
*/
|
||||||
|
import styles from "./style/ConverstationComponent.style"
|
||||||
|
import { SkinComponent } from "./Skin"
|
||||||
|
|
||||||
|
export const ConversationComponent :
|
||||||
|
/* Parameters :
|
||||||
|
* skin : Skin to be displayed
|
||||||
|
* state : Indicates from wich screen the component has been called
|
||||||
|
*/
|
||||||
|
FC<{conv: Conversation, state: String}> =
|
||||||
|
({conv, state}) =>
|
||||||
|
{
|
||||||
|
/* 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 shop (shop) : Image + Name + Price, Pressable => Buy the skin
|
||||||
|
* From the profile (profile) : Name + Image, Pressable => Change the skin
|
||||||
|
*/
|
||||||
|
switch (state) {
|
||||||
|
case 'Preview':
|
||||||
|
return(
|
||||||
|
<View style={{flexDirection: 'row', height: 70, borderBottomWidth: 2,borderBottomColor: '#2D2C33', paddingLeft: '5%',}}>
|
||||||
|
<View style={{alignSelf: 'center'}}>
|
||||||
|
<SkinComponent skin={conv.getTabUser()[1].getCurrentSkin()} state='icon'/>
|
||||||
|
</View>
|
||||||
|
<View style={{marginLeft: '5%', justifyContent: 'space-evenly'}}>
|
||||||
|
<Text style={styles.textNom}>{conv.getTabUser()[1].getUsername()}</Text>
|
||||||
|
<Text style={styles.textMess}>{conv.getLastMessage()}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
import { FC, ReactNode } from "react"
|
||||||
|
import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native"
|
||||||
|
import React from "react"
|
||||||
|
import { trace } from "console"
|
||||||
|
import { Game } from "../core/game"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Importing the correct stylesheet
|
||||||
|
*/
|
||||||
|
import styles from './style/Game.style';
|
||||||
|
|
||||||
|
export const GameComponent :
|
||||||
|
/*
|
||||||
|
* game : Game that must be displayed
|
||||||
|
* nav : tool needed to allow the navigation between the screens
|
||||||
|
*/
|
||||||
|
FC<{game: Game, nav: any}> =
|
||||||
|
({game, nav}) =>
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<Pressable onPress={() => Alert.alert("Lancement du jeu")}>
|
||||||
|
<Image
|
||||||
|
style={styles.image}
|
||||||
|
source={game.getImageSource()}
|
||||||
|
/>
|
||||||
|
<Text style={styles.name}>{game.getName()}</Text>
|
||||||
|
</Pressable>
|
||||||
|
</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}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
import { FC, ReactNode } from "react"
|
||||||
|
import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native"
|
||||||
|
import React from "react"
|
||||||
|
import styles from './style/ScreenIndicator.style'
|
||||||
|
|
||||||
|
export const ScreenIndicator: FC<{title: String}> = ({title}) =>
|
||||||
|
{
|
||||||
|
return(
|
||||||
|
<View style={styles.textTopView}>
|
||||||
|
<Text style={styles.textTop}>{title}</Text>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
import { FC, ReactNode } from "react"
|
||||||
|
import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native"
|
||||||
|
import React from "react"
|
||||||
|
import { Skin } from "../core/skin"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Importing the correct stylesheet
|
||||||
|
*/
|
||||||
|
import styles from "./style/Skin.style"
|
||||||
|
import { useDispatch, useSelector } from "react-redux"
|
||||||
|
import { loginUser } from "../redux/features/currentUserSlice"
|
||||||
|
import { RootState } from "../redux/store"
|
||||||
|
|
||||||
|
export const SkinComponent :
|
||||||
|
/* Parameters :
|
||||||
|
* skin : Skin to be displayed
|
||||||
|
* state : Indicates from wich screen the component has been called
|
||||||
|
*/
|
||||||
|
FC<{skin: Skin, state: String}> =
|
||||||
|
({skin, state}) =>
|
||||||
|
{
|
||||||
|
const dispatch=useDispatch();
|
||||||
|
|
||||||
|
const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
|
||||||
|
|
||||||
|
/* 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 shop (shop) : Image + Name + Price, Pressable => Buy the skin
|
||||||
|
* From the profile (profile) : Name + Image, Pressable => Change the skin
|
||||||
|
*/
|
||||||
|
switch (state) {
|
||||||
|
case 'icon':
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<Image source={skin.getSkinSource()} style={styles.icon}/>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
|
||||||
|
case 'shop':
|
||||||
|
return(
|
||||||
|
<Pressable onPress={() => Alert.alert("Achat du skin")} style={styles.imageWrapper}>
|
||||||
|
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
|
||||||
|
<Image
|
||||||
|
style={styles.imageSkin}
|
||||||
|
source={skin.getSkinSource()}
|
||||||
|
/>
|
||||||
|
<Text style={styles.nomSkin}>100€</Text>
|
||||||
|
</Pressable>
|
||||||
|
)
|
||||||
|
case 'liste':
|
||||||
|
return(
|
||||||
|
<Pressable onPress={() => {currentUser.setCurrentSkin(skin); dispatch(loginUser(currentUser))}} style={styles.imageWrapper}>
|
||||||
|
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
|
||||||
|
<Image
|
||||||
|
style={styles.imageSkin}
|
||||||
|
source={skin.getSkinSource()}
|
||||||
|
/>
|
||||||
|
</Pressable>
|
||||||
|
)
|
||||||
|
case 'profile':
|
||||||
|
return(
|
||||||
|
<Pressable onPress={() => Alert.alert("Achat du skin")} style={styles.imageWrapperProfil}>
|
||||||
|
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
|
||||||
|
<Image
|
||||||
|
style={styles.imageSkin}
|
||||||
|
source={skin.getSkinSource()}
|
||||||
|
/>
|
||||||
|
</Pressable>
|
||||||
|
)
|
||||||
|
default:
|
||||||
|
return(
|
||||||
|
<Image
|
||||||
|
style={styles.imageSkin}
|
||||||
|
source={skin.getSkinSource()}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
import { FC, ReactNode } from "react"
|
||||||
|
import { Pressable, Image, Text, View} from "react-native"
|
||||||
|
import { Skin } from "../core/Skin"
|
||||||
|
import React from "react"
|
||||||
|
import { SkinComponent } from "./Skin"
|
||||||
|
import { User } from "../core/User/user"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Import the correct stylesheet
|
||||||
|
*/
|
||||||
|
import styles from './style/TopBar.style';
|
||||||
|
import { useSelector } from "react-redux"
|
||||||
|
import { RootState } from "../redux/store"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Images required
|
||||||
|
*/
|
||||||
|
const engrenage = require('../../assets/Icons/UnSelected/Cogs.png');
|
||||||
|
const cross = require('../../assets/Icons/UnSelected/Cross.png');
|
||||||
|
const msc = require('../../assets/Icons/FondGris.png');
|
||||||
|
|
||||||
|
export const TopBar :
|
||||||
|
/* Parameters:
|
||||||
|
* skin : optional skin to display
|
||||||
|
* nav : tool needed to allow the navigation between the screens
|
||||||
|
* state : optional parameter that indicates from which screen the component has been called
|
||||||
|
(the string must be the name of the screen)
|
||||||
|
*/
|
||||||
|
FC<{nav: any, state?: string}> =
|
||||||
|
({nav, state}) =>
|
||||||
|
{
|
||||||
|
|
||||||
|
const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
|
||||||
|
|
||||||
|
/* 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 other : skin + Title + parameters icon
|
||||||
|
*/
|
||||||
|
switch (state) {
|
||||||
|
case 'settings':
|
||||||
|
return (
|
||||||
|
<View style={styles.header}>
|
||||||
|
<Pressable>
|
||||||
|
<Image source={msc} style={styles.icon}/>
|
||||||
|
</Pressable>
|
||||||
|
<Text style={styles.titre}>BOB PARTY</Text>
|
||||||
|
<Pressable onPress={() => nav.goBack()}>
|
||||||
|
<Image source={cross} style={styles.icon}/>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
default:
|
||||||
|
return (
|
||||||
|
<View style={styles.header}>
|
||||||
|
<Pressable onPress={() => nav.navigate('ProfileTab', {screen: 'Profile'})}>
|
||||||
|
<SkinComponent skin={currentUser.getCurrentSkin()} state='icon' />
|
||||||
|
</Pressable>
|
||||||
|
<Text style={styles.titre}>BOB PARTY</Text>
|
||||||
|
<Pressable onPress={() => nav.navigate('Settings')}>
|
||||||
|
<Image source={engrenage} style={styles.icon}/>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
import { FC, ReactNode } from "react"
|
|
||||||
import { Button, Image, ImageStyle, Text, View } from "react-native"
|
|
||||||
import { Skin } from "../core/Skin"
|
|
||||||
import React from "react"
|
|
||||||
|
|
||||||
export const SkinComponent : FC<{skin: Skin, children: ImageStyle, childrenTest: ReactNode}> = ({skin, children, childrenTest}) => {
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
<Image source={{uri: skin.Source}} style={children}/>
|
|
||||||
{childrenTest}
|
|
||||||
</View>
|
|
||||||
)
|
|
||||||
}
|
|
@ -0,0 +1,20 @@
|
|||||||
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
|
/*
|
||||||
|
Stylesheet for the BotBar component
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
footer: {
|
||||||
|
flex: 0.15,
|
||||||
|
flexDirection: 'row',
|
||||||
|
backgroundColor: '#2D2C33',
|
||||||
|
width: '100%',
|
||||||
|
justifyContent: 'space-evenly',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
width: 65,
|
||||||
|
height: 65,
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1,25 @@
|
|||||||
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
|
/*
|
||||||
|
Stylesheet for the ButtonGameTypeChoice component
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
button: {
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
height: '30%',
|
||||||
|
width: '70%',
|
||||||
|
margin: '5%',
|
||||||
|
borderRadius: 10,
|
||||||
|
elevation: 3,
|
||||||
|
backgroundColor: '#0085FF',
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 21,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1,29 @@
|
|||||||
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
button: {
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
padding: 3,
|
||||||
|
marginTop: 5,
|
||||||
|
borderRadius: 10,
|
||||||
|
backgroundColor: '#2D2C33',
|
||||||
|
paddingHorizontal: 10,
|
||||||
|
},
|
||||||
|
buttonProfile: {
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
padding: 3,
|
||||||
|
marginTop: 5,
|
||||||
|
borderRadius: 10,
|
||||||
|
backgroundColor: '#2D2C33',
|
||||||
|
marginHorizontal: 10,
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 21,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1,15 @@
|
|||||||
|
import { StyleSheet } from "react-native";
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
textNom: {
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
textMess: {
|
||||||
|
fontSize: 15,
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: '#D9D9D9',
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,24 @@
|
|||||||
|
import { StyleSheet } from "react-native";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Stylesheet for the GameComponent component
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default StyleSheet.create(
|
||||||
|
{
|
||||||
|
image : {
|
||||||
|
borderRadius: 15,
|
||||||
|
marginTop: 15,
|
||||||
|
marginRight: 15,
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
name :{
|
||||||
|
textAlign: 'center',
|
||||||
|
fontSize: 15,
|
||||||
|
fontFamily: 'Helvetica',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
})
|
@ -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',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
@ -0,0 +1,21 @@
|
|||||||
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
textTop: {
|
||||||
|
textAlign: "center",
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 21,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
textTopView: {
|
||||||
|
backgroundColor: '#0085FF',
|
||||||
|
width: '30%',
|
||||||
|
padding: 5,
|
||||||
|
paddingBottom: 10,
|
||||||
|
alignSelf: 'center',
|
||||||
|
borderBottomRightRadius: 50,
|
||||||
|
borderBottomLeftRadius: 50,
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,36 @@
|
|||||||
|
import { StyleSheet } from "react-native";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Stylesheet for the Skin component
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
icon: {
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
borderRadius: 50,
|
||||||
|
},
|
||||||
|
imageWrapper: {
|
||||||
|
height: 135,
|
||||||
|
width: '40%',
|
||||||
|
flexDirection: "column",
|
||||||
|
margin: 10,
|
||||||
|
},
|
||||||
|
imageWrapperProfil: {
|
||||||
|
height: 135,
|
||||||
|
flexDirection: "column",
|
||||||
|
margin: 10,
|
||||||
|
},
|
||||||
|
imageSkin : {
|
||||||
|
borderRadius: 15,
|
||||||
|
width: '100%',
|
||||||
|
flex:1
|
||||||
|
},
|
||||||
|
nomSkin :{
|
||||||
|
textAlign: 'center',
|
||||||
|
fontSize: 25,
|
||||||
|
fontFamily: 'Helvetica',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1,35 @@
|
|||||||
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
|
/*
|
||||||
|
Stylesheet for the TopBar component
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
header: {
|
||||||
|
flex: 0.15,
|
||||||
|
flexDirection: 'row',
|
||||||
|
backgroundColor: '#2D2C33',
|
||||||
|
width: '100%',
|
||||||
|
justifyContent: 'space-evenly',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
avatar: {
|
||||||
|
borderRadius: 50,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
},
|
||||||
|
titre: {
|
||||||
|
flex: 0.7,
|
||||||
|
flexDirection: 'column',
|
||||||
|
textAlign: 'center',
|
||||||
|
fontSize: 30,
|
||||||
|
fontFamily: 'Helvetica',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
const tabSex = [
|
||||||
|
{ label: "Homme", value: "Homme" },
|
||||||
|
{ label: "Femme", value: "Femme" },
|
||||||
|
{ label: "Non-binaire", value: "Non-binaire" },
|
||||||
|
{ label: "Autre", value: "Autre" },
|
||||||
|
]
|
||||||
|
|
||||||
|
export default tabSex;
|
@ -0,0 +1,26 @@
|
|||||||
|
import { loginUser } from '../../redux/features/currentUserSlice';
|
||||||
|
import { updateIncorrectCredentials } from '../../redux/features/credentialErrorsSlice';
|
||||||
|
import tabUS from "../../constUser";
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { RootState } from '../../redux/store';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const checkCredentials = (login: string, password: string, dispatch: any, nav: any) => {
|
||||||
|
if((tabUS.map((User) => User.getUsername()).indexOf(login)) !== -1){
|
||||||
|
let id = (tabUS.map((User) => User.getUsername()).indexOf(login))
|
||||||
|
if ((tabUS.map((User) => User.getUsername()).indexOf(login) === id) && ( tabUS[id].getPassword() === password) ){
|
||||||
|
dispatch(loginUser(tabUS[id]));
|
||||||
|
nav.navigate('HomeTab')
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dispatch(updateIncorrectCredentials(true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dispatch(updateIncorrectCredentials(true));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -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');
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,79 @@
|
|||||||
|
import { randomBytes } from "crypto";
|
||||||
|
import { ImageSourcePropType } from "react-native";
|
||||||
|
import internal from "stream";
|
||||||
|
|
||||||
|
export abstract class Game{
|
||||||
|
readonly id:string;
|
||||||
|
private name:string;
|
||||||
|
private imageSource:ImageSourcePropType;
|
||||||
|
private gameSource:string;
|
||||||
|
private nbPlayerMin: number;
|
||||||
|
private nbPlayerMax:number;
|
||||||
|
|
||||||
|
/* Constructor of the class */
|
||||||
|
constructor (id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){
|
||||||
|
this.id=id;
|
||||||
|
this.name=name;
|
||||||
|
this.imageSource=imageSource;
|
||||||
|
this.gameSource=gameSource;
|
||||||
|
this.nbPlayerMin=nbPlayerMin;
|
||||||
|
this.nbPlayerMax=nbPlayerMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the id of a game */
|
||||||
|
getId(){
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the name of a game */
|
||||||
|
getName(){
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the name of a game */
|
||||||
|
setName(name:string){
|
||||||
|
this.name=name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the image of a game */
|
||||||
|
getImageSource(){
|
||||||
|
return this.imageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the image of a game */
|
||||||
|
setImageSource(imageSource:ImageSourcePropType){
|
||||||
|
this.imageSource=imageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the source of a game */
|
||||||
|
getGameSource(){
|
||||||
|
return this.gameSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the source of a game */
|
||||||
|
setGameSource(gameSource:string){
|
||||||
|
this.gameSource=gameSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the number of player */
|
||||||
|
getNbPlayerMin(){
|
||||||
|
return this.nbPlayerMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the number of player*/
|
||||||
|
setNbPlayerMin(nbPlayerMin:number){
|
||||||
|
this.nbPlayerMin=nbPlayerMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the number of player */
|
||||||
|
getNbPlayerMax(){
|
||||||
|
return this.nbPlayerMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the number of player*/
|
||||||
|
setNbPlayerMax(nbPlayerMax:number){
|
||||||
|
this.nbPlayerMax=nbPlayerMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract coinsCalculator(points: number): number;
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
import { User } from "./user";
|
||||||
|
|
||||||
|
export class ManagerCoinsUser{
|
||||||
|
addCoins(u:User, coins:number){
|
||||||
|
u.setCurrentCoins(u.getCurrentCoins()+coins);
|
||||||
|
u.setTotalCoins(u.getTotalCoins()+coins);
|
||||||
|
//modif dans la bdd
|
||||||
|
}
|
||||||
|
|
||||||
|
removeCoins(u:User, coins:number){
|
||||||
|
u.setCurrentCoins(u.getCurrentCoins()-coins);
|
||||||
|
//modif dans la bdd
|
||||||
|
}
|
||||||
|
|
||||||
|
changeCurrentCoins(u:User, coins:number){
|
||||||
|
u.setCurrentCoins(coins);
|
||||||
|
//modif dans la bdd
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,156 @@
|
|||||||
|
import { Skin } from '../Skin'
|
||||||
|
import { Conversation } from '../conversation';
|
||||||
|
import { sign } from 'crypto';
|
||||||
|
import { TextBase } from 'react-native';
|
||||||
|
|
||||||
|
export class User{
|
||||||
|
readonly id: string;
|
||||||
|
private username: string;
|
||||||
|
private password: string;
|
||||||
|
private nationality: string;
|
||||||
|
private sexe: string;
|
||||||
|
private dateOfBirth: Date;
|
||||||
|
private currentCoins: number;
|
||||||
|
private totalCoins: number;
|
||||||
|
private nbGamesPlayed: number;
|
||||||
|
private currentSkin: Skin;
|
||||||
|
private tabSkin: Skin[];
|
||||||
|
|
||||||
|
/* Consturctor of the class */
|
||||||
|
constructor(id: string, username: string, password:string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number,
|
||||||
|
nbGamesPlayed:number, currentSkin: Skin, tabSkin: Skin[]){
|
||||||
|
this.id=id;
|
||||||
|
this.username=username;
|
||||||
|
this.password=password;
|
||||||
|
this.nationality=nationality;
|
||||||
|
this.sexe=sexe;
|
||||||
|
this.dateOfBirth=dateOfBirth;
|
||||||
|
this.nbGamesPlayed=nbGamesPlayed;
|
||||||
|
this.currentCoins=currentCoins;
|
||||||
|
this.totalCoins=totalCoins;
|
||||||
|
this.currentSkin=currentSkin;
|
||||||
|
this.tabSkin=tabSkin.copyWithin(tabSkin.length, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Brief : Function getting the name of a user */
|
||||||
|
getUsername(){
|
||||||
|
return this.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the name of a user */
|
||||||
|
setUsername(username: string){
|
||||||
|
this.username=username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the id of a user */
|
||||||
|
getId(){
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the password of a user */
|
||||||
|
getPassword(){
|
||||||
|
return this.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the password of a user */
|
||||||
|
setPassword(password:string){
|
||||||
|
this.password=password;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the current number of coins of a user */
|
||||||
|
getCurrentCoins(){
|
||||||
|
return this.currentCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the current number of coins of a user */
|
||||||
|
setCurrentCoins(currentCoins: number){
|
||||||
|
this.currentCoins=currentCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the sex of a user */
|
||||||
|
getSexe(){
|
||||||
|
return this.sexe;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the sex of a user */
|
||||||
|
setSexe(sexe: string){
|
||||||
|
this.sexe=sexe;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the date of birth of a user */
|
||||||
|
getDateOfBirth(){
|
||||||
|
return this.dateOfBirth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the date of birth of a user */
|
||||||
|
setDateOfBirth(dateOfBirth: Date){
|
||||||
|
this.dateOfBirth=dateOfBirth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the nationality of a user */
|
||||||
|
getNationality(){
|
||||||
|
return this.nationality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the nationality of a user */
|
||||||
|
setNationality(nationality: string){
|
||||||
|
this.nationality=nationality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the total number of coins of a user */
|
||||||
|
getTotalCoins(){
|
||||||
|
return this.totalCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the total number of coins of a user */
|
||||||
|
setTotalCoins(totalCoins: number){
|
||||||
|
this.totalCoins=totalCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the current number of games played by a user */
|
||||||
|
|
||||||
|
getGamesPlayed(){
|
||||||
|
return this.nbGamesPlayed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the current number of games played by a user */
|
||||||
|
|
||||||
|
setGamesPlayed(nb: number){
|
||||||
|
this.nbGamesPlayed=nb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the current skin of a user */
|
||||||
|
|
||||||
|
getCurrentSkin(){
|
||||||
|
return this.currentSkin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the current skin of a user */
|
||||||
|
setCurrentSkin(newSkin: Skin){
|
||||||
|
this.currentSkin=newSkin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the skins of a user */
|
||||||
|
getTabSkin(){
|
||||||
|
return this.tabSkin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the skins of a user */
|
||||||
|
setTabSkin(tabSkin: Skin[]){
|
||||||
|
this.tabSkin=[...tabSkin];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function adding a skin to a user */
|
||||||
|
addSkin(skin:Skin){
|
||||||
|
this.tabSkin.push(skin);
|
||||||
|
}
|
||||||
|
|
||||||
|
isEqual(u:User){
|
||||||
|
if (u.getId()==this.id){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
import { User } from "./user";
|
||||||
|
import tabSkinApp from "../../constSkin";
|
||||||
|
import { Conversation } from "../conversation";
|
||||||
|
|
||||||
|
export class UserCreator{
|
||||||
|
createUser(username:string, password:string, nationality:string, sexe:string, date:Date){
|
||||||
|
//Récup l'ID d'après dans la bdd
|
||||||
|
const u = new User('0000', username, password, nationality, sexe, date, 0, 0, 0, tabSkinApp[0], [tabSkinApp[0]]);
|
||||||
|
//Ajout du joueur dans la bdd
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
import { User } from "./user";
|
||||||
|
|
||||||
|
|
||||||
|
export default class UserModificationManager{
|
||||||
|
changePassword(user:User, password:string){
|
||||||
|
user.setPassword(password);
|
||||||
|
//modif dans la bdd
|
||||||
|
}
|
||||||
|
|
||||||
|
changeUsername(user:User, username:string){
|
||||||
|
user.setPassword(username);
|
||||||
|
//modif dans la bdd
|
||||||
|
}
|
||||||
|
|
||||||
|
changeNationality(user:User, nationality:string){
|
||||||
|
user.setNationality(nationality);
|
||||||
|
//modif dans la bdd
|
||||||
|
}
|
||||||
|
|
||||||
|
changeSexe(user:User, sexe:string){
|
||||||
|
user.setSexe(sexe);
|
||||||
|
//modif dans la bdd
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
import { Skin } from '../Skin'
|
||||||
|
import { User } from './user'
|
||||||
|
|
||||||
|
|
||||||
|
export default class UserSkinModifier{
|
||||||
|
addSkin(user:User, skin:Skin){
|
||||||
|
user.addSkin(skin);
|
||||||
|
}
|
||||||
|
|
||||||
|
changeCurrentSkin(user:User, skin:Skin){
|
||||||
|
user.setCurrentSkin(skin);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
import { Message } from "./message"
|
||||||
|
import { User } from "./User/user";
|
||||||
|
|
||||||
|
|
||||||
|
export class Conversation{
|
||||||
|
private Id: string;
|
||||||
|
private tabUser: User[];
|
||||||
|
private tabMessage: Message[];
|
||||||
|
private name: string;
|
||||||
|
|
||||||
|
/* Constructor of the class */
|
||||||
|
constructor(id: string, tabUser: User[], tabMessage:Message[], name:string){
|
||||||
|
this.Id=id;
|
||||||
|
this.tabUser=[...tabUser];
|
||||||
|
this.tabMessage=[...tabMessage];
|
||||||
|
this.name=name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : function returning the messages of a conversation */
|
||||||
|
getTabMessage(){
|
||||||
|
this.sortMessageDesc();
|
||||||
|
return this.tabMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : function returning the users of a conversation */
|
||||||
|
getTabUser(){
|
||||||
|
return this.tabUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : function adding an user to a conversation */
|
||||||
|
ajouterUser(us:User){
|
||||||
|
this.tabUser?.push(us);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : function adding a message to a conversation */
|
||||||
|
ajouterMessage(mess:Message){
|
||||||
|
this.tabMessage?.push(mess);
|
||||||
|
this.sortMessageDesc();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : function returning the id of a conversation */
|
||||||
|
getId(){
|
||||||
|
return this.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : function returning the name to a conversation */
|
||||||
|
getName(){
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : function setting the name to a conversation */
|
||||||
|
setName(name:string){
|
||||||
|
this.name=name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : function returning the last message of a conversation */
|
||||||
|
getLastMessage(){
|
||||||
|
this.sortMessageDesc();
|
||||||
|
return this.tabMessage[0].getMessageContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : function sorting the messages of a conversation to be in the discussion order */
|
||||||
|
sortMessageDesc(){
|
||||||
|
this.tabMessage.sort(
|
||||||
|
(objA, objB) => objB.getMessageDate().getTime() - objA.getMessageDate().getTime(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
import { ImageSourcePropType } from 'react-native';
|
||||||
|
import { Game } from './game'
|
||||||
|
|
||||||
|
export class GameCasino extends Game{
|
||||||
|
|
||||||
|
constructor(id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){
|
||||||
|
super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
coinsCalculator(points: number): number {
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
import { ImageSourcePropType } from 'react-native';
|
||||||
|
import { Game } from './game'
|
||||||
|
|
||||||
|
export class GameMulti extends Game{
|
||||||
|
readonly rankToCoins:Map<number,number>
|
||||||
|
|
||||||
|
constructor(id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map<number,number>){
|
||||||
|
super(id, name, imageSource, gameSource, nbPlayerMin, nbPlayerMax);
|
||||||
|
this.rankToCoins=rankToCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the map of the game with the rank as the key and the coins as the values
|
||||||
|
getMultiMap(){
|
||||||
|
return this.rankToCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns the coins gained depending on the rank
|
||||||
|
coinsCalculator(points:number): number{
|
||||||
|
let coins=0;
|
||||||
|
let test;
|
||||||
|
for (let key of this.rankToCoins.keys()){
|
||||||
|
test = this.rankToCoins.get(key);
|
||||||
|
if (test != undefined){
|
||||||
|
coins=test;
|
||||||
|
}
|
||||||
|
if (points==key ){
|
||||||
|
return coins;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return coins;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
import { ImageSourcePropType } from 'react-native';
|
||||||
|
import { Game } from './game'
|
||||||
|
|
||||||
|
export class GameSolo extends Game{
|
||||||
|
readonly ptsToCoins:Map<number,number>
|
||||||
|
|
||||||
|
constructor(id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map<number,number>){
|
||||||
|
super(id, name, imageSource, gameSource, nbPlayerMin,nbPlayerMax);
|
||||||
|
this.ptsToCoins=ptsToCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the map of the game with points millestone as the keys and coins as the values
|
||||||
|
getSoloMap(){
|
||||||
|
return this.ptsToCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns the gain depending on the number of points
|
||||||
|
coinsCalculator(points:number): number{
|
||||||
|
let coins=0;
|
||||||
|
let test;
|
||||||
|
for (let key of this.ptsToCoins.keys()){
|
||||||
|
test = this.ptsToCoins.get(key);
|
||||||
|
if (test != undefined){
|
||||||
|
coins=test;
|
||||||
|
}
|
||||||
|
if (points<key ){
|
||||||
|
return coins;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return coins;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
import { ImageSourcePropType } from 'react-native';
|
||||||
|
import { Game } from './game';
|
||||||
|
import { User } from "./User/user";
|
||||||
|
|
||||||
|
|
||||||
|
export abstract class Match{
|
||||||
|
readonly code:string;
|
||||||
|
private inGame:Boolean;
|
||||||
|
private tabUsers:User[];
|
||||||
|
private theGame:Game;
|
||||||
|
|
||||||
|
constructor(code:string, inGame:Boolean, tabUser:User[], game:Game){
|
||||||
|
this.code=code;
|
||||||
|
this.inGame=false;
|
||||||
|
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/managerCoinsUser";
|
||||||
|
|
||||||
|
export class MatchMulti extends Match{
|
||||||
|
|
||||||
|
constructor(code:string, 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,17 @@
|
|||||||
|
import { Match } from "./match";
|
||||||
|
import { User } from "./User/user";
|
||||||
|
import { Game } from "./game";
|
||||||
|
import { GameMulti } from "./gameMulti";
|
||||||
|
import { ManagerCoinsUser } from "./User/managerCoinsUser";
|
||||||
|
|
||||||
|
export class MatchMulti extends Match{
|
||||||
|
|
||||||
|
constructor(code:string, 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/managerCoinsUser";
|
||||||
|
|
||||||
|
export class MatchSolo extends Match{
|
||||||
|
|
||||||
|
constructor(code:string, 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));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
import { User } from './User/user'
|
||||||
|
|
||||||
|
|
||||||
|
export class Message{
|
||||||
|
private Id: string;
|
||||||
|
private Content: string;
|
||||||
|
private Sender: User;
|
||||||
|
private DateEnvoie: Date;
|
||||||
|
|
||||||
|
/* Constructor of the class */
|
||||||
|
constructor(id: string, content: string, sender:User, dateEnvoie:Date){
|
||||||
|
this.Id=id;
|
||||||
|
this.Content=content;
|
||||||
|
this.Sender=sender;
|
||||||
|
this.DateEnvoie=dateEnvoie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the content of a message */
|
||||||
|
setMessageContent(content: string){
|
||||||
|
this.Content=content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the sender of a message */
|
||||||
|
setMessageSender(sender: User){
|
||||||
|
this.Sender=sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function setting the date of a message */
|
||||||
|
setMessageDate(dateEnvoie: Date){
|
||||||
|
this.DateEnvoie=dateEnvoie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the id of a message */
|
||||||
|
getMessageId(){
|
||||||
|
return this.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the content of a message */
|
||||||
|
getMessageContent(){
|
||||||
|
return this.Content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the sender of a message */
|
||||||
|
getMessageSender(){
|
||||||
|
return this.Sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Function getting the date of a message */
|
||||||
|
getMessageDate(){
|
||||||
|
return this.DateEnvoie;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,25 +1,51 @@
|
|||||||
|
import { ImageSourcePropType } from "react-native";
|
||||||
|
|
||||||
export class Skin{
|
export class Skin{
|
||||||
private Name: string;
|
readonly id: string;
|
||||||
Source: string;
|
private name: string;
|
||||||
|
private source: ImageSourcePropType;
|
||||||
|
private cost:number;
|
||||||
|
|
||||||
constructor(name: string, source:string){
|
/* Constructor of the class */
|
||||||
this.Name=name;
|
constructor(id:string, name: string, source:ImageSourcePropType, Cost:number){
|
||||||
this.Source=source;
|
this.id=id;
|
||||||
|
this.name=name;
|
||||||
|
this.source=source;
|
||||||
|
this.cost=Cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Brief : Fuction setting the name of a skin */
|
||||||
setSkinName(name: string){
|
setSkinName(name: string){
|
||||||
this.Name=name;
|
this.name=name;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSkinSource(source: string){
|
/* Brief : Fuction setting the source of the image of a skin */
|
||||||
this.Source=source;
|
setSkinSource(source: ImageSourcePropType){
|
||||||
|
this.source=source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Brief : Fuction getting the source of the image of a skin */
|
||||||
getSkinSource(){
|
getSkinSource(){
|
||||||
return this.Source;
|
return this.source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Brief : Fuction getting the name of a skin */
|
||||||
getSkinName(){
|
getSkinName(){
|
||||||
return this.Name;
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Fuction getting the id of a skin */
|
||||||
|
getSkinId(){
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Fuction getting the cost of a skin */
|
||||||
|
getSkinCost(){
|
||||||
|
return this.cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Brief : Fuction getting the cost of a skin */
|
||||||
|
setSkinCost(cost:number){
|
||||||
|
this.cost=cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
import exp from 'constants';
|
||||||
|
import { Conversation } from '../Conversation';
|
||||||
|
import { Message } from '../Message';
|
||||||
|
import { Skin } from '../Skin';
|
||||||
|
import { User } from '../User/user';
|
||||||
|
|
||||||
|
|
||||||
|
// Instances
|
||||||
|
let conv:Conversation[] = [];
|
||||||
|
let tab:Skin[] = [];
|
||||||
|
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
|
||||||
|
let dateBirth = new Date(2010,0o3,0o7);
|
||||||
|
let usr = new User('00001', '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);
|
||||||
|
let theDate = new Date(2022,10,14);
|
||||||
|
let theDate2 = new Date(2022,10,13);
|
||||||
|
let theDate3 = new Date(2022,10,15);
|
||||||
|
let mess = new Message('M0001', 'Bob Party est le meilleur projet', usr, theDate2);
|
||||||
|
let tabU:User[] = [usr, usr2];
|
||||||
|
let mess2 = new Message('M0002', 'Oui tout à fait', usr2, theDate);
|
||||||
|
let mess3 = new Message('M0003', 'Mais oui trop de ouf', usr, theDate3);
|
||||||
|
let tabM:Message[] = [mess, mess2];
|
||||||
|
let convo = new Conversation('C0001', tabU, tabM, 'the conv');
|
||||||
|
let usr3 = new User('00003', 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
|
||||||
|
|
||||||
|
|
||||||
|
// Get tests
|
||||||
|
describe('Conversation get tests', () => {
|
||||||
|
it('should return C0001', () => {
|
||||||
|
expect(convo.getId()).toBe('C0001');
|
||||||
|
})
|
||||||
|
it('should return the conv', () => {
|
||||||
|
expect(convo.getName()).toBe('the conv');
|
||||||
|
})
|
||||||
|
it('should return tabU [usr, usr2] (users)', () => {
|
||||||
|
expect(convo.getTabUser()).toBe(tabU);
|
||||||
|
})
|
||||||
|
it('should return tabM [mess, mess2] (messages)', () => {
|
||||||
|
expect(convo.getTabMessage()).toBe(tabM);
|
||||||
|
})
|
||||||
|
it('should return Oui tout à fait (mess2)', () => {
|
||||||
|
expect(convo.getLastMessage()).toBe('Oui tout à fait');
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// Setting new value
|
||||||
|
convo.setName('THE conv');
|
||||||
|
convo.ajouterUser(usr3);
|
||||||
|
convo.ajouterMessage(mess3);
|
||||||
|
|
||||||
|
|
||||||
|
// Set test
|
||||||
|
describe('Conversation set test', () => {
|
||||||
|
it('should return THE conv', () => {
|
||||||
|
expect(convo.setName).toBe('THE conv');
|
||||||
|
})
|
||||||
|
it('should return tabU [usr, usr2, usr3] (users)', () => {
|
||||||
|
expect(convo.getTabUser()).toBe(tabU);
|
||||||
|
})
|
||||||
|
it('should return tabM [mess, mess2, mess3] (messages)', () => {
|
||||||
|
expect(convo.getTabMessage()).toBe(tabM);
|
||||||
|
})
|
||||||
|
it('should return Mais oui trop de ouf (mess3)', () => {
|
||||||
|
expect(convo.getLastMessage()).toBe('Mais oui trop de ouf');
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,64 @@
|
|||||||
|
import { Game } from '../game';
|
||||||
|
import { GameSolo } from '../GameSolo';
|
||||||
|
|
||||||
|
|
||||||
|
// Instances
|
||||||
|
|
||||||
|
let myMap = new Map<number, number>([
|
||||||
|
[50, 3],
|
||||||
|
[75, 4],
|
||||||
|
[100, 5],
|
||||||
|
[150, 6]
|
||||||
|
]);
|
||||||
|
let game:Game = new GameSolo("id", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
|
||||||
|
|
||||||
|
|
||||||
|
// Get tests
|
||||||
|
describe('GameSolo get tests', () => {
|
||||||
|
it('should return id', () => {
|
||||||
|
expect(game.getId()).toBe('id');
|
||||||
|
})
|
||||||
|
it('should return bo jeu', () => {
|
||||||
|
expect(game.getName()).toBe('bo jeu');
|
||||||
|
})
|
||||||
|
it('should return require(blackjack.jpg)', () => {
|
||||||
|
expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg'));
|
||||||
|
})
|
||||||
|
it('should return super jeu', () => {
|
||||||
|
expect(game.getGameSource()).toBe('super jeu');
|
||||||
|
})
|
||||||
|
it('should return 1', () => {
|
||||||
|
expect(game.getNbPlayerMin()).toBe(1);
|
||||||
|
})
|
||||||
|
it('should return 1', () => {
|
||||||
|
expect(game.getNbPlayerMax()).toBe(1);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// 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
|
||||||
|
describe('GameSolo set tests', () => {
|
||||||
|
it('should return beau jeu', () => {
|
||||||
|
expect(game.getName()).toBe('beau jeu');
|
||||||
|
})
|
||||||
|
it('should return require(JeuDeDame.jpg)', () => {
|
||||||
|
expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
|
||||||
|
})
|
||||||
|
it('should return trop cool le jeu', () => {
|
||||||
|
expect(game.getGameSource()).toBe('trop cool le jeu');
|
||||||
|
})
|
||||||
|
it('should return 2', () => {
|
||||||
|
expect(game.getNbPlayerMin()).toBe(2);
|
||||||
|
})
|
||||||
|
it('should return 3', () => {
|
||||||
|
expect(game.getNbPlayerMax()).toBe(3);
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,62 @@
|
|||||||
|
import { GameCasino } from '../GameCasino';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Instances
|
||||||
|
let game = new GameCasino("GC001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5);
|
||||||
|
|
||||||
|
|
||||||
|
// Get tests
|
||||||
|
describe('GameMuti get tests', () => {
|
||||||
|
it('should return bo jeu', () => {
|
||||||
|
expect(game.getName()).toBe('bo jeu');
|
||||||
|
})
|
||||||
|
it('should return require(blackjack.jpg)', () => {
|
||||||
|
expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg'));
|
||||||
|
})
|
||||||
|
it('should return super jeu', () => {
|
||||||
|
expect(game.getGameSource()).toBe('super jeu');
|
||||||
|
})
|
||||||
|
it('should return 1', () => {
|
||||||
|
expect(game.getNbPlayerMin()).toBe(1);
|
||||||
|
})
|
||||||
|
it('should return 5', () => {
|
||||||
|
expect(game.getNbPlayerMax()).toBe(5);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// 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
|
||||||
|
describe('GameCasino set tests', () => {
|
||||||
|
it('should return beau jeu', () => {
|
||||||
|
expect(game.getName()).toBe('beau jeu');
|
||||||
|
})
|
||||||
|
it('should return require(JeuDeDame.jpg)', () => {
|
||||||
|
expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
|
||||||
|
})
|
||||||
|
it('should return trop cool le jeu', () => {
|
||||||
|
expect(game.getGameSource()).toBe('trop cool le jeu');
|
||||||
|
})
|
||||||
|
it('should return trop cool le jeu', () => {
|
||||||
|
expect(game.getNbPlayerMin()).toBe(2);
|
||||||
|
})
|
||||||
|
it('should return 4', () => {
|
||||||
|
expect(game.getNbPlayerMin()).toBe(4);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// Coins Calculator Tests
|
||||||
|
describe('Coins calculator tests', () => {
|
||||||
|
it('should return 200', () => {
|
||||||
|
expect(game.coinsCalculator(200)).toBe(200);
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,85 @@
|
|||||||
|
import { Game } from '../game';
|
||||||
|
import { GameSolo } from '../GameSolo';
|
||||||
|
import { GameMulti } from '../GameMulti';
|
||||||
|
import { GameCasino } from '../GameCasino';
|
||||||
|
|
||||||
|
|
||||||
|
// Instances
|
||||||
|
let myMap = new Map<number, number>([
|
||||||
|
[4, 1],
|
||||||
|
[3, 3],
|
||||||
|
[2, 5],
|
||||||
|
[1, 10]
|
||||||
|
]);
|
||||||
|
let game = new GameMulti("GM001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5, myMap);
|
||||||
|
|
||||||
|
|
||||||
|
// Get tests
|
||||||
|
describe('GameMuti get tests', () => {
|
||||||
|
it('should return GM001', () => {
|
||||||
|
expect(game.getId()).toBe('GM001');
|
||||||
|
})
|
||||||
|
it('should return bo jeu', () => {
|
||||||
|
expect(game.getName()).toBe('bo jeu');
|
||||||
|
})
|
||||||
|
it('should return require(blackjack.jpg)', () => {
|
||||||
|
expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg'));
|
||||||
|
})
|
||||||
|
it('should return super jeu', () => {
|
||||||
|
expect(game.getGameSource()).toBe('super jeu');
|
||||||
|
})
|
||||||
|
it('should return 1', () => {
|
||||||
|
expect(game.getNbPlayerMin()).toBe(1);
|
||||||
|
})
|
||||||
|
it('should return 5', () => {
|
||||||
|
expect(game.getNbPlayerMax()).toBe(5);
|
||||||
|
})
|
||||||
|
it('should return myMap', () => {
|
||||||
|
expect(game.getMultiMap()).toBe(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
|
||||||
|
describe('GameMulti set tests', () => {
|
||||||
|
it('should return beau jeu', () => {
|
||||||
|
expect(game.getName()).toBe('beau jeu');
|
||||||
|
})
|
||||||
|
it('should return require(JeuDeDame.jpg)', () => {
|
||||||
|
expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
|
||||||
|
})
|
||||||
|
it('should return trop cool le jeu', () => {
|
||||||
|
expect(game.getGameSource()).toBe('trop cool le jeu');
|
||||||
|
})
|
||||||
|
it('should return trop cool le jeu', () => {
|
||||||
|
expect(game.getNbPlayerMin()).toBe(2);
|
||||||
|
})
|
||||||
|
it('should return 4', () => {
|
||||||
|
expect(game.getNbPlayerMin()).toBe(4);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// Coins Calculator tests
|
||||||
|
describe('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);
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,82 @@
|
|||||||
|
import exp from 'constants';
|
||||||
|
import { GameSolo } from '../GameSolo';
|
||||||
|
|
||||||
|
// Instances
|
||||||
|
let myMap = new Map<number, number>([
|
||||||
|
[50, 3],
|
||||||
|
[75, 4],
|
||||||
|
[100, 5],
|
||||||
|
[150, 6]
|
||||||
|
]);
|
||||||
|
let game=new GameSolo("G0001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
|
||||||
|
|
||||||
|
|
||||||
|
// Get tests
|
||||||
|
describe('GameSolo get tests', () => {
|
||||||
|
it('should return G0001', () => {
|
||||||
|
expect(game.getId()).toBe('G0001');
|
||||||
|
})
|
||||||
|
it('should return bo jeu', () => {
|
||||||
|
expect(game.getName()).toBe('bo jeu');
|
||||||
|
})
|
||||||
|
it('should return require(blackjack.jpg)', () => {
|
||||||
|
expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg'));
|
||||||
|
})
|
||||||
|
it('should return super jeu', () => {
|
||||||
|
expect(game.getGameSource()).toBe('super jeu');
|
||||||
|
})
|
||||||
|
it('should return 1', () => {
|
||||||
|
expect(game.getNbPlayerMin()).toBe(1);
|
||||||
|
})
|
||||||
|
it('should return 1', () => {
|
||||||
|
expect(game.getNbPlayerMax()).toBe(1);
|
||||||
|
})
|
||||||
|
it('should return myMap', () => {
|
||||||
|
expect(game.getSoloMap()).toBe(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
|
||||||
|
describe('GameSolo set tests', () => {
|
||||||
|
it('should return beau jeu', () => {
|
||||||
|
expect(game.getName()).toBe('beau jeu');
|
||||||
|
})
|
||||||
|
it('should return require(JeuDeDame.jpg)', () => {
|
||||||
|
expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
|
||||||
|
})
|
||||||
|
it('should return trop cool le jeu', () => {
|
||||||
|
expect(game.getGameSource()).toBe('trop cool le jeu');
|
||||||
|
})
|
||||||
|
it('should return 2', () => {
|
||||||
|
expect(game.getNbPlayerMin()).toBe(2);
|
||||||
|
})
|
||||||
|
it('should return 3', () => {
|
||||||
|
expect(game.getNbPlayerMax()).toBe(3);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// Coins Calculator tests
|
||||||
|
describe('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);
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,84 @@
|
|||||||
|
import { MatchSolo } from '../MatchSolo';
|
||||||
|
import { Conversation } from '../Conversation';
|
||||||
|
import { Skin } from '../Skin';
|
||||||
|
import { User } from '../User/user';
|
||||||
|
import { GameSolo } from '../GameSolo';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Instances
|
||||||
|
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
|
||||||
|
let blue = new Skin("S0002", "Bob Blue", require('bob_party/assets/BobsSkins/BobBlue.png'), 100);
|
||||||
|
let tab:Skin[] = [classique, blue];
|
||||||
|
let dateBirth = new Date(2010,0o3,0o7);
|
||||||
|
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
|
||||||
|
let usr2 = new User('00002', 'Rémi', 'pwd', 'Martinique', 'M', dateBirth, 0, 0, 0, classique, tab);
|
||||||
|
let tabU:User[] = [usr];
|
||||||
|
let myMap = new Map<number, number>([
|
||||||
|
[50, 3],
|
||||||
|
[75, 4],
|
||||||
|
[100, 5],
|
||||||
|
[150, 6]
|
||||||
|
]);
|
||||||
|
let game=new GameSolo("G0001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
|
||||||
|
let match = new MatchSolo("machin", false, tabU, game);
|
||||||
|
let tabU2:User[] = [];
|
||||||
|
let game2 = new GameSolo("G0002", "jeu magnifique", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "wow jeu", 1, 1, myMap)
|
||||||
|
|
||||||
|
|
||||||
|
// Get tests
|
||||||
|
describe('Match get tests', () => {
|
||||||
|
it('should return machin', () => {
|
||||||
|
expect(match.getCode()).toBe('machin');
|
||||||
|
})
|
||||||
|
it('should return false', () => {
|
||||||
|
expect(match.getInGame()).toBe(false);
|
||||||
|
})
|
||||||
|
it('should return tabU [usr] (users)', () => {
|
||||||
|
expect(match.getTabUsers()).toBe(tabU);
|
||||||
|
})
|
||||||
|
it('should return game', () => {
|
||||||
|
expect(match.getGame).toBe(game);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// Setting new values
|
||||||
|
match.setGame(game2);
|
||||||
|
match.setInGame(true);
|
||||||
|
match.setTabUser(tabU2);
|
||||||
|
|
||||||
|
|
||||||
|
// Set tests
|
||||||
|
describe('Match set tests', () => {
|
||||||
|
it('should return tabU2 [] (users)', () => {
|
||||||
|
expect(match.getTabUsers()).toBe(tabU2);
|
||||||
|
})
|
||||||
|
it('should return true', () => {
|
||||||
|
expect(match.getInGame()).toBe(true);
|
||||||
|
})
|
||||||
|
it('should return 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);
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,52 @@
|
|||||||
|
import { Message } from '../Message';
|
||||||
|
import { User } from '../User/user';
|
||||||
|
import { Conversation } from '../Conversation';
|
||||||
|
import { Skin } from '../Skin';
|
||||||
|
|
||||||
|
// Instances
|
||||||
|
let conv:Conversation[] = [];
|
||||||
|
let tab:Skin[] = [];
|
||||||
|
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
|
||||||
|
let dateBirth = new Date(2010,0o3,0o7);
|
||||||
|
let usr = new User('00001', '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);
|
||||||
|
let theDate = new Date(2022,10,14);
|
||||||
|
let theDate2 = new Date(2022,10,13);
|
||||||
|
let mess = new Message('M0001', 'Bob Party est le meilleur projet', usr, theDate);
|
||||||
|
|
||||||
|
|
||||||
|
// Get tests
|
||||||
|
describe('Message get tests', () => {
|
||||||
|
it('should return M0001', () => {
|
||||||
|
expect(mess.getMessageId()).toBe('M0001');
|
||||||
|
})
|
||||||
|
it('should return Bob Party est le meilleur projet', () => {
|
||||||
|
expect(mess.getMessageContent()).toBe('Bob Party est le meilleur projet');
|
||||||
|
})
|
||||||
|
it('should return usr', () => {
|
||||||
|
expect(mess.getMessageSender()).toBe(usr);
|
||||||
|
})
|
||||||
|
it('should return theDate', () => {
|
||||||
|
expect(mess.getMessageDate()).toBe(theDate);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// Setting new values
|
||||||
|
mess.setMessageContent('Vive Bob Party');
|
||||||
|
mess.setMessageSender(usr2);
|
||||||
|
mess.setMessageDate(theDate2);
|
||||||
|
|
||||||
|
|
||||||
|
// Set tests
|
||||||
|
describe('Message set tests', () => {
|
||||||
|
it('should return Vive Bob Party', () => {
|
||||||
|
expect(mess.getMessageContent()).toBe('Vive Bob Party');
|
||||||
|
})
|
||||||
|
it('should return usr2', () => {
|
||||||
|
expect(mess.getMessageSender()).toBe(usr2);
|
||||||
|
})
|
||||||
|
it('should return theDate2', () => {
|
||||||
|
expect(mess.getMessageDate()).toBe(theDate2);
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,50 @@
|
|||||||
|
import { Skin } from '../Skin';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Instance
|
||||||
|
|
||||||
|
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Get tests
|
||||||
|
|
||||||
|
describe('Skin get tests', () => {
|
||||||
|
it('should return S0001', () => {
|
||||||
|
expect(classique.getSkinId()).toBe('S0001');
|
||||||
|
})
|
||||||
|
it('should return Bob', () => {
|
||||||
|
expect(classique.getSkinName()).toBe('Bob');
|
||||||
|
})
|
||||||
|
it('should return require(BobClassic.png)', () => {
|
||||||
|
expect(classique.getSkinSource()).toBe(require('bob_party/assets/BobsSkins/BobClassic.png'));
|
||||||
|
})
|
||||||
|
it('should return 0', () => {
|
||||||
|
expect(classique.getSkinCost()).toBe(0);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Setting new values
|
||||||
|
|
||||||
|
classique.setSkinName('Bob Blue');
|
||||||
|
classique.setSkinCost(100);
|
||||||
|
classique.setSkinSource(require('bob_party/assets/BobsSkins/BobBlue.png'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Set tests
|
||||||
|
|
||||||
|
describe('Skin set tests', () => {
|
||||||
|
it('should return The Classique', () => {
|
||||||
|
expect(classique.getSkinName()).toBe('Bob blue');
|
||||||
|
})
|
||||||
|
it('should return require(BobBlue.png)', () => {
|
||||||
|
expect(classique.getSkinSource()).toBe(require('bob_party/assets/BobsSkins/BobBlue.png'));
|
||||||
|
})
|
||||||
|
it('should return 100', () => {
|
||||||
|
expect(classique.getSkinCost()).toBe(0);
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,99 @@
|
|||||||
|
import { User } from '../User/user';
|
||||||
|
import { Skin } from '../Skin';
|
||||||
|
import { Conversation } from '../Conversation';
|
||||||
|
|
||||||
|
|
||||||
|
// Instances
|
||||||
|
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
|
||||||
|
let blue = new Skin("S0002", "Bob Blue", require('bob_party/assets/BobsSkins/BobBlue.png'), 100);
|
||||||
|
let tab:Skin[] = [];
|
||||||
|
let tab2:Skin[] = [classique, blue];
|
||||||
|
let dateBirth = new Date(2010,0o3,0o7);
|
||||||
|
let dateBirth2 = new Date(2009,0o3,0o7);
|
||||||
|
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab);
|
||||||
|
|
||||||
|
|
||||||
|
// Tests des get
|
||||||
|
describe('User get tests', () => {
|
||||||
|
it('should return 00001', () => {
|
||||||
|
expect(usr.getId()).toBe('00001');
|
||||||
|
})
|
||||||
|
it('should return Killyan', () => {
|
||||||
|
expect(usr.getUsername()).toBe('Killyan');
|
||||||
|
})
|
||||||
|
it('should return password', () => {
|
||||||
|
expect(usr.getPassword()).toBe('password');
|
||||||
|
})
|
||||||
|
it('should return France', () => {
|
||||||
|
expect(usr.getNationality()).toBe('France');
|
||||||
|
})
|
||||||
|
it('should return M', () => {
|
||||||
|
expect(usr.getSexe()).toBe('M');
|
||||||
|
})
|
||||||
|
it('should return 2010-03-07 (dateBirth)', () => {
|
||||||
|
expect(usr.getDateOfBirth()).toBe(dateBirth);
|
||||||
|
})
|
||||||
|
it('should return 0', () => {
|
||||||
|
expect(usr.getCurrentCoins()).toBe(0);
|
||||||
|
})
|
||||||
|
it('should return 0', () => {
|
||||||
|
expect(usr.getTotalCoins()).toBe(0);
|
||||||
|
})
|
||||||
|
it('should return 0', () => {
|
||||||
|
expect(usr.getGamesPlayed()).toBe(0);
|
||||||
|
})
|
||||||
|
it('should return classique', () => {
|
||||||
|
expect(usr.getCurrentSkin()).toBe(classique);
|
||||||
|
})
|
||||||
|
it('should return tab', () => {
|
||||||
|
expect(usr.getTabSkin()).toBe(tab);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// 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.setGamesPlayed(4);
|
||||||
|
usr.setCurrentSkin(blue);
|
||||||
|
usr.setTabSkin(tab2);
|
||||||
|
|
||||||
|
|
||||||
|
// Tests des set
|
||||||
|
describe('User get tests', () => {
|
||||||
|
it('should return BgKillyan', () => {
|
||||||
|
expect(usr.getUsername()).toBe('BgKillyan');
|
||||||
|
})
|
||||||
|
it('should return 1234', () => {
|
||||||
|
expect(usr.getPassword()).toBe('1234');
|
||||||
|
})
|
||||||
|
it('should return Marseille', () => {
|
||||||
|
expect(usr.getNationality()).toBe('Marseille');
|
||||||
|
})
|
||||||
|
it('should return F', () => {
|
||||||
|
expect(usr.getSexe()).toBe('F');
|
||||||
|
})
|
||||||
|
it('should return 07/03/2009 (dateBirth2)', () => {
|
||||||
|
expect(usr.getDateOfBirth()).toBe(dateBirth2);
|
||||||
|
})
|
||||||
|
it('should return 2', () => {
|
||||||
|
expect(usr.getCurrentCoins()).toBe(2);
|
||||||
|
})
|
||||||
|
it('should return 2', () => {
|
||||||
|
expect(usr.getTotalCoins()).toBe(2);
|
||||||
|
})
|
||||||
|
it('should return 4', () => {
|
||||||
|
expect(usr.getGamesPlayed()).toBe(4);
|
||||||
|
})
|
||||||
|
it('should return kikou', () => {
|
||||||
|
expect(usr.getCurrentSkin()).toBe(blue);
|
||||||
|
})
|
||||||
|
it('should return tab2', () => {
|
||||||
|
expect(usr.getTabSkin()).toBe(tab2);
|
||||||
|
})
|
||||||
|
})
|
@ -1,98 +0,0 @@
|
|||||||
import { Skin } from './Skin'
|
|
||||||
|
|
||||||
export class User{
|
|
||||||
private Id: string;
|
|
||||||
private Username: string;
|
|
||||||
private Nationality: string;
|
|
||||||
private Sexe: string;
|
|
||||||
private DateOfBirth: string;
|
|
||||||
private CurrentCoins: number;
|
|
||||||
private TotalCoins: number;
|
|
||||||
private CurrentSkin: Skin;
|
|
||||||
private TabSkin: Skin[];
|
|
||||||
|
|
||||||
constructor(id: string, username: string, nationality: string, sexe: string, dateOfBirth: string, currentCoins: number, totalCoins: number,
|
|
||||||
currentSkin: Skin, tabSkin: Skin[] ){
|
|
||||||
this.Id=id;
|
|
||||||
this.Username=username;
|
|
||||||
this.Nationality=nationality;
|
|
||||||
this.Sexe=sexe;
|
|
||||||
this.DateOfBirth=dateOfBirth;
|
|
||||||
this.CurrentCoins=currentCoins;
|
|
||||||
this.TotalCoins=totalCoins;
|
|
||||||
this.CurrentSkin=currentSkin;
|
|
||||||
this.TabSkin=tabSkin;
|
|
||||||
}
|
|
||||||
|
|
||||||
getUsername(){
|
|
||||||
return this.Username;
|
|
||||||
}
|
|
||||||
|
|
||||||
setUsername(username: string){
|
|
||||||
this.Username=username;
|
|
||||||
}
|
|
||||||
|
|
||||||
getId(){
|
|
||||||
return this.Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
setId(id: string){
|
|
||||||
this.Id=id;
|
|
||||||
}
|
|
||||||
|
|
||||||
getCurrentCoins(){
|
|
||||||
return this.CurrentCoins;
|
|
||||||
}
|
|
||||||
|
|
||||||
setCurrentCoins(currentCoins: number){
|
|
||||||
this.CurrentCoins=currentCoins;
|
|
||||||
}
|
|
||||||
|
|
||||||
getSexe(){
|
|
||||||
return this.Sexe;
|
|
||||||
}
|
|
||||||
|
|
||||||
setSexe(sexe: string){
|
|
||||||
this.Sexe=sexe;
|
|
||||||
}
|
|
||||||
|
|
||||||
getDateOfBirth(){
|
|
||||||
return this.DateOfBirth;
|
|
||||||
}
|
|
||||||
|
|
||||||
setDateOfBirth(dateOfBirth: string){
|
|
||||||
this.DateOfBirth=dateOfBirth;
|
|
||||||
}
|
|
||||||
|
|
||||||
getNationality(){
|
|
||||||
return this.Nationality;
|
|
||||||
}
|
|
||||||
|
|
||||||
setNationality(nationality: string){
|
|
||||||
this.Nationality=nationality;
|
|
||||||
}
|
|
||||||
|
|
||||||
getTotalCoins(){
|
|
||||||
return this.TotalCoins;
|
|
||||||
}
|
|
||||||
|
|
||||||
setTotalCoins(totalCoins: number){
|
|
||||||
this.TotalCoins=totalCoins;
|
|
||||||
}
|
|
||||||
|
|
||||||
getCurrentSkin(){
|
|
||||||
return this.CurrentSkin;
|
|
||||||
}
|
|
||||||
|
|
||||||
setCurrentSkin(newSkin: Skin){
|
|
||||||
this.CurrentSkin=newSkin;
|
|
||||||
}
|
|
||||||
|
|
||||||
getTabSkin(){
|
|
||||||
return this.TabSkin;
|
|
||||||
}
|
|
||||||
|
|
||||||
setTabSkin(tabSkin: Skin[]){
|
|
||||||
this.TabSkin=tabSkin;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
@ -0,0 +1,75 @@
|
|||||||
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit"
|
||||||
|
import { Skin } from "../../core/Skin";
|
||||||
|
import { User } from "../../core/User/user";
|
||||||
|
|
||||||
|
const dateNull = new Date();
|
||||||
|
|
||||||
|
const userNull:User= new User("","","","","",dateNull);
|
||||||
|
|
||||||
|
var currentUser:User = userNull;
|
||||||
|
|
||||||
|
export const currentUserSlice = createSlice({
|
||||||
|
name: "currentUserManager",
|
||||||
|
initialState : {
|
||||||
|
currentUser
|
||||||
|
},
|
||||||
|
reducers: {
|
||||||
|
loginUser: (state, action: PayloadAction<User>) => {
|
||||||
|
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>) =>{
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
state.currentUser = newUser;
|
||||||
|
},
|
||||||
|
updatePseudo: (state, action: PayloadAction<string>) =>{
|
||||||
|
const newUser: User = new User(currentUser.getId(), currentUser.getUsername(), currentUser.getPassword(), currentUser.getNationality(), currentUser.getSexe(), currentUser.getDateOfBirth());
|
||||||
|
|
||||||
|
console.log(currentUser);
|
||||||
|
newUser.setUsername(action.payload);
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
currentUser: newUser,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updatePassword: (state, action: PayloadAction<string>) =>{
|
||||||
|
const newUser = state.currentUser;
|
||||||
|
currentUser.setPassword(action.payload)
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
currentUser: newUser,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updateNationality: (state, action: PayloadAction<string>) =>{
|
||||||
|
const newUser = state.currentUser;
|
||||||
|
currentUser.setNationality(action.payload)
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
currentUser: newUser,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updateSex: (state, action: PayloadAction<string>) =>{
|
||||||
|
const newUser = state.currentUser;
|
||||||
|
currentUser.setSexe(action.payload)
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
currentUser: newUser,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const { loginUser } = currentUserSlice.actions
|
||||||
|
export const { updateSkin } = currentUserSlice.actions
|
||||||
|
export const { updatePseudo } = currentUserSlice.actions
|
||||||
|
export const { updatePassword } = currentUserSlice.actions
|
||||||
|
export const { updateNationality } = currentUserSlice.actions
|
||||||
|
export const { updateSex } = currentUserSlice.actions
|
||||||
|
|
||||||
|
export default currentUserSlice.reducer;
|
@ -0,0 +1,20 @@
|
|||||||
|
import { configureStore } from "@reduxjs/toolkit";
|
||||||
|
import currentUserReducer from "./features/currentUserSlice";
|
||||||
|
import credentialErrorsSlice from "./features/credentialErrorsSlice";
|
||||||
|
import { getDefaultMiddleware } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
const customizedMiddleware = getDefaultMiddleware({
|
||||||
|
serializableCheck: false
|
||||||
|
})
|
||||||
|
|
||||||
|
const store = configureStore({
|
||||||
|
reducer: {
|
||||||
|
currentUserManager: currentUserReducer,
|
||||||
|
credentialErrors: credentialErrorsSlice,
|
||||||
|
},
|
||||||
|
middleware: (getDefaultMiddleware) => customizedMiddleware,
|
||||||
|
})
|
||||||
|
|
||||||
|
export type RootState = ReturnType<typeof store.getState>;
|
||||||
|
export type AppDispatch = typeof store.dispatch;
|
||||||
|
export default store;
|
@ -1,156 +1,36 @@
|
|||||||
import { StatusBar } from 'expo-status-bar'
|
import { StatusBar } from 'expo-status-bar'
|
||||||
import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import stylesScreen from './style/screens.style';
|
||||||
|
import { TopBar } from '../components/TopBar';
|
||||||
|
import { BotBar } from '../components/BotBar';
|
||||||
|
import { FlatList } from 'react-native-gesture-handler';
|
||||||
|
import { ConversationComponent } from '../components/ConversationComponent';
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { RootState } from '../redux/store';
|
||||||
|
|
||||||
|
function Chat(props: { navigation: any; }) {
|
||||||
|
const { navigation } = props
|
||||||
|
|
||||||
const avatar = require('../../assets/Icons/BobClassic.png');
|
const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
|
||||||
const engrenage = require('../../assets/Icons/UnSelected/Cogs.png');
|
|
||||||
const gamepad = require('../../assets/Icons/UnSelected/Gamepad.png');
|
|
||||||
const message = require('../../assets/Icons/Selected/SChat.png');
|
|
||||||
const store = require('../../assets/Icons/UnSelected/Store.png');
|
|
||||||
|
|
||||||
function Store(props: { navigation: any; }) {
|
|
||||||
const { navigation } = props
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={stylesScreen.container}>
|
||||||
<View style={styles.header}>
|
<TopBar
|
||||||
<Pressable onPress={() => navigation.navigate('Profile')}>
|
nav={navigation}
|
||||||
<Image
|
|
||||||
style={styles.avatar}
|
|
||||||
source={avatar}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
<Text style={styles.titre}>BOB PARTY</Text>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Settings')}>
|
|
||||||
<Image
|
|
||||||
style={styles.engrenage}
|
|
||||||
source={engrenage}
|
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
<View style={stylesScreen.bodyStart}>
|
||||||
</View>
|
<FlatList
|
||||||
<View style={styles.body}>
|
data={currentUser.getTabConv()}
|
||||||
<Text style={styles.text}>couille</Text>
|
renderItem={({item}) => <ConversationComponent conv={item} state='Preview'/>}
|
||||||
</View>
|
/>
|
||||||
<View style={styles.footer}>
|
|
||||||
<Pressable>
|
|
||||||
<Image
|
|
||||||
style={styles.iconFooter}
|
|
||||||
source={message}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Home')}>
|
|
||||||
<Image
|
|
||||||
style={styles.iconFooter}
|
|
||||||
source={gamepad}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Store')}>
|
|
||||||
<Image
|
|
||||||
style={styles.iconStore}
|
|
||||||
source={store}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
</View>
|
||||||
|
<BotBar
|
||||||
|
nav={navigation}
|
||||||
|
state='Chat'
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default Chat
|
||||||
function Button(props: { onPress: any; title?: "Save" | undefined; }) {
|
|
||||||
const { onPress, title = 'Save' } = props;
|
|
||||||
return (
|
|
||||||
<Pressable style={styles.button} onPress={onPress}>
|
|
||||||
<Text style={styles.text}>{title}</Text>
|
|
||||||
</Pressable>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
body: {
|
|
||||||
flex: 1,
|
|
||||||
flexDirection: 'column',
|
|
||||||
alignItems: 'flex-start',
|
|
||||||
width: '70%',
|
|
||||||
},
|
|
||||||
|
|
||||||
container: {
|
|
||||||
flex: 1,
|
|
||||||
backgroundColor: "#45444E",
|
|
||||||
flexDirection: "column",
|
|
||||||
justifyContent: "flex-start",
|
|
||||||
alignItems: "center",
|
|
||||||
},
|
|
||||||
button: {
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
height: '30%',
|
|
||||||
width: '100%',
|
|
||||||
marginTop: '10%',
|
|
||||||
paddingVertical: 12,
|
|
||||||
paddingHorizontal: 32,
|
|
||||||
borderRadius: 10,
|
|
||||||
elevation: 3,
|
|
||||||
backgroundColor: '#0085FF',
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
fontSize: 16,
|
|
||||||
lineHeight: 21,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
letterSpacing: 0.25,
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
flex : 0.15,
|
|
||||||
width: '100%',
|
|
||||||
flexDirection: 'row',
|
|
||||||
backgroundColor: '#2D2C33',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-around',
|
|
||||||
},
|
|
||||||
titre: {
|
|
||||||
flex: 0.7,
|
|
||||||
flexDirection: 'column',
|
|
||||||
textAlign: 'center',
|
|
||||||
fontSize: 30,
|
|
||||||
fontFamily: 'Helvetica',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
letterSpacing: 0.25,
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
engrenage: {
|
|
||||||
borderRadius: 50,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
avatar: {
|
|
||||||
borderRadius: 50,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
|
|
||||||
footer: {
|
|
||||||
flex: 0.15,
|
|
||||||
flexDirection: 'row',
|
|
||||||
backgroundColor: '#2D2C33',
|
|
||||||
flexWrap: 'wrap',
|
|
||||||
width: '100%',
|
|
||||||
justifyContent: 'space-evenly',
|
|
||||||
},
|
|
||||||
iconFooter: {
|
|
||||||
marginBot: 25,
|
|
||||||
marginTop: 10,
|
|
||||||
width: 65,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
iconStore: {
|
|
||||||
marginBot: 25,
|
|
||||||
marginTop: 10,
|
|
||||||
marginLeft: 7,
|
|
||||||
marginRight: 8,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default Store
|
|
@ -0,0 +1,155 @@
|
|||||||
|
import { StatusBar } from 'expo-status-bar'
|
||||||
|
import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native'
|
||||||
|
import React from 'react';
|
||||||
|
import { Game } from '../core/game';
|
||||||
|
import { Skin } from '../core/skin';
|
||||||
|
import { TopBar } from '../components/TopBar';
|
||||||
|
import { BotBar } from '../components/BotBar';
|
||||||
|
import { GameComponent } from '../components/GameComponent';
|
||||||
|
import { User } from '../core/User/user';
|
||||||
|
import tabSkinApp from '../constSkin';
|
||||||
|
import { Conversation } from '../core/conversation';
|
||||||
|
import { GameSolo } from '../core/gameSolo';
|
||||||
|
let tabConv:Conversation[]=[];
|
||||||
|
|
||||||
|
|
||||||
|
const msc = require('../../assets/Icons/FondGris.png');
|
||||||
|
|
||||||
|
//const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv);
|
||||||
|
const jeuTest= new GameSolo("1", "SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin", 1, 1, new Map<number,number>);
|
||||||
|
function GameChoice(props: { navigation: any; }) {
|
||||||
|
const { navigation } = props
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<TopBar
|
||||||
|
nav={navigation}
|
||||||
|
/>
|
||||||
|
<View style={styles.body}>
|
||||||
|
<GameComponent
|
||||||
|
game={jeuTest}
|
||||||
|
nav={navigation}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<BotBar
|
||||||
|
nav={navigation}
|
||||||
|
state='Home'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Button(props: { onPress: any; title?: any | undefined; }) {
|
||||||
|
const { onPress, title = 'Save' } = props;
|
||||||
|
return (
|
||||||
|
<Pressable style={styles.button} onPress={onPress}>
|
||||||
|
<Text style={styles.text}>{title}</Text>
|
||||||
|
</Pressable>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
body: {
|
||||||
|
flex: 1,
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
width: '70%',
|
||||||
|
},
|
||||||
|
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: "#45444E",
|
||||||
|
flexDirection: "column",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
button: {
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
height: '30%',
|
||||||
|
width: '100%',
|
||||||
|
marginTop: '10%',
|
||||||
|
paddingVertical: 12,
|
||||||
|
paddingHorizontal: 32,
|
||||||
|
borderRadius: 10,
|
||||||
|
elevation: 3,
|
||||||
|
backgroundColor: '#0085FF',
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 21,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
flex : 0.15,
|
||||||
|
width: '100%',
|
||||||
|
flexDirection: 'row',
|
||||||
|
backgroundColor: '#2D2C33',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-around',
|
||||||
|
},
|
||||||
|
titre: {
|
||||||
|
flex: 0.7,
|
||||||
|
flexDirection: 'column',
|
||||||
|
textAlign: 'center',
|
||||||
|
fontSize: 30,
|
||||||
|
fontFamily: 'Helvetica',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
engrenage: {
|
||||||
|
borderRadius: 50,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
},
|
||||||
|
avatar: {
|
||||||
|
borderRadius: 50,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
},
|
||||||
|
|
||||||
|
footer: {
|
||||||
|
flex: 0.15,
|
||||||
|
flexDirection: 'row',
|
||||||
|
backgroundColor: '#2D2C33',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
width: '100%',
|
||||||
|
justifyContent: 'space-evenly',
|
||||||
|
},
|
||||||
|
iconFooter: {
|
||||||
|
marginBottom: 25,
|
||||||
|
marginTop: 10,
|
||||||
|
width: 65,
|
||||||
|
height: 50,
|
||||||
|
},
|
||||||
|
iconStore: {
|
||||||
|
marginBottom: 25,
|
||||||
|
marginTop: 10,
|
||||||
|
marginLeft: 7,
|
||||||
|
marginRight: 8,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
},
|
||||||
|
imageSkin : {
|
||||||
|
borderRadius: 15,
|
||||||
|
marginTop: 15,
|
||||||
|
marginRight: 15,
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
nomSkin :{
|
||||||
|
textAlign: 'center',
|
||||||
|
fontSize: 15,
|
||||||
|
fontFamily: 'Helvetica',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export default GameChoice
|
@ -1,163 +1,46 @@
|
|||||||
import { StatusBar } from 'expo-status-bar'
|
import { StatusBar } from 'expo-status-bar'
|
||||||
import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native'
|
import { View} from 'react-native'
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { SkinComponent } from '../../components/skinAvatar';
|
import stylesScreen from './style/screens.style'
|
||||||
import { User } from '../../core/user';
|
import { TopBar } from '../components/TopBar';
|
||||||
import { Skin } from '../../core/skin';
|
import { BotBar } from '../components/BotBar';
|
||||||
|
import { Conversation } from '../core/conversation';
|
||||||
|
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { RootState } from '../redux/store';
|
||||||
|
|
||||||
|
|
||||||
const avatar = require('../../assets/Icons/BobClassic.png');
|
|
||||||
const skinTest= new Skin("Bob", '../../assets/Icons/BobClassic.png');
|
//const test= new GameSolo("test", require('bob_party/assets/ImagesJeux/BatailleNavale.jpeg'), "test", );
|
||||||
const engrenage = require('../../assets/Icons/UnSelected/Cogs.png');
|
let tabConv:Conversation[]=[];
|
||||||
const gamepad = require('../../assets/Icons/Selected/Gamepad.png');
|
|
||||||
const message = require('../../assets/Icons/UnSelected/Chat.png');
|
|
||||||
const store = require('../../assets/Icons/UnSelected/Store.png');
|
|
||||||
|
|
||||||
function Home(props: { navigation: any; }) {
|
function Home(props: { navigation: any; }) {
|
||||||
|
|
||||||
|
|
||||||
const { navigation } = props
|
const { navigation } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={stylesScreen.container}>
|
||||||
<View style={styles.header}>
|
<TopBar
|
||||||
<Pressable onPress={() => navigation.navigate('Profile')}>
|
nav={navigation}
|
||||||
<SkinComponent skin={skinTest} children={styles.avatar} childrenTest={<Text>Bite</Text>} />
|
state= 'Home'
|
||||||
</Pressable>
|
|
||||||
<Text style={styles.titre}>BOB PARTY</Text>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Settings')}>
|
|
||||||
<Image
|
|
||||||
style={styles.engrenage}
|
|
||||||
source={engrenage}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
|
||||||
<View style={styles.body}>
|
|
||||||
<Button
|
|
||||||
title='Jouer Seul'
|
|
||||||
onPress={() => Alert.alert('On Joue seul')}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
title='Défier mes amis'
|
|
||||||
onPress={() => Alert.alert('On Joue avec les potos')}
|
|
||||||
/>
|
/>
|
||||||
</View>
|
<View style={stylesScreen.bodyCenter}>
|
||||||
<View style={styles.footer}>
|
<ButtonGameTypeChoice
|
||||||
<Pressable onPress={() => navigation.navigate('Chat')}>
|
title='Jouer Seul'
|
||||||
<Image
|
onPress={() => navigation.navigate('GameChoice')}
|
||||||
style={styles.iconFooter}
|
|
||||||
source={message}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
<Pressable >
|
|
||||||
<Image
|
|
||||||
style={styles.iconFooter}
|
|
||||||
source={gamepad}
|
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
<ButtonGameTypeChoice
|
||||||
<Pressable onPress={() => navigation.navigate('Store')}>
|
title='Défier mes amis'
|
||||||
<Image
|
onPress={() => navigation.navigate('GameChoice')}
|
||||||
style={styles.iconStore}
|
|
||||||
source={store}
|
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
</View>
|
||||||
|
<BotBar
|
||||||
|
nav={navigation}
|
||||||
|
state='Home'
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function Button(props: { onPress: any; title?: any | undefined; }) {
|
|
||||||
const { onPress, title = 'Save' } = props;
|
|
||||||
return (
|
|
||||||
<Pressable style={styles.button} onPress={onPress}>
|
|
||||||
<Text style={styles.text}>{title}</Text>
|
|
||||||
</Pressable>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
container: {
|
|
||||||
flex: 1,
|
|
||||||
backgroundColor: '#45444E',
|
|
||||||
flexDirection: "column",
|
|
||||||
justifyContent: "flex-start",
|
|
||||||
alignItems: "center",
|
|
||||||
},
|
|
||||||
button: {
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
height: '30%',
|
|
||||||
width: '100%',
|
|
||||||
marginTop: '10%',
|
|
||||||
paddingVertical: 12,
|
|
||||||
paddingHorizontal: 32,
|
|
||||||
borderRadius: 10,
|
|
||||||
elevation: 3,
|
|
||||||
backgroundColor: '#0085FF',
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
fontSize: 16,
|
|
||||||
lineHeight: 21,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
letterSpacing: 0.25,
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
flex : 0.15,
|
|
||||||
width: '100%',
|
|
||||||
flexDirection: 'row',
|
|
||||||
backgroundColor: '#2D2C33',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-around',
|
|
||||||
},
|
|
||||||
titre: {
|
|
||||||
flex: 0.7,
|
|
||||||
flexDirection: 'column',
|
|
||||||
textAlign: 'center',
|
|
||||||
fontSize: 30,
|
|
||||||
fontFamily: 'Helvetica',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
letterSpacing: 0.25,
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
engrenage: {
|
|
||||||
borderRadius: 50,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
avatar: {
|
|
||||||
borderRadius: 50,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
body: {
|
|
||||||
flex: 1,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
width: '70%',
|
|
||||||
},
|
|
||||||
footer: {
|
|
||||||
flex: 0.15,
|
|
||||||
flexDirection: 'row',
|
|
||||||
backgroundColor: '#2D2C33',
|
|
||||||
flexWrap: 'wrap',
|
|
||||||
width: '100%',
|
|
||||||
justifyContent: 'space-evenly',
|
|
||||||
},
|
|
||||||
iconFooter: {
|
|
||||||
marginBot: 25,
|
|
||||||
marginTop: 10,
|
|
||||||
width: 65,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
iconStore: {
|
|
||||||
marginBot: 25,
|
|
||||||
marginTop: 10,
|
|
||||||
marginLeft: 7,
|
|
||||||
marginRight: 8,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default Home
|
export default Home
|
@ -1,156 +1,55 @@
|
|||||||
import { StatusBar } from 'expo-status-bar'
|
import { StatusBar } from 'expo-status-bar'
|
||||||
import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native'
|
import { View, Text, Image} from 'react-native'
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import stylesScreen from './style/screens.style'
|
||||||
|
import styles from './style/Profile.style'
|
||||||
|
import { TopBar } from '../components/TopBar';
|
||||||
|
import { BotBar } from '../components/BotBar';
|
||||||
|
import { SkinComponent } from '../components/Skin';
|
||||||
|
import { ButtonGreySmall } from '../components/ButtonGreySmall';
|
||||||
|
import { ScreenIndicator } from '../components/ScreenIndicator';
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { RootState } from '../redux/store';
|
||||||
|
|
||||||
const avatar = require('../../assets/Icons/BobClassic.png');
|
const coin = require('../../assets/Icons/Coin.png')
|
||||||
const engrenage = require('../../assets/Icons/UnSelected/Cogs.png');
|
|
||||||
const gamepad = require('../../assets/Icons/UnSelected/Gamepad.png');
|
|
||||||
const message = require('../../assets/Icons/UnSelected/Chat.png');
|
|
||||||
const store = require('../../assets/Icons/UnSelected/Store.png');
|
|
||||||
|
|
||||||
function Store(props: { navigation: any; }) {
|
|
||||||
|
|
||||||
|
function Profile(props: { navigation: any; }) {
|
||||||
const { navigation } = props
|
const { navigation } = props
|
||||||
|
|
||||||
|
const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={stylesScreen.container}>
|
||||||
<View style={styles.header}>
|
<TopBar
|
||||||
<Pressable>
|
nav={navigation}
|
||||||
<Image
|
|
||||||
style={styles.avatar}
|
|
||||||
source={avatar}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
<Text style={styles.titre}>BOB PARTY</Text>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Settings')}>
|
|
||||||
<Image
|
|
||||||
style={styles.engrenage}
|
|
||||||
source={engrenage}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
|
||||||
<View style={styles.body}>
|
|
||||||
<Text style={styles.text}>couille</Text>
|
|
||||||
</View>
|
|
||||||
<View style={styles.footer}>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Chat')}>
|
|
||||||
<Image
|
|
||||||
style={styles.iconFooter}
|
|
||||||
source={message}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Home')}>
|
|
||||||
<Image
|
|
||||||
style={styles.iconFooter}
|
|
||||||
source={gamepad}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Store')}>
|
|
||||||
<Image
|
|
||||||
style={styles.iconStore}
|
|
||||||
source={store}
|
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
<View style={stylesScreen.bodyStart}>
|
||||||
|
<ScreenIndicator title='Profil'/>
|
||||||
|
<Text style={styles.pseudoText}>{currentUser.getUsername()}</Text>
|
||||||
|
<View style={styles.coinSkinView}>
|
||||||
|
<View style={styles.coinView}>
|
||||||
|
<Image
|
||||||
|
style={styles.coin}
|
||||||
|
source={coin}
|
||||||
|
/>
|
||||||
|
<Text style={styles.coinText}>{currentUser.getCurrentCoins()}</Text>
|
||||||
|
</View>
|
||||||
|
<View style={styles.skinView}>
|
||||||
|
<SkinComponent skin={currentUser.getCurrentSkin()} state='profile' />
|
||||||
|
<ButtonGreySmall onPress={() => navigation.navigate('SkinList')} title='Changer de skin' state='Profile'/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View style={styles.infoView}>
|
||||||
|
<Text style={styles.infoText}>Total de BobCoin gagnés: {currentUser.getTotalCoins()}</Text>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
<BotBar
|
||||||
|
nav={navigation}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Button(props: { onPress: any; title?: any | undefined; }) {
|
export default Profile
|
||||||
const { onPress, title = 'Save' } = props;
|
|
||||||
return (
|
|
||||||
<Pressable style={styles.button} onPress={onPress}>
|
|
||||||
<Text style={styles.text}>{title}</Text>
|
|
||||||
</Pressable>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
body: {
|
|
||||||
flex: 1,
|
|
||||||
flexDirection: 'column',
|
|
||||||
alignItems: 'flex-start',
|
|
||||||
width: '70%',
|
|
||||||
},
|
|
||||||
|
|
||||||
container: {
|
|
||||||
flex: 1,
|
|
||||||
backgroundColor: "#45444E",
|
|
||||||
flexDirection: "column",
|
|
||||||
justifyContent: "flex-start",
|
|
||||||
alignItems: "center",
|
|
||||||
},
|
|
||||||
button: {
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
height: '30%',
|
|
||||||
width: '100%',
|
|
||||||
marginTop: '10%',
|
|
||||||
paddingVertical: 12,
|
|
||||||
paddingHorizontal: 32,
|
|
||||||
borderRadius: 10,
|
|
||||||
elevation: 3,
|
|
||||||
backgroundColor: '#0085FF',
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
fontSize: 16,
|
|
||||||
lineHeight: 21,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
letterSpacing: 0.25,
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
flex : 0.15,
|
|
||||||
width: '100%',
|
|
||||||
flexDirection: 'row',
|
|
||||||
backgroundColor: '#2D2C33',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-around',
|
|
||||||
},
|
|
||||||
titre: {
|
|
||||||
flex: 0.7,
|
|
||||||
flexDirection: 'column',
|
|
||||||
textAlign: 'center',
|
|
||||||
fontSize: 30,
|
|
||||||
fontFamily: 'Helvetica',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
letterSpacing: 0.25,
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
engrenage: {
|
|
||||||
borderRadius: 50,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
avatar: {
|
|
||||||
borderRadius: 50,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
|
|
||||||
footer: {
|
|
||||||
flex: 0.15,
|
|
||||||
flexDirection: 'row',
|
|
||||||
backgroundColor: '#2D2C33',
|
|
||||||
flexWrap: 'wrap',
|
|
||||||
width: '100%',
|
|
||||||
justifyContent: 'space-evenly',
|
|
||||||
},
|
|
||||||
iconFooter: {
|
|
||||||
marginBottom: 25,
|
|
||||||
marginTop: 10,
|
|
||||||
width: 65,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
iconStore: {
|
|
||||||
marginBottom: 25,
|
|
||||||
marginTop: 10,
|
|
||||||
marginLeft: 7,
|
|
||||||
marginRight: 8,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default Store
|
|
@ -1,131 +1,84 @@
|
|||||||
import { StatusBar } from 'expo-status-bar'
|
import { StatusBar } from 'expo-status-bar'
|
||||||
import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native'
|
import { View, Text } from 'react-native'
|
||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import stylesScreen from './style/screens.style';
|
||||||
|
import styles from './style/Settings.style';
|
||||||
|
import { TopBar } from '../components/TopBar';
|
||||||
|
import { ButtonGreySmall } from '../components/ButtonGreySmall';
|
||||||
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
import { RootState } from '../redux/store';
|
||||||
|
import DialogInput from "react-native-dialog-input";
|
||||||
|
import { updatePseudo, updatePassword, updateNationality, updateSex } from "../redux/features/currentUserSlice";
|
||||||
|
import Dialog from "react-native-dialog"
|
||||||
|
import RNPickerSelect from "react-native-picker-select";
|
||||||
|
import tabNat from '../constNat';
|
||||||
|
import tabSex from '../constSex';
|
||||||
|
import { PickerGreySmall } from '../components/PickerGreySmall';
|
||||||
|
|
||||||
const msc = require('../../assets/Icons/FondGris.png');
|
function Settings(props: { navigation: any; }) {
|
||||||
const engrenage = require('../../assets/Icons/UnSelected/Cross.png');
|
|
||||||
|
|
||||||
function Store(props: { navigation: any; }) {
|
|
||||||
const { navigation } = props
|
const { navigation } = props
|
||||||
return (
|
|
||||||
<View style={styles.container}>
|
|
||||||
<View style={styles.header}>
|
|
||||||
<Image
|
|
||||||
style={styles.engrenage}
|
|
||||||
source={msc}
|
|
||||||
/>
|
|
||||||
<Text style={styles.titre}>Paramètres</Text>
|
|
||||||
<Pressable onPress={() => props.navigation.goBack()}>
|
|
||||||
<Image
|
|
||||||
style={styles.engrenage}
|
|
||||||
source={engrenage}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
|
||||||
<View style={styles.body}>
|
|
||||||
<Text style={styles.text}>couille</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
|
||||||
|
|
||||||
function Button(props: { onPress: any; title?: any | undefined; }) {
|
const [dialogPseudoVisible, setDialogPseudoVisible] = useState(false);
|
||||||
const { onPress, title = 'Save' } = props;
|
const [dialogPasswordVisible, setDialogPasswordVisible] = useState(false);
|
||||||
return (
|
|
||||||
<Pressable style={styles.button} onPress={onPress}>
|
const [selectedSex, setSelectedSex] = useState("");
|
||||||
<Text style={styles.text}>{title}</Text>
|
const [selectedNationality, setSelectedNationality] = useState("");
|
||||||
</Pressable>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const dispatch=useDispatch();
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
return (
|
||||||
body: {
|
<View style={stylesScreen.container}>
|
||||||
flex: 1,
|
<TopBar
|
||||||
flexDirection: 'column',
|
nav={navigation}
|
||||||
alignItems: 'flex-start',
|
state='settings'
|
||||||
width: '70%',
|
/>
|
||||||
},
|
<View style={stylesScreen.bodyStartCenter}>
|
||||||
|
<Text style={styles.title}>Informations du Joueur</Text>
|
||||||
|
<View style={styles.infoView}>
|
||||||
|
<View style={{flexDirection: 'row', justifyContent: 'space-between',}}>
|
||||||
|
<View>
|
||||||
|
<View>
|
||||||
|
<Text style={styles.text}>Pseudo: {currentUser.getUsername()}</Text>
|
||||||
|
<ButtonGreySmall onPress={() => setDialogPseudoVisible(true)} title='Changer le pseudo'/>
|
||||||
|
</View>
|
||||||
|
<View>
|
||||||
|
<Text style={styles.text}>Mot de passe: {currentUser.getPassword()}</Text>
|
||||||
|
<ButtonGreySmall onPress={() => setDialogPasswordVisible(true)} title='Changer le mot de passe'/>
|
||||||
|
</View>
|
||||||
|
<View>
|
||||||
|
<Text style={styles.text}>Nationalité: {currentUser.getNationality()}</Text>
|
||||||
|
<PickerGreySmall title='Changer la nationalité' valueChange={(value:string) => setSelectedNationality(value)} donePress={() => dispatch(updateNationality(selectedNationality))} values={tabNat} />
|
||||||
|
</View>
|
||||||
|
<View>
|
||||||
|
<Text style={styles.text}>Sexe: {currentUser.getSexe()}</Text>
|
||||||
|
<PickerGreySmall title='Changer le sexe' valueChange={(value:string) => setSelectedSex(value)} donePress={() => dispatch(updateSex(selectedSex))} values={tabSex} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<Text style={styles.textID}>ID: {currentUser.getId()}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
container: {
|
<DialogInput
|
||||||
flex: 1,
|
isDialogVisible={dialogPseudoVisible}
|
||||||
backgroundColor: "#45444E",
|
title="Inserer le nouveau pseudo"
|
||||||
flexDirection: "column",
|
hintInput ="Pseudo"
|
||||||
justifyContent: "flex-start",
|
submitInput={ (inputText: string) => {dispatch(updatePseudo(inputText)); setDialogPseudoVisible(false)} }
|
||||||
alignItems: "center",
|
closeDialog={ () => {setDialogPseudoVisible(false)}}>
|
||||||
},
|
</DialogInput>
|
||||||
button: {
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
height: '30%',
|
|
||||||
width: '100%',
|
|
||||||
marginTop: '10%',
|
|
||||||
paddingVertical: 12,
|
|
||||||
paddingHorizontal: 32,
|
|
||||||
borderRadius: 10,
|
|
||||||
elevation: 3,
|
|
||||||
backgroundColor: '#0085FF',
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
fontSize: 16,
|
|
||||||
lineHeight: 21,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
letterSpacing: 0.25,
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
flex : 0.15,
|
|
||||||
width: '100%',
|
|
||||||
flexDirection: 'row',
|
|
||||||
backgroundColor: '#2D2C33',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-around',
|
|
||||||
},
|
|
||||||
titre: {
|
|
||||||
flex: 0.7,
|
|
||||||
flexDirection: 'column',
|
|
||||||
textAlign: 'center',
|
|
||||||
fontSize: 30,
|
|
||||||
fontFamily: 'Helvetica',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
letterSpacing: 0.25,
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
engrenage: {
|
|
||||||
borderRadius: 10,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
avatar: {
|
|
||||||
borderRadius: 10,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
|
|
||||||
footer: {
|
<DialogInput
|
||||||
flex: 0.15,
|
isDialogVisible={dialogPasswordVisible}
|
||||||
flexDirection: 'row',
|
title="Inserer le nouveau mot de passe"
|
||||||
backgroundColor: '#2D2C33',
|
hintInput ="Mot de passe"
|
||||||
flexWrap: 'wrap',
|
submitInput={ (inputText: string) => {dispatch(updatePassword(inputText)); setDialogPasswordVisible(false)} }
|
||||||
width: '100%',
|
closeDialog={ () => {setDialogPasswordVisible(false)}}>
|
||||||
justifyContent: 'space-evenly',
|
</DialogInput>
|
||||||
},
|
|
||||||
iconFooter: {
|
|
||||||
marginBottom: 25,
|
|
||||||
marginTop: 10,
|
|
||||||
width: 65,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
iconStore: {
|
|
||||||
marginBottom: 25,
|
|
||||||
marginTop: 10,
|
|
||||||
marginLeft: 7,
|
|
||||||
marginRight: 8,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default Store
|
export default Settings
|
@ -0,0 +1,57 @@
|
|||||||
|
import { StatusBar } from 'expo-status-bar'
|
||||||
|
import { View, Pressable, Text, Alert} from 'react-native'
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import stylesScreen from './style/screens.style'
|
||||||
|
import { TextInput } from 'react-native-gesture-handler';
|
||||||
|
import styles from "./style/SignIn.style";
|
||||||
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
import tabUS from '../constUser';
|
||||||
|
import { loginUser } from '../redux/features/currentUserSlice';
|
||||||
|
import { checkCredentials } from '../core/Auth/login';
|
||||||
|
import { RootState } from '../redux/store';
|
||||||
|
import { updateIncorrectCredentials } from '../redux/features/credentialErrorsSlice';
|
||||||
|
import Dialog from "react-native-dialog";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function SignIn(props: { navigation: any; }) {
|
||||||
|
const { navigation } = props
|
||||||
|
|
||||||
|
const errorList = useSelector((state: RootState) => state.credentialErrors.loginErrorList);
|
||||||
|
|
||||||
|
const [pseudo, setPseudo] = useState('');
|
||||||
|
const [password, setPassword] = useState('');
|
||||||
|
const dispatch=useDispatch();
|
||||||
|
|
||||||
|
if (errorList.incorrectCredentials){
|
||||||
|
Alert.alert("Pseudo ou Mot de passe incorrect");
|
||||||
|
dispatch(updateIncorrectCredentials(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={stylesScreen.container}>
|
||||||
|
<View style={stylesScreen.bodyCenter}>
|
||||||
|
<TextInput style={styles.textInput} placeholder='Login' onChangeText={(val) => setPseudo(val)} autoCapitalize='none' />
|
||||||
|
<TextInput style={styles.textInput} placeholder='Password' onChangeText={(val) => setPassword(val)} autoCapitalize='none' secureTextEntry={true}/>
|
||||||
|
<Pressable style={styles.button} onPress={() => checkCredentials(pseudo, password, dispatch, navigation)}>
|
||||||
|
<Text style={styles.text}>Se connecter</Text>
|
||||||
|
</Pressable>
|
||||||
|
<Pressable onPress={() => navigation.navigate('SignUp')}>
|
||||||
|
<Text style={styles.textLink}>Pas de compte? Inscrivez vous !</Text>
|
||||||
|
</Pressable>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SignIn
|
@ -0,0 +1,142 @@
|
|||||||
|
import { StatusBar } from 'expo-status-bar'
|
||||||
|
import { StyleSheet, View, ImageSourcePropType, Pressable, Text, Alert} from 'react-native'
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import stylesScreen from './style/screens.style'
|
||||||
|
import { TextInput } from 'react-native-gesture-handler';
|
||||||
|
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
|
||||||
|
import styleScreen from "./style/screens.style";
|
||||||
|
import styles from "./style/SignUp.style";
|
||||||
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
import { checkNewUserValidity } from '../core/Auth/newUser';
|
||||||
|
import DateTimePicker, { DateTimePickerEvent } from '@react-native-community/datetimepicker';
|
||||||
|
import RNPickerSelect from "react-native-picker-select";
|
||||||
|
import tabSex from '../constSex';
|
||||||
|
import tabNat from '../constNat';
|
||||||
|
import { PickerGreySmall } from '../components/PickerGreySmall';
|
||||||
|
import { loginUser } from '../redux/features/currentUserSlice';
|
||||||
|
import { RootState } from '../redux/store';
|
||||||
|
import { updateImpossibleBirthDate, updateInvalidPassword, updateInvalidPseudo, updateTooLongPseudo, updateTooShortPassword, updateUndefinedBirthDate, updateUndefinedNationality, updateUndefinedPassword, updateUndefinedPseudo, updateUndefinedSex } from '../redux/features/credentialErrorsSlice';
|
||||||
|
import { getSystemErrorMap } from 'util';
|
||||||
|
import RNDateTimePicker from '@react-native-community/datetimepicker';
|
||||||
|
|
||||||
|
function SignUp(props: { navigation: any; }) {
|
||||||
|
const { navigation } = props
|
||||||
|
|
||||||
|
const [pseudo, setPseudo] = useState('');
|
||||||
|
const [password, setPassword] = useState('');
|
||||||
|
const [date, setDate] = useState(new Date())
|
||||||
|
|
||||||
|
|
||||||
|
function onDateSelected(event : DateTimePickerEvent, value : Date | undefined) {
|
||||||
|
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={tabNat} />
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={{width: '60%', alignItems: 'center'}}>
|
||||||
|
<Text style={styles.text}>Sexe</Text>
|
||||||
|
<PickerGreySmall title='Choisir le sexe' valueChange={(value:string) => setSelectedSex(value)} values={tabSex} />
|
||||||
|
</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
|
@ -0,0 +1,40 @@
|
|||||||
|
import { StatusBar } from 'expo-status-bar'
|
||||||
|
import { View } from 'react-native'
|
||||||
|
import React from 'react';
|
||||||
|
import stylesScreen from './style/screens.style'
|
||||||
|
import { TopBar } from '../components/TopBar';
|
||||||
|
import { BotBar } from '../components/BotBar';
|
||||||
|
import { FlatList } from 'react-native-gesture-handler';
|
||||||
|
import { SkinComponent } from '../components/Skin';
|
||||||
|
import tabSkinApp from '../constSkin';
|
||||||
|
import { ScreenIndicator } from '../components/ScreenIndicator';
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { RootState } from '../redux/store';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function SkinList(props: { navigation: any; }) {
|
||||||
|
const { navigation } = props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={stylesScreen.container}>
|
||||||
|
<TopBar
|
||||||
|
nav={navigation}
|
||||||
|
/>
|
||||||
|
<View style={stylesScreen.bodyStart}>
|
||||||
|
<ScreenIndicator title='Mes Skins'/>
|
||||||
|
<FlatList
|
||||||
|
data={tabSkinApp}
|
||||||
|
numColumns={2}
|
||||||
|
columnWrapperStyle={{ flex: 1, justifyContent: "space-around"}}
|
||||||
|
keyExtractor={item =>item.getSkinName()}
|
||||||
|
renderItem={({item}) => <SkinComponent skin={item} state='liste'/>} />
|
||||||
|
</View>
|
||||||
|
<BotBar
|
||||||
|
nav={navigation}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SkinList
|
@ -1,156 +1,40 @@
|
|||||||
import { StatusBar } from 'expo-status-bar'
|
import { StatusBar } from 'expo-status-bar'
|
||||||
import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native'
|
import { View } from 'react-native'
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import stylesScreen from './style/screens.style';
|
||||||
const avatar = require('../../assets/Icons/BobClassic.png');
|
import { TopBar } from '../components/TopBar';
|
||||||
const engrenage = require('../../assets/Icons/UnSelected/Cogs.png');
|
import { BotBar } from '../components/BotBar';
|
||||||
const gamepad = require('../../assets/Icons/UnSelected/Gamepad.png');
|
import { FlatList } from 'react-native-gesture-handler';
|
||||||
const message = require('../../assets/Icons/UnSelected/Chat.png');
|
import { SkinComponent } from '../components/Skin';
|
||||||
const store = require('../../assets/Icons/Selected/Store.png');
|
import { ScreenIndicator } from '../components/ScreenIndicator';
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { RootState } from '../redux/store';
|
||||||
|
|
||||||
function Store(props: { navigation: any; }) {
|
function Store(props: { navigation: any; }) {
|
||||||
const { navigation } = props
|
const { navigation } = props
|
||||||
return (
|
|
||||||
<View style={styles.container}>
|
|
||||||
<View style={styles.header}>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Profile')}>
|
|
||||||
<Image
|
|
||||||
style={styles.avatar}
|
|
||||||
source={avatar}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
<Text style={styles.titre}>BOB PARTY</Text>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Settings')}>
|
|
||||||
<Image
|
|
||||||
style={styles.engrenage}
|
|
||||||
source={engrenage}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
|
||||||
<View style={styles.body}>
|
|
||||||
<Text style={styles.text}>couille</Text>
|
|
||||||
</View>
|
|
||||||
<View style={styles.footer}>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Chat')}>
|
|
||||||
<Image
|
|
||||||
style={styles.iconFooter}
|
|
||||||
source={message}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
<Pressable onPress={() => navigation.navigate('Home')}>
|
|
||||||
<Image
|
|
||||||
style={styles.iconFooter}
|
|
||||||
source={gamepad}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
<Pressable >
|
|
||||||
<Image
|
|
||||||
style={styles.iconStore}
|
|
||||||
source={store}
|
|
||||||
/>
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
|
||||||
|
|
||||||
function Button(props: { onPress: any; title?: any | undefined; }) {
|
|
||||||
const { onPress, title = 'Save' } = props;
|
|
||||||
return (
|
return (
|
||||||
<Pressable style={styles.button} onPress={onPress}>
|
<View style={stylesScreen.container}>
|
||||||
<Text style={styles.text}>{title}</Text>
|
<TopBar
|
||||||
</Pressable>
|
nav={navigation}
|
||||||
|
/>
|
||||||
|
<View style={stylesScreen.bodyStart}>
|
||||||
|
<ScreenIndicator title='Store'/>
|
||||||
|
<FlatList
|
||||||
|
data={currentUser.getTabSkin()}
|
||||||
|
numColumns={2}
|
||||||
|
columnWrapperStyle={{ flex: 1, justifyContent: "space-around"}}
|
||||||
|
keyExtractor={item =>item.getSkinName()}
|
||||||
|
renderItem={({item}) => <SkinComponent skin={item} state='shop'/>} />
|
||||||
|
</View>
|
||||||
|
<BotBar
|
||||||
|
nav={navigation}
|
||||||
|
state='Store'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
body: {
|
|
||||||
flex: 1,
|
|
||||||
flexDirection: 'column',
|
|
||||||
alignItems: 'flex-start',
|
|
||||||
width: '70%',
|
|
||||||
},
|
|
||||||
|
|
||||||
container: {
|
|
||||||
flex: 1,
|
|
||||||
backgroundColor: "#45444E",
|
|
||||||
flexDirection: "column",
|
|
||||||
justifyContent: "flex-start",
|
|
||||||
alignItems: "center",
|
|
||||||
},
|
|
||||||
button: {
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
height: '30%',
|
|
||||||
width: '100%',
|
|
||||||
marginTop: '10%',
|
|
||||||
paddingVertical: 12,
|
|
||||||
paddingHorizontal: 32,
|
|
||||||
borderRadius: 10,
|
|
||||||
elevation: 3,
|
|
||||||
backgroundColor: '#0085FF',
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
fontSize: 16,
|
|
||||||
lineHeight: 21,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
letterSpacing: 0.25,
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
flex : 0.15,
|
|
||||||
width: '100%',
|
|
||||||
flexDirection: 'row',
|
|
||||||
backgroundColor: '#2D2C33',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-around',
|
|
||||||
},
|
|
||||||
titre: {
|
|
||||||
flex: 0.7,
|
|
||||||
flexDirection: 'column',
|
|
||||||
textAlign: 'center',
|
|
||||||
fontSize: 30,
|
|
||||||
fontFamily: 'Helvetica',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
letterSpacing: 0.25,
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
engrenage: {
|
|
||||||
borderRadius: 50,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
avatar: {
|
|
||||||
borderRadius: 50,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
|
|
||||||
footer: {
|
|
||||||
flex: 0.15,
|
|
||||||
flexDirection: 'row',
|
|
||||||
backgroundColor: '#2D2C33',
|
|
||||||
flexWrap: 'wrap',
|
|
||||||
width: '100%',
|
|
||||||
justifyContent: 'space-evenly',
|
|
||||||
},
|
|
||||||
iconFooter: {
|
|
||||||
marginBottom: 25,
|
|
||||||
marginTop: 10,
|
|
||||||
width: 65,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
iconStore: {
|
|
||||||
marginBottom: 25,
|
|
||||||
marginTop: 10,
|
|
||||||
marginLeft: 7,
|
|
||||||
marginRight: 8,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default Store
|
export default Store
|
@ -0,0 +1,52 @@
|
|||||||
|
import { StyleSheet } from "react-native";
|
||||||
|
|
||||||
|
const coinSkinGap = 10;
|
||||||
|
const infoGap = 20;
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
coinSkinView: {
|
||||||
|
flexDirection:'row',
|
||||||
|
},
|
||||||
|
coinView: {
|
||||||
|
width: '50%',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
skinView: {
|
||||||
|
width: '50%',
|
||||||
|
},
|
||||||
|
coin: {
|
||||||
|
width: 75,
|
||||||
|
height: 75,
|
||||||
|
marginVertical: (coinSkinGap/2),
|
||||||
|
},
|
||||||
|
coinText: {
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 21,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
marginVertical: (coinSkinGap/2),
|
||||||
|
},
|
||||||
|
infoView: {
|
||||||
|
marginLeft: '5%',
|
||||||
|
marginTop: '5%',
|
||||||
|
},
|
||||||
|
infoText: {
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 21,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
marginVertical: (infoGap/2),
|
||||||
|
},
|
||||||
|
pseudoText: {
|
||||||
|
fontSize: 24,
|
||||||
|
lineHeight: 21,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
marginTop :25,
|
||||||
|
alignSelf: 'center',
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,32 @@
|
|||||||
|
import { StyleSheet } from "react-native";
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
textID: {
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 21,
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
textAlign: 'right',
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 21,
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
fontSize: 20,
|
||||||
|
lineHeight: 21,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
letterSpacing: 0.25,
|
||||||
|
color: 'white',
|
||||||
|
marginTop: 15,
|
||||||
|
},
|
||||||
|
infoView: {
|
||||||
|
borderColor: '#2D2C33',
|
||||||
|
borderWidth: 2,
|
||||||
|
width: '90%',
|
||||||
|
margin: 15,
|
||||||
|
padding: 15,
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1,34 @@
|
|||||||
|
import { StyleSheet } from "react-native";
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
button: {
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
height: 50,
|
||||||
|
width: 225,
|
||||||
|
marginTop: '15%',
|
||||||
|
margin:'5%',
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
textInput: {
|
||||||
|
width: '80%',
|
||||||
|
height: '5%',
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
import { StyleSheet } from "react-native";
|
||||||
|
|
||||||
|
export default StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: '#45444E',
|
||||||
|
flexDirection: "column",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
bodyStart: {
|
||||||
|
flex: 1,
|
||||||
|
flexDirection: 'column',
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
bodyStartCenter: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
bodyCenter: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
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(): 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): 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): 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): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deleteConversation methode that delete a Conversation in the data management system
|
||||||
|
* c the Conversation we want to delete
|
||||||
|
*/
|
||||||
|
deleteConversation(c:Conversation):void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateConversation methode that update a Conversation in the data management system
|
||||||
|
* c the Conversation we want to update
|
||||||
|
*/
|
||||||
|
updateConversation(c:Conversation): void;
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
import { Match } from "../../core/match";
|
||||||
|
|
||||||
|
export default interface ILoaderMatch{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadAllMatch methode that load every Match from the data management system
|
||||||
|
* return an array of Match
|
||||||
|
*/
|
||||||
|
loadAllMatch(): 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): Match | null;
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
import { Match } from "../../core/match";
|
||||||
|
|
||||||
|
export default interface ISaverMatch{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* saveMatch methode that save a Match in the data management system
|
||||||
|
* m the Match we want to save
|
||||||
|
*/
|
||||||
|
|
||||||
|
saveMatch(m:Match): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deleteMatch methode that delete a Match in the data management system
|
||||||
|
* m the Match we want to delete
|
||||||
|
*/
|
||||||
|
deleteMatch(m:Match):void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateMatch methode that update a Match in the data management system
|
||||||
|
* m the Match we want to update
|
||||||
|
*/
|
||||||
|
updateMatch(m:Match): void;
|
||||||
|
}
|
@ -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(): 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): 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): 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): void;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
import { Conversation } from "../../core/conversation";
|
||||||
|
import { Match } from "../../core/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(): 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:string): 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): 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): User | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadUserByMatch methode that load every user in a game
|
||||||
|
* return an array of User
|
||||||
|
*/
|
||||||
|
loadUserByMatch(m:Match): User[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* laodUserByConversation methode that load every user in a Conversation
|
||||||
|
* return an array of User
|
||||||
|
*/
|
||||||
|
laodUserByConversation(c:Conversation): User[];
|
||||||
|
}
|
@ -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(u:User): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deleteUser methode that delete a User in the data management system
|
||||||
|
* u the user we want to delete
|
||||||
|
*/
|
||||||
|
deleteUser(u:User):void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateUser methode that update a User in the data management system
|
||||||
|
* u the user we want to update
|
||||||
|
*/
|
||||||
|
updateUser(u:User): void;
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
import { User } from "../../core/User/user";
|
||||||
|
import ILoaderUser from "./ILoaderUser";
|
||||||
|
import ISaverUser from "./ISaverUser";
|
||||||
|
|
||||||
|
export default class ManagerUser{
|
||||||
|
|
||||||
|
private currentUser: User | null;
|
||||||
|
|
||||||
|
private loaderUser: ILoaderUser;
|
||||||
|
|
||||||
|
private saverUser: ISaverUser;
|
||||||
|
|
||||||
|
constructor(loader:ILoaderUser, saver:ISaverUser){
|
||||||
|
this.currentUser=null;
|
||||||
|
this.loaderUser=loader;
|
||||||
|
this.saverUser=saver;
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentUser(){
|
||||||
|
return this.currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentUser(u:User){
|
||||||
|
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{
|
||||||
|
|
||||||
|
saveUser(u: User): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
deleteUser(u: User): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateUser(u: User): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
import { Conversation } from "../../core/conversation";
|
||||||
|
import { Match } from "../../core/match";
|
||||||
|
import { User } from "../../core/User/user";
|
||||||
|
import ILoaderUser from "./ILoaderUser";
|
||||||
|
|
||||||
|
export default class LoaderUserApi implements ILoaderUser{
|
||||||
|
|
||||||
|
loadAllUser(): User[] {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
loadByID(id: string): User | null {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
loadByUsername(username: string): User | null {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
loadByUsernamePassword(username: string, password: string): User | null {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
loadUserByMatch(m: Match): User[] {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
laodUserByConversation(c: Conversation): User[] {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
import { User } from "../../core/User/user";
|
||||||
|
import ISaverUser from "./ISaverUser";
|
||||||
|
|
||||||
|
|
||||||
|
export default class SaverUserApi implements ISaverUser{
|
||||||
|
|
||||||
|
saveUser(u: User): void {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
deleteUser(u: User): void {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
updateUser(u: User): void {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
import { Conversation } from "../../core/conversation";
|
||||||
|
import { Match } from "../../core/match";
|
||||||
|
import { Skin } from "../../core/skin";
|
||||||
|
import { User } from "../../core/User/user";
|
||||||
|
import ILoaderUser from "./ILoaderUser";
|
||||||
|
|
||||||
|
export default class StubUser implements ILoaderUser{
|
||||||
|
|
||||||
|
tabUS:User[]=[
|
||||||
|
new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
|
||||||
|
new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
|
||||||
|
new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)],),
|
||||||
|
new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
|
||||||
|
];
|
||||||
|
|
||||||
|
loadAllUser(): User[] {
|
||||||
|
return this.tabUS;
|
||||||
|
}
|
||||||
|
loadByID(id: string): User | null {
|
||||||
|
for(let u of this.tabUS){
|
||||||
|
if (u.getId()==id){
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
loadByUsername(username: string): User | null {
|
||||||
|
for(let u of this.tabUS){
|
||||||
|
if (u.getUsername()==username){
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
loadByUsernamePassword(username: string, password: string): User | null {
|
||||||
|
for(let u of this.tabUS){
|
||||||
|
if (u.getUsername()==username && u.getPassword()==password){
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadUserByMatch(m: Match): User[] {
|
||||||
|
let tabUser:User[]=[];
|
||||||
|
m.getTabUsers().forEach(u => {
|
||||||
|
tabUser.push(u);
|
||||||
|
});
|
||||||
|
return tabUser;
|
||||||
|
}
|
||||||
|
laodUserByConversation(c: Conversation): User[] {
|
||||||
|
let tabUser:User[]=[];
|
||||||
|
c.getTabUser().forEach(u => {
|
||||||
|
tabUser.push(u);
|
||||||
|
});
|
||||||
|
return tabUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|