Advertisement
svetlio_top

HeroesOfCodeAndLigic

Apr 9th, 2020
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input){
  2. let n = input.shift();
  3. //let command = input.shift();
  4. let obj = {};
  5.  
  6.     for (let i = 0; i < n; i++) {
  7.         const line = input[i];
  8.         let arr = line.split(' ');
  9.         let [heroe, hp, mp] = arr;
  10.         obj[heroe] = [hp, mp];  
  11.         input.shift();
  12.     }
  13.     //console.log(obj);
  14.  
  15.     let command = input.shift();
  16.     while(command !== 'End'){
  17.         let arr = command.split(' - ');
  18.         let com = arr[0];
  19.         let heroe = arr[1];
  20.         console.log(obj[heroe]);
  21.         if(com === 'CastSpell'){
  22.             // if(obj[heroe]){
  23.  
  24.             // }else{
  25.  
  26.             // }
  27.         }else if(com === 'TakeDamage'){
  28.  
  29.         }else if(com === 'Recharge'){
  30.  
  31.         }else if(com === 'Heal'){
  32.             // if(obj[heroe]){
  33.  
  34.             // }else{
  35.  
  36.             // }
  37.         }
  38.         //console.log(arr);
  39.        
  40.         command = input.shift();
  41.     }
  42.  
  43. }
  44. solve([
  45.     '2',
  46.     'Solmyr 85 120',
  47.     'Kyrre 99 50',
  48.     'Heal - Solmyr - 10',
  49.     'Recharge - Solmyr - 50',
  50.     'TakeDamage - Kyrre - 66 - Orc',
  51.     'CastSpell - Kyrre - 15 - ViewEarth',
  52.     'End'
  53. ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement