0
I am Creating a card game that runs in the browser and I need that in some situations, there may be the same cards in different hands ("Computer" or Player). However, I don’t want to have to create another object to represent the enemy cards. This one below for example, is an object that represents a card.
Bherk_tropa = {
nome: 'Bherk',
raca: 'Anão',
classe: 'Clerigo',
id: 'Bherk',
corpo_a_corpo: true,
pesadas: true,
longo_alcance: true,
armadadura: true,
pvInical: 150,
pontos_de_vida: 150,
ataque: 70,
defesa: 80,
agilidade: 06,
brutalidade: 13,
Efeito: function(){
}
}
To create another card similar to this in the enemy’s hand changing only the attribute and id for example, I tried the following line of code:
Bherk_tropa_Inimigo = Bherk_tropa;
Bherk_tropa_Inimigo.id = "BherInimigo";
But the result was that when changed the id of Bherk_tropa_enemy the id of Bherk_tropa was also changed. I hope to get enlightenment through some good soul. I thank you give of now. XD
It worked!! Thank you very much friend. But what this 'Let' does?
– Erick Fraga
It initializes the variable, in case a
Bherk_tropa_Inimigo
, the same asvar
however has a smaller scope. If you use the code please accept as the correct answer. Thank you.– guastallaigor
Vlw, thank you very much
– Erick Fraga