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

typescript^2
Alban GUILHOT 2 years ago
commit 2ceac8dafc

@ -3,10 +3,15 @@ import App from './App'
import store from './src/redux/store'
import { Provider } from 'react-redux'
export default function Index(){
return(
<App/>
/*
<Provider store={store}>
<App />
</Provider>
*/
)
}

@ -10,6 +10,8 @@
},
"dependencies": {
"@react-native-community/datetimepicker": "6.2.0",
"@expo/webpack-config": "^0.17.0",
"@react-native-picker/picker": "2.4.2",
"@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13",
"@react-navigation/stack": "^6.3.2",

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

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

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

@ -1,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, undefined);
let UserTest:User=new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[2], tabSkinApp, undefined);
let Alban:User=new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, tabSkinApp[1], tabSkinApp, tabConv);
let Fefe63:User=new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[6], tabSkinApp, undefined);
let tabUS:User[]=[UserActu, UserTest, Alban, Fefe63];
export default tabUS;

@ -1,7 +1,9 @@
import { randomBytes } from "crypto";
import { ImageSourcePropType } from "react-native";
import internal from "stream";
export abstract class Game{
readonly id:string;
private name:string;
private imageSource:ImageSourcePropType;
private gameSource:string;
@ -9,7 +11,8 @@ export abstract class Game{
private nbPlayerMax:number;
/* Constructor of the class */
constructor (name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){
constructor (id:string, name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){
this.id=id;
this.name=name;
this.imageSource=imageSource;
this.gameSource=gameSource;
@ -17,6 +20,11 @@ export abstract class Game{
this.nbPlayerMax=nbPlayerMax;
}
/* Brief : Function getting the id of a game */
getId(){
return this.id;
}
/* Brief : Function getting the name of a game */
getName(){
return this.name;
@ -66,4 +74,6 @@ export abstract class Game{
setNbPlayerMax(nbPlayerMax:number){
this.nbPlayerMax=nbPlayerMax;
}
abstract coinsCalculator(points: number): number;
}

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

@ -4,13 +4,16 @@ export class ManagerCoinsUser{
addCoins(u:User, coins:number){
u.setCurrentCoins(u.getCurrentCoins()+coins);
u.setTotalCoins(u.getTotalCoins()+coins);
//modif dans la bdd
}
removeCoins(u:User, coins:number){
u.setCurrentCoins(u.getCurrentCoins()-coins);
//modif dans la bdd
}
changeCurrentCoins(u:User, coins:number){
u.setCurrentCoins(coins);
//modif dans la bdd
}
}

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

@ -0,0 +1,12 @@
import { User } from "./user";
import tabSkinApp from "../../constSkin";
import { Conversation } from "../conversation";
export class UserCreator{
createUser(username:string, password:string, nationality:string, sexe:string, date:Date){
//Récup l'ID d'après dans la bdd
const u = new User('0000', username, password, nationality, sexe, date, 0, 0, 0, tabSkinApp[0], [tabSkinApp[0]]);
//Ajout du joueur dans la bdd
return u;
}
}

@ -0,0 +1,24 @@
import { User } from "./user";
export default class UserModificationManager{
changePassword(user:User, password:string){
user.setPassword(password);
//modif dans la bdd
}
changeUsername(user:User, username:string){
user.setPassword(username);
//modif dans la bdd
}
changeNationality(user:User, nationality:string){
user.setNationality(nationality);
//modif dans la bdd
}
changeSexe(user:User, sexe:string){
user.setSexe(sexe);
//modif dans la bdd
}
}

@ -0,0 +1,13 @@
import { Skin } from '../Skin'
import { User } from './user'
export default class UserSkinModifier{
addSkin(user:User, skin:Skin){
user.addSkin(skin);
}
changeCurrentSkin(user:User, skin:Skin){
user.setCurrentSkin(skin);
}
}

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

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

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

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

@ -1,56 +1,72 @@
import { ImageSourcePropType } from 'react-native';
import { Game } from './game';
import { GameCasino } from './gameCasino';
import { GameMulti } from './gameMulti';
import { GameSolo } from './gameSolo';
import { User } from "./User/user";
export abstract class Match{
readonly code:string;
private inGame:Boolean;
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];
this.theGame=game;
}
/* Brief : Fuction getting if the match is currently in a game */
getInGame(){
return this.inGame;
}
/* Brief : Fuction setting the boolean inGame */
setInGame(inGame:Boolean){
this.inGame=inGame;
}
/* Brief : Fuction getting the array of User */
getTabUsers(){
return this.tabUsers;
}
/* Brief : Fuction setting the array of User */
setTabUser(tabUser:User[]){
this.tabUsers=[...tabUser];
}
/* Brief : Fuction getting code of a match */
getCode(){
return this.code;
}
/* Brief : Fuction getting the game of a match */
getGame(){
return this.theGame;
}
/* Brief : Fuction setting the game of a match */
setGame(game:Game){
this.theGame=game;
}
/*
convertMechanismToCoins(){
if (this.TheGame instanceof GameSolo){
return this.TheGame.CoinsWithPoints(this.GainingMechanism);
}
else if (this.TheGame instanceof GameMulti){
return this.TheGame.CoinsWithRank(this.GainingMechanism);
}
else if (this.TheGame instanceof GameCasino){
return this.TheGame.betToCoins(this.GainingMechanism);
}
return -1;
}
*/
abstract updatePostMatch(user:User, points:number):void;
}

@ -2,10 +2,17 @@ import { Match } from "./match";
import { User } from "./User/user";
import { Game } from "./game";
import { GameCasino } from "./gameCasino";
import { ManagerCoinsUser } from "./User/managerCoinsUser";
export class MatchMulti extends Match{
constructor(code:string, 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, points: number): void {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -2,10 +2,16 @@ import { Match } from "./match";
import { User } from "./User/user";
import { Game } from "./game";
import { GameMulti } from "./gameMulti";
import { ManagerCoinsUser } from "./User/managerCoinsUser";
export class MatchMulti extends Match{
constructor(code:string, 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, points: number): void {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -2,10 +2,16 @@ import { Match } from "./match";
import { GameSolo } from "./gameSolo";
import { User } from "./User/user";
import { Game } from "./game";
import { ManagerCoinsUser } from "./User/managerCoinsUser";
export class MatchSolo extends Match{
constructor(code:string, 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 {
const manage= new ManagerCoinsUser();
manage.addCoins(user, this.getGame().coinsCalculator(points));
}
}

@ -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';
@ -9,31 +10,34 @@ 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 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 usr3 = new User('00003', 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, 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');
})
})

@ -0,0 +1,64 @@
import { Game } from '../game';
import { GameSolo } from '../GameSolo';
// Instances
let myMap = new Map<number, number>([
[50, 3],
[75, 4],
[100, 5],
[150, 6]
]);
let game:Game = new GameSolo("id", "bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 1, myMap);
// Get tests
describe('GameSolo get tests', () => {
it('should return id', () => {
expect(game.getId()).toBe('id');
})
it('should return bo jeu', () => {
expect(game.getName()).toBe('bo jeu');
})
it('should return require(blackjack.jpg)', () => {
expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg'));
})
it('should return super jeu', () => {
expect(game.getGameSource()).toBe('super jeu');
})
it('should return 1', () => {
expect(game.getNbPlayerMin()).toBe(1);
})
it('should return 1', () => {
expect(game.getNbPlayerMax()).toBe(1);
})
})
// Setting new values
game.setGameSource('trop cool le jeu');
game.setImageSource(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
game.setName('beau jeu');
game.setNbPlayerMin(2);
game.setNbPlayerMax(3);
// Set tests
describe('GameSolo set tests', () => {
it('should return beau jeu', () => {
expect(game.getName()).toBe('beau jeu');
})
it('should return require(JeuDeDame.jpg)', () => {
expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
})
it('should return trop cool le jeu', () => {
expect(game.getGameSource()).toBe('trop cool le jeu');
})
it('should return 2', () => {
expect(game.getNbPlayerMin()).toBe(2);
})
it('should return 3', () => {
expect(game.getNbPlayerMax()).toBe(3);
})
})

@ -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);
})
})
})
// Coins Calculator Tests
describe('Coins calculator tests', () => {
it('should return 200', () => {
expect(game.coinsCalculator(200)).toBe(200);
})
})

