Création de CategoryBar dans le but de gérer les barres de façon groupé - Création des barres par paire (on a 5 "jetons" par paire de barre). Les barres sont paires avec celle au dessus ou en dessous d'elle - Modification des stats de base pour équilibrer un petit peu chaque catégorie - Modifcation des robots ennemy pour les adapter comme un robot équilibré
parent
5af7388a95
commit
5b8a587017
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -0,0 +1,31 @@
|
||||
class CategoryBar {
|
||||
constructor(startValue = 1, valueMax = VALUE_MAX_BAR) {
|
||||
this.startValue = startValue;
|
||||
this.valueMax = valueMax;
|
||||
this.point = this.valueMax;
|
||||
}
|
||||
|
||||
addPoint(point) {
|
||||
this.point += point;
|
||||
if (this.point < 0) {
|
||||
let send = this.point;
|
||||
this.point = 0;
|
||||
return send;
|
||||
}
|
||||
if (this.point > this.valueMax) {
|
||||
this.point = this.valueMax;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
setValueOf(bar, newValue) {
|
||||
let diff = newValue - bar.value;
|
||||
let oldValue = bar.value;
|
||||
if (this.point >= diff) {
|
||||
bar.setValue(newValue);
|
||||
} else {
|
||||
bar.setValue(bar.value + this.point);
|
||||
}
|
||||
this.addPoint(oldValue - bar.value);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue