stub-api
Alban GUILHOT 3 years ago
commit c4041b1023

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

@ -1,57 +1,69 @@
import { randomBytes } from "crypto"; import { randomBytes } from "crypto";
import { ImageSourcePropType } from "react-native"; import { ImageSourcePropType } from "react-native";
export class Game{ export abstract class Game{
private Name:string; private name:string;
private ImageSource:ImageSourcePropType; private imageSource:ImageSourcePropType;
private GameSource:string; private gameSource:string;
private NbPlayer: number; private nbPlayerMin: number;
private nbPlayerMax:number;
/* Constructor of the class */ /* Constructor of the class */
constructor (name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number){ constructor (name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){
this.Name=name; this.name=name;
this.ImageSource=imageSource; this.imageSource=imageSource;
this.GameSource=gameSource; this.gameSource=gameSource;
this.NbPlayer=nbPlayer; this.nbPlayerMin=nbPlayerMin;
this.nbPlayerMax=nbPlayerMax;
} }
/* Brief : Function getting the name of a game */ /* Brief : Function getting the name of a game */
getName(){ getName(){
return this.Name; return this.name;
} }
/* Brief : Function setting the name of a game */ /* Brief : Function setting the name of a game */
setName(name:string){ setName(name:string){
this.Name=name; this.name=name;
} }
/* Brief : Function getting the image of a game */ /* Brief : Function getting the image of a game */
getImageSource(){ getImageSource(){
return this.ImageSource; return this.imageSource;
} }
/* Brief : Function setting the image of a game */ /* Brief : Function setting the image of a game */
setImageSource(imageSource:ImageSourcePropType){ setImageSource(imageSource:ImageSourcePropType){
this.ImageSource=imageSource; this.imageSource=imageSource;
} }
/* Brief : Function getting the source of a game */ /* Brief : Function getting the source of a game */
getGameSource(){ getGameSource(){
return this.GameSource; return this.gameSource;
} }
/* Brief : Function setting the source of a game */ /* Brief : Function setting the source of a game */
setGameSource(gameSource:string){ setGameSource(gameSource:string){
this.GameSource=gameSource; this.gameSource=gameSource;
} }
/* Brief : Function getting the number of player */ /* Brief : Function getting the number of player */
getNbPlayer(){ getNbPlayerMin(){
return this.NbPlayer; return this.nbPlayerMin;
} }
/* Brief : Function setting the number of player*/ /* Brief : Function setting the number of player*/
setNbPlayer(nbPlayer:number){ setNbPlayerMin(nbPlayerMin:number){
this.NbPlayer=nbPlayer; this.nbPlayerMin=nbPlayerMin;
}
/* Brief : Function getting the number of player */
getNbPlayerMax(){
return this.nbPlayerMax;
}
/* Brief : Function setting the number of player*/
setNbPlayerMax(nbPlayerMax:number){
this.nbPlayerMax=nbPlayerMax;
} }
} }

@ -0,0 +1,14 @@
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());
}
}

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

