Open RobertCorey opened 5 years ago
https://github.com/tomcorey26/pokemon-battle-clone/blob/9557916f94e5e01f6361010f787a5f3736d6b055/fight/app.js#L58
you could have an object { "rock": { "effective": ["scissors"], "ineffective": ["paper"] }
{ "rock": { "effective": ["scissors"], "ineffective": ["paper"] }
so then you could look up the attack.type in the object like object[attack.type] then look recipient in the arrays
object[attack.type]
let table = { rock: { paper: 0.7, scissors: 1.3, rock: 1.0 } }; return table[moveType][enemyType];
https://github.com/tomcorey26/pokemon-battle-clone/blob/9557916f94e5e01f6361010f787a5f3736d6b055/fight/app.js#L58
you could have an object
{ "rock": { "effective": ["scissors"], "ineffective": ["paper"] }
so then you could look up the attack.type in the object like
object[attack.type]
then look recipient in the arrays