Cthulhu

With the hope of keeping this project organized I'm going to keep a log of things on this page. It will probably get pretty cluttered as I go along. My goal at this point is to translate some of the rule set into the base functions which will be used through the 'game'. Ability Modifiers

function ability_modifier($stat) { if ($stat 1) { $modifier = -5; } else if ($stat >= 2 && $stat <= 3) { $modifier = -4; } else if ($stat >= 4 && $stat <= 5) { $modifier = -3; } else if ($stat >= 6 && $stat <= 7) { $modifier = -2; } else if ($stat >= 8 && $stat <= 9) { $modifier = -1; } else if ($stat >= 10 && $stat <= 11) { $modifier = 0; } else if ($stat >= 12 && $stat <= 13) { $modifier = 1; } else if ($stat >= 14 && $stat <= 15) { $modifier = 2; } else if ($stat >= 16 && $stat <= 17) { $modifier = 3; } else if ($stat >= 18 && $stat <= 19) { $modifier = 4; } else if ($stat >= 20 && $stat <= 21) { $modifier = 5; } return $modifier; }

The code is very simple - call the function as abilitymodifier(12) for example and it will it will store a value of 1 in the $modifier variable and return. It does need to be modified as ability scores can go higher the 21. But, for now 21 will be the max. Hit Points> function basehitpoints($con) { $additionalhp = abilitymodifier($con); $startinghitpoints = 6 + $additionalhp; return $starting_hitpoints; }

According to my ebook source every player character starts with 6 hit points plus the constitution modifier. Upon leveling the new hitpoints are determined with: hp = 1d6 + con modifier + hp > function leveluphitpoints($hp, $con) { $modifier = abilitymodifier($con); $1d6 = rand(1,6); $hp = $hp + $1d6 + $modifier; return $hp; }

Experience With the rules that I'm using for the base of this monstrosity it seems that experience isn't handed out each time you kill a monster but, when you complete an overall task. For example: Survive an attack from a dozen Deep Ones. Their example is: 300 * average character level / number of players. But since I'm starting will only a single player it will be 300 * level. > function award_experience($level) { $award = 300 * $level; return $award; }

Sanity Being a Cthulhu based game we need to take character sanity into account. > function base_sanity($wis) { $sanity = $wis * 5; return $sanity; }

Sanity is affected when a character encounters a horror. However, that may not be the case if the character encounters the same horror again. After a while if running into Deep Ones the character will get used to their existence. > function sanitycheck($currentsanity, $successfulloss, $unsuccessfulloss, $lossmodifier) { $checkroll = rand(1, 99); if ($checkroll <= $currentsanity && $successfulloss != '1d6' && $successfulloss != '1d3') { $loss = $successfulloss; } else if ($checkroll > $currentsanity) { $loss = rand (1, $unsuccessfulloss) + $lossmodifier; } else if ($checkroll <= $currentsanity && $successfulloss '1d6') { $loss = rand (1, 6); } else if ($checkroll <= $currentsanity && $successful_loss == '1d3') { $loss = rand (1, 3); } return $loss; }

Because some of the horrors deal a random amount of loss to sanity I had to code in some a couple of extra ifs to account for that. They may not stay in though I may just modify the successful loss to be constant. Mikey pointed out that I didn't include any code for MaxSanity. Hopefully, I'll be able to get some more code work done once I get my highspeed internet back.