@ -1,159 +1,159 @@
import { Skin } from './Skin' import { Skin } from '../Skin'
import { Conversation } from './conversation'; import { Conversation } from '../conversation';
import { sign } from 'crypto'; import { sign } from 'crypto';
export class User{ export class User{
readonly Id: string; readonly id: string;
private Username: string; private username: string;
private Password: string; private password: string;
private Nationality: string; private nationality: string;
private Sexe: string; private sexe: string;
private DateOfBirth: Date; private dateOfBirth: Date;
private CurrentCoins: number; private currentCoins: number;
private TotalCoins: number; private totalCoins: number;
private NbGamePlayed: number; private nbGamePlayed: number;
private CurrentSkin: Skin; private currentSkin: Skin;
private TabSkin: Skin[]; private tabSkin: Skin[];
private TabConv?: Conversation[]; private tabConv?: Conversation[];
/* Consturctor of the class */ /* Consturctor of the class */
constructor(id: string, username: string, password:string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number, constructor(id: string, username: string, password:string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number,
nbGamePlayed:number, currentSkin: Skin, tabSkin: Skin[], tabConv?: Conversation[] ){ nbGamePlayed:number, currentSkin: Skin, tabSkin: Skin[], tabConv?: Conversation[] ){
this.Id=id; this.id=id;
this.Username=username; this.username=username;
this.Password=password; this.password=password;
this.Nationality=nationality; this.nationality=nationality;
this.Sexe=sexe; this.sexe=sexe;
this.DateOfBirth=dateOfBirth; this.dateOfBirth=dateOfBirth;
this.NbGamePlayed=nbGamePlayed; this.nbGamePlayed=nbGamePlayed;
this.CurrentCoins=currentCoins; this.currentCoins=currentCoins;
this.TotalCoins=totalCoins; this.totalCoins=totalCoins;
this.CurrentSkin=currentSkin; this.currentSkin=currentSkin;
this.TabSkin=[...tabSkin]; this.tabSkin=[...tabSkin];
tabConv?.forEach(conv => { tabConv?.forEach(conv => {
this.TabConv?.push(conv); this.tabConv?.push(conv);
}); });
} }
/* Brief : Function getting the name of an user */ /* Brief : Function getting the name of an user */
getUsername(){ getUsername(){
return this.Username; return this.username;
} }
/* Brief : Function setting the name of an user */ /* Brief : Function setting the name of an user */
setUsername(username: string){ setUsername(username: string){
this.Username=username; this.username=username;
} }
/* Brief : Function getting the id of an user */ /* Brief : Function getting the id of an user */
getId(){ getId(){
return this.Id; return this.id;
} }
getPassword(){ getPassword(){
return this.Password; return this.password;
} }
setPassword(password:string){ setPassword(password:string){
this.Password=password; this.password=password;
} }
/* Brief : Function getting the current number of coins of an user */ /* Brief : Function getting the current number of coins of an user */
getCurrentCoins(){ getCurrentCoins(){
return this.CurrentCoins; return this.currentCoins;
} }
/* Brief : Function setting the current number of coins of an user */ /* Brief : Function setting the current number of coins of an user */
setCurrentCoins(currentCoins: number){ setCurrentCoins(currentCoins: number){
this.CurrentCoins=currentCoins; this.currentCoins=currentCoins;
} }
/* Brief : Function getting the sex of an user */ /* Brief : Function getting the sex of an user */
getSexe(){ getSexe(){
return this.Sexe; return this.sexe;
} }
/* Brief : Function getting the sex of an user */ /* Brief : Function getting the sex of an user */
setSexe(sexe: string){ setSexe(sexe: string){
this.Sexe=sexe; this.sexe=sexe;
} }
/* Brief : Function getting the date of birth of an user */ /* Brief : Function getting the date of birth of an user */
getDateOfBirth(){ getDateOfBirth(){
return this.DateOfBirth; return this.dateOfBirth;
} }
/* Brief : Function setting the date of birth of an user */ /* Brief : Function setting the date of birth of an user */
setDateOfBirth(dateOfBirth: Date){ setDateOfBirth(dateOfBirth: Date){
this.DateOfBirth=dateOfBirth; this.dateOfBirth=dateOfBirth;
} }
/* Brief : Function getting the nationality of an user */ /* Brief : Function getting the nationality of an user */
getNationality(){ getNationality(){
return this.Nationality; return this.nationality;
} }
/* Brief : Function setting the nationality of an user */ /* Brief : Function setting the nationality of an user */
setNationality(nationality: string){ setNationality(nationality: string){
this.Nationality=nationality; this.nationality=nationality;
} }
/* Brief : Function getting the total number of coins of an user */ /* Brief : Function getting the total number of coins of an user */
getTotalCoins(){ getTotalCoins(){
return this.TotalCoins; return this.totalCoins;
} }
/* Brief : Function setting the total number of coins of an user */ /* Brief : Function setting the total number of coins of an user */
setTotalCoins(totalCoins: number){ setTotalCoins(totalCoins: number){
this.TotalCoins=totalCoins; this.totalCoins=totalCoins;
} }
/* Brief : Function getting the current number of game played by an user */ /* Brief : Function getting the current number of game played by an user */
getGamePlayed(){ getGamePlayed(){
return this.NbGamePlayed; return this.nbGamePlayed;
} }
/* Brief : Function setting the current number of game played by an user */ /* Brief : Function setting the current number of game played by an user */
setGamePlayed(nb: number){ setGamePlayed(nb: number){
this.NbGamePlayed=nb; this.nbGamePlayed=nb;
} }
/* Brief : Function getting the current skin of an user */ /* Brief : Function getting the current skin of an user */
getCurrentSkin(){ getCurrentSkin(){
return this.CurrentSkin; return this.currentSkin;
} }
/* Brief : Function setting the current skin of an user */ /* Brief : Function setting the current skin of an user */
setCurrentSkin(newSkin: Skin){ setCurrentSkin(newSkin: Skin){
this.CurrentSkin=newSkin; this.currentSkin=newSkin;
} }
/* Brief : Function getting the skins of an user */ /* Brief : Function getting the skins of an user */
getTabSkin(){ getTabSkin(){
return this.TabSkin; return this.tabSkin;
} }
/* Brief : Function setting the skins of an user */ /* Brief : Function setting the skins of an user */
setTabSkin(tabSkin: Skin[]){ setTabSkin(tabSkin: Skin[]){
this.TabSkin=[...tabSkin]; this.tabSkin=[...tabSkin];
} }
/* Brief : Function getting the conversations of an user */ /* Brief : Function getting the conversations of an user */
getTabConv(){ getTabConv(){
return this.TabConv; return this.tabConv;
} }
/* Brief : Function setting the conversations of an user */ /* Brief : Function setting the conversations of an user */
setTabConv(tabConv?: Conversation[]){ setTabConv(tabConv?: Conversation[]){
tabConv?.forEach(conv => { tabConv?.forEach(conv => {
this.TabConv?.push(conv); this.tabConv?.push(conv);
}); });
} }
/*
changeUserCoins(coin:number){ changeUserCoins(coin:number){
this.CurrentCoins+=coin; this.CurrentCoins+=coin;
if (coin>0){ if (coin>0){
@ -175,4 +175,9 @@ export class User{
} }
return false; return false;
} }
usrPasswordEquals(username:string, password:string){
return this.Password==password && this.Username==username;
}
*/
} }

