-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.js
129 lines (108 loc) · 3.45 KB
/
user.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
'use strict';
var User = function(id) {
this.health = 0;
this.deck = {};
this.deck.monsters = new Array();
this.deck.items = new Array();
this.deck.skill = new Array();
this.deck.deity = new Array();
this.coins = 5;
this.additionalDefense = 0
this.additionalAttack = 0
this.id = id;
};
User.prototype.getHealth = function() {
return this.health;
}
User.prototype.addHealth = function(val) {
this.health += val;
if (this.health>0) this.health = 0;
}
User.prototype.getDefense = function() {
var points = 0;
for(let i=0;i < this.deck.monsters.length;i++) {
points += this.deck.monsters[i].constDefense;
}
if (this.deck.monsters.length) points += this.deck.monsters[0].temporaryDefense;
for(let i=0;i < this.deck.items.length;i++) {
points += this.deck.items[i].constDefense;
}
if (this.deck.items.length) points += this.deck.items[0].temporaryDefense;
for(let i=0;i < this.deck.skill.length;i++) {
points += this.deck.skill[i].constDefense;
}
if (this.deck.skill.length) points += this.deck.skill[0].temporaryDefense;
for(let i=0;i < this.deck.deity.length;i++) {
points += this.deck.deity[i].constDefense;
}
if (this.deck.deity.length) points += this.deck.deity[0].temporaryDefense;
return points + this.additionalDefense;
}
User.prototype.getAttack = function() {
var points = 0;
for(let i=0;i < this.deck.monsters.length;i++) {
points += this.deck.monsters[i].constAttack;
}
if (this.deck.monsters.length) points += this.deck.monsters[0].temporaryAttack;
for(let i=0;i < this.deck.items.length;i++) {
points += this.deck.items[i].constAttack;
}
if (this.deck.items.length) points += this.deck.items[0].temporaryAttack;
for(let i=0;i < this.deck.skill.length;i++) {
points += this.deck.skill[i].constAttack;
}
if (this.deck.skill.length) points += this.deck.skill[0].temporaryAttack;
for(let i=0;i < this.deck.deity.length;i++) {
points += this.deck.deity[i].constAttack;
}
if (this.deck.deity.length) points += this.deck.deity[0].temporaryAttack;
return points + this.additionalAttack;
}
User.prototype.addCard = function(card) {
//not working yet... ...working in game object its so wrong...
}
User.prototype.getDeck = function() {
return this.deck;
}
User.prototype.getCoins = function() {
return this.coins;
}
User.prototype.addCoins = function(val) {
this.coins += val;
if (this.coins < 0) this.coins = 0;
}
User.prototype.getVictoryPoints = function(game) {
var victoryPoints = this.health;
victoryPoints += Math.min(this.deck.skill.length, this.deck.monsters.lenght);
for(let i=0;i < this.deck.monsters.length;i++) {
victoryPoints += this.deck.monsters[i].victoryPoints;
}
for(let i=0;i < this.deck.items.length;i++) {
victoryPoints += this.deck.items[i].victoryPoints;
}
for(let i=0;i < this.deck.skill.length;i++) {
victoryPoints += this.deck.skill[i].victoryPoints;
}
for(let i=0;i < this.deck.deity.length;i++) {
victoryPoints += this.deck.deity[i].victoryPoints;
}
// victoryPoints += game.campCard.victoryPointsAction(game, this);
return victoryPoints;
}
User.prototype.trashCard = function (type) {
switch (type) {
case "monster":
return this.deck.monsters.shift();
break;
case "item":
return this.deck.items.shift();
break;
case "skill":
return this.deck.skill.shift();
break;
case "deity":
return this.deck.deity.shift();
break;
}
}
exports.User = User;