Forum Moderators: open

Message Too Old, No Replies

Store this!

if I can... mysql and php beginner

         

pengo

9:19 pm on Sep 10, 2008 (gmt 0)

10+ Year Member



Ok, I'm totally new to programming, db, and everything binary. I'm trying to program a character generation utility for a pen and paper role playing game, using PHP and mysql.
Now, problem is, I need to store a value and I don't know how.

e.g.: skill swords has a default value of [dexterity]/2.

when creating a character, you spend character points: to raise a skill, you spend 1 character point per each point of increase from default [d]/2 to stat value [d], then 2 character points per point of increase.

e.g.: char has dex 12. swords skill defaults at d/2=6. Player want to raise char swords skill to 14. So player spend 12-6=6 points to get it to 12, and then 14-12=2*2=4 points to get sword skill to 14.

This, just to give the idea. So I need to store the default factor, which is oe more stats, an operation (usually a fraction but can also be a subtraction or average fraction), and a number.

So... first of all, is it possible to store an operation?
(I'd like to post some code to prove my good will, but I haven't got a clue, sorry...)

carguy84

5:58 am on Sep 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can store whatever you want in the DB, it will be up to the PHP to translate it back into something useful.

pengo

12:19 pm on Sep 12, 2008 (gmt 0)

10+ Year Member



Thanks, I had stumbled in something like eval(), that could help I think.