Advertisement
Liliana797979

heroes - js advanced

Sep 21st, 2021
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve() {
  2.  
  3.     let mage = (name) => {
  4.  
  5.         return {
  6.             name,
  7.             health: 100,
  8.             mana: 100,
  9.             cast(spell) {
  10.                 this.mana -= 1;
  11.                 console.log(`${name} cast ${spell}`);
  12.             }
  13.         }
  14.  
  15.     }
  16.     let fighter = (name) => {
  17.  
  18.         return {
  19.             name,
  20.             health: 100,
  21.             stamina: 100,
  22.             fight() {
  23.                 this.stamina -= 1;
  24.                 console.log(`${name} slashes at the foe!`);
  25.             }
  26.         }
  27.  
  28.     }
  29.     return { mage: mage, fighter: fighter }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement