1
I’m trying to make a Pokemon simulator similar to Pokémon Showdown, but I’m doing it from scratch. In addition to having the functions of a common Pokemón game, you’ll have some customized.
I would like to know how I declare a class and how to define the same values.
In C# after having declared the class model and the new value to it Pessoa numero01 = new Pessoa();
for example, just use as an example numero01.nome = "José";
.
According to my notes, it is not the same thing. And now when I try to define the value as follows appears undefined
.
class Move {
constructor(info, spUsage, atkUsage, baseDamage, name, secEff, accuracy, instaFail, pp)
{
this.info = info;
this.spUsage = spUsage;
this.atkUsage = atkUsage;
this.baseDamage = baseDamage;
this.name = name;
this.secEff = secEff;
this.accuracy = accuracy;
this.instaFail = instaFail;
this.pp = pp;
}
getMoveData(value)
{
//retorna o valor da propriedade inserida. Ex: iceBeam.getMoveData(name); retorna 'Ice Beam'
return value;
}
setMoveData(data, value)
{
//onde 'data' seria um valor da classe como 'info' e 'value' seria o valor para associa-lo ao mesmo como 'true' ou '11' etc.
data = value;
}
}
//Começo da database dos movimentos
iceBeam = new Move();
iceBeam.setMoveData(spUsage, true);
Could make use of setters and getters also, who entered ES6
– Rafael Tavares
@Ricardo Punctual, my class has several values, would not have a way to make the
function set
was universal? That is, it "set" all the necessary values of the class?– user216621
"universal"? use in the constructor can pass all values, or do direct
iceBeam.accuracy, iceBeam.... etc
– Ricardo Pontual
@Rafaeltavares yes good suggestion, I declared a set to demonstrate the difference of how it works and as this the other set declared in the class, more to illustrate.
– Ricardo Pontual