Today I wrote up the code for experience tables, gaining experience from battles, levelling up, etc. I think the hardest part was figuring out the overly complex system for stat gains. lolol complications.
Basically, when you level up you're given access to the stat allocation page. You can difer the allocation indefinitely - if you level up multiple times without allocating stats it'll recognize that and let you allocate multiple times etc etc.
You choose 3 of the 6 stats to increase; you can choose any stat any number of times, it doesn't care (though its not really advantageous to do so due to a couple ceils, but I haven't really looked into that).
Basically, you're guarenteed that 7 stat points will be allocated between the 3 categories you select. The ternary stat will always get less than or equal to the secondary, which always is less than or equal to the primary.
$statinc3 = rand( 1, 2 );
$statinc2 = rand( $statinc3, 4 - $statinc3 );
$statinc1 = 7 - $statinc2 - $statinc3;
Makes a nice distribution, I think.
Anyway, there are 3 main secondary stats: maximum HP, maximum MP and dexterity. Each of the 6 core stats is combined with multipliers then summed to get the raw secondary stat gain, which is then scaled by a somewhat random factor. Each primary stat has weights that make logical sense with the different weapon classes, so a dagger-user ends up with the most dexterity, and the magic-user gets the highest max MP. That was a nightmare working out...
Anyway, that leaves us with luck, which is... randomly gained :3
$rawluk = rand(0,1)*rand(0,1) + rand(0,1)*rand(0,1) + rand(0,1)*rand(0,1);
And so on. This presents us with a nice little screen (using the stat choices from the above screen) like this -
I'm going to finish up the weapon/armor code tommorrow, which involves the stats and such to determine overall power/defense/evasion/accuracy and such. Basically, the transformation between the numbers and the actual gameplay mechanic. Its all starting to come together...