-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.ts
42 lines (36 loc) · 1.03 KB
/
Player.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Profile from "./Profile";
export default class Player {
profile: Profile;
id: number;
name: string;
score: number;
wins: number;
totalGamesPlayed: number;
cardArray: Array<number>;
constructor(profile: Profile) {
this.profile = profile;
this.id = profile.id;
this.name = profile.name;
this.score = 0;
this.wins = 0;
this.totalGamesPlayed = 0;
this.cardArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
}
changeScore(change: number) {
this.score = this.score + change;
}
retrieveScore() {
return this.score;
}
getWinRate() {
return this.wins / this.totalGamesPlayed;
}
updateProfile() {
// this.profile.update(this.wins, this.totalGamesPlayed, this.cardArray);
this.profile.gamesPlayed += this.totalGamesPlayed;
this.profile.gamesWon += this.wins;
for (let i = 0; i < 14; i++) {
this.profile.cardDistribution[i] += this.cardArray[i];
}
}
}