corrections user (suppression du tabConv)
continuous-integration/drone/push Build is failing Details

temp
Mathilde JEAN 2 years ago
parent 4fde4eadb4
commit 70d58cab45

@ -15,11 +15,10 @@ export class User{
private nbGamesPlayed: number; private nbGamesPlayed: number;
private currentSkin: Skin; private currentSkin: Skin;
private tabSkin: Skin[]; private tabSkin: Skin[];
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,
nbGamesPlayed:number, currentSkin: Skin, tabSkin: Skin[], tabConv: Conversation[] ){ nbGamesPlayed:number, currentSkin: Skin, tabSkin: Skin[]){
this.id=id; this.id=id;
this.username=username; this.username=username;
this.password=password; this.password=password;
@ -31,7 +30,6 @@ export class User{
this.totalCoins=totalCoins; this.totalCoins=totalCoins;
this.currentSkin=currentSkin; this.currentSkin=currentSkin;
this.tabSkin=tabSkin.copyWithin(tabSkin.length, 0); this.tabSkin=tabSkin.copyWithin(tabSkin.length, 0);
this.tabConv=tabConv.copyWithin(tabConv.length, 0);
} }
@ -142,27 +140,12 @@ export class User{
setTabSkin(tabSkin: Skin[]){ setTabSkin(tabSkin: Skin[]){
this.tabSkin=[...tabSkin]; 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 */ /* Brief : Function adding a skin to a user */
addSkin(skin:Skin){ addSkin(skin:Skin){
this.tabSkin.push(skin); this.tabSkin.push(skin);
} }
/* Brief : Function adding a conversation to a user */
addConversation(conv:Conversation){
this.tabConv.push(conv);
}
isEqual(u:User){ isEqual(u:User){
if (u.getId()==this.id){ if (u.getId()==this.id){
return true; return true;

@ -4,9 +4,8 @@ import { Conversation } from "../conversation";
export class UserCreator{ export class UserCreator{
createUser(username:string, password:string, nationality:string, sexe:string, date:Date){ createUser(username:string, password:string, nationality:string, sexe:string, date:Date){
let tabConv:Conversation[]=[];
//Récup l'ID d'après dans la bdd //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 //Ajout du joueur dans la bdd
return u; return u;
} }

@ -9,8 +9,8 @@ let conv:Conversation[] = [];
let tab:Skin[] = []; let tab:Skin[] = [];
let classique = new Skin("S0001", "Bob", require('bob_party/assets/BobsSkins/BobClassic.png'), 0); 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', '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', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab, conv); let usr2 = new User('00002', 'Karina', '1234', 'France', 'F', dateBirth, 5, 6, 8, classique, tab);
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 theDate3 = new Date(2022,10,15); 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 mess3 = new Message('Mais oui trop de ouf', usr, theDate3);
let tabM:Message[] = [mess, mess2]; let tabM:Message[] = [mess, mess2];
let convo = new Conversation(tabU, tabM, 'the conv'); 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 // Get tests

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