This commit is contained in:
Morgan Bazalgette
2017-01-14 18:42:10 +01:00
parent 41ee4c90b3
commit 3961e310b1
444 changed files with 179208 additions and 0 deletions

21
vendor/zxq.co/ripple/ocl/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Morgan Bazalgette
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

1
vendor/zxq.co/ripple/ocl/README.md vendored Normal file
View File

@@ -0,0 +1 @@
# ocl [![GoDoc](https://godoc.org/git.zxq.co/ripple/ocl?status.svg)](https://godoc.org/git.zxq.co/ripple/ocl) [![Go Report Card](https://goreportcard.com/badge/git.zxq.co/ripple/ocl)](https://goreportcard.com/report/git.zxq.co/ripple/ocl)

53
vendor/zxq.co/ripple/ocl/level.go vendored Normal file
View File

@@ -0,0 +1,53 @@
// Package ocl allows you to do calculation of osu! levels in Go.
package ocl
import "math"
// GetLevel calculates what's the level of a score. It will stop at the
// level 10,000, after which it will give up. If you want to calculate the
// level without brakes of any kind, use GetLevelWithMax(score, -1).
func GetLevel(score int64) int {
return GetLevelWithMax(score, 10000)
}
// GetLevelWithMax calculates what's the level of a score, having a maximum
// level. Set brake to a negative number to free yourself from any brakes.
func GetLevelWithMax(score int64, brake int) int {
i := 1
for {
if brake > 0 && i >= brake {
return i
}
lScore := GetRequiredScoreForLevel(i)
if score < lScore {
return i - 1
}
i++
}
}
// GetRequiredScoreForLevel retrieves the score required to reach a certain
// level.
func GetRequiredScoreForLevel(level int) int64 {
if level <= 100 {
if level > 1 {
return int64(math.Floor(float64(5000)/3*(4*math.Pow(float64(level), 3)-3*math.Pow(float64(level), 2)-float64(level)) + math.Floor(1.25*math.Pow(1.8, float64(level)-60))))
}
return 1
}
return 26931190829 + 100000000000*int64(level-100)
}
// GetLevelPrecise gets a precise level, meaning that decimal digits are
// included. There isn't any maximum level.
func GetLevelPrecise(score int64) float64 {
baseLevel := GetLevelWithMax(score, -1)
baseLevelScore := GetRequiredScoreForLevel(baseLevel)
scoreProgress := score - baseLevelScore
scoreLevelDifference := GetRequiredScoreForLevel(baseLevel+1) - baseLevelScore
res := float64(scoreProgress)/float64(scoreLevelDifference) + float64(baseLevel)
if math.IsInf(res, 0) || math.IsNaN(res) {
return 0
}
return res
}