diff --git a/bob_party/src/constCov.ts b/bob_party/src/constCov.ts index 5918814..9051b6a 100644 --- a/bob_party/src/constCov.ts +++ b/bob_party/src/constCov.ts @@ -1,7 +1,7 @@ import { Message } from "./core/message" import { Conversation } from "./core/conversation" 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); diff --git a/bob_party/src/core/Game.ts b/bob_party/src/core/Game.ts index 52c1b0a..23dbd69 100644 --- a/bob_party/src/core/Game.ts +++ b/bob_party/src/core/Game.ts @@ -1,57 +1,69 @@ import { randomBytes } from "crypto"; import { ImageSourcePropType } from "react-native"; -export class Game{ - private Name:string; - private ImageSource:ImageSourcePropType; - private GameSource:string; - private NbPlayer: number; +export abstract class Game{ + private name:string; + private imageSource:ImageSourcePropType; + private gameSource:string; + private nbPlayerMin: number; + private nbPlayerMax:number; /* Constructor of the class */ - constructor (name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number){ - this.Name=name; - this.ImageSource=imageSource; - this.GameSource=gameSource; - this.NbPlayer=nbPlayer; + constructor (name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){ + this.name=name; + this.imageSource=imageSource; + this.gameSource=gameSource; + this.nbPlayerMin=nbPlayerMin; + this.nbPlayerMax=nbPlayerMax; } /* Brief : Function getting the name of a game */ getName(){ - return this.Name; + return this.name; } /* Brief : Function setting the name of a game */ setName(name:string){ - this.Name=name; + this.name=name; } /* Brief : Function getting the image of a game */ getImageSource(){ - return this.ImageSource; + return this.imageSource; } /* Brief : Function setting the image of a game */ setImageSource(imageSource:ImageSourcePropType){ - this.ImageSource=imageSource; + this.imageSource=imageSource; } /* Brief : Function getting the source of a game */ getGameSource(){ - return this.GameSource; + return this.gameSource; } /* Brief : Function setting the source of a game */ setGameSource(gameSource:string){ - this.GameSource=gameSource; + this.gameSource=gameSource; } /* Brief : Function getting the number of player */ - getNbPlayer(){ - return this.NbPlayer; + getNbPlayerMin(){ + return this.nbPlayerMin; } /* Brief : Function setting the number of player*/ - setNbPlayer(nbPlayer:number){ - this.NbPlayer=nbPlayer; + setNbPlayerMin(nbPlayerMin:number){ + this.nbPlayerMin=nbPlayerMin; + } + + /* Brief : Function getting the number of player */ + getNbPlayerMax(){ + return this.nbPlayerMax; + } + + /* Brief : Function setting the number of player*/ + setNbPlayerMax(nbPlayerMax:number){ + this.nbPlayerMax=nbPlayerMax; } } \ No newline at end of file diff --git a/bob_party/src/core/User/SkinBuyer.ts b/bob_party/src/core/User/SkinBuyer.ts new file mode 100644 index 0000000..692c9b2 --- /dev/null +++ b/bob_party/src/core/User/SkinBuyer.ts @@ -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()); + + } +} \ No newline at end of file diff --git a/bob_party/src/core/User/managerCoinsUser.ts b/bob_party/src/core/User/managerCoinsUser.ts new file mode 100644 index 0000000..2f81893 --- /dev/null +++ b/bob_party/src/core/User/managerCoinsUser.ts @@ -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); + } +} \ No newline at end of file diff --git a/bob_party/src/core/user.ts b/bob_party/src/core/User/user.ts similarity index 62% rename from bob_party/src/core/user.ts rename to bob_party/src/core/User/user.ts index f2ce858..c421f9c 100644 --- a/bob_party/src/core/user.ts +++ b/bob_party/src/core/User/user.ts @@ -1,159 +1,159 @@ -import { Skin } from './Skin' -import { Conversation } from './conversation'; +import { Skin } from '../Skin' +import { Conversation } from '../conversation'; import { sign } from 'crypto'; export class User{ - readonly Id: string; - private Username: string; - private Password: string; - private Nationality: string; - private Sexe: string; - private DateOfBirth: Date; - private CurrentCoins: number; - private TotalCoins: number; - private NbGamePlayed: number; - private CurrentSkin: Skin; - private TabSkin: Skin[]; - private TabConv?: Conversation[]; + readonly id: string; + private username: string; + private password: string; + private nationality: string; + private sexe: string; + private dateOfBirth: Date; + private currentCoins: number; + private totalCoins: number; + private nbGamePlayed: 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[] ){ - this.Id=id; - this.Username=username; - this.Password=password; - this.Nationality=nationality; - this.Sexe=sexe; - this.DateOfBirth=dateOfBirth; - this.NbGamePlayed=nbGamePlayed; - this.CurrentCoins=currentCoins; - this.TotalCoins=totalCoins; - this.CurrentSkin=currentSkin; - this.TabSkin=[...tabSkin]; + this.id=id; + this.username=username; + this.password=password; + this.nationality=nationality; + this.sexe=sexe; + this.dateOfBirth=dateOfBirth; + this.nbGamePlayed=nbGamePlayed; + this.currentCoins=currentCoins; + this.totalCoins=totalCoins; + this.currentSkin=currentSkin; + this.tabSkin=[...tabSkin]; tabConv?.forEach(conv => { - this.TabConv?.push(conv); + this.tabConv?.push(conv); }); } /* Brief : Function getting the name of an user */ getUsername(){ - return this.Username; + return this.username; } /* Brief : Function setting the name of an user */ setUsername(username: string){ - this.Username=username; + this.username=username; } /* Brief : Function getting the id of an user */ getId(){ - return this.Id; + return this.id; } getPassword(){ - return this.Password; + return this.password; } setPassword(password:string){ - this.Password=password; + this.password=password; } /* Brief : Function getting the current number of coins of an user */ getCurrentCoins(){ - return this.CurrentCoins; + return this.currentCoins; } /* Brief : Function setting the current number of coins of an user */ setCurrentCoins(currentCoins: number){ - this.CurrentCoins=currentCoins; + this.currentCoins=currentCoins; } /* Brief : Function getting the sex of an user */ getSexe(){ - return this.Sexe; + return this.sexe; } /* Brief : Function getting the sex of an user */ setSexe(sexe: string){ - this.Sexe=sexe; + this.sexe=sexe; } /* Brief : Function getting the date of birth of an user */ getDateOfBirth(){ - return this.DateOfBirth; + return this.dateOfBirth; } /* Brief : Function setting the date of birth of an user */ setDateOfBirth(dateOfBirth: Date){ - this.DateOfBirth=dateOfBirth; + this.dateOfBirth=dateOfBirth; } /* Brief : Function getting the nationality of an user */ getNationality(){ - return this.Nationality; + return this.nationality; } /* Brief : Function setting the nationality of an user */ setNationality(nationality: string){ - this.Nationality=nationality; + this.nationality=nationality; } /* Brief : Function getting the total number of coins of an user */ getTotalCoins(){ - return this.TotalCoins; + return this.totalCoins; } /* Brief : Function setting the total number of coins of an user */ setTotalCoins(totalCoins: number){ - this.TotalCoins=totalCoins; + this.totalCoins=totalCoins; } /* Brief : Function getting the current number of game played by an user */ getGamePlayed(){ - return this.NbGamePlayed; + return this.nbGamePlayed; } /* Brief : Function setting the current number of game played by an user */ setGamePlayed(nb: number){ - this.NbGamePlayed=nb; + this.nbGamePlayed=nb; } /* Brief : Function getting the current skin of an user */ getCurrentSkin(){ - return this.CurrentSkin; + return this.currentSkin; } /* Brief : Function setting the current skin of an user */ setCurrentSkin(newSkin: Skin){ - this.CurrentSkin=newSkin; + this.currentSkin=newSkin; } /* Brief : Function getting the skins of an user */ getTabSkin(){ - return this.TabSkin; + return this.tabSkin; } /* Brief : Function setting the skins of an user */ setTabSkin(tabSkin: Skin[]){ - this.TabSkin=[...tabSkin]; + this.tabSkin=[...tabSkin]; } /* Brief : Function getting the conversations of an user */ getTabConv(){ - return this.TabConv; + return this.tabConv; } /* Brief : Function setting the conversations of an user */ setTabConv(tabConv?: Conversation[]){ tabConv?.forEach(conv => { - this.TabConv?.push(conv); + this.tabConv?.push(conv); }); } - + /* changeUserCoins(coin:number){ this.CurrentCoins+=coin; if (coin>0){ @@ -175,4 +175,9 @@ export class User{ } return false; } + + usrPasswordEquals(username:string, password:string){ + return this.Password==password && this.Username==username; + } + */ } \ No newline at end of file diff --git a/bob_party/src/core/conversation.test.ts b/bob_party/src/core/conversation.test.ts deleted file mode 100644 index 11a40a9..0000000 --- a/bob_party/src/core/conversation.test.ts +++ /dev/null @@ -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); - }) -}) \ No newline at end of file diff --git a/bob_party/src/core/conversation.ts b/bob_party/src/core/conversation.ts index 76a49cc..524b70e 100644 --- a/bob_party/src/core/conversation.ts +++ b/bob_party/src/core/conversation.ts @@ -1,60 +1,72 @@ import { Message } from "./message" -import { User } from "./user"; +import { User } from "./User/user"; export class Conversation{ - private TabUser: User[]; - private TabMessage: Message[]; - private Name: string; + private tabUser: User[]; + private tabMessage: Message[]; + private name: string; /* Constructor of the class */ constructor(tabUser: User[], tabMessage:Message[], name:string){ - this.TabUser=[...tabUser]; - this.TabMessage=[...tabMessage]; - this.Name=name; + this.tabUser=[...tabUser]; + this.tabMessage=[...tabMessage]; + this.name=name; } /* Brief : function returning the messages of a conversation */ getTabMessage(){ this.sortMessageDesc(); - return this.TabMessage; + return this.tabMessage; } /* Brief : function returning the users of a conversation */ +<<<<<<< HEAD +======= + +>>>>>>> fe24058f3896c88fae68bff0b08ab4cb8b61ca2e getTabUser(){ - return this.TabUser; + return this.tabUser; } /* Brief : function adding an user to a conversation */ ajouterUser(us:User){ - this.TabUser?.push(us); + this.tabUser?.push(us); } /* Brief : function adding a message to a conversation */ ajouterMessage(mess:Message){ - this.TabMessage?.push(mess); + this.tabMessage?.push(mess); this.sortMessageDesc(); } /* Brief : function returning the name to a conversation */ getName(){ - return this.Name; +<<<<<<< HEAD +======= + +>>>>>>> fe24058f3896c88fae68bff0b08ab4cb8b61ca2e + return this.name; } /* Brief : function setting the name to a conversation */ +<<<<<<< HEAD +======= + +>>>>>>> fe24058f3896c88fae68bff0b08ab4cb8b61ca2e setName(name:string){ - this.Name=name; + this.name=name; } /* Brief : function returning the last message of a conversation */ getLastMessage(){ 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 */ sortMessageDesc(){ - this.TabMessage.sort( + this.tabMessage.sort( (objA, objB) => objB.getMessageDate().getTime() - objA.getMessageDate().getTime(), ); } diff --git a/bob_party/src/core/gameCasino.ts b/bob_party/src/core/gameCasino.ts index b58caa4..1786def 100644 --- a/bob_party/src/core/gameCasino.ts +++ b/bob_party/src/core/gameCasino.ts @@ -2,20 +2,8 @@ import { ImageSourcePropType } from 'react-native'; import { Game } from './game' export class GameCasino extends Game{ - readonly Coef:number; - constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, coef:number){ - super(name, imageSource, gameSource, nbPlayer); - 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; + constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number){ + super(name, imageSource, gameSource, nbPlayerMin, nbPlayerMax); } } \ No newline at end of file diff --git a/bob_party/src/core/gameMulti.ts b/bob_party/src/core/gameMulti.ts index 4555331..3fc5ea0 100644 --- a/bob_party/src/core/gameMulti.ts +++ b/bob_party/src/core/gameMulti.ts @@ -2,23 +2,23 @@ import { ImageSourcePropType } from 'react-native'; import { Game } from './game' export class GameMulti extends Game{ - readonly RankToCoins:Map + readonly rankToCoins:Map - constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, rankToCoins:Map){ - super(name, imageSource, gameSource, nbPlayer); - this.RankToCoins=rankToCoins; + constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, rankToCoins:Map){ + super(name, imageSource, gameSource, nbPlayerMin, nbPlayerMax); + this.rankToCoins=rankToCoins; } //Get the map of the game with the rank as the key and the coins as the values getMultiMap(){ - return this.RankToCoins; + return this.rankToCoins; } //Returns the coins gained depending on the rank CoinsWithRank(rank:number){ let coins; - for (let key of this.RankToCoins.keys()){ - coins = this.RankToCoins.get(key); + for (let key of this.rankToCoins.keys()){ + coins = this.rankToCoins.get(key); if (rank==key ){ return coins; } diff --git a/bob_party/src/core/gameSolo.ts b/bob_party/src/core/gameSolo.ts index 64cecdb..ba88a33 100644 --- a/bob_party/src/core/gameSolo.ts +++ b/bob_party/src/core/gameSolo.ts @@ -2,23 +2,23 @@ import { ImageSourcePropType } from 'react-native'; import { Game } from './game' export class GameSolo extends Game{ - readonly PtsToCoins:Map + readonly ptsToCoins:Map - constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, ptsToCoins:Map){ - super(name, imageSource, gameSource, nbPlayer); - this.PtsToCoins=ptsToCoins; + constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayerMin:number, nbPlayerMax:number, ptsToCoins:Map){ + super(name, imageSource, gameSource, nbPlayerMin,nbPlayerMax); + this.ptsToCoins=ptsToCoins; } //Get the map of the game with points millestone as the keys and coins as the values getSoloMap(){ - return this.PtsToCoins; + return this.ptsToCoins; } - //Returns the gained depending on the number of points + //Returns the gain depending on the number of points CoinsWithPoints(nbPoints:number){ let coins; - for (let key of this.PtsToCoins.keys()){ - coins = this.PtsToCoins.get(key); + for (let key of this.ptsToCoins.keys()){ + coins = this.ptsToCoins.get(key); if (nbPoints { - 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'); - }) -})*/ \ No newline at end of file diff --git a/bob_party/src/core/skin.ts b/bob_party/src/core/skin.ts index 57d6b60..3ae712f 100644 --- a/bob_party/src/core/skin.ts +++ b/bob_party/src/core/skin.ts @@ -1,51 +1,51 @@ import { ImageSourcePropType } from "react-native"; export class Skin{ - readonly Id: string; - private Name: string; - private Source: ImageSourcePropType; - private Cost:number; + readonly id: string; + private name: string; + private source: ImageSourcePropType; + private cost:number; /* Constructor of the class */ constructor(id:string, name: string, source:ImageSourcePropType, Cost:number){ - this.Id=id; - this.Name=name; - this.Source=source; - this.Cost=Cost; + this.id=id; + this.name=name; + this.source=source; + this.cost=Cost; } /* Brief : Fuction setting the name of a skin */ setSkinName(name: string){ - this.Name=name; + this.name=name; } /* Brief : Fuction setting the source of the image of a skin */ setSkinSource(source: ImageSourcePropType){ - this.Source=source; + this.source=source; } /* Brief : Fuction getting the source of the image of a skin */ getSkinSource(){ - return this.Source; + return this.source; } /* Brief : Fuction getting the name of a skin */ getSkinName(){ - return this.Name; + return this.name; } /* Brief : Fuction getting the id of a skin */ getSkinId(){ - return this.Id; + return this.id; } /* Brief : Fuction getting the cost of a skin */ getSkinCost(){ - return this.Cost; + return this.cost; } /* Brief : Fuction getting the cost of a skin */ setSkinCost(cost:number){ - this.Cost=cost; + this.cost=cost; } } \ No newline at end of file diff --git a/bob_party/src/core/tests/conversation.test.ts b/bob_party/src/core/tests/conversation.test.ts new file mode 100644 index 0000000..4f56c84 --- /dev/null +++ b/bob_party/src/core/tests/conversation.test.ts @@ -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'); + }) +}) \ No newline at end of file diff --git a/bob_party/src/core/tests/gameCasino.test.ts b/bob_party/src/core/tests/gameCasino.test.ts new file mode 100644 index 0000000..6900cd3 --- /dev/null +++ b/bob_party/src/core/tests/gameCasino.test.ts @@ -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); + }) \ No newline at end of file diff --git a/bob_party/src/core/tests/gameMulti.test.ts b/bob_party/src/core/tests/gameMulti.test.ts new file mode 100644 index 0000000..61e0e3c --- /dev/null +++ b/bob_party/src/core/tests/gameMulti.test.ts @@ -0,0 +1,62 @@ +import { GameMulti } from '../gameMulti'; + + +// Instances +let myMap = new Map([ + [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); + }) +}) \ No newline at end of file diff --git a/bob_party/src/core/tests/gameSolo.test.ts b/bob_party/src/core/tests/gameSolo.test.ts new file mode 100644 index 0000000..10e9c87 --- /dev/null +++ b/bob_party/src/core/tests/gameSolo.test.ts @@ -0,0 +1,62 @@ +import { GameSolo } from '../GameSolo'; + + +// Instances +let myMap = new Map([ + [50, 3], + [75, 4], + [100, 5], + [150, 6] +]); +let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, 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); + }) +}) \ No newline at end of file diff --git a/bob_party/src/core/tests/match.test.ts b/bob_party/src/core/tests/match.test.ts new file mode 100644 index 0000000..3a561e8 --- /dev/null +++ b/bob_party/src/core/tests/match.test.ts @@ -0,0 +1,3 @@ +import { Match } from '../Match'; + + diff --git a/bob_party/src/core/tests/matchSolo.test.ts b/bob_party/src/core/tests/matchSolo.test.ts new file mode 100644 index 0000000..a85962f --- /dev/null +++ b/bob_party/src/core/tests/matchSolo.test.ts @@ -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([ + [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); + }) +}) \ No newline at end of file diff --git a/bob_party/src/core/message.test.ts b/bob_party/src/core/tests/message.test.ts similarity index 63% rename from bob_party/src/core/message.test.ts rename to bob_party/src/core/tests/message.test.ts index f8eb98d..a4df757 100644 --- a/bob_party/src/core/message.test.ts +++ b/bob_party/src/core/tests/message.test.ts @@ -1,21 +1,21 @@ -import { Message } from './Message'; -import { User } from './User'; -import { Conversation } from './Conversation'; -import { Skin } from './Skin'; +import { Message } from '../Message'; +import { User } from '../User/user'; +import { Conversation } from '../Conversation'; +import { Skin } from '../Skin'; -// Instance +// Instances let conv:Conversation[] = []; 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 usr = new User('00001', 'Killyan', 'France', 'M', dateBirth, 0, 0, classique, tab, conv); -let usr2 = new User('00002', 'Karina', 'France', 'F', dateBirth, 5, 6, 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', '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 mess = new Message('Bob Party est le meilleur projet', usr, theDate); -// Tests des get +// Get tests describe('Message get tests', () => { it('should return 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.setSMessageSender(usr2); -mess.setSMessageDate(theDate2); +mess.setMessageSender(usr2); +mess.setMessageDate(theDate2); -// Tests de set +// Set tests describe('Message set tests', () => { it('should return Vive Bob Party', () => { expect(mess.getMessageContent()).toBe('Vive Bob Party'); diff --git a/bob_party/src/core/tests/skin.test.ts b/bob_party/src/core/tests/skin.test.ts new file mode 100644 index 0000000..4ef52fb --- /dev/null +++ b/bob_party/src/core/tests/skin.test.ts @@ -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); + }) +}) \ No newline at end of file diff --git a/bob_party/src/core/users.test.ts b/bob_party/src/core/tests/users.test.ts similarity index 70% rename from bob_party/src/core/users.test.ts rename to bob_party/src/core/tests/users.test.ts index c46a712..867c9f5 100644 --- a/bob_party/src/core/users.test.ts +++ b/bob_party/src/core/tests/users.test.ts @@ -1,18 +1,18 @@ -import { User } from './User'; -import { Skin } from './Skin'; -import { Conversation } from './Conversation'; +import { User } from '../User/user'; +import { Skin } from '../Skin'; +import { Conversation } from '../Conversation'; // Instances -let classique = new Skin('Classique', 'wouhou'); -let kikou = new Skin('Kikou', 'trop beau'); +let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0); +let blue = new Skin("S0002", "Bob Blue", require('bob_party/assets/BobsSkins/BobBlue.png'), 100); let tab:Skin[] = []; -let tab2:Skin[] = [classique, kikou]; +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', '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 @@ -23,6 +23,9 @@ describe('User get tests', () => { it('should return Killyan', () => { expect(usr.getUsername()).toBe('Killyan'); }) + it('should return password', () => { + expect(usr.getPassword()).toBe('password'); + }) it('should return France', () => { expect(usr.getNationality()).toBe('France'); }) @@ -38,6 +41,9 @@ describe('User get tests', () => { it('should return 0', () => { expect(usr.getTotalCoins()).toBe(0); }) + it('should return 0', () => { + expect(usr.getGamePlayed()).toBe(0); + }) it('should return classique', () => { expect(usr.getCurrentSkin()).toBe(classique); }) @@ -51,26 +57,27 @@ describe('User get tests', () => { // Set de nouvelles valeurs -usr.setId('00002'); usr.setUsername('BgKillyan'); +usr.setPassword('1234'); usr.setNationality('Marseille'); usr.setSexe('F'); usr.setDateOfBirth(dateBirth2); usr.setCurrentCoins(2); usr.setTotalCoins(2); -usr.setCurrentSkin(kikou); +usr.setGamePlayed(4); +usr.setCurrentSkin(blue); usr.setTabSkin(tab2); usr.setTabConv(conv2); // Tests des set describe('User get tests', () => { - it('should return 00002', () => { - expect(usr.getId()).toBe('00002'); - }) it('should return BgKillyan', () => { expect(usr.getUsername()).toBe('BgKillyan'); }) + it('should return 1234', () => { + expect(usr.getPassword()).toBe('1234'); + }) it('should return Marseille', () => { expect(usr.getNationality()).toBe('Marseille'); }) @@ -86,8 +93,11 @@ describe('User get tests', () => { it('should return 2', () => { expect(usr.getTotalCoins()).toBe(2); }) + it('should return 4', () => { + expect(usr.getGamePlayed()).toBe(4); + }) it('should return kikou', () => { - expect(usr.getCurrentSkin()).toBe(kikou); + expect(usr.getCurrentSkin()).toBe(blue); }) it('should return tab2', () => { expect(usr.getTabSkin()).toBe(tab2); diff --git a/bob_party/src/screens/Chat.tsx b/bob_party/src/screens/Chat.tsx index 01fa2ae..1b1532f 100644 --- a/bob_party/src/screens/Chat.tsx +++ b/bob_party/src/screens/Chat.tsx @@ -6,7 +6,7 @@ import { Skin } from '../core/skin'; import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { ScreenIndicator } from '../components/ScreenIndicator'; -import { User } from '../core/user'; +import { User } from '../core/User/user'; import { FlatList } from 'react-native-gesture-handler'; import { ConversationComponent } from '../components/ConversationComponent'; diff --git a/bob_party/src/screens/GameChoice.tsx b/bob_party/src/screens/GameChoice.tsx index c5088d5..f5878ec 100644 --- a/bob_party/src/screens/GameChoice.tsx +++ b/bob_party/src/screens/GameChoice.tsx @@ -1,21 +1,22 @@ import { StatusBar } from 'expo-status-bar' import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native' import React from 'react'; -import { Game } from '../core/Game'; +import { Game } from '../core/game'; import { Skin } from '../core/skin'; import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { GameComponent } from '../components/GameComponent'; -import { User } from '../core/user'; +import { User } from '../core/User/user'; import tabSkinApp from '../constSkin'; import { Conversation } from '../core/conversation'; +import { GameSolo } from '../core/gameSolo'; let tabConv:Conversation[]=[]; const msc = require('../../assets/Icons/FondGris.png'); const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv); -const jeuTest= new 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); function GameChoice(props: { navigation: any; }) { const { navigation } = props return ( diff --git a/bob_party/src/screens/Home.tsx b/bob_party/src/screens/Home.tsx index 73d774b..14acbb9 100644 --- a/bob_party/src/screens/Home.tsx +++ b/bob_party/src/screens/Home.tsx @@ -2,7 +2,7 @@ import { StatusBar } from 'expo-status-bar' import { StyleSheet, View, ImageSourcePropType} from 'react-native' import React from 'react'; import stylesScreen from './style/screens.style' -import { User } from '../core/user'; +import { User } from '../core/User/user'; import { Skin } from '../core/skin'; import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; diff --git a/bob_party/src/screens/Profile.tsx b/bob_party/src/screens/Profile.tsx index 631e9e9..d9f44d0 100644 --- a/bob_party/src/screens/Profile.tsx +++ b/bob_party/src/screens/Profile.tsx @@ -6,7 +6,7 @@ import styles from './style/Profile.style' import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { SkinComponent } from '../components/Skin'; -import { User } from '../core/user'; +import { User } from '../core/User/user'; import tabSkinApp from '../constSkin'; import tabConv from '../constCov' import { ButtonGreySmall } from '../components/ButtonGreySmall';