@ -1,41 +0,0 @@
import { Conversation } from './Conversation';
import { Message } from './Message';
import { User } from './User';
// Instance
// Tests des get
describe('Message get tests', () => {
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', () => {
expect(mess.getMessageDate()).toBe(theDate);
})
})
// Set de nouvelles valeurs
mess.setMessageContent('Vive Bob Party');
mess.setSMessageSender(usr2);
mess.setSMessageDate(theDate2);
// Tests de set
describe('Message set tests', () => {
it('should return Vive Bob Party', () => {
expect(mess.getMessageContent()).toBe('Vive Bob Party');
})
it('should return usr2', () => {
expect(mess.getMessageSender()).toBe(usr2);
})
it('should return theDate2', () => {
expect(mess.getMessageDate()).toBe(theDate2);
})
})

@ -1,60 +1,72 @@
import { Message } from "./message" import { Message } from "./message"
import { User } from "./user"; import { User } from "./User/user";
export class Conversation{ export class Conversation{
private TabUser: User[]; private tabUser: User[];
private TabMessage: Message[]; private tabMessage: Message[];
private Name: string; private name: string;
/* Constructor of the class */ /* Constructor of the class */
constructor(tabUser: User[], tabMessage:Message[], name:string){ constructor(tabUser: User[], tabMessage:Message[], name:string){
this.TabUser=[...tabUser]; this.tabUser=[...tabUser];
this.TabMessage=[...tabMessage]; this.tabMessage=[...tabMessage];
this.Name=name; this.name=name;
} }
/* Brief : function returning the messages of a conversation */ /* Brief : function returning the messages of a conversation */
getTabMessage(){ getTabMessage(){
this.sortMessageDesc(); this.sortMessageDesc();
return this.TabMessage; return this.tabMessage;
} }
/* Brief : function returning the users of a conversation */ /* Brief : function returning the users of a conversation */
<<<<<<< HEAD
=======
>>>>>>> fe24058f3896c88fae68bff0b08ab4cb8b61ca2e
getTabUser(){ getTabUser(){
return this.TabUser; return this.tabUser;
} }
/* Brief : function adding an user to a conversation */ /* Brief : function adding an user to a conversation */
ajouterUser(us:User){ ajouterUser(us:User){
this.TabUser?.push(us); this.tabUser?.push(us);
} }
/* Brief : function adding a message to a conversation */ /* Brief : function adding a message to a conversation */
ajouterMessage(mess:Message){ ajouterMessage(mess:Message){
this.TabMessage?.push(mess); this.tabMessage?.push(mess);
this.sortMessageDesc(); this.sortMessageDesc();
} }
/* Brief : function returning the name to a conversation */ /* Brief : function returning the name to a conversation */
getName(){ getName(){
return this.Name; <<<<<<< HEAD
=======
>>>>>>> fe24058f3896c88fae68bff0b08ab4cb8b61ca2e
return this.name;
} }
/* Brief : function setting the name to a conversation */ /* Brief : function setting the name to a conversation */
<<<<<<< HEAD
=======
>>>>>>> fe24058f3896c88fae68bff0b08ab4cb8b61ca2e
setName(name:string){ setName(name:string){
this.Name=name; this.name=name;
} }
/* Brief : function returning the last message of a conversation */ /* Brief : function returning the last message of a conversation */
getLastMessage(){ getLastMessage(){
this.sortMessageDesc(); this.sortMessageDesc();
return this.TabMessage[0].getMessageContent(); return this.tabMessage[0].getMessageContent();
} }
/* Brief : function sorting the messages of a conversation to be in the discussion order */ /* Brief : function sorting the messages of a conversation to be in the discussion order */
sortMessageDesc(){ sortMessageDesc(){
this.TabMessage.sort( this.tabMessage.sort(
(objA, objB) => objB.getMessageDate().getTime() - objA.getMessageDate().getTime(), (objA, objB) => objB.getMessageDate().getTime() - objA.getMessageDate().getTime(),
); );
} }

@ -2,20 +2,8 @@ import { ImageSourcePropType } from 'react-native';
import { Game } from './game' import { Game } from './game'
export class GameCasino extends Game{ export class GameCasino extends Game{
readonly Coef:number;
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, coef:number){ constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){
super(name, imageSource, gameSource, nbPlayer); super(name, imageSource, gameSource, nbPlayerMin, nbPlayerMax);
this.Coef=coef;
}
//Get the coefficient of the casino game
getCoef(){
return this.Coef;
}
//Returns the coins gained with the initial bet of the user times the coefficient of the game
betToCoins(bet:number){
return this.Coef*bet;
} }
} }

