Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(a) {
- let action = a.shift().split(' - ')
- // while (action[0] !== 'End') {
- // let b = action[0]
- // if (b === 'CastSpell') {
- // let [_, name, MP, spellName] = action;
- // console.log(_);
- // console.log(name);
- // console.log(MP);
- // console.log(spellName);
- // } else if (b === 'TakeDamage') {
- // let [_, name, MP, spellName] = action;
- // console.log('--------------');
- // console.log(_);
- // console.log(name);
- // console.log(MP);
- // console.log(spellName);
- // }
- // action = a.shift().split(' - ')
- // }
- while (action[0] !== 'End') {
- let b = action[0]
- switch (b) {
- case 'CastSpell':
- let [_,name,MP,spellName] = action;
- console.log(_);
- console.log(name);
- console.log(MP);
- console.log(spellName);
- break;
- case 'TakeDamage':
- let [_,name,MP,spellName] = action;
- console.log('--------------');
- console.log(_);
- console.log(name);
- console.log(MP);
- console.log(spellName);
- break;
- }
- action = a.shift().split(' - ')
- }
- }
- solve([
- 'CastSpell - Tyris - 1000 - Fireball',
- 'TakeDamage - Tyris - 99 - Fireball',
- 'End'
- ])
Advertisement
Add Comment
Please, Sign In to add comment