@ -1,18 +1,24 @@
import { GameMulti } from '../gameMulti';
import { Game } from '../game';
import { GameSolo } from '../GameSolo';
import { GameMulti } from '../GameMulti';
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');
})
@ -59,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);
})
})

@ -1,6 +1,6 @@
import exp from 'constants';
import { GameSolo } from '../GameSolo';
// Instances
let myMap = new Map<number, number>([
[50, 3],
@ -8,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,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);
})
})

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

@ -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 match = new MatchSolo("machin", tabU, game);
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
@ -31,6 +31,9 @@ describe('Match get tests', () => {
it('should return machin', () => {
expect(match.getCode()).toBe('machin');
})
it('should return false', () => {
expect(match.getInGame()).toBe(false);
})
it('should return tabU [usr] (users)', () => {
expect(match.getTabUsers()).toBe(tabU);
})
@ -42,6 +45,7 @@ describe('Match get tests', () => {
// Setting new values
match.setGame(game2);
match.setInGame(true);
match.setTabUser(tabU2);
@ -50,7 +54,31 @@ describe('Match set tests', () => {
it('should return tabU2 [] (users)', () => {
expect(match.getTabUsers()).toBe(tabU2);
})
it('should return true', () => {
expect(match.getInGame()).toBe(true);
})
it('should return game2', () => {
expect(match.getGame).toBe(game2);
})
})
// Update Post-Match tests
describe('Update post-match tests', () => {
it('should return 3', () => {
match.updatePostMatch(tabU[0],50);
expect(tabU[0].getCurrentCoins()).toBe(3);
})
it('should return 8', () => {
match.updatePostMatch(tabU[0],100);
expect(tabU[0].getCurrentCoins()).toBe(8);
})
it('should return 4', () => {
match.updatePostMatch(usr2,75);
expect(usr2.getCurrentCoins()).toBe(4);
})
it('should return 10', () => {
match.updatePostMatch(usr2,150);
expect(usr2.getCurrentCoins()).toBe(10);
})
})

@ -8,22 +8,25 @@ 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');
})
it('should return usr', () => {
expect(mess.getMessageSender()).toBe(usr);
})
it('should return wouhou', () => {
it('should return theDate', () => {
expect(mess.getMessageDate()).toBe(theDate);
})
})

@ -10,9 +10,7 @@ let tab:Skin[] = [];
let tab2:Skin[] = [classique, blue];
let dateBirth = new Date(2010,0o3,0o7);
let dateBirth2 = new Date(2009,0o3,0o7);
let conv:Conversation[] = [];
let conv2: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);
// Tests des get
@ -42,7 +40,7 @@ describe('User get tests', () => {
expect(usr.getTotalCoins()).toBe(0);
})
it('should return 0', () => {
expect(usr.getGamePlayed()).toBe(0);
expect(usr.getGamesPlayed()).toBe(0);
})
it('should return classique', () => {
expect(usr.getCurrentSkin()).toBe(classique);
@ -50,9 +48,6 @@ describe('User get tests', () => {
it('should return tab', () => {
expect(usr.getTabSkin()).toBe(tab);
})
it('should return conv', () => {
expect(usr.getTabConv()).toBe(conv);
})
})
@ -64,10 +59,9 @@ usr.setSexe('F');
usr.setDateOfBirth(dateBirth2);
usr.setCurrentCoins(2);
usr.setTotalCoins(2);
usr.setGamePlayed(4);
usr.setGamesPlayed(4);
usr.setCurrentSkin(blue);
usr.setTabSkin(tab2);
usr.setTabConv(conv2);
// Tests des set
@ -94,7 +88,7 @@ describe('User get tests', () => {
expect(usr.getTotalCoins()).toBe(2);
})
it('should return 4', () => {
expect(usr.getGamePlayed()).toBe(4);
expect(usr.getGamesPlayed()).toBe(4);
})
it('should return kikou', () => {
expect(usr.getCurrentSkin()).toBe(blue);
@ -102,7 +96,4 @@ describe('User get tests', () => {
it('should return tab2', () => {
expect(usr.getTabSkin()).toBe(tab2);
})
it('should return conv2', () => {
expect(usr.getTabConv()).toBe(conv2);
})
})

@ -15,7 +15,8 @@ let tabConv:Conversation[]=[];
const msc = require('../../assets/Icons/FondGris.png');
const jeuTest= new GameSolo("SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin", 1, 1,new Map<number,number>);
//const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv);
const jeuTest= new GameSolo("1", "SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin", 1, 1, new Map<number,number>);
function GameChoice(props: { navigation: any; }) {
const { navigation } = props
return (

@ -10,11 +10,13 @@ import { useSelector } from 'react-redux';
import { RootState } from '../redux/store';
//const test= new GameSolo("test", require('bob_party/assets/ImagesJeux/BatailleNavale.jpeg'), "test", );
let tabConv:Conversation[]=[];
function Home(props: { navigation: any; }) {
const { navigation } = props
return (

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

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

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

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

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

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

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

@ -0,0 +1,23 @@
import { User } from "../../core/User/user";
export default interface ISaverUser{
/**
* saveUser methode that save a User in the data management system
* u the user we want to save
*/
saveUser(u:User): void;
/**
* deleteUser methode that delete a User in the data management system
* u the user we want to delete
*/
deleteUser(u:User):void;
/**
* updateUser methode that update a User in the data management system
* u the user we want to update
*/
updateUser(u:User): void;
}

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

@ -0,0 +1,16 @@
import { User } from "../../core/User/user";
import ISaverUser from "./ISaverUser";
export default class FakeSaverUser implements ISaverUser{
saveUser(u: User): void {
return;
}
deleteUser(u: User): void {
return;
}
updateUser(u: User): void {
return;
}
}

@ -0,0 +1,29 @@
import { Conversation } from "../../core/conversation";
import { Match } from "../../core/match";
import { User } from "../../core/User/user";
import ILoaderUser from "./ILoaderUser";
export default class LoaderUserApi implements ILoaderUser{
loadAllUser(): User[] {
throw new Error("Method not implemented.");
}
loadByID(id: string): User | null {
throw new Error("Method not implemented.");
}
loadByUsername(username: string): User | null {
throw new Error("Method not implemented.");
}
loadByUsernamePassword(username: string, password: string): User | null {
throw new Error("Method not implemented.");
}
loadUserByMatch(m: Match): User[] {
throw new Error("Method not implemented.");
}
laodUserByConversation(c: Conversation): User[] {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,17 @@
import { User } from "../../core/User/user";
import ISaverUser from "./ISaverUser";
export default class SaverUserApi implements ISaverUser{
saveUser(u: User): void {
throw new Error("Method not implemented.");
}
deleteUser(u: User): void {
throw new Error("Method not implemented.");
}
updateUser(u: User): void {
throw new Error("Method not implemented.");
}
}

@ -0,0 +1,59 @@
import { Conversation } from "../../core/conversation";
import { Match } from "../../core/match";
import { Skin } from "../../core/skin";
import { User } from "../../core/User/user";
import ILoaderUser from "./ILoaderUser";
export default class StubUser implements ILoaderUser{
tabUS:User[]=[
new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
new User("48", "WeshWesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
new User("17", "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)],),
new User("17", "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0), [new Skin("S0001", "Bob",require('bob_party/assets/BobsSkins/BobClassic.png'), 0)]),
];
loadAllUser(): User[] {
return this.tabUS;
}
loadByID(id: string): User | null {
for(let u of this.tabUS){
if (u.getId()==id){
return u;
}
}
return null;
}
loadByUsername(username: string): User | null {
for(let u of this.tabUS){
if (u.getUsername()==username){
return u;
}
}
return null;
}
loadByUsernamePassword(username: string, password: string): User | null {
for(let u of this.tabUS){
if (u.getUsername()==username && u.getPassword()==password){
return u;
}
}
return null;
}
loadUserByMatch(m: Match): User[] {
let tabUser:User[]=[];
m.getTabUsers().forEach(u => {
tabUser.push(u);
});
return tabUser;
}
laodUserByConversation(c: Conversation): User[] {
let tabUser:User[]=[];
c.getTabUser().forEach(u => {
tabUser.push(u);
});
return tabUser;
}
}

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

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save