Comments (3)
Not the first time I've heard somebody say that. I suspect the splits are wrong within the API.
from uthgard-herald.
@thekroko The current code has a classic off-by-one issue which can be fixed by handling the zero RP case dfiferently and adding 10
to each n-i
'th value:
func getRRForRP(rp int32) int {
if rp > 0 {
n := len(rpForLevel)
for i := range rpForLevel {
idx := n - i - 1
if rpForLevel[idx] <= rp {
return (n - i) + 10
}
}
}
return 10
}
(based of http://pastebin.com/7cAwJUUQ)
You should probably add some tests to your test suites. The following cases turned out to be useful:
func main() {
type Test struct {
rp int32
rank int
}
tests := []Test{
Test{0, 10},
Test{25, 12},
Test{750, 15},
Test{73683, 31},
Test{1668226, 69},
Test{66181501, 130},
}
for _, test := range tests {
rr := getRRForRP(test.rp)
if rr != test.rank {
fmt.Printf("%v shoule be %v (%v)\n", rr, test.rank, test.rp)
} else {
fmt.Printf(" ✓ %v is %v (%v)\n", rr, test.rank, test.rp)
}
}
}
from uthgard-herald.
Fixed with next push. Thank you! :)
from uthgard-herald.
Related Issues (20)
- Add a search for character HOT 6
- Make a page for guild data HOT 1
- Update README.md with dependencies HOT 2
- Add Access-Control-Origin Header to api server HOT 3
- License of the project HOT 2
- Realm war map HOT 6
- Add build status
- Fix docker build HOT 1
- Tests are broken HOT 8
- Guild emblem image endpoint HOT 2
- Update URL to guild emblem image HOT 1
- Player search algorithm needs improvement HOT 4
- Player API reporting incorrect character level. HOT 2
- Guild endpoint doesn't work HOT 2
- favicon missing HOT 4
- Realm 7 -- custom content???? HOT 2
- Launch? HOT 10
- Lacking overview of implemented API endpoints HOT 3
- Use the old code?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uthgard-herald.