久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

調平系統進度條

Progress Bar for Leveling System(調平系統進度條)
本文介紹了調平系統進度條的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

所以這是一個 2 個問題,但基本上我正在為我的 Discord 機器人 (Discord.js) 制作排名/等級系統,并且我在下一個級別的進度條上遇到問題.到目前為止,這是我所得到的:

So this is kind of 2 questions in one, but basically I'm making a ranking/leveling system for my Discord bot (Discord.js) and I'm having problems with a progress bar for the next level. Here's what I've got so far:

        const x = "□";
        let progressBarArr = [x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x];

        let currentLevel = Math.ceil(result.allocatedExp/1000)*1000;
        if (currentLevel < 1000) currentLevel = 1000;

        let progressBar = "["+progressBarArr.fill("=", Math.ceil(result.allocatedExp/currentLevel)*35).join('')+"]"

每增加 1,000 XP,您就會升級,因此假設用戶的 XP 為 1234,他們將達到 1 級,并且達到 2 級的 23%.我只需要在進度條類型樣式.我現在擁有的代碼有效,但前提是他們的 XP 低于 1k,否則欄總是滿的.

Every 1,000 XP You gain you level up, So say the XP for a user is 1234 they would be level 1 and 23% of the way to level 2. I just need to show that in a progress-bar type style. The code I have right now works but only if they have under 1k XP, otherwise the bar is always full.

我的另一個問題對大多數人來說很可能是微不足道的,但我被它難住了,假設用戶有 15k xp,我如何從 15000 中得到 15 來表示他們是 15 級?

The other question I have is most likely trivial for most people but I'm stumped by it, say a user has 15k xp, how would I get the 15 from 15000 to say that they're level 15?

謝謝!

推薦答案

只需使用Math.floor(xp/1000)即可獲取玩家當前等級.

Just take Math.floor(xp / 1000) to get the player's current level.

對于進度條,使用模 1000 來檢查玩家在最后 1000 和下 1000 之間的距離,然后將結果乘以 35 來計算要顯示多少 =:

For the progress bar, use modulo 1000 to check how far the player is between the last 1000 and the next 1000, and multiply the result by 35 to figure out how many =s to display:

const showBar = xp => {
  const currentLevel = Math.floor(xp / 1000);
  const progress = (xp % 1000) / 1000;
  const progressOutOf35 = Math.round(progress * 35);
  
  const x = "□";
  const barStr = `[${'='.repeat(progressOutOf35)}${'□'.repeat(35 - progressOutOf35)}]`;
  console.log(barStr + ', currntly at level ' + currentLevel);
};

showBar(1500);
showBar(3900);
showBar(15000);

這篇關于調平系統進度條的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 国产精品久久久久久久久久 | 色婷婷亚洲一区二区三区 | 国产 欧美 日韩 一区 | 偷拍亚洲色图 | 波多野结衣一区二区三区 | 婷婷福利视频导航 | 国产精品成人久久久久 | 一级毛片在线视频 | 乱码av午夜噜噜噜噜动漫 | 久久久妇女国产精品影视 | 色悠悠久| 九九热在线精品视频 | 精品久久久久久国产 | 精品在线一区 | 久久精品视频在线观看 | 凹凸日日摸日日碰夜夜 | 日本精品视频 | a级片在线观看 | 国产这里只有精品 | 中文av在线播放 | 国产一区二区三区四区 | 亚洲激情在线观看 | 性高湖久久久久久久久aaaaa | 国产欧美日韩在线观看 | 二区不卡 | 国产一级电影在线观看 | 国产久| 国产精品久久国产愉拍 | 久久成人综合 | 日韩成人一区二区 | 三级视频在线观看电影 | 欧美精品在线免费观看 | 国产免费让你躁在线视频 | 亚洲免费一区二区 | 亚洲a一区二区 | 亚洲永久在线 | 成人美女免费网站视频 | 成人精品一区亚洲午夜久久久 | 日本欧美国产在线 | 91亚洲精品在线观看 | 1级黄色大片 |