tomcorey26 / pokemon-battle-clone

pokemon battle clone web app
https://meme-fighters.herokuapp.com/
0 stars 0 forks source link

Refactor Effectiveness #1

Open RobertCorey opened 5 years ago

RobertCorey commented 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"] }

so then you could look up the attack.type in the object like object[attack.type] then look recipient in the arrays

RobertCorey commented 5 years ago

let table = { rock: { paper: 0.7, scissors: 1.3, rock: 1.0 } }; return table[moveType][enemyType];