@ -2,23 +2,23 @@ import { ImageSourcePropType } from 'react-native';
import { Game } from './game' import { Game } from './game'
export class GameMulti extends Game{ export class GameMulti extends Game{
readonly RankToCoins:Map<number,number> readonly rankToCoins:Map<number,number>
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, rankToCoins:Map<number,number>){ constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map<number,number>){
super(name, imageSource, gameSource, nbPlayer); super(name, imageSource, gameSource, nbPlayerMin, nbPlayerMax);
this.RankToCoins=rankToCoins; this.rankToCoins=rankToCoins;
} }
//Get the map of the game with the rank as the key and the coins as the values //Get the map of the game with the rank as the key and the coins as the values
getMultiMap(){ getMultiMap(){
return this.RankToCoins; return this.rankToCoins;
} }
//Returns the coins gained depending on the rank //Returns the coins gained depending on the rank
CoinsWithRank(rank:number){ CoinsWithRank(rank:number){
let coins; let coins;
for (let key of this.RankToCoins.keys()){ for (let key of this.rankToCoins.keys()){
coins = this.RankToCoins.get(key); coins = this.rankToCoins.get(key);
if (rank==key ){ if (rank==key ){
return coins; return coins;
} }

@ -2,23 +2,23 @@ import { ImageSourcePropType } from 'react-native';
import { Game } from './game' import { Game } from './game'
export class GameSolo extends Game{ export class GameSolo extends Game{
readonly PtsToCoins:Map<number,number> readonly ptsToCoins:Map<number,number>
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, ptsToCoins:Map<number,number>){ constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map<number,number>){
super(name, imageSource, gameSource, nbPlayer); super(name, imageSource, gameSource, nbPlayerMin,nbPlayerMax);
this.PtsToCoins=ptsToCoins; this.ptsToCoins=ptsToCoins;
} }
//Get the map of the game with points millestone as the keys and coins as the values //Get the map of the game with points millestone as the keys and coins as the values
getSoloMap(){ getSoloMap(){
return this.PtsToCoins; return this.ptsToCoins;
} }
//Returns the gained depending on the number of points //Returns the gain depending on the number of points
CoinsWithPoints(nbPoints:number){ CoinsWithPoints(nbPoints:number){
let coins; let coins;
for (let key of this.PtsToCoins.keys()){ for (let key of this.ptsToCoins.keys()){
coins = this.PtsToCoins.get(key); coins = this.ptsToCoins.get(key);
if (nbPoints<key ){ if (nbPoints<key ){
return coins; return coins;
} }

@ -3,55 +3,42 @@ import { Game } from './game';
import { GameCasino } from './gameCasino'; import { GameCasino } from './gameCasino';
import { GameMulti } from './gameMulti'; import { GameMulti } from './gameMulti';
import { GameSolo } from './gameSolo'; import { GameSolo } from './gameSolo';
import { User } from "./user"; import { User } from "./User/user";
let index:number=0;
export class Match{ export abstract class Match{
readonly Code:string; readonly code:string;
private TabUsers:User[]; private tabUsers:User[];
private TheGame:Game; private theGame:Game;
private GainingMechanism:number=0;
constructor(tabUser:User[], game:Game){ constructor(code:string, tabUser:User[], game:Game){
index++; this.code=code;
this.Code=index.toString(); this.tabUsers=[...tabUser];
this.TabUsers=[...tabUser]; this.theGame=game;
this.TheGame=game;
} }
getTabUsers(){ getTabUsers(){
return this.TabUsers; return this.tabUsers;
}
ajouterUser(us:User){
this.TabUsers.push(us);
} }
setTabUser(tabUser:User[]){ setTabUser(tabUser:User[]){
this.TabUsers=[...tabUser]; this.tabUsers=[...tabUser];
} }
getCode(){ getCode(){
return this.Code; return this.code;
} }
getGame(){ getGame(){
return this.TheGame; return this.theGame;
} }
setGame(game:Game){ setGame(game:Game){
this.TheGame=game; this.theGame=game;
} }
getGainingMechanism(){
return this.GainingMechanism;
}
setGainingMechanism(gain:number){
this.GainingMechanism=gain;
}
/*
convertMechanismToCoins(){ convertMechanismToCoins(){
if (this.TheGame instanceof GameSolo){ if (this.TheGame instanceof GameSolo){
return this.TheGame.CoinsWithPoints(this.GainingMechanism); return this.TheGame.CoinsWithPoints(this.GainingMechanism);
@ -62,6 +49,8 @@ export class Match{
else if (this.TheGame instanceof GameCasino){ else if (this.TheGame instanceof GameCasino){
return this.TheGame.betToCoins(this.GainingMechanism); return this.TheGame.betToCoins(this.GainingMechanism);
} }
return -1;
} }
*/
} }

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

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

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

@ -1,4 +1,4 @@
import { User } from './user' import { User } from './User/user'
export class Message{ export class Message{

@ -1,34 +0,0 @@
import { Skin } from './Skin';
/*
// Instance
let classique = new Skin('Classique', 'wouhou');
// Tests des get
describe('Skin get tests', () => {
it('should return Classique', () => {
expect(classique.getSkinName()).toBe('Classique');
})
it('should return wouhou', () => {
expect(classique.getSkinSource()).toBe('wouhou');
})
})
// Set de nouvelles valeurs
classique.setSkinName('The Classique');
classique.setSkinSource('The wouhou');
// Tests de set
describe('Skin set tests', () => {
it('should return The Classique', () => {
expect(classique.getSkinName()).toBe('The Classique');
})
it('should return The wouhou', () => {
expect(classique.getSkinSource()).toBe('The wouhou');
})
})*/

@ -1,51 +1,51 @@
import { ImageSourcePropType } from "react-native"; import { ImageSourcePropType } from "react-native";
export class Skin{ export class Skin{
readonly Id: string; readonly id: string;
private Name: string; private name: string;
private Source: ImageSourcePropType; private source: ImageSourcePropType;
private Cost:number; private cost:number;
/* Constructor of the class */ /* Constructor of the class */
constructor(id:string, name: string, source:ImageSourcePropType, Cost:number){ constructor(id:string, name: string, source:ImageSourcePropType, Cost:number){
this.Id=id; this.id=id;
this.Name=name; this.name=name;
this.Source=source; this.source=source;
this.Cost=Cost; this.cost=Cost;
} }
/* Brief : Fuction setting the name of a skin */ /* Brief : Fuction setting the name of a skin */
setSkinName(name: string){ setSkinName(name: string){
this.Name=name; this.name=name;
} }
/* Brief : Fuction setting the source of the image of a skin */ /* Brief : Fuction setting the source of the image of a skin */
setSkinSource(source: ImageSourcePropType){ setSkinSource(source: ImageSourcePropType){
this.Source=source; this.source=source;
} }
/* Brief : Fuction getting the source of the image of a skin */ /* Brief : Fuction getting the source of the image of a skin */
getSkinSource(){ getSkinSource(){
return this.Source; return this.source;
} }
/* Brief : Fuction getting the name of a skin */ /* Brief : Fuction getting the name of a skin */
getSkinName(){ getSkinName(){
return this.Name; return this.name;
} }
/* Brief : Fuction getting the id of a skin */ /* Brief : Fuction getting the id of a skin */
getSkinId(){ getSkinId(){
return this.Id; return this.id;
} }
/* Brief : Fuction getting the cost of a skin */ /* Brief : Fuction getting the cost of a skin */
getSkinCost(){ getSkinCost(){
return this.Cost; return this.cost;
} }
/* Brief : Fuction getting the cost of a skin */ /* Brief : Fuction getting the cost of a skin */
setSkinCost(cost:number){ setSkinCost(cost:number){
this.Cost=cost; this.cost=cost;
} }
} }

@ -0,0 +1,52 @@
import { Conversation } from '../Conversation';
import { Message } from '../Message';
import { Skin } from '../Skin';
import { User } from '../User/user';
// Instances
let conv:Conversation[] = [];
let tab:Skin[] = [];
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
let dateBirth = new Date(2010,0o3,0o7);
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv);
let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab, conv);
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 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 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);
// Get tests
describe('Conversation get tests', () => {
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');
})
})
// Setting new value
convo.setName('THE conv');
// Set test
describe('Conversation set test', () => {
it('should return THE conv', () => {
expect(convo.setName).toBe('THE conv');
})
})

@ -0,0 +1,53 @@
import { GameCasino } from '../GameCasino';
// Instances
let game = new GameCasino("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 5);
// Get tests
describe('GameMuti get tests', () => {
it('should return bo jeu', () => {
expect(game.getName()).toBe('bo jeu');
})
it('should return require(blackjack.jpg)', () => {
expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg'));
})
it('should return super jeu', () => {
expect(game.getGameSource()).toBe('super jeu');
})
it('should return 1', () => {
expect(game.getNbPlayerMin()).toBe(1);
})
it('should return 5', () => {
expect(game.getNbPlayerMax()).toBe(5);
})
})
// Setting new values
game.setGameSource('trop cool le jeu');
game.setImageSource(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
game.setName('beau jeu');
game.setNbPlayerMin(2);
game.setNbPlayerMax(4);
// Set tests
describe('GameCasino set tests', () => {
it('should return beau jeu', () => {
expect(game.getName()).toBe('beau jeu');
})
it('should return require(JeuDeDame.jpg)', () => {
expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
})
it('should return trop cool le jeu', () => {
expect(game.getGameSource()).toBe('trop cool le jeu');
})
it('should return trop cool le jeu', () => {
expect(game.getNbPlayerMin()).toBe(2);
})
it('should return 4', () => {
expect(game.getNbPlayerMin()).toBe(4);
})

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

@ -0,0 +1,62 @@
import { GameSolo } from '../GameSolo';
// Instances
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, 1, myMap);
// Get tests
describe('GameSolo get tests', () => {
it('should return bo jeu', () => {
expect(game.getName()).toBe('bo jeu');
})
it('should return require(blackjack.jpg)', () => {
expect(game.getImageSource()).toBe(require('bob_party/assets/ImagesJeux/blackjack.jpg'));
})
it('should return super jeu', () => {
expect(game.getGameSource()).toBe('super jeu');
})
it('should return 1', () => {
expect(game.getNbPlayerMin()).toBe(1);
})
it('should return 1', () => {
expect(game.getNbPlayerMax()).toBe(1);
})
it('should return myMap', () => {
expect(game.getSoloMap()).toBe(myMap);
})
})
// Setting new values
game.setGameSource('trop cool le jeu');
game.setImageSource(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
game.setName('beau jeu');
game.setNbPlayerMin(2);
game.setNbPlayerMax(3);
// Set tests
describe('GameSolo set tests', () => {
it('should return beau jeu', () => {
expect(game.getName()).toBe('beau jeu');
})
it('should return require(JeuDeDame.jpg)', () => {
expect(game.getImageSource).toBe(require('bob_party/assets/ImagesJeux/JeuDeDame.jpg'));
})
it('should return trop cool le jeu', () => {
expect(game.getGameSource()).toBe('trop cool le jeu');
})
it('should return 2', () => {
expect(game.getNbPlayerMin()).toBe(2);
})
it('should return 3', () => {
expect(game.getNbPlayerMax()).toBe(3);
})
})

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

@ -0,0 +1,56 @@
import { MatchSolo } from '../MatchSolo';
import { Conversation } from '../Conversation';
import { Skin } from '../Skin';
import { User } from '../User/user';
import { GameSolo } from '../GameSolo';
// Instances
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
let blue = new Skin("S0002", "Bob Blue", require('bob_party/assets/BobsSkins/BobBlue.png'), 100);
let tab:Skin[] = [classique, blue];
let dateBirth = new Date(2010,0o3,0o7);
let conv:Conversation[] = [];
let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv);
let tabU:User[] = [usr];
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, 1, myMap);
let match = new MatchSolo("machin", tabU, game);
let tabU2:User[] = [];
let game2 = new GameSolo("jeu magnifique", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "wow jeu", 1, 1, myMap)
// Get tests
describe('Match get tests', () => {
it('should return machin', () => {
expect(match.getCode()).toBe('machin');
})
it('should return tabU [usr] (users)', () => {
expect(match.getTabUsers()).toBe(tabU);
})
it('should return game', () => {
expect(match.getGame).toBe(game);
})
})
// Setting new values
match.setGame(game2);
match.setTabUser(tabU2);
// Set tests
describe('Match set tests', () => {
it('should return tabU2 [] (users)', () => {
expect(match.getTabUsers()).toBe(tabU2);
})
it('should return game2', () => {
expect(match.getGame).toBe(game2);
})
})

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

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

@ -1,18 +1,18 @@
import { User } from './User'; import { User } from '../User/user';
import { Skin } from './Skin'; import { Skin } from '../Skin';
import { Conversation } from './Conversation'; import { Conversation } from '../Conversation';
// Instances // Instances
let classique = new Skin('Classique', 'wouhou'); let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0);
let kikou = new Skin('Kikou', 'trop beau'); let blue = new Skin("S0002", "Bob Blue", require('bob_party/assets/BobsSkins/BobBlue.png'), 100);
let tab:Skin[] = []; let tab:Skin[] = [];
let tab2:Skin[] = [classique, kikou]; let tab2:Skin[] = [classique, blue];
let dateBirth = new Date(2010,0o3,0o7); let dateBirth = new Date(2010,0o3,0o7);
let dateBirth2 = new Date(2009,0o3,0o7); let dateBirth2 = new Date(2009,0o3,0o7);
let conv:Conversation[] = []; let conv:Conversation[] = [];
let conv2:Conversation[] = []; let conv2:Conversation[] = [];
let usr = new User('00001', 'Killyan', 'France', 'M', dateBirth, 0, 0, classique, tab, conv); let usr = new User('00001', 'Killyan', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab, conv);
// Tests des get // Tests des get
@ -23,6 +23,9 @@ describe('User get tests', () => {
it('should return Killyan', () => { it('should return Killyan', () => {
expect(usr.getUsername()).toBe('Killyan'); expect(usr.getUsername()).toBe('Killyan');
}) })
it('should return password', () => {
expect(usr.getPassword()).toBe('password');
})
it('should return France', () => { it('should return France', () => {
expect(usr.getNationality()).toBe('France'); expect(usr.getNationality()).toBe('France');
}) })
@ -38,6 +41,9 @@ describe('User get tests', () => {
it('should return 0', () => { it('should return 0', () => {
expect(usr.getTotalCoins()).toBe(0); expect(usr.getTotalCoins()).toBe(0);
}) })
it('should return 0', () => {
expect(usr.getGamePlayed()).toBe(0);
})
it('should return classique', () => { it('should return classique', () => {
expect(usr.getCurrentSkin()).toBe(classique); expect(usr.getCurrentSkin()).toBe(classique);
}) })
@ -51,26 +57,27 @@ describe('User get tests', () => {
// Set de nouvelles valeurs // Set de nouvelles valeurs
usr.setId('00002');
usr.setUsername('BgKillyan'); usr.setUsername('BgKillyan');
usr.setPassword('1234');
usr.setNationality('Marseille'); usr.setNationality('Marseille');
usr.setSexe('F'); usr.setSexe('F');
usr.setDateOfBirth(dateBirth2); usr.setDateOfBirth(dateBirth2);
usr.setCurrentCoins(2); usr.setCurrentCoins(2);
usr.setTotalCoins(2); usr.setTotalCoins(2);
usr.setCurrentSkin(kikou); usr.setGamePlayed(4);
usr.setCurrentSkin(blue);
usr.setTabSkin(tab2); usr.setTabSkin(tab2);
usr.setTabConv(conv2); usr.setTabConv(conv2);
// Tests des set // Tests des set
describe('User get tests', () => { describe('User get tests', () => {
it('should return 00002', () => {
expect(usr.getId()).toBe('00002');
})
it('should return BgKillyan', () => { it('should return BgKillyan', () => {
expect(usr.getUsername()).toBe('BgKillyan'); expect(usr.getUsername()).toBe('BgKillyan');
}) })
it('should return 1234', () => {
expect(usr.getPassword()).toBe('1234');
})
it('should return Marseille', () => { it('should return Marseille', () => {
expect(usr.getNationality()).toBe('Marseille'); expect(usr.getNationality()).toBe('Marseille');
}) })
@ -86,8 +93,11 @@ describe('User get tests', () => {
it('should return 2', () => { it('should return 2', () => {
expect(usr.getTotalCoins()).toBe(2); expect(usr.getTotalCoins()).toBe(2);
}) })
it('should return 4', () => {
expect(usr.getGamePlayed()).toBe(4);
})
it('should return kikou', () => { it('should return kikou', () => {
expect(usr.getCurrentSkin()).toBe(kikou); expect(usr.getCurrentSkin()).toBe(blue);
}) })
it('should return tab2', () => { it('should return tab2', () => {
expect(usr.getTabSkin()).toBe(tab2); expect(usr.getTabSkin()).toBe(tab2);

@ -6,7 +6,7 @@ import { Skin } from '../core/skin';
import { TopBar } from '../components/TopBar'; import { TopBar } from '../components/TopBar';
import { BotBar } from '../components/BotBar'; import { BotBar } from '../components/BotBar';
import { ScreenIndicator } from '../components/ScreenIndicator'; import { ScreenIndicator } from '../components/ScreenIndicator';
import { User } from '../core/user'; import { User } from '../core/User/user';
import { FlatList } from 'react-native-gesture-handler'; import { FlatList } from 'react-native-gesture-handler';
import { ConversationComponent } from '../components/ConversationComponent'; import { ConversationComponent } from '../components/ConversationComponent';

@ -1,21 +1,22 @@
import { StatusBar } from 'expo-status-bar' import { StatusBar } from 'expo-status-bar'
import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native' import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native'
import React from 'react'; import React from 'react';
import { Game } from '../core/Game'; import { Game } from '../core/game';
import { Skin } from '../core/skin'; import { Skin } from '../core/skin';
import { TopBar } from '../components/TopBar'; import { TopBar } from '../components/TopBar';
import { BotBar } from '../components/BotBar'; import { BotBar } from '../components/BotBar';
import { GameComponent } from '../components/GameComponent'; import { GameComponent } from '../components/GameComponent';
import { User } from '../core/user'; import { User } from '../core/User/user';
import tabSkinApp from '../constSkin'; import tabSkinApp from '../constSkin';
import { Conversation } from '../core/conversation'; import { Conversation } from '../core/conversation';
import { GameSolo } from '../core/gameSolo';
let tabConv:Conversation[]=[]; let tabConv:Conversation[]=[];
const msc = require('../../assets/Icons/FondGris.png'); const msc = require('../../assets/Icons/FondGris.png');
const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv); const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv);
const jeuTest= new Game("SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin", 1); const jeuTest= new GameSolo("SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin", 1, new Map<number,number>);
function GameChoice(props: { navigation: any; }) { function GameChoice(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
return ( return (

@ -2,7 +2,7 @@ import { StatusBar } from 'expo-status-bar'
import { StyleSheet, View, ImageSourcePropType} from 'react-native' import { StyleSheet, View, ImageSourcePropType} from 'react-native'
import React from 'react'; import React from 'react';
import stylesScreen from './style/screens.style' import stylesScreen from './style/screens.style'
import { User } from '../core/user'; import { User } from '../core/User/user';
import { Skin } from '../core/skin'; import { Skin } from '../core/skin';
import { TopBar } from '../components/TopBar'; import { TopBar } from '../components/TopBar';
import { BotBar } from '../components/BotBar'; import { BotBar } from '../components/BotBar';

@ -6,7 +6,7 @@ import styles from './style/Profile.style'
import { TopBar } from '../components/TopBar'; import { TopBar } from '../components/TopBar';
import { BotBar } from '../components/BotBar'; import { BotBar } from '../components/BotBar';
import { SkinComponent } from '../components/Skin'; import { SkinComponent } from '../components/Skin';
import { User } from '../core/user'; import { User } from '../core/User/user';
import tabSkinApp from '../constSkin'; import tabSkinApp from '../constSkin';
import tabConv from '../constCov' import tabConv from '../constCov'
import { ButtonGreySmall } from '../components/ButtonGreySmall'; import { ButtonGreySmall } from '../components/ButtonGreySmall';

Loading…
Cancel
Save