diff --git a/bob_party/App.tsx b/bob_party/App.tsx
index f3badc9..66568f5 100644
--- a/bob_party/App.tsx
+++ b/bob_party/App.tsx
@@ -1,3 +1,6 @@
+import MainTabNavigator from './src/navigation/AppNavigator'
+import store from './src/redux/store'
+import { Provider } from 'react-redux'
import LoaderUserApi from './src/services/userServices/loaderUserApi'
import ManagerUser from './src/services/userServices/ManagerUser'
import FakeSaverUser from './src/services/userServices/fakeSaverUser'
@@ -6,7 +9,6 @@ import React, { useCallback } from 'react';
import { useUserStore } from './userContext';
import stylesScreen from './src/screens/style/screens.style'
import { User } from './src/core/User/user';
-import tabSkinApp from './src/constSkin';
import { stat } from 'fs';
import StubUser from './src/services/userServices/stub';
@@ -57,12 +59,9 @@ export const MANAGER_USER = new ManagerUser(new StubUser, new FakeSaverUser);
return (
-
-
-
-
-
-
+
+
+
);
}
@@ -78,6 +77,4 @@ export const MANAGER_USER = new ManagerUser(new StubUser, new FakeSaverUser);
Money {test}
);
- };
-
-
+ };
\ No newline at end of file
diff --git a/bob_party/assets/BobsSkins/unlogged.png b/bob_party/assets/BobsSkins/unlogged.png
new file mode 100644
index 0000000..651da3e
Binary files /dev/null and b/bob_party/assets/BobsSkins/unlogged.png differ
diff --git a/bob_party/package.json b/bob_party/package.json
index b10d8ba..e2a99bf 100644
--- a/bob_party/package.json
+++ b/bob_party/package.json
@@ -9,7 +9,7 @@
"web": "expo start --web"
},
"dependencies": {
- "@expo/webpack-config": "^0.17.0",
+ "@react-native-community/datetimepicker": "6.2.0",
"@react-native-picker/picker": "2.4.2",
"@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13",
@@ -24,6 +24,7 @@
"react": "18.0.0",
"react-dom": "18.0.0",
"react-native": "^0.69.6",
+ "react-native-date-picker": "^4.2.5",
"react-native-dialog": "^9.2.2",
"react-native-dialog-input": "^1.0.8",
"react-native-gesture-handler": "~2.5.0",
diff --git a/bob_party/src/components/PickerGreySmall.tsx b/bob_party/src/components/PickerGreySmall.tsx
new file mode 100644
index 0000000..ba0d5b3
--- /dev/null
+++ b/bob_party/src/components/PickerGreySmall.tsx
@@ -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(
+
+ )
+ }
\ No newline at end of file
diff --git a/bob_party/src/components/Skin.tsx b/bob_party/src/components/Skin.tsx
index 2caf613..5008344 100644
--- a/bob_party/src/components/Skin.tsx
+++ b/bob_party/src/components/Skin.tsx
@@ -7,8 +7,9 @@ import { Skin } from "../core/skin"
Importing the correct stylesheet
*/
import styles from "./style/Skin.style"
-import { useDispatch } from "react-redux"
-import { updateSkin } from "../redux/features/currentUserSlice"
+import { useDispatch, useSelector } from "react-redux"
+import { loginUser } from "../redux/features/currentUserSlice"
+import { RootState } from "../redux/store"
export const SkinComponent :
/* Parameters :
@@ -19,6 +20,8 @@ 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
@@ -46,7 +49,7 @@ FC<{skin: Skin, state: String}> =
)
case 'liste':
return(
- dispatch(updateSkin(skin))} style={styles.imageWrapper}>
+ {currentUser.setCurrentSkin(skin); dispatch(loginUser(currentUser))}} style={styles.imageWrapper}>
{skin.getSkinName()}
=
({nav, state}) =>
{
- const currentUser = useSelector((state: RootState) => state.currentUser.value)[0];
+ 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
diff --git a/bob_party/src/components/style/PickerGreySmall.js b/bob_party/src/components/style/PickerGreySmall.js
new file mode 100644
index 0000000..3f12ac2
--- /dev/null
+++ b/bob_party/src/components/style/PickerGreySmall.js
@@ -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',
+ },
+ }
+)
\ No newline at end of file
diff --git a/bob_party/src/constCov.ts b/bob_party/src/constCov.ts
deleted file mode 100644
index f0dee15..0000000
--- a/bob_party/src/constCov.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { Message } from "./core/message"
-import { Conversation } from "./core/conversation"
-import tabSkinApp from './constSkin'
-import { User } from "./core/User/user";
-
-
-let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, []);
-let UserTest:User=new User("48", "Wesh Wesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[5], tabSkinApp, []);
-
-let tabMessageTest:Message[]=[
- new Message("Salut", UserActu, new Date(2022,12,12,11,30,40)),
- new Message("Wesh", UserTest, new Date(2022,12,13,12,20,40)),
- new Message("Ca va", UserActu, new Date(2022,12,14, 12, 30, 35)),
- new Message("Ouais et toi?", UserTest, new Date(2022,12,14,12,35,0)),
-]
-
-let tabUS:User[]=[UserActu, UserTest];
-
-let conv = new Conversation(tabUS, tabMessageTest, "le super nom");
-
-let tabConv:Conversation[]=[conv];
-
-export default tabConv;
-
-
diff --git a/bob_party/src/constNat.ts b/bob_party/src/constNat.ts
deleted file mode 100644
index 4ea8813..0000000
--- a/bob_party/src/constNat.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-
-const tabNat = [
- { label: "France", value: "Français" },
- { label: "Allemagne", value: "Allemand" },
- { label: "Espagne", value: "Espagnol" },
- { label: "Royaume-Uni", value: "Anglais" },
- { label: "États-Unis", value: "Américain" },
- { label: "Italie", value: "Italien" },
-]
-
-export default tabNat;
\ No newline at end of file
diff --git a/bob_party/src/constSex.ts b/bob_party/src/constSex.ts
index 373c68d..4e955d5 100644
--- a/bob_party/src/constSex.ts
+++ b/bob_party/src/constSex.ts
@@ -1,7 +1,7 @@
const tabSex = [
{ label: "Homme", value: "Homme" },
- { label: "Femmme", value: "Femmme" },
+ { label: "Femme", value: "Femme" },
{ label: "Non-binaire", value: "Non-binaire" },
{ label: "Autre", value: "Autre" },
]
diff --git a/bob_party/src/constSkin.ts b/bob_party/src/constSkin.ts
deleted file mode 100644
index a5c4d54..0000000
--- a/bob_party/src/constSkin.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { Skin } from "./core/skin";
-
-let tabSkinApp:Skin[]=[
- new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0),
- new Skin("S0002", "Bob Blue",require('bob_party/assets/BobsSkins/BobBlue.png'), 100),
- new Skin("S0003", "Bob BW",require('bob_party/assets/BobsSkins/BobBW.png'), 100),
- new Skin("S0004", "Bob Green",require('bob_party/assets/BobsSkins/BobGreen.png'), 100),
- new Skin("S0005", "Bob P&T",require('bob_party/assets/BobsSkins/BobPinkTurquoise.png'), 100),
- new Skin("S0006", "Bob Red",require('bob_party/assets/BobsSkins/BobRed.png'), 100),
- new Skin("S0007", "Bob Cute",require('bob_party/assets/BobsSkins/BobYellowGreenBlueHeart.png'), 100),
-]
-
-
-export default tabSkinApp;
\ No newline at end of file
diff --git a/bob_party/src/constUser.ts b/bob_party/src/constUser.ts
deleted file mode 100644
index d4151f7..0000000
--- a/bob_party/src/constUser.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Message } from "./core/message"
-import { Conversation } from "./core/conversation"
-import tabSkinApp from './constSkin'
-import { User } from "./core/User/user";
-import tabConv from "./constCov";
-
-
-let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, []);
-let UserTest:User=new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[2], tabSkinApp, []);
-let Alban:User=new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, tabSkinApp[1], tabSkinApp, tabConv);
-let Fefe63:User=new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp, []);
-
-let tabUS:User[]=[UserActu, UserTest, Alban, Fefe63];
-
-export default tabUS;
\ No newline at end of file
diff --git a/bob_party/src/core/Auth/login.ts b/bob_party/src/core/Auth/login.ts
new file mode 100644
index 0000000..971d454
--- /dev/null
+++ b/bob_party/src/core/Auth/login.ts
@@ -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));
+ }
+};
+
diff --git a/bob_party/src/core/Auth/newUser.ts b/bob_party/src/core/Auth/newUser.ts
new file mode 100644
index 0000000..d8a357c
--- /dev/null
+++ b/bob_party/src/core/Auth/newUser.ts
@@ -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');
+ }
+};
\ No newline at end of file
diff --git a/bob_party/src/core/conversation.ts b/bob_party/src/core/conversation.ts
index 522e866..5d4eed3 100644
--- a/bob_party/src/core/conversation.ts
+++ b/bob_party/src/core/conversation.ts
@@ -3,12 +3,14 @@ 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(tabUser: User[], tabMessage:Message[], name:string){
+ constructor(id: string, tabUser: User[], tabMessage:Message[], name:string){
+ this.Id=id;
this.tabUser=[...tabUser];
this.tabMessage=[...tabMessage];
this.name=name;
@@ -36,6 +38,11 @@ export class Conversation{
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;
diff --git a/bob_party/src/core/match.ts b/bob_party/src/core/match.ts
index d7b7c10..4ecfacc 100644
--- a/bob_party/src/core/match.ts
+++ b/bob_party/src/core/match.ts
@@ -9,7 +9,7 @@ export abstract class Match{
private tabUsers:User[];
private theGame:Game;
- constructor(code:string, tabUser:User[], game:Game){
+ constructor(code:string, inGame:Boolean, tabUser:User[], game:Game){
this.code=code;
this.inGame=false;
this.tabUsers=[...tabUser];
@@ -67,6 +67,6 @@ export abstract class Match{
}
- abstract updatePostMatch(user:User, coins:number):void;
+ abstract updatePostMatch(user:User, points:number):void;
}
\ No newline at end of file
diff --git a/bob_party/src/core/matchCasino.ts b/bob_party/src/core/matchCasino.ts
index 7b229f0..f758b48 100644
--- a/bob_party/src/core/matchCasino.ts
+++ b/bob_party/src/core/matchCasino.ts
@@ -6,13 +6,13 @@ import { ManagerCoinsUser } from "./User/userCoinsModifier";
export class MatchMulti extends Match{
- constructor(code:string, tabUser:User[], game:GameCasino){
- super(code, tabUser, game);
+ constructor(code:string, inGame:Boolean, tabUser:User[], game:GameCasino){
+ super(code, inGame, tabUser, game);
}
- updatePostMatch(user:User, coins: number): void {
+ updatePostMatch(user:User, points: number): void {
const manage= new ManagerCoinsUser();
- manage.addCoins(user, this.getGame().coinsCalculator(coins));
+ manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}
\ No newline at end of file
diff --git a/bob_party/src/core/matchMulti.ts b/bob_party/src/core/matchMulti.ts
index 6473f32..2003035 100644
--- a/bob_party/src/core/matchMulti.ts
+++ b/bob_party/src/core/matchMulti.ts
@@ -6,12 +6,12 @@ import { ManagerCoinsUser } from "./User/userCoinsModifier";
export class MatchMulti extends Match{
- constructor(code:string, tabUser:User[], game:GameMulti){
- super(code, tabUser, game);
+ constructor(code:string, inGame:Boolean, tabUser:User[], game:GameMulti){
+ super(code, inGame, tabUser, game);
}
- updatePostMatch(user:User, coins: number): void {
+ updatePostMatch(user:User, points: number): void {
const manage= new ManagerCoinsUser();
- manage.addCoins(user, this.getGame().coinsCalculator(coins));
+ manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}
\ No newline at end of file
diff --git a/bob_party/src/core/matchSolo.ts b/bob_party/src/core/matchSolo.ts
index 159c4cf..1fd2287 100644
--- a/bob_party/src/core/matchSolo.ts
+++ b/bob_party/src/core/matchSolo.ts
@@ -6,8 +6,8 @@ import { ManagerCoinsUser } from "./User/userCoinsModifier";
export class MatchSolo extends Match{
- constructor(code:string, tabUser:User[], game:GameSolo){
- super(code, tabUser, game);
+ constructor(code:string, inGame:Boolean, tabUser:User[], game:GameSolo){
+ super(code, inGame, tabUser, game);
}
updatePostMatch(user:User, points: number): void {
diff --git a/bob_party/src/core/message.ts b/bob_party/src/core/message.ts
index 57ba52a..087833d 100644
--- a/bob_party/src/core/message.ts
+++ b/bob_party/src/core/message.ts
@@ -2,12 +2,14 @@ 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(content: string, sender:User, dateEnvoie:Date){
+ constructor(id: string, content: string, sender:User, dateEnvoie:Date){
+ this.Id=id;
this.Content=content;
this.Sender=sender;
this.DateEnvoie=dateEnvoie;
@@ -28,6 +30,11 @@ export class Message{
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;
diff --git a/bob_party/src/core/tests/conversation.test.ts b/bob_party/src/core/tests/conversation.test.ts
index 82f9062..c7ea9be 100644
--- a/bob_party/src/core/tests/conversation.test.ts
+++ b/bob_party/src/core/tests/conversation.test.ts
@@ -1,3 +1,4 @@
+import exp from 'constants';
import { Conversation } from '../Conversation';
import { Message } from '../Message';
import { Skin } from '../Skin';
@@ -14,26 +15,29 @@ let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8
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('Bob Party est le meilleur projet', usr, theDate2);
+let mess = new Message('M0001', 'Bob Party est le meilleur projet', usr, theDate2);
let tabU:User[] = [usr, usr2];
-let mess2 = new Message('Oui tout à fait', usr2, theDate);
-let mess3 = new Message('Mais oui trop de ouf', usr, theDate3);
+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(tabU, tabM, 'the conv');
+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 the conv', () => {
- expect(convo.getName()).toBe('the conv');
- })
it('should return Oui tout à fait (mess2)', () => {
expect(convo.getLastMessage()).toBe('Oui tout à fait');
})
@@ -42,6 +46,8 @@ describe('Conversation get tests', () => {
// Setting new value
convo.setName('THE conv');
+convo.ajouterUser(usr3);
+convo.ajouterMessage(mess3);
// Set test
@@ -49,4 +55,13 @@ 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');
+ })
})
\ No newline at end of file
diff --git a/bob_party/src/core/tests/game.test.ts b/bob_party/src/core/tests/game.test.ts
index 3d1bc42..1912f95 100644
--- a/bob_party/src/core/tests/game.test.ts
+++ b/bob_party/src/core/tests/game.test.ts
@@ -37,7 +37,6 @@ describe('GameSolo get tests', () => {
// Setting new values
-game.setId('newId');
game.setGameSource('trop cool le jeu');
game.setImageSource(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
game.setName('beau jeu');
@@ -47,9 +46,6 @@ game.setNbPlayerMax(3);
// Set tests
describe('GameSolo set tests', () => {
- it('should return newId', () => {
- expect(game.getId()).toBe('newId');
- })
it('should return beau jeu', () => {
expect(game.getName()).toBe('beau jeu');
})
diff --git a/bob_party/src/core/tests/gameCasino.test.ts b/bob_party/src/core/tests/gameCasino.test.ts
index 6900cd3..27ffeb9 100644
--- a/bob_party/src/core/tests/gameCasino.test.ts
+++ b/bob_party/src/core/tests/gameCasino.test.ts
@@ -3,7 +3,7 @@ import { GameCasino } from '../GameCasino';
// Instances
-let game = new GameCasino("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5);
+let game = new GameCasino("GC001", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5);
// Get tests
@@ -50,4 +50,13 @@ describe('GameCasino set tests', () => {
})
it('should return 4', () => {
expect(game.getNbPlayerMin()).toBe(4);
- })
\ No newline at end of file
+ })
+})
+
+
+// Coins Calculator Tests
+describe('Coins calculator tests', () => {
+ it('should return 200', () => {
+ expect(game.coinsCalculator(200)).toBe(200);
+ })
+})
\ No newline at end of file
diff --git a/bob_party/src/core/tests/gameMulti.test.ts b/bob_party/src/core/tests/gameMulti.test.ts
index 1c74a48..c38af68 100644
--- a/bob_party/src/core/tests/gameMulti.test.ts
+++ b/bob_party/src/core/tests/gameMulti.test.ts
@@ -6,16 +6,19 @@ import { GameCasino } from '../GameCasino';
// Instances
let myMap = new Map([
- [50, 3],
- [75, 4],
- [100, 5],
- [150, 6]
+ [4, 1],
+ [3, 3],
+ [2, 5],
+ [1, 10]
]);
-let game = new GameMulti("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5, myMap);
+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');
})
@@ -62,4 +65,21 @@ describe('GameMulti set tests', () => {
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);
+ })
})
\ No newline at end of file
diff --git a/bob_party/src/core/tests/gameSolo.test.ts b/bob_party/src/core/tests/gameSolo.test.ts
index 27e59b7..dbd2332 100644
--- a/bob_party/src/core/tests/gameSolo.test.ts
+++ b/bob_party/src/core/tests/gameSolo.test.ts
@@ -1,3 +1,4 @@
+import exp from 'constants';
import { GameSolo } from '../GameSolo';
// Instances
@@ -7,11 +8,14 @@ let myMap = new Map([
[100, 5],
[150, 6]
]);
-let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
+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');
})
@@ -58,4 +62,21 @@ describe('GameSolo set tests', () => {
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);
+ })
})
\ No newline at end of file
diff --git a/bob_party/src/core/tests/matchSolo.test.ts b/bob_party/src/core/tests/matchSolo.test.ts
index ea8d483..94f4d72 100644
--- a/bob_party/src/core/tests/matchSolo.test.ts
+++ b/bob_party/src/core/tests/matchSolo.test.ts
@@ -11,8 +11,8 @@ let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/Bob
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 conv:Conversation[] = [];
-let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv);
+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([
[50, 3],
@@ -20,10 +20,10 @@ let myMap = new Map([
[100, 5],
[150, 6]
]);
-let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
+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("jeu magnifique", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "wow jeu", 1, 1, myMap)
+let game2 = new GameSolo("G0002", "jeu magnifique", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "wow jeu", 1, 1, myMap)
// Get tests
@@ -60,4 +60,25 @@ describe('Match set tests', () => {
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);
+ })
})
\ No newline at end of file
diff --git a/bob_party/src/core/tests/message.test.ts b/bob_party/src/core/tests/message.test.ts
index a157f65..63bbba3 100644
--- a/bob_party/src/core/tests/message.test.ts
+++ b/bob_party/src/core/tests/message.test.ts
@@ -8,15 +8,18 @@ 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, conv);
-let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab, conv);
+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('Bob Party est le meilleur projet', usr, theDate);
+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');
})
diff --git a/bob_party/src/navigation/AppNavigator.tsx b/bob_party/src/navigation/AppNavigator.tsx
index c9821e3..0a299bd 100644
--- a/bob_party/src/navigation/AppNavigator.tsx
+++ b/bob_party/src/navigation/AppNavigator.tsx
@@ -11,7 +11,7 @@ import Profile from '../screens/Profile'
import SkinList from '../screens/SkinList'
import GameChoice from '../screens/GameChoice'
import SignIn from '../screens/SignIn'
-//import SignUp from '../screens/SignUp'
+import SignUp from '../screens/SignUp'
@@ -87,6 +87,7 @@ function MainTabNavigator() {
+
)
diff --git a/bob_party/src/redux/features/credentialErrorsSlice.ts b/bob_party/src/redux/features/credentialErrorsSlice.ts
new file mode 100644
index 0000000..8376956
--- /dev/null
+++ b/bob_party/src/redux/features/credentialErrorsSlice.ts
@@ -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) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ incorrectCredentials: action.payload
+ }
+ }
+ },
+ updateTooLongPseudo: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ tooShortPseudo: action.payload
+ }
+ }
+ },
+ updateTooLongPassword: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ tooLongPassword: action.payload
+ }
+ }
+ },
+ updateTooShortPassword: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ tooShortPassword: action.payload
+ }
+ }
+ },
+ updateInvalidPseudo: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ invalidPseudo: action.payload
+ }
+ }
+ },
+ updateInvalidPassword: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ invalidPassword: action.payload
+ }
+ }
+ },
+ updateImpossibleBirthDate: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ impossibleBirthDate: action.payload
+ }
+ }
+ },
+ updateUndefinedPseudo: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ undefinedPseudo: action.payload
+ }
+ }
+ },
+ updateUndefinedPassword: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ undefinedPassword: action.payload
+ }
+ }
+ },
+ updateUndefinedBirthDate: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ undefinedBirthDate: action.payload
+ }
+ }
+ },
+ updateUndefinedNationality: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ undefinedNationality: action.payload
+ }
+ }
+ },
+ updateUndefinedSex: (state, action: PayloadAction) => {
+ return {
+ ...state,
+ newUserErrorList:{
+ ...state.newUserErrorList,
+ undefinedSex: action.payload
+ }
+ }
+ },
+ updateAlreadyUsedPseudo: (state, action: PayloadAction) => {
+ 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;
\ No newline at end of file
diff --git a/bob_party/src/redux/features/currentUserSlice.ts b/bob_party/src/redux/features/currentUserSlice.ts
index 460ad02..99823ae 100644
--- a/bob_party/src/redux/features/currentUserSlice.ts
+++ b/bob_party/src/redux/features/currentUserSlice.ts
@@ -2,50 +2,65 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"
import { Skin } from "../../core/Skin";
import { User } from "../../core/User/user";
-interface currentUserState {
- value: User[]
-}
+const dateNull = new Date();
-const initialState: currentUserState = {
- value: [],
-}
+const userNull:User= new User("","","","","",dateNull);
+
+var currentUser:User = userNull;
export const currentUserSlice = createSlice({
- name: "currentUser",
- initialState,
+ name: "currentUserManager",
+ initialState : {
+ currentUser
+ },
reducers: {
loginUser: (state, action: PayloadAction) => {
- state.value.push(action.payload);
+ const newUser : User = new User(action.payload.getId(), action.payload.getUsername(),action.payload.getPassword(),action.payload.getNationality(),action.payload.getSexe(),action.payload.getDateOfBirth(), action.payload.getCurrentCoins(), action.payload.getTotalCoins(),action.payload.getGamePlayed(),action.payload.getCurrentSkin(),action.payload.getTabSkin(), action.payload.getTabConv())
+
+ state.currentUser = newUser;
},
updateSkin: (state, action: PayloadAction) =>{
- const newUser = state.value[0]
+
+
+ const newUser : User = new User(currentUser.getId(), currentUser.getUsername(),currentUser.getPassword(),currentUser.getNationality(),currentUser.getSexe(),currentUser.getDateOfBirth(), currentUser.getCurrentCoins(), currentUser.getTotalCoins(),currentUser.getGamePlayed(),currentUser.getCurrentSkin(),currentUser.getTabSkin(), currentUser.getTabConv())
+
newUser.setCurrentSkin(action.payload);
- state.value.pop();
- state.value.push(newUser);
+
+ state.currentUser = newUser;
},
updatePseudo: (state, action: PayloadAction) =>{
- const newUser = state.value[0]
+ const newUser: User = new User(currentUser.getId(), currentUser.getUsername(), currentUser.getPassword(), currentUser.getNationality(), currentUser.getSexe(), currentUser.getDateOfBirth());
+
+ console.log(currentUser);
newUser.setUsername(action.payload);
- state.value.pop();
- state.value.push(newUser);
+ return {
+ ...state,
+ currentUser: newUser,
+ }
},
updatePassword: (state, action: PayloadAction) =>{
- const newUser = state.value[0]
- newUser.setPassword(action.payload);
- state.value.pop();
- state.value.push(newUser);
+ const newUser = state.currentUser;
+ currentUser.setPassword(action.payload)
+ return {
+ ...state,
+ currentUser: newUser,
+ }
},
updateNationality: (state, action: PayloadAction) =>{
- const newUser = state.value[0]
- newUser.setNationality(action.payload);
- state.value.pop();
- state.value.push(newUser);
+ const newUser = state.currentUser;
+ currentUser.setNationality(action.payload)
+ return {
+ ...state,
+ currentUser: newUser,
+ }
},
updateSex: (state, action: PayloadAction) =>{
- const newUser = state.value[0]
- newUser.setSexe(action.payload);
- state.value.pop();
- state.value.push(newUser);
+ const newUser = state.currentUser;
+ currentUser.setSexe(action.payload)
+ return {
+ ...state,
+ currentUser: newUser,
+ }
}
},
});
diff --git a/bob_party/src/redux/store.ts b/bob_party/src/redux/store.ts
index 2f9f420..f8ece5b 100644
--- a/bob_party/src/redux/store.ts
+++ b/bob_party/src/redux/store.ts
@@ -1,5 +1,6 @@
import { configureStore } from "@reduxjs/toolkit";
import currentUserReducer from "./features/currentUserSlice";
+import credentialErrorsSlice from "./features/credentialErrorsSlice";
import { getDefaultMiddleware } from '@reduxjs/toolkit';
const customizedMiddleware = getDefaultMiddleware({
@@ -8,7 +9,8 @@ const customizedMiddleware = getDefaultMiddleware({
const store = configureStore({
reducer: {
- currentUser: currentUserReducer,
+ currentUserManager: currentUserReducer,
+ credentialErrors: credentialErrorsSlice,
},
middleware: (getDefaultMiddleware) => customizedMiddleware,
})
diff --git a/bob_party/src/screens/Chat.tsx b/bob_party/src/screens/Chat.tsx
index dedaabf..3e9b1d1 100644
--- a/bob_party/src/screens/Chat.tsx
+++ b/bob_party/src/screens/Chat.tsx
@@ -12,7 +12,7 @@ import { RootState } from '../redux/store';
function Chat(props: { navigation: any; }) {
const { navigation } = props
- const currentUser = useSelector((state: RootState) => state.currentUser.value[0]);
+ const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
return (
diff --git a/bob_party/src/screens/Home.tsx b/bob_party/src/screens/Home.tsx
index 3c5216d..dc7544e 100644
--- a/bob_party/src/screens/Home.tsx
+++ b/bob_party/src/screens/Home.tsx
@@ -19,7 +19,6 @@ function Home(props: { navigation: any; }) {
const { navigation } = props
-
return (
state.currentUser.value)[0];
-
+ const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
return (
state.currentUser.value)[0];
+ const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
const [dialogPseudoVisible, setDialogPseudoVisible] = useState(false);
const [dialogPasswordVisible, setDialogPasswordVisible] = useState(false);
- const [dialogNationalityVisible, setDialogNationalityVisible] = useState(false);
- const [dialogSexVisible, setDialogSexVisible] = useState(false);
const [selectedSex, setSelectedSex] = useState("");
const [selectedNationality, setSelectedNationality] = useState("");
@@ -50,11 +49,11 @@ function Settings(props: { navigation: any; }) {
Nationalité: {currentUser.getNationality()}
- setDialogNationalityVisible(true)} title='Changer la nationnalité'/>
+ setSelectedNationality(value)} donePress={() => dispatch(updateNationality(selectedNationality))} values={tabNat} />
Sexe: {currentUser.getSexe()}
- setDialogSexVisible(true)} title='Changer le sexe'/>
+ setSelectedSex(value)} donePress={() => dispatch(updateSex(selectedSex))} values={tabSex} />
ID: {currentUser.getId()}
@@ -78,32 +77,6 @@ function Settings(props: { navigation: any; }) {
closeDialog={ () => {setDialogPasswordVisible(false)}}>
-
- Changer de nationalité
-
- setSelectedNationality(value)}
- items={tabNat}
- />
-
- setDialogNationalityVisible(false)} />
- {dispatch(updateNationality(selectedNationality)); setDialogNationalityVisible(false)}} />
-
-
-
- Changer de sexe
-
- setSelectedSex(value)}
- items={tabSex}
- />
-
- setDialogSexVisible(false)} />
- {dispatch(updateSex(selectedSex)); setDialogSexVisible(false)}} />
-
-
);
}
diff --git a/bob_party/src/screens/SignIn.tsx b/bob_party/src/screens/SignIn.tsx
index ad7414b..ce1e681 100644
--- a/bob_party/src/screens/SignIn.tsx
+++ b/bob_party/src/screens/SignIn.tsx
@@ -1,13 +1,16 @@
import { StatusBar } from 'expo-status-bar'
-import { View, Pressable, Text} from 'react-native'
+import { View, Pressable, Text, Alert} from 'react-native'
import React, { useState } from 'react';
import stylesScreen from './style/screens.style'
import { TextInput } from 'react-native-gesture-handler';
-import tabUS from "../constUser";
-import styles from "./style/SignIn.style"
-import { useDispatch, } from 'react-redux';
+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";
@@ -15,34 +18,39 @@ import { loginUser } from '../redux/features/currentUserSlice';
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();
- function userVerif(login: string, password: string, 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');
- }
- }
+ if (errorList.incorrectCredentials){
+ Alert.alert("Pseudo ou Mot de passe incorrect");
+ dispatch(updateIncorrectCredentials(true));
}
-
+
return (
setPseudo(val)} autoCapitalize='none' />
- setPassword(val)} autoCapitalize='none' />
- userVerif(pseudo, password, navigation)}>
+ setPassword(val)} autoCapitalize='none' secureTextEntry={true}/>
+ checkCredentials(pseudo, password, dispatch, navigation)}>
Se connecter
navigation.navigate('SignUp')}>
- Pas de compte? Inscrivez vous !
+ Pas de compte? Inscrivez vous !
+
+ Ce pseudo n'exsite pas
+ dispatch(updateIncorrectCredentials(false))} />
+
+
+ Mot de passe incorrect
+ dispatch(updateIncorrectCredentials(false))} />
+
+
);
}
diff --git a/bob_party/src/screens/SignUp.tsx b/bob_party/src/screens/SignUp.tsx
index 69d2d66..3a14bc3 100644
--- a/bob_party/src/screens/SignUp.tsx
+++ b/bob_party/src/screens/SignUp.tsx
@@ -1,29 +1,142 @@
-// import { StatusBar } from 'expo-status-bar'
-// import { StyleSheet, View, ImageSourcePropType, Pressable, Text} from 'react-native'
-// import React from 'react';
-// import stylesScreen from './style/screens.style'
-// import { TextInput } from 'react-native-gesture-handler';
-// import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
-
-// import styles from "./style/SignIn.style"
-
-// function SignUp(props: { navigation: any; }) {
-// const { navigation } = props
-// return (
-//
-//
-//
-//
-//
-//
-//
-//
-//
-// S'inscrire
-//
-//
-//
-// );
-// }
-
-// export default SignUp
+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 (
+
+
+
+
+ Login
+ setPseudo(val)} autoCapitalize='none' />
+
+
+
+ Password
+ setPassword(val)} autoCapitalize='none' />
+
+
+
+
+ Date de naissance
+
+ onDateSelected(event, value)} mode='date' value={date} themeVariant='dark'/>
+
+
+
+
+ Nationalité
+
+ setSelectedNationality(value)} values={tabNat} />
+
+
+
+ Sexe
+ setSelectedSex(value)} values={tabSex} />
+
+ checkNewUserValidity(pseudo,password,date,selectedNationality,selectedSex, dispatch, navigation)}>
+ S'inscrire
+
+ navigation.navigate('SignIn')}>
+ J'ai déjà un compte
+
+
+
+ );
+}
+
+export default SignUp
diff --git a/bob_party/src/screens/SkinList.tsx b/bob_party/src/screens/SkinList.tsx
index 94b5faa..d7d8d00 100644
--- a/bob_party/src/screens/SkinList.tsx
+++ b/bob_party/src/screens/SkinList.tsx
@@ -16,8 +16,6 @@ import { RootState } from '../redux/store';
function SkinList(props: { navigation: any; }) {
const { navigation } = props
- const currentUser = useSelector((state: RootState) => state.currentUser.value[0]);
-
return (
state.currentUser.value[0]);
+ const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
return (
diff --git a/bob_party/src/screens/style/Settings.style.js b/bob_party/src/screens/style/Settings.style.js
index a1edfb3..5b12448 100644
--- a/bob_party/src/screens/style/Settings.style.js
+++ b/bob_party/src/screens/style/Settings.style.js
@@ -29,8 +29,4 @@ export default StyleSheet.create({
margin: 15,
padding: 15,
},
- RNPView: {
- alignSelf: 'center',
- padding: 20,
- }
});
\ No newline at end of file
diff --git a/bob_party/src/screens/style/SignIn.style.js b/bob_party/src/screens/style/SignIn.style.js
index 881500f..34eeeb6 100644
--- a/bob_party/src/screens/style/SignIn.style.js
+++ b/bob_party/src/screens/style/SignIn.style.js
@@ -19,14 +19,16 @@ export default StyleSheet.create({
letterSpacing: 0.25,
color: 'white',
},
- signup:{
+ textLink:{
fontSize:15,
color:'white',
textDecorationLine:"underline",
},
textInput: {
- width: '50%',
+ width: '80%',
height: '5%',
backgroundColor: 'white',
+ padding: 10,
+ marginVertical: 10,
}
});
\ No newline at end of file
diff --git a/bob_party/src/screens/style/SignUp.style.js b/bob_party/src/screens/style/SignUp.style.js
new file mode 100644
index 0000000..6889ee4
--- /dev/null
+++ b/bob_party/src/screens/style/SignUp.style.js
@@ -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",
+ },
+})
+
diff --git a/bob_party/src/screens/style/screens.style.js b/bob_party/src/screens/style/screens.style.js
index f3f0773..d994c1c 100644
--- a/bob_party/src/screens/style/screens.style.js
+++ b/bob_party/src/screens/style/screens.style.js
@@ -23,5 +23,9 @@ export default StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
width: '100%',
- },
+ },
+ RNPView: {
+ alignSelf: 'center',
+ padding: 20,
+ }
});
\ No newline at end of file
diff --git a/bob_party/src/services/userServices/ManagerUser.ts b/bob_party/src/services/userServices/ManagerUser.ts
index 350e5d7..9807230 100644
--- a/bob_party/src/services/userServices/ManagerUser.ts
+++ b/bob_party/src/services/userServices/ManagerUser.ts
@@ -1,4 +1,3 @@
-import tabSkinApp from "../../constSkin";
import { User } from "../../core/User/user";
import ILoaderUser from "./ILoaderUser";
import ISaverUser from "./ISaverUser";
diff --git a/bob_party/src/testGameSolo.ts b/bob_party/src/testGameSolo.ts
deleted file mode 100644
index c8d6c14..0000000
--- a/bob_party/src/testGameSolo.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { GameSolo } from "./core/gameSolo";
-
-let myMap = new Map([
- [50, 3],
- [75, 4],
- [100, 5],
- [150, 6]
-]);
-
-let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, myMap);
-
-export default game;
\ No newline at end of file
diff --git a/create.sql b/create.sql
deleted file mode 100644
index 398fa4b..0000000
--- a/create.sql
+++ /dev/null
@@ -1,108 +0,0 @@
-#Drop all the tables
-
-DROP TABLE Battle;
-DROP TABLE Own;
-DROP TABLE Message;
-DROP TABLE Belong;
-DROP TABLE ConvGroup;
-DROP TABLE User;
-DROP TABLE Skin;
-DROP TABLE Game;
-
-
-
-
-#Create the User table
-
-CREATE TABLE User (
- ID char(5) PRIMARY KEY,
- Username varchar(20) NOT NULL,
- Password varchar(20) NOT NULL,
- Nationality varchar(20) NOT NULL,
- Sex char(1) NOT NULL,
- DateOfBirth date NOT NULL,
- CurrentBobCoins bigint(255) DEFAULT 0,
- TotalBobCoins bigint(255) DEFAULT 0,
- NbGamePlayed bigint(255) DEFAULT 0
-);
-
-
-
-#Create the Skin table
-
-CREATE TABLE Skin (
- ID char(5) PRIMARY KEY,
- Name varchar(20) UNIQUE NOT NULL,
- Image varchar(20) UNIQUE NOT NULL
-);
-
-
-
-#Create the Own table
-
-CREATE TABLE Own (
- IDSkin char(5),
- IDUser char(5),
- CONSTRAINT FK_Skin FOREIGN KEY (IDSkin) REFERENCES User(ID),
- CONSTRAINT FK_User FOREIGN KEY (IDUser) REFERENCES Skin(ID),
- PRIMARY KEY (IDUser, IDSkin)
-);
-
-
-
-#Create the Game table
-
-CREATE TABLE Game (
- ID char(5) PRIMARY KEY,
- Name varchar(20) UNIQUE NOT NULL
-);
-
-
-
-#Create the Match table
-
-CREATE TABLE Battle (
- ID char(5) PRIMARY KEY,
- Winner char(5) NOT NULL,
- Loser char(5) NOT NULL,
- Game char(5) NOT NULL,
- CONSTRAINT Fk_Winner FOREIGN KEY (Winner) REFERENCES User(ID),
- CONSTRAINT Fk_Loser FOREIGN KEY (Loser) REFERENCES User(ID),
- CONSTRAINT Fk_Game FOREIGN KEY (Game) REFERENCES Game(ID)
-);
-
-
-
-#Create the Group table
-
-CREATE TABLE ConvGroup (
- ID char(5) PRIMARY KEY,
- Name varchar(20) NOT NULL
-);
-
-
-
-#Create the Message table
-
-CREATE TABLE Message (
- ID char(5) PRIMARY KEY,
- Message text NOT NULL,
- IDSender char(5) NOT NULL,
- IDUserReceiver char(5),
- IDGroupReceiver char(5),
- CONSTRAINT Fk_Sender FOREIGN KEY (IDSender) REFERENCES User(ID),
- CONSTRAINT Fk_UsRec FOREIGN KEY (IDUserReceiver) REFERENCES User(ID),
- CONSTRAINT Fk_GrRec FOREIGN KEY (IDGroupReceiver) REFERENCES ConvGroup(ID)
-);
-
-
-
-#Create the Belong Table
-
-CREATE TABLE Belong (
- IDUser char(5),
- IDGroup char(5),
- CONSTRAINT Fk_UserID FOREIGN KEY (IDUser) REFERENCES User(ID),
- CONSTRAINT Fk_Group FOREIGN KEY (IDGroup) REFERENCES ConvGroup(ID),
- PRIMARY KEY (IDUser, IDGroup)
-);
\ No newline at end of file