How to use the flying-squid.getBaseXpFromLevel function in flying-squid

To help you get started, we’ve selected a few flying-squid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PrismarineJS / flying-squid / src / lib / plugins / experience.js View on Github external
action (args) {
      const isLevel = !!args[2]
      const amt = parseInt(args[1])
      const user = args[3] ? serv.getPlayer(args[3]) : player
      if (!user) return args[3] + ' is not on this server!'

      if (!isLevel) {
        user.setXp(user.xp + amt)
        player.chat('Gave ' + user.username + ' ' + amt + ' xp')
      } else {
        const currLevel = getXpLevel(player.xp)
        const baseCurrLevel = getBaseXpFromLevel(currLevel)
        const extraXp = player.xp - baseCurrLevel
        user.setXp(getBaseXpFromLevel(currLevel + amt) + extraXp)
        player.chat('Gave ' + user.username + ' ' + amt + ' levels')
      }
    }
  })
github PrismarineJS / flying-squid / src / lib / plugins / experience.js View on Github external
action (args) {
      const isLevel = !!args[2]
      const amt = parseInt(args[1])
      const user = args[3] ? serv.getPlayer(args[3]) : player
      if (!user) return args[3] + ' is not on this server!'

      if (!isLevel) {
        user.setXp(user.xp + amt)
        player.chat('Gave ' + user.username + ' ' + amt + ' xp')
      } else {
        const currLevel = getXpLevel(player.xp)
        const baseCurrLevel = getBaseXpFromLevel(currLevel)
        const extraXp = player.xp - baseCurrLevel
        user.setXp(getBaseXpFromLevel(currLevel + amt) + extraXp)
        player.chat('Gave ' + user.username + ' ' + amt + ' levels')
      }
    }
  })