You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.3 KiB

class InitStat {
constructor(scene, posX, posY, width, height, valueMax) {
this.scene = scene;
this.posX = posX;
this.posY = posY;
this.width = width;
this.height = height;
this.category = new CategoryBar(valueMax);
this.lBar = [];
this.lText = [];
this.category.addText(this.scene, selectWord("TOKENS : ", "JETONS : "), this.posX, this.posY, this.height);
}
addBar(value, valueMax, color, text) {
this.lText.push(text);
this.lBar.push(new Bar(this.scene, selectWord(text[0], text[1]), this.width, this.height, this.posX, this.posY, color, this.category, value, valueMax));
this.posY += this.height * 1.5;
this.category.setTextPos(this.posX, this.posY);
}
getJson() {
let json = '{';
json += '"lBar":[';
this.lBar.forEach(bar => json += bar.getJson() + ',');
json = endLineJson(json) + '],';
json += '"lText":[';
this.lText.forEach(text => {
json += '[';
text.forEach(word => {
json += '"' + word + '",';
});
json = endLineJson(json);
json += '],';
});
json = endLineJson(json);
json += ']';
json += '}';
return json;
}
}