Created
January 20, 2022 23:24
-
-
Save TwoSquirrels/07862ef908397d25889baf070a0a6431 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 経験値計算 | |
| * @author TwoSquirrels | |
| */ | |
| // レベルアップに必要な経験値は (level*level+a)*b とする(つまり二次関数) | |
| // ここでは a=2,B=10 としとく | |
| const a = 2, b = 10; | |
| const expToLevelUp = (level) => (level * level + a) + b; | |
| // するとレベルまでに必要な総合経験値は (((level-1)*level*(level*2+1)/6)+level*a)*b となる(二乗の和の公式を利用<-これ数B範囲) | |
| const totalExpToLevel = (level) = (((level - 1) * level * (level * 2 + 1) / 6) + level * a) * b; | |
| // これがデータだとする(鯖ならデータベースとか小規模ならjsonファイルとかに保管しといて毎回取り出すべき) | |
| const levelData = { | |
| "hogehoge": { level: 0, exp: 5n }, | |
| "fugafuga": { level: 314, exp: 1592n }, | |
| }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment