Merge branch 'typescript' into temp
continuous-integration/drone/push Build is passing Details

temp
Alban GUILHOT 2 years ago
commit 82a3b0b5c8

@ -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 (
<View style={stylesScreen.bodyCenter}>
<AUser />
<Button onPress={handleUserConnect} title="Connect"></Button>
<Button onPress={handleUserLogout} title="Logout"></Button>
<Button onPress={handleUserChange} title="testChangement"></Button>
</View>
<Provider store={store}>
<MainTabNavigator/>
</Provider>
);
}
@ -79,5 +78,3 @@ export const MANAGER_USER = new ManagerUser(new StubUser, new FakeSaverUser);
</View>
);
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

@ -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",

@ -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}
/>
)
}

@ -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 :
@ -20,6 +21,8 @@ FC<{skin: Skin, state: String}> =
{
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
@ -46,7 +49,7 @@ FC<{skin: Skin, state: String}> =
)
case 'liste':
return(
<Pressable onPress={() => dispatch(updateSkin(skin))} style={styles.imageWrapper}>
<Pressable onPress={() => {currentUser.setCurrentSkin(skin); dispatch(loginUser(currentUser))}} style={styles.imageWrapper}>
<Text style={styles.nomSkin}>{skin.getSkinName()}</Text>
<Image
style={styles.imageSkin}

@ -30,7 +30,7 @@ FC<{nav: any, state?: string}> =
({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

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

@ -1,25 +0,0 @@
import { Message } from "./core/message"
import { Conversation } from "./core/conversation"
import tabSkinApp from './constSkin'
import { User } from "./core/User/user";
let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, []);
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;

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

@ -1,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" },
]

@ -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;

@ -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;

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

@ -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;

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

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

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

@ -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 {

@ -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;

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

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

@ -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
@ -51,3 +51,12 @@ describe('GameCasino set tests', () => {
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);
})
})

@ -6,16 +6,19 @@ import { GameCasino } from '../GameCasino';
// Instances
let myMap = new Map<number, number>([
[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');
})
@ -63,3 +66,20 @@ describe('GameMulti set tests', () => {
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);
})
})

@ -1,3 +1,4 @@
import exp from 'constants';
import { GameSolo } from '../GameSolo';
// Instances
@ -7,11 +8,14 @@ let myMap = new Map<number, number>([
[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');
})
@ -59,3 +63,20 @@ describe('GameSolo set tests', () => {
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);
})
})

@ -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<number, number>([
[50, 3],
@ -20,10 +20,10 @@ let myMap = new Map<number, number>([
[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
@ -61,3 +61,24 @@ describe('Match set tests', () => {
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);
})
})

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

@ -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() {
<Tab.Screen name='ChatTab' component={ChatStackScreen} />
<Tab.Screen name='ProfileTab' component={ProfileStackScreen} />
<Tab.Screen name='SignIn' component={SignIn} />
<Tab.Screen name='SignUp' component={SignUp} />
</Tab.Navigator>
</NavigationContainer>
)

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

@ -2,50 +2,65 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"
import { Skin } from "../../core/Skin";
import { 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<User>) => {
state.value.push(action.payload);
const newUser : User = new User(action.payload.getId(), action.payload.getUsername(),action.payload.getPassword(),action.payload.getNationality(),action.payload.getSexe(),action.payload.getDateOfBirth(), action.payload.getCurrentCoins(), action.payload.getTotalCoins(),action.payload.getGamePlayed(),action.payload.getCurrentSkin(),action.payload.getTabSkin(), action.payload.getTabConv())
state.currentUser = newUser;
},
updateSkin: (state, action: PayloadAction<Skin>) =>{
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<string>) =>{
const newUser = state.value[0]
const newUser: User = new User(currentUser.getId(), currentUser.getUsername(), currentUser.getPassword(), currentUser.getNationality(), currentUser.getSexe(), currentUser.getDateOfBirth());
console.log(currentUser);
newUser.setUsername(action.payload);
state.value.pop();
state.value.push(newUser);
return {
...state,
currentUser: newUser,
}
},
updatePassword: (state, action: PayloadAction<string>) =>{
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<string>) =>{
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<string>) =>{
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,
}
}
},
});

@ -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,
})

