# Formula for primary stats on level up?

I'm creating a stat level up calculator and was reading through this guide > https://www.gamefaqs.com/pc/130791-final-fantasy-vii/faqs/36775

For leveling up on primary stats, it says "This difference is then capped at 0 to 11 inclusive", however I see the number can be calculated above 11 when testing with my java code...

``````    // Dexterity
int levelUp = 7; // cloud starting level(6)
dex = 6; // cloud starting dexterity at level 6
baseNumber = 6; // cloud rank curve is 6 (for dex), and is within 2-11 levelUp bracket, so 6 is the number on table
gradient = 72; // cloud rank curve is 6 (for dex), and is within 2-11 levelUp bracket, so 72 is the number on table
baselineStat = baseNumber + ((gradient * levelUp) / 100);
randomStatDifferenceOne = 1 + baselineStat - dex;
randomStatDifferenceTwo = 2 + baselineStat - dex;
randomStatDifferenceThree = 3 + baselineStat - dex;
randomStatDifferenceFour = 4 + baselineStat - dex;
randomStatDifferenceFive = 5 + baselineStat - dex;
randomStatDifferenceSix = 6 + baselineStat - dex;
randomStatDifferenceSeven = 7 + baselineStat - dex;
randomStatDifferenceEight = 8 + baselineStat - dex;
System.out.println(randomStatDifferenceOne);
System.out.println(randomStatDifferenceTwo);
System.out.println(randomStatDifferenceThree);
System.out.println(randomStatDifferenceFour);
System.out.println(randomStatDifferenceFive);
System.out.println(randomStatDifferenceSix);
System.out.println(randomStatDifferenceSeven);
System.out.println(randomStatDifferenceEight);
``````

This gives me the following results with Rnd(1-8):

``````6
7
8
9
10
11
12
13
``````

In the guide... he has the following level up stat calculated as follows for the difference number (that should only be 0-11):

``````     *     Difference | Stat Gain
*         0-3    |     0
*         4-6    |     1
*         7-9    |     2
*        10-11   |     3
``````

So my question is how is it handled when the number is above 11, or below 0(assuming below 0 is possible)?

• You said it yourself, capped (...) to 11. – Oak Apr 28 '17 at 13:59
• By the way, (even though this isn't Stackoverflow): Why don't you just create a superclass for randomstatdifference or at the very least put it in an array. That code is really messy mate – Oak Apr 28 '17 at 14:49
• You might get more responses on Game Dev, but also check their guidelines before posting your question – Wondercricket Apr 28 '17 at 19:26
• @oak The thing is, it's not capped at 11. I got a difference of 12 and 13. I need to know what to do with those numbers when it's higher than 11. As for the code question, this is just reference code (not the actual code in my application). It allows me to refer back to so I can see how the formula works. – Fiddle Freak Apr 28 '17 at 20:03
• But that's the thing that capped means, up to 11. If it's 12,13,999, it's 11. At least, that's what the word means. It's not that hard to check either, just compile it and cheat the game with a 9999 exp after battle cheat. You'll confirm your results – Oak Apr 28 '17 at 20:04