javascript - Creating a rank structure based on score without coding each possibility -
i trying code simple rank structure without coding each possibility.
i want ranks 1-10 separated 25 point increments ( 0 points = level 1 though)
than ranks 11-20 separated 50, 21-30 100 etc. increasing amount between levels double every 10 levels.
i started bunch of if statements, , tried switch statements feel sloppy , waste of time , code. suggestions can point me right direction, not coding every possibility?
i tagged javascript because coding in, more looking general direction/formula , can figure out code.
to clear:
0-25 points = rank 1 26-50 points = rank 2 51-75 points = rank 3 etc... 201-225 points = rank 9 226-250 points = rank 10 etc.... 251-300 = rank 11 301 - 350 = rank 12
as can see once ranks 1-10 have delta of 25 points between ranks. ranks 11-20 have delta of 50 points between ranks, 21-30 should have 100 point delta between ranks etc.
also trying remainder, know how far until next rank.
if you're going repeatedly calculating rank (eg. every time gains points), limited number of possible ranks, build table (array) of total point requirements per rank, using for
loop keeping track of rank number, total points needed far, , points needed rank current rank. ranktable[rank] = totalpointsneededforrank
. then, whenever gains points, can check if they've reached threshold next rank looking next rank in table.
Comments
Post a Comment