2004/5/30 0:03
Gisa_Iag
Just popping in
Posts: 7
Since: 2004/4/10
################################################################### MOD Title: Dice BBCode## MOD Author: Hades < phpbb@hades.me.uk > - Lee Conlin -http://www.celestialvault.com/blast## MOD Description: Adds a dice roller BBCode to your forum.## MOD Version: 1.2.3#### Installation Level: Intermediate## Installation Time: 10 Minutes## Files To Edit: bbcode.php, posting.php, bbcode.tpl, posting_body.tpl, lang_main.php, lang_bbcode.php## Included Files: n/a################################################################ For Security Purposes, Please Check:http://www.phpbb.com/mods/ for the## latest version of this MOD. Downloading this MOD from other sites could cause malicious code## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered## in our MOD-Database, located at:http://www.phpbb.com/mods/################################################################## Author Notes:#### BASED ON THE DICE MOD BY Jeff Leigh#### IMPORTANT: if you are installing manually (without EasyMod) you MUST first## install the Multi BBCode MOD available athttp://www.phpbb.com/mods/downloads#### For serious use of this MOD, you MUST disable non-moderator editing of posts.. otherwise, users## can simply edit their posts a few times until they get a good roll. Also, if a post is edited (by a## moderator or user) the word 'Fixed' will appear in the dice roll. This prevents users from 'fixing'## their results by passing in a result seed they know brings good results... but is nessassary to## allow a post to be edited without changing the results. I am not quite happy with this, but## it does the job.#### The obvious way to avoid the above issues is to use the Post_ID to seed the results. This,## however, appeared to require changes to phpbb function declarations - a thing I try very## hard to avoid (as it can cause problems for other MODs not expecting these changes).################################################################## MOD History:#### 2003-09-16 - Version 1.2.3## - Updated for phpBB 2.0.6#### 2003-08-04 - Version 1.2.2## - Updated to reflect changes in MOD Template. Dates missing on other version entries due to the fact I can't remember them.## - Updated code for phpBB 2.0.5#### 1.2.1 - Set limits of number of dice and number of sides to prevent silly people from rolling## dice that would cause fatal errors for reaching max execution time. Neat error message displayed## instead. - Idea by Wooly Spud#### 1.2.0 - Hades took over development.## - Re-wrote seed generation to give multiple die rolls in the same post different seeds for added randomness.## This fixed the bug where mutiple occurances of the same roll string within## a post would all generate identicle results.## - Removed all dice images. Smaller versions may be added in a later version, but for now they are not needed.## - Brought this MOD in line with Nutzzy's Multi-BBCode MOD.## This also eliminates the conflict with the multi-BBCode MOD. =)#### 1.1.2 - Jeff Leigh's last release.################################################################## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD################################################################-----[ OPEN ]------------------------------------------#includes/bbcode.php##-----[ FIND ]------------------------------------------# $bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']);##-----[ AFTER, ADD ]------------------------------------------# // -------------------------------- // DICE MOD CODE // -------------------------------- $bbcode_tpl['dice_open2'] = str_replace('{ROLLED}', $lang['Dice_Mod_Rolled'] . " - \\1", $bbcode_tpl['dice_open']); $bbcode_tpl['dice_open'] = str_replace('{ROLLED}', $lang['Dice_Mod_Rolled'], $bbcode_tpl['dice_open']); // -------------------------------- // END DICE MOD CODE // --------------------------------##-----[ FIND ]------------------------------------------# // user@domain.tld code.. $patterns[] = "#\[email\]([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si"; $replacements[] = $bbcode_tpl['email']; $text = preg_replace($patterns, $replacements, $text);##-----[ AFTER, ADD ]------------------------------------------# // -------------------------------- // BEGIN DICE MOD CODE // -------------------------------- // [dice] tags for rolling dice $text = bbencode_second_pass_pda($text, "/\[dice:$uid\]/is", "[/dice:$uid]", 'replace_dice_results', $bbcode_tpl['dice_open'], $bbcode_tpl['dice_close'] ); $text = preg_replace("/\[dice:$uid=(?:\"?([^\"]*)\"?)\]/si", $bbcode_tpl['dice_open2'] . "[dice:$uid=\"\\1\"]", $text); $text = bbencode_second_pass_pda($text, "/\[dice:$uid=(\\\".*\\\")\]/is", "[/dice:$uid]", 'replace_dice_results', '', $bbcode_tpl['dice_close']); // -------------------------------- // END DICE MOD CODE // --------------------------------##-----[ FIND ]------------------------------------------#function bbencode_first_pass($text, $uid){##-----[ BEFORE, ADD ]------------------------------------------#// --------------------------------// BEGIN DICE MOD CODE// --------------------------------function replace_dice_results($text, $uid){ global $lang; // Take the desired Die string ($text) and generate values for each roll. $Expressions = explode('=', $text); if( (isset($Expressions[0])) && (isset($Expressions[1])) ) { $Dice_Rolls = $Expressions[0]; $MT_Seed = intval($Expressions[1]);//(double)microtime()*1000000; doesn't work as it causes the rolls to be re-rolled every time the topic/post is re-loaded// $Fixed = $Expressions[2]; } else { return; } // Make sure we restore the MT gen to a random state after we are done... $Future_Seed = mt_rand(); mt_srand( $MT_Seed ); $Original_Roll_String = (isset($Fixed)) ? $Dice_Rolls . ' <b><span style="color: #AA0000">' . $lang['Dice_Mod_Fixed'] . '</span></b>': $Dice_Rolls; $Die_Rolls = explode(' ', trim($Dice_Rolls)); while( $Die = array_shift($Die_Rolls)) { $footer = ''; $header = ''; $Die_Count = substr($Die,0,strpos($Die,'d')); $Die_Type = substr($Die,strpos($Die,'d')+1); if( strpos($Die_Type, '+') ) { $Method = 1; $Modifier = substr($Die_Type,strpos($Die_Type,'+')+1); $Die_Type = substr($Die_Type,0,strpos($Die_Type,'+')); } else if( strpos($Die_Type, '-') ) { $Method = 2; $Modifier = substr($Die_Type,strpos($Die_Type,'-')+1); $Die_Type = substr($Die_Type,0,strpos($Die_Type,'-')); } else if( strpos($Die_Type, '*') ) { $Method = 3; $Modifier = substr($Die_Type,strpos($Die_Type,'*')+1); $Die_Type = substr($Die_Type,0,strpos($Die_Type,'*')); } else if( strpos($Die_Type, 'x') ) { $Method = 3; $Modifier = substr($Die_Type,strpos($Die_Type,'x')+1); $Die_Type = substr($Die_Type,0,strpos($Die_Type,'x')); } else if( strpos($Die_Type, '/') ) { $Method = 4; $Modifier = substr($Die_Type,strpos($Die_Type,'/')+1); $Die_Type = substr($Die_Type,0,strpos($Die_Type,'/')); } else { $Method = 0; $Modifier = 0; } $header = '<b>' . $lang['Dice_Mod_Roll_String'] . '</b>: ' . $Original_Roll_String . '<br /><b>' . $Die_Type . '-Sided Dice Results: </b>'; $footer = ''; $Die_Count = intval($Die_Count); if( $Die_Count == 0 ) $Die_Count = 1; $total = 0; if( $Method ) { $footer = $footer . "("; } // Loop Limit to prevent 500000d500000 sort of dice due to max. execution time limit if($Die_Count <= 200 && $Die_Type <= 100) { for( $i = 0; $i < $Die_Count; $i++ ) { if( $Die_Type == 100 ) { $value1 = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * 10) * 10; $value2 = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * 10); $total = $total + ($value1 + $value2); $footer = ($i != $Die_Count - 1) ? $footer . $value1 . '+' . $value2 . '(' .($value1 + $value2) . '<b></b>), ' : $footer . $value1 . '+' . $value2 . '(' . ($value1 + $value2) . '<b></b>)'; } else { $value = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * $Die_Type) + 1; $total = $total + $value; $footer = ($i != $Die_Count - 1) ? $footer . $value . ', ' : $footer . $value . ''; } } } // Loop limit else { $total = 0; $Modifier = 0; $footer = 'Too many dice and/or too many sides'; } switch( $Method ) { case 1: $footer = $footer . '<b></b>) + ' . $Modifier . ' '; $total = $total + $Modifier; break; case 2: $footer = $footer . '<b></b>) - ' . $Modifier . ' '; $total = $total - $Modifier; break; case 3: $footer = $footer . '<b></b>) * ' . $Modifier . ' '; $total = $total * $Modifier; break; case 4: $footer = $footer . '<b></b>) / ' . $Modifier . ' '; $total = $total / $Modifier; break; } // I do b - /b on purpose... kills out some smilies that crop up. if( ($Die_Count > 1) || ($Method != 0) ) { $footer= $footer . ' (<b>Total =</b> ' . $total . '<b></b>)<BR>'; } else { $footer = $footer . '<BR>'; } $footer = $footer. ""; $results = $results . $header . $footer; } // Restore MT randomness mt_srand($Future_Seed); return $results;}// --------------------------------// END DICE MOD CODE// --------------------------------##-----[ FIND ]------------------------------------------# // code.. $text = preg_replace("#\[img\]((ht|f)tp://)([^\r\n\t<\"]*?)\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text);##-----[ AFTER, ADD ]------------------------------------------# // -------------------------------- // BEGIN DICE MOD CODE // -------------------------------- $occurances = preg_match_all("#\[dice\]([-\s\w+/*]*?)\[/dice\]#i", $text, $temp); //list($usec,$sec)=explode(" ",microtime()); mt_srand((double)microtime()*1000000);//$sec * $usec); // Loop to fix randomness problem of results when multiple die rolls are made in a single post - Hades for($i=0;$i<=$occurances;$i++) { $dice_seed = mt_rand(); $text = preg_replace("#\[dice\]([-\s\w+/*]*?)\[/dice\]#i", "[dice:$uid]\\1 = $dice_seed [/dice:$uid] $limit", $text, 1); $text = preg_replace("#\[dice=(\\\\\".*?\\\\\")\]([-\s\w+/*]*?)\[/dice\]#i", "[dice:$uid=\\1]\\2 = $dice_seed [/dice:$uid] $limit", $text, 1); } $text = preg_replace("#\[dice\]([-\s\w+/*]*?)=([\s\d]*?)\[/dice\]#i", "[dice:$uid]\\1 = \\2 = Fixed[/dice:$uid]", $text); $text = preg_replace("#\[dice\]([-\s\w+/*]*?)=([\s\d]*?)=\s*?Fixed\s*?\[/dice\]#i", "[dice:$uid]\\1 = \\2 = Fixed[/dice:$uid]", $text); $text = preg_replace("#\[dice=(\\\\\".*?\\\\\")\]([-\s\w+/*]*?)=([\s\d]*?)\[/dice\]#i", "[dice:$uid=\\1]\\2 = \\3 = Fixed[/dice:$uid]", $text); $text = preg_replace("#\[dice=(\\\\\".*?\\\\\")\]([-\s\w+/*]*?)=([\s\d]*?)=\s*?Fixed\s*?\[/dice\]#i", "[dice:$uid=\\1]\\2 = \\3 = Fixed[/dice:$uid]", $text); // -------------------------------- // END DICE MOD CODE // --------------------------------##-----[ FIND ]------------------------------------------# return $text;} // bbencode_first_pass_pda()##-----[ AFTER, ADD ]------------------------------------------#// --------------------------------// BEGIN DICE MOD CODE// --------------------------------function bbencode_second_pass_pda($text, $open_tag, $close_tag,$func,$open_template, $close_template){ $open_tag_count = 0; $close_tag_length = strlen($close_tag); $use_function_pointer = ($func && ($func != '')); $stack = array(); if (is_array($open_tag)) { if (0 == count($open_tag)) { // No opening tags to match, so return. return $text; } $open_tag_count = count($open_tag); } else { // only one opening tag. make it into a 1-element array. $open_tag_temp = $open_tag; $open_tag = array(); $open_tag[0] = $open_tag_temp; $open_tag_count = 1; } $open_is_regexp = true; // Start at the 2nd char of the string, looking for opening tags. $curr_pos = 1; while ($curr_pos && ($curr_pos < strlen($text))) { $curr_pos = strpos($text, "[", $curr_pos); // If not found, $curr_pos will be 0, and the loop will end. if ($curr_pos) { // We found a [. It starts at $curr_pos. // check if it's a starting or ending tag. $found_start = false; $which_start_tag = ""; $start_tag_index = -1; for ($i = 0; $i < $open_tag_count; $i++) { // Grab everything until the first "]"... $possible_start = substr($text, $curr_pos, strpos($text, "]", $curr_pos + 1) - $curr_pos + 1); // // We're going to try and catch usernames with "[' characters. // if( preg_match('/\[quote\=\\\\"/si', $possible_start) && !preg_match('/\[quote=\\\\"[^"]*\\\\"\]/si', $possible_start) ) { // // OK we are in a quote tag that probably contains a ] bracket. // Grab a bit more of the string to hopefully get all of it.. // $possible_start = substr($text, $curr_pos, strpos($text, "\"]", $curr_pos + 1) - $curr_pos + 2); } // // Now compare, either using regexp or not. $match_result = array(); // PREG regexp comparison. if (preg_match($open_tag[$i], $possible_start, $match_result)) { $found_start = true; $which_start_tag = $match_result[0]; $start_tag_index = $i; break; } } if ($found_start) { // We have an opening tag. // Push its position, the text we matched, and its index in the open_tag array on to the stack, and then keep going to the right. $match = array("pos" => $curr_pos, "tag" => $which_start_tag, "index" => $start_tag_index); bbcode_array_push($stack, $match); ++$curr_pos; } else { // check for a closing tag.. $possible_end = substr($text, $curr_pos, $close_tag_length); if (0 == strcasecmp($close_tag, $possible_end)) { // We have an ending tag. // Check if we've already found a matching starting tag. if (sizeof($stack) > 0) { // There exists a starting tag. $curr_nesting_depth = sizeof($stack); // We need to do 2 replacements now. $match = bbcode_array_pop($stack); $start_index = $match['pos']; $start_tag = $match['tag']; $start_length = strlen($start_tag); $start_tag_index = $match['index']; // everything before the opening tag. $before_start_tag = substr($text, 0, $start_index); // everything after the opening tag, but before the closing tag. $between_tags = substr($text, $start_index + $start_length, $curr_pos - $start_index - $start_length); // Run the given function on the text between the tags.. if ($use_function_pointer) { $between_tags = $func($between_tags, $uid); } // everything after the closing tag. $after_end_tag = substr($text, $curr_pos + $close_tag_length); // Mark the lowest nesting level if needed. $text = $before_start_tag . $open_template . $between_tags . $close_template . $after_end_tag; // Now.. we've screwed up the indices by changing the length of the string. // So, if there's anything in the stack, we want to resume searching just after it. // otherwise, we go back to the start. if (sizeof($stack) > 0) { $match = bbcode_array_pop($stack); $curr_pos = $match['pos']; bbcode_array_push($stack, $match); ++$curr_pos; } else { $curr_pos = 1; } } else { // No matching start tag found. Increment pos, keep going. ++$curr_pos; } } else { // No starting tag or ending tag.. Increment pos, keep looping., ++$curr_pos; } } } } // while return $text;} // bbencode_second_pass_pda()// --------------------------------// END DICE MOD CODE// --------------------------------##-----[ OPEN ]------------------------------------------#posting.php##-----[ FIND ]---------------------------------#$EMBB_keys = array(''$EMBB_widths = array(''$EMBB_values = array(''##-----[ IN-LINE FIND ]---------------------------------#$EMBB_keys = array(''##-----[ IN-LINE AFTER, ADD ]---------------------------------#,'d'##-----[ IN-LINE FIND ]---------------------------------#$EMBB_widths = array(''##-----[ IN-LINE AFTER, ADD ]---------------------------------#,'40'##-----[ IN-LINE FIND ]---------------------------------#$EMBB_values = array(''##-----[ IN-LINE AFTER, ADD ]---------------------------------#,'Dice'##-----[ FIND ]---------------------------------## NOTE: the full line to look for is:# 'L_BBCODE_F_HELP' => $lang['bbcode_f_help'],# 'L_BBCODE_F_HELP' =>##-----[ AFTER, ADD ]--------------------------------# 'L_BBCODE_D_HELP' => $lang['bbcode_d_help'],##-----[ OPEN ]------------------------------------------#templates/subSilver/bbcode.tpl##-----[ FIND ]------------------------------------------#<!-- BEGIN email --><a href="mailto:{EMAIL}">{EMAIL}</A><!-- END email -->##-----[ AFTER, ADD ]------------------------------------------#<!-- BEGIN dice_open --><table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr> <td><span class="genmed"><b>{ROLLED}:</b></span></td> </tr> <tr> <td class="quote"><!-- END dice_open --><!-- BEGIN dice_close --></td> </tr></table><span class="postbody"><!-- END dice_close -->##-----[ OPEN ]------------------------------------------#templates/subSilver/posting_body.tpl##-----[ FIND ]---------------------------------## NOTE: the full line to look for is:#f_help = "{L_BBCODE_F_HELP}";#f_help =##-----[ AFTER, ADD ]---------------------------------#d_help = "{L_BBCODE_D_HELP}";##-----[ FIND ]---------------------------------## NOTE: the actual line to find is MUCH longer, containing all the bbcode tags#bbtags = new Array(##-----[ IN-LINE FIND ]---------------------------------#'[url]','[/url]'##-----[ IN-LINE AFTER, ADD ]---------------------------------#,'[dice]','[/dice]'##-----[ OPEN ]------------------------------------------#language/lang_english/lang_main.php##-----[ FIND ]------------------------------------------#//// That's all Folks!// -------------------------------------------------##-----[ BEFORE, ADD ]------------------------------------------#// --------------------------------// BEGIN DICE MOD CODE// --------------------------------$lang['Dice_Mod_Rolled'] ='Dice Roll';$lang['Dice_Mod_Fixed'] ='Fixed';$lang['Dice_Mod_Roll_String'] = 'Original Roll String';$lang['bbcode_d_help'] = 'Roll Dice: [dice]dice string[/dice] (alt-d) Tip: Use the (#)d(Sides) convention.';// --------------------------------// END DICE MOD CODE// --------------------------------##-----[ OPEN ]------------------------------------------#language/lang_english/lang_bbcode.php##-----[ FIND ]------------------------------------------#$faq[] = array("--", "Other matters");$faq[] = array("Can I add my own tags?", "No, I am afraid not directly in phpBB 2.0. We are looking at offering customisable BBCode tags for the next major version");##-----[ BEFORE, ADD ]------------------------------------------#// --------------------------------// BEGIN DICE MOD CODE// --------------------------------$faq[] = array("--", "Roleplaying Features");$faq[] = array("Rolling dice in a post", "Posts and private messages can also include dice rolls. Using the [dice]...[/dice] tags you can specify one or more rolls to be displayed in your message.<br><span style=\"font-weight: bold\">Dice Command Syntax:</span><ul><li>[dice](<span style=\"font-style: italic\">Dice Strings</span>)[/dice]<li>[dice=\"Roll Title\"](<span style=\"font-style: italic\">Dice Strings</span>)[/dice]</ul>The Dice String parameter can include mutliple dice strings in the standard throw syntax.<br /><br /><span style=\"font-weight: bold\">Throw Syntax:</span><ul><li>(<span style=\"font-style: italic\">Number of Dice</span>)d(<span style=\"font-style: italic\">Type of Dice</span>)<li>(<span style=\"font-style: italic\">Number of Dice</span>)d(<span style=\"font-style: italic\">Type of Dice</span>)(<span style=\"font-style: italic\">+,-,x,*,/</span>)(<span style=\"font-style: italic\">Modifier</span>)</ul>It may look complicated if you've never seen this sytem before, but it is actually quite easy to understand.<br /><br />Optionally, you can specify an operation and modifier for each throw, as shown above. Supported operations are addition (+), subtraction (-), multiplication (* or x), and division (/).<br /><br /><span style=\"font-weight: bold\">Some Examples:</span><ul><li>d6 - Throw a single 6-sided die.<li>d20 - Throw a single 20-sided die.<li>2d20 - Throw two 6-sided dice.<li>d100 - Somewhat special, throws two 10 sided die, and multiplies one by 10.. resulting in a range of 100<li>d20+5 - Throw a 20-sided die and add 5 to the result.<li>4d20+10 - Throw four 20-sided dice and add 10 to the total.</ul>Hopefully you understand.<br /><br /><span style=\"font-weight: bold\">Output Examples:</span><br /><br />Here are a few instances of the 'Die' code in action, with the code above. <br />Totals are provided for convience, but obviously are not relevent to all throws.<br /><br /><span style=\"font-weight: bold\">Code:</span> [dice]d20[/dice]<br /><table width=\"90%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr> <td><span class=\"genmed\"><b>Dice Roll:</b></span></td> </tr> <tr> <td class=\"quote\"><b>Original Roll String:</b> <font color=\"#000088\">d20</font><BR><BR><b>20-Sided Dice Results: </b>6<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"><img src=\"./images/dice/white/dice_20_sided_6.jpg\"></td></tr></table></center></div></td></tr></table><span class=\"postbody\"><br /><span style=\"font-weight: bold\">Code:</span> [dice=\"Fire Save\"]2d20+10[/dice]<br /><table width=\"90%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><span class=\"genmed\"><b>Dice Roll - Fire Save:</b></span></td></tr><tr><td class=\"quote\"><b>Original Roll String:</b> <font color=\"#000088\">2d20+10</font><BR><BR><b>20-Sided Dice Results: </b>(4, 1<b></b>) + 10 (<b>Total =</b> 15<b></b>)<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"><img src=\"./images/dice/white/dice_20_sided_4.jpg\"><img src=\"./images/dice/white/dice_20_sided_1.jpg\"></td></tr></table></center></div></td></tr></table><span class=\"postbody\"><br /><span style=\"font-weight: bold\">Code:</span> [dice=\"Statistic Generation\"]4d4+10 3d6x2 2d100 4d4+10[/dice]<br /><table width=\"90%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><span class=\"genmed\"><b>Dice Roll - Statistic Generation:</b></span></td></tr><tr><td class=\"quote\"><b>Original Roll String:</b> <font color=\"#000088\">d4+10 3d6x2 2d100 4d4+10</font><BR><BR><b>4-Sided Dice Results: </b>(2<b></b>) + 10 (<b>Total =</b> 12<b></b>)<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"><img src=\"./images/dice/white/dice_4_sided_2.jpg\"></td></tr></table></center></div><b>6-Sided Dice Results: </b>(1, 4, 3<b></b>) * 2 (<b>Total =</b> 16<b></b>)<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"><img src=\"./images/dice/white/dice_6_sided_1.jpg\"><img src=\"./images/dice/white/dice_6_sided_4.jpg\"><img src=\"./images/dice/white/dice_6_sided_3.jpg\"></td></tr></table></center></div><b>100-Sided Dice Results: </b>60+1(61<b></b>), 30+1(31<b></b>) (<b>Total =</b> 92<b></b>)<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"><img src=\"./images/dice/white/dice_100_sided_60.jpg\"><img src=\"./images/dice/white/dice_10_sided_1.jpg\"><img src=\"./images/dice/white/dice_spacer.jpg\"><img src=\"./images/dice/white/dice_100_sided_30.jpg\"><img src=\"./images/dice/white/dice_10_sided_1.jpg\"><img src=\"./images/dice/white/dice_spacer.jpg\"></td></tr></table></center></div><b>4-Sided Dice Results: </b>(1, 3, 4, 1<b></b>) + 10 (<b>Total =</b> 19<b></b>)<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"><img src=\"./images/dice/white/dice_4_sided_1.jpg\"><img src=\"./images/dice/white/dice_4_sided_3.jpg\"><img src=\"./images/dice/white/dice_4_sided_4.jpg\"><img src=\"./images/dice/white/dice_4_sided_1.jpg\"></td></tr></table></center></div></td></tr></table><span class=\"postbody\"><br /><br />In case you are wondering, the numbers you see when you 'preview' will probably change when you go to post.<BR><BR><i>Dice Mod (version 1.1.0) by Jeff Leigh.</i>");// --------------------------------// END DICE MOD CODE// --------------------------------##-----[ SAVE/CLOSE ALL FILES ]------------------------------------------## EoM UPDATES E BUGS FIXES# #-----[ OPEN ]------------------------------------------ # includes/bbcode.php # #-----[ FIND ]------------------------------------------ # $header = '<b>' . $Die_Type . '-Sided Dice Results: </b>'; $footer = ''; $Die_Count = intval($Die_Count); if( $Die_Count == 0 ) $Die_Count = 1; $total = 0; if( $Method ) { $footer = $footer . "("; } for( $i = 0; $i < $Die_Count; $i++ ) { if( $Die_Type == 100 ) { $value1 = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * 10) * 10; $value2 = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * 10); $total = $total + ($value1 + $value2); $footer = ($i != $Die_Count - 1) ? $footer . $value1 . '+' . $value2 . '(' .($value1 + $value2) . '<b></b>), ' : $footer . $value1 . '+' . $value2 . '(' . ($value1 + $value2) . '<b></b>)'; } else { $value = ($Die_Type == 10 ) ? (integer)(((double)mt_rand()/(double)mt_getrandmax()) * $Die_Type + 1) : (integer)(((double)mt_rand()/(double)mt_getrandmax()) * $Die_Type) + 1; $total = $total + $value; $footer = ($i != $Die_Count - 1) ? $footer . $value . ', ' : $footer . $value . ''; } } switch( $Method ) # #-----[ REPLACE WITH ]------------------------------------------ # $header = '<b>' . $lang['Dice_Mod_Roll_String'] . '</b>: ' . $Original_Roll_String . '<br /><b>' . $Die_Type . '-Sided Dice Results: </b>'; $footer = ''; $Die_Count = intval($Die_Count); if( $Die_Count == 0 ) $Die_Count = 1; $total = 0; if( $Method ) { $footer = $footer . "("; } // Loop Limit to prevent 500000d500000 sort of dice due to max. execution time limit if($Die_Count <= 200 && $Die_Type <= 100) { for( $i = 0; $i < $Die_Count; $i++ ) { if( $Die_Type == 100 ) { $value1 = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * 10) * 10; $value2 = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * 10); $total = $total + ($value1 + $value2); $footer = ($i != $Die_Count - 1) ? $footer . $value1 . '+' . $value2 . '(' .($value1 + $value2) . '<b></b>), ' : $footer . $value1 . '+' . $value2 . '(' . ($value1 + $value2) . '<b></b>)'; } else { $value = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * $Die_Type) + 1; $total = $total + $value; $footer = ($i != $Die_Count - 1) ? $footer . $value . ', ' : $footer . $value . ''; } } } // Loop limit else { $total = 0; $Modifier = 0; $footer = 'Too many dice and/or too many sides'; } switch( $Method ) # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM
2004/9/10 3:15
Anonymous
Posts: 0
Since:
2004/10/16 23:17
Advanced Search
282 user(s) are online (183 user(s) are browsing Support Forums)
Members: 0
Guests: 282