From 70d58cab456d344cfcaf6b323375a8f898547b70 Mon Sep 17 00:00:00 2001 From: majean5 Date: Thu, 17 Nov 2022 10:46:17 +0100 Subject: [PATCH] corrections user (suppression du tabConv) --- bob_party/src/core/User/user.ts | 19 +------------------ bob_party/src/core/User/userCreator.ts | 3 +-- bob_party/src/core/tests/conversation.test.ts | 6 +++--- bob_party/src/core/tests/users.test.ts | 17 ++++------------- 4 files changed, 9 insertions(+), 36 deletions(-) diff --git a/bob_party/src/core/User/user.ts b/bob_party/src/core/User/user.ts index 4ab3882..9f139f5 100644 --- a/bob_party/src/core/User/user.ts +++ b/bob_party/src/core/User/user.ts @@ -15,11 +15,10 @@ export class User{ 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, - nbGamesPlayed:number, currentSkin: Skin, tabSkin: Skin[], tabConv: Conversation[] ){ + nbGamesPlayed:number, currentSkin: Skin, tabSkin: Skin[]){ this.id=id; this.username=username; this.password=password; @@ -31,7 +30,6 @@ export class User{ this.totalCoins=totalCoins; this.currentSkin=currentSkin; this.tabSkin=tabSkin.copyWithin(tabSkin.length, 0); - this.tabConv=tabConv.copyWithin(tabConv.length, 0); } @@ -142,27 +140,12 @@ export class User{ setTabSkin(tabSkin: Skin[]){ this.tabSkin=[...tabSkin]; } - - /* Brief : Function getting the conversations of a user */ - getTabConv(){ - return this.tabConv; - } - - /* Brief : Function setting the conversations of a user */ - setTabConv(tabConv: Conversation[]){ - this.tabConv=[...tabConv] - } /* Brief : Function adding a skin to a user */ addSkin(skin:Skin){ this.tabSkin.push(skin); } - /* Brief : Function adding a conversation to a user */ - addConversation(conv:Conversation){ - this.tabConv.push(conv); - } - isEqual(u:User){ if (u.getId()==this.id){ return true; diff --git a/bob_party/src/core/User/userCreator.ts b/bob_party/src/core/User/userCreator.ts index f93240e..787f784 100644 --- a/bob_party/src/core/User/userCreator.ts +++ b/bob_party/src/core/User/userCreator.ts @@ -4,9 +4,8 @@ import { Conversation } from "../conversation"; export class UserCreator{ createUser(username:string, password:string, nationality:string, sexe:string, date:Date){ - let tabConv:Conversation[]=[]; //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]], tabConv); + 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; } diff --git a/bob_party/src/core/tests/conversation.test.ts b/bob_party/src/core/tests/conversation.test.ts index 4f56c84..82f9062 100644 --- a/bob_party/src/core/tests/conversation.test.ts +++ b/bob_party/src/core/tests/conversation.test.ts @@ -9,8 +9,8 @@ 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); @@ -20,7 +20,7 @@ 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); +let usr3 = new User('00003', 'wow', 'password', 'France', 'M', dateBirth, 0, 0, 0, classique, tab); // Get tests diff --git a/bob_party/src/core/tests/users.test.ts b/bob_party/src/core/tests/users.test.ts index 867c9f5..d397627 100644 --- a/bob_party/src/core/tests/users.test.ts +++ b/bob_party/src/core/tests/users.test.ts @@ -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); - }) }) \ No newline at end of file