Jump to content

Evermore

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

About Evermore

  • Birthday 01/09/1997

Profile Information

  • Gender
    Female
  • Location
    Switzerland, Bern

Evermore's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Actually, there is. Type in 24 sided dice into Google Images and they will come out.
  2. I am not a very good PHP programmer, and I got a project to "work" on. I need help writing a Dice Roll Function. This is how I'm supposed to do the two functions: New Function: dice_roll (int sides) - $ returns a random number of how many sided the dice is, between 1 and the $. New Function: dice_roll_str (string dicestr) - A string describing the dice [0-9] + d [0-9 ]+[+-][ 0-9] + size (d <number_of_dices> <number_of_sides> [+-][modifying_value]) - For example if I call the function with "3d6-3", this means: we throw 3 times with a 6-sided dice, add it up, then subtract 3-t. - The function is to return a false value on error - Possible errors: - Minimum number of of sides of the dice is 2 the maximum is 24 - A minimum number of dices 1 the maximum is 8 - The result should always be a positive number, which is not greater than twice of the result we got. I've already done the first function. This is my code: function dice_roll($sides_num) { $rand_num = rand(1, $sides_num); return $rand_num; } I'm not sure it correct. It is the second function that I don't know how to do. Please, if you can help I'd be really grateful. If you can please put explanations on how the code works. Thank you so much, Evermore
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.