If I use the following code:
card01.state = 3;
console.log(card01);
I can modify the state, but I'm interested in updating the state of the card chosen by the random function.
class Item {
constructor(name, state) {
this.name = name;
this.state = state;
}
};
class Card extends Item {
constructor(name, damage, state, rarity) {
super(name, state);
this.damage = damage;
this.rarity = rarity;
}
};
var collectibles = [
card01 = new Card("card of death", 5, 1, 0),
card02 = new Card("two towers", 5, 1, 0),
card03 = new Card("lovers", 5, 1, 0),
];
function gachaCard() {
let random = collectibles[Math.floor(Math.random() * collectibles.length)];
return random
}