@ -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 (
<View style={stylesScreen.container}>

@ -19,7 +19,6 @@ function Home(props: { navigation: any; }) {
const { navigation } = props
return (
<View style={stylesScreen.container}>
<TopBar

@ -18,8 +18,7 @@ const coin = require('../../assets/Icons/Coin.png')
function Profile(props: { navigation: any; }) {
const { navigation } = props
const currentUser = useSelector((state: RootState) => state.currentUser.value)[0];
const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
return (
<View style={stylesScreen.container}>
<TopBar

@ -13,16 +13,15 @@ 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';
function Settings(props: { navigation: any; }) {
const { navigation } = props
const currentUser = useSelector((state: RootState) => 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; }) {
</View>
<View>
<Text style={styles.text}>Nationalité: {currentUser.getNationality()}</Text>
<ButtonGreySmall onPress={() => setDialogNationalityVisible(true)} title='Changer la nationnalité'/>
<PickerGreySmall title='Changer la nationalité' valueChange={(value:string) => setSelectedNationality(value)} donePress={() => dispatch(updateNationality(selectedNationality))} values={tabNat} />
</View>
<View>
<Text style={styles.text}>Sexe: {currentUser.getSexe()}</Text>
<ButtonGreySmall onPress={() => setDialogSexVisible(true)} title='Changer le sexe'/>
<PickerGreySmall title='Changer le sexe' valueChange={(value:string) => setSelectedSex(value)} donePress={() => dispatch(updateSex(selectedSex))} values={tabSex} />
</View>
</View>
<Text style={styles.textID}>ID: {currentUser.getId()}</Text>
@ -78,32 +77,6 @@ function Settings(props: { navigation: any; }) {
closeDialog={ () => {setDialogPasswordVisible(false)}}>
</DialogInput>
<Dialog.Container visible={dialogNationalityVisible}>
<Dialog.Title>Changer de nationalité</Dialog.Title>
<View style={styles.RNPView}>
<RNPickerSelect
placeholder={{label:"Cliquez pour changer", value: null}}
onValueChange={(value:string) => setSelectedNationality(value)}
items={tabNat}
/>
</View>
<Dialog.Button label="Cancel" onPress={() => setDialogNationalityVisible(false)} />
<Dialog.Button label="Valider" onPress={() => {dispatch(updateNationality(selectedNationality)); setDialogNationalityVisible(false)}} />
</Dialog.Container>
<Dialog.Container visible={dialogSexVisible}>
<Dialog.Title>Changer de sexe</Dialog.Title>
<View style={styles.RNPView}>
<RNPickerSelect
placeholder={{label:"Cliquez pour changer", value: null}}
onValueChange={(value:string) => setSelectedSex(value)}
items={tabSex}
/>
</View>
<Dialog.Button label="Cancel" onPress={() => setDialogSexVisible(false)} />
<Dialog.Button label="Valider" onPress={() => {dispatch(updateSex(selectedSex)); setDialogSexVisible(false)}} />
</Dialog.Container>
</View>
);
}

@ -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 (
<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' />
<Pressable style={styles.button} onPress={() => userVerif(pseudo, password, navigation)}>
<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.signup}>Pas de compte? Inscrivez vous !</Text>
<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>
);
}

@ -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 (
// <View style={stylesScreen.container}>
// <View style={stylesScreen.bodyCenter}>
// <CustomTextInput placeholder={""} text="Pseudo"/>
// <CustomTextInput placeholder={""} text="Mot de passe"/>
// <CustomTextInput placeholder={""} text="Mot de passe"/>
// <CustomTextInput placeholder={""} text="Nationalité"/>
// <CustomTextInput placeholder={""} text="Date de naisance"/>
// <CustomTextInput placeholder={""} text="Sexe"/>
// <Pressable style={styles.button} onPress={navigation.navigate('Home')}>
// <Text style={styles.text}>S'inscrire</Text>
// </Pressable>
// </View>
// </View>
// );
// }
// 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 (
<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

@ -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 (
<View style={stylesScreen.container}>
<TopBar

@ -13,7 +13,7 @@ import { RootState } from '../redux/store';
function Store(props: { navigation: any; }) {
const { navigation } = props
const currentUser = useSelector((state: RootState) => state.currentUser.value[0]);
const currentUser = useSelector((state: RootState) => state.currentUserManager.currentUser);
return (
<View style={stylesScreen.container}>

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

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

@ -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",
},
})

@ -23,5 +23,9 @@ export default StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
width: '100%',
},
},
RNPView: {
alignSelf: 'center',
padding: 20,
}
});

@ -1,4 +1,3 @@
import tabSkinApp from "../../constSkin";
import { User } from "../../core/User/user";
import ILoaderUser from "./ILoaderUser";
import ISaverUser from "./ISaverUser";

@ -1,12 +0,0 @@
import { GameSolo } from "./core/gameSolo";
let myMap = new Map<number, number>([
[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;

@ -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)
);
Loading…
Cancel
Save