I am writing some JavaScript code for my webapp. I need to make a variable that has an attribute linked to it. ie: Dice1.PowerUp
So when I code I can roll a dice that is different when the powerup linked to it is at 0, 1 or 2. Do I have to code 2 different variable and set them at the same time or can I just code a linked variable that will work like an attribute to sort it.
While waiting for an answer I am coding it with 2 variables that will be set at the same time.
Code:
var consDie = new Array(3);
//Implanté les élément de constance des dés.
for (var i = 0; i <= 2; i++){
consDie[i] = 12 - (i * 2);
console.log("D" + consDie[i]);
//Ça marché... holy macaroony!
}
var consNDice = 6; //Constante pour le nombre de dés
var consAlign = {
UnAl : consDie[2],
Bal : consDie[1],
Phys : consDie[0],
Ment : consDie[0]
};
//declaration of an object that contain the kind of dice that is rolled by powerup
you can create a class for the dice:
so you can create a dice object with a power up associated, and then use the rollDice function to get the value