CVS edit link for Bastlynn

I would like to offer an integrated Dice Roller module for Drupal 6 and eventually Drupal 7 as well. Dice rollers are one of the most requested features on role playing sites. This module will provide feature and convenience for forum based play. This module will also eliminate the risk of players tampering with roll results by integrating the roller with node and comment posts. I've looked through the existing modules and found nothing similar already in existence.

Comments

Bastlynn’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new5.83 KB

The attached code was sent through the Coder module.

zzolo’s picture

Status: Needs review » Needs work

Per the CVS application requirements, can you expand on your modules and its features more before someone reviews it. Thank you.

Anonymous’s picture

Issue tags: +Module review

The previous application was #559080: Bastlynn [bastlynn].

Bastlynn’s picture

My apologies for the delay in answer - I've been out of range of my computer for the week on a trip. I'll get some additional screenshots and details into the thread this evening once I'm at a computer with the right features for it.

Bastlynn’s picture

StatusFileSize
new34.62 KB
new39.66 KB
new37.74 KB

This module adds an option to forum posts and comments to provide an integrated dice roller. The dice roller options are based on the standards set at http://openrpg.com for dice rolling.

Once the module is activated there is no additional configuration needed. The option to roll dice will automatically appear in forum node creation and comments.

Once the roll is made, there is no option for the user to go back to remove the roll from the post nor any option to modify the roll. This is to prevent tampering with results, negating the risk of cheating.

Please see the screenshots for a walk through on what to expect.

avpaderno’s picture

Status: Needs work » Needs review
Bastlynn’s picture

StatusFileSize
new6.69 KB

I haven't heard back on this one in awhile. So I put in the few things I'd spotted that I personally wanted to get in place.

Changes made in this version:

Bugs Fixed
ln 6 typo
ln 44 removed use of t() in light of markup in text
ln 138 corrected non standard comment format (and other instances)
overall corrected tabbing from four spaces to two spaces
Removed forum dependency (though best used with)
Schema Changes
None
Additional Features
Added administration page to associate rolls to specific types of nodes
Added permissions for administrating the dice roller, using it, and viewing it

Modifications in Install Directions:

Once activated,
Go to admin/settings/dice_roller to select node types to enable the dice roller for.
Go to admin/user/permissions to configure user access permissions.

Please let me know if there is additional feedback for this module, or any stylistic changes to be made.

Bastlynn’s picture

Is there anything I need to do to get this application moving? Is there a step I missed?

adaddinsane’s picture

I'll take a look at this a bit later today - I've been playing RPGs (table-top and live - can't be bothered with computer RPGs) for over 30 years :-)

Anyway I'll gie it a review during my lunchbreak.

adaddinsane’s picture

Status: Needs review » Needs work

Well you certainly cleaned it up as far as "coder" is concerned since it reported nothing. But you can't get away scott free :-)

We're always keen to keep the code footprint as small as possible, so putting the settings form into a separate file (using 'file' => 'dice_roller.admin.inc' in hook_menu) would be good. Likewise you could put the dice rolling code (which is a fair chunk) in a separate file and just load it when you need to evaluate a roll which would be far less often than just displaying a previously calculated result.

In the same vein, your massive amount of help (a good thing, obviously) is not going to be needed most of the time - can you change it to, say, theme('dice_roller_help') and then that can go in a separate file as well.

And on the subject of themes: your _dice_roller_get_roll() function should be a theme - so another developer/administrator can display it a different way if they want to.

Minor issue, and not critical since it works fine, in your hook_nodeapi you check for !$teaser on every IF, wouldn't it be more efficient to just check that first and exit if TRUE? Also using 'elseif' would have a slightly quicker execution time :-) since only one op is going to be true at any given entry to the function. (Personally I prefer 'switch' - but that's just me.)

You might also want to take a look at hook_content_extra_fields, this allows you to integrate your fields with the "CCK Manage fields" pages so administrators can decide where in the sequence of fields your ones appear.

Hope that helps.

Bastlynn’s picture

Yay marching orders! :) Ok, I'll get started on those updates.

I had a version of the code with an API integrated into it to allow other modules to add dice rolls types to support specific game systems but I feel that's a large enough update from this initial version of the code that I'm a little hesitant to dump it on the reviewers. It can be pretty hard to evaluate a moving target.

Let me know if you're interested in digging into that aspect as well, and I'll apply the updates to that branch instead.

adaddinsane’s picture

I almost wrote about having an API. However you were asking for approval on this code, so that's what I reviewed. Once you have the CVS account you can do all the changes you want without anyone interfering :-)

Bastlynn’s picture

StatusFileSize
new8.41 KB

Ok, changes are in place. :)
Let me know if I completely missed something in what you were saying. I'm really glad you took a look at this actually since I personally prefer switch statements as well. I guess I just didn't have enough coffee that morning or something, to not see how moving the teaser up would let me use switch. ;)

Bastlynn’s picture

Status: Needs work » Needs review
Bastlynn’s picture

@adaddinsane Anything else I need to fix? I'm pretty eager to get this thing up so I can add in all the other ideas I've had :)

adaddinsane’s picture

Nothing from me - but I can't do anything else.

zzolo’s picture

Status: Needs review » Needs work

I can finish this up. You are definitely in the right direction and getting close.

The following points are just a start and do not encompass all of the changes that may be necessary for your approval. Also, a specific point may just be an example and may apply in other places.

  1. Your README.txt suggestions versions which is unnecessary as you have not realized the module yet. Also, your README.txt is more of a changelog. I would suggest removing the INSTALL.txt and just having a README.txt, then when new releases happen add a CHANGELOG.txt
  2. Follow Drupal Coding Standards. Note that Drupal coding standards are more than just PHP code. Also, look at using Coder to help automate SOME of this. Examples (there are many):
            'description' => 'The primary identifier for a roll.',
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE),
    

    You need proper docblocks for all functions and files.

  3. /**
     * Implementation of hook_form_alter(), add the number input to both comment and form
     */
    function dice_roller_menu() {
    

    This is not accurate.

  4.     return $form; /* Exit if this user can't use the dice roller */
    

    No need to return the form as it is passed by reference.

  5.   if (drupal_strlen($pid)==0) {
        return '';
      }
    

    Use empty() and is_string() to be more accurate of what you are looking for.

  6.           include_once('dice_roller.roller.inc');
    

    Please utilise http://api.drupal.org/api/function/module_load_include

  7.     $str_rolls .= '<div class="dice_roll">I rolled '. $roll_command .', the result is '. $roll_results[$index] .'</div>';
    

    Utilize t()

  8. The help tpl does not use t().

--
Note: Please be patient with the CVS application process. It is all done by volunteers. Our goal is not to be arbitrarily slow or meticulous. Our goal is to get you CVS access and ensure that you are and will become a more responsible Drupal contributor. For a quick reference on what I look for in a code review, please see this article.

Bastlynn’s picture

Hi, zzolo! Thanks for taking a look. I'll get dug into this list this week. I'm really not so much worried about getting this module approved now-now-now and much more just not wanting to completely slip through the cracks. There's a lot of applications in, and I know this isn't the most interesting of modules for the more business minded reviewer. ;) Please let me know if I'm bumping sooner than I ought to compared to the normal rate of work from reviewers on the apps, I don't want to be a pest.

zzolo’s picture

Hey @Bastlynn, thanks for your patience and understanding; you are actually one of the more understanding. We don't try to favor any application over the other, but it is all volunteer, so there probably is some sort of favoritism going on. Nonetheless, we look forward to your updates.

Bastlynn’s picture

I haven't forgotten - I'm currently in the middle of a job transition, so haven't had the chance to put as much time to this as I'd like. Please bear with me. :)

Bastlynn’s picture

Status: Needs work » Needs review
StatusFileSize
new8.14 KB

Ok, I'm back!

Latest updates are:

1 - README.txt changed to include the install information. INSTALL.txt file removed. I'll add CHANGELOG.txt later when it's needed.

2 - I wasn't quite sure what this was referring to. But based on the example given and on reviewing the Standards I would guess it was re: the array ending parenthesis and end comma? If so - fixed throughout. If not... can I get a more detailed explanation?

3 - Opps - I wasn't paying attention on that. All have been fixed now with updated docblocks.

4 - Fixed.

5 - Fixed. I also merged this catch with the catch below it. There was no need to waste space there.

6 - Thank you! I didn't know PHP had the empty function. Very handy in the future and is now added to my regular toolkit. :) Also - fixed.

7,8 - I've applied t() throughout these tpl's. I was a little unsure re: how to handle the html within the strings, so where possible I've avoided including it. Let me know if this case calls for it to be handled the other way.

Let me know what the next round of changes need to be. :)

deekayen’s picture

Status: Needs review » Needs work
StatusFileSize
new5.13 KB

RPG package - what else is in there on the modules page? Is there a package of other similar RPG modules you could change it to or should it just be in Other?

Menu heading on admin/settings shouldn't say Configure and should have description. Note everything else is just a name because you're already in a configuration area.

Most of the headings on links like on admin/settings are ucfirst() format. Is it intentional that Dice Roller differs from that for some reason?

Since the only configuation for dice roller is what content types it should display on, those settings might fit better on the content type configuration forms rather than having to find them in a separate area. If you use hook_form_alter() to insert the activation for node_type_form, you could have a dice roller activated there. See the http://drupal.org/project/submitagain module for an example. If you move it to the content type configuration, then you can entirely remove the menu callback and configuration form, of course.

When I activate the module on node/add/page, again there's a ucfirst() issue, but there's also a complete lack of descriptions on the form fields. I have no idea what to type into the roll box, why I would make a note, and the help box is blank. If you could get the instructions clearly into one sentence, then the Help fieldset might not even be necessary, but if you keep it, it should have content. Afterall, even if I had read the README first, the site admin knowing what it does doesn't tell the users how to use it.

The first time I saved the node, nothing happened. That was expected behavior. Then I edited the node and I didn't know what to type, so I rolled "133432dd". As a result, I got:

* warning: implode(): Invalid arguments passed in /var/www/d6/sites/all/modules/dice_roller/dice_roller.roller.inc on line 25.
* warning: htmlspecialchars() expects parameter 1 to be string, array given in /var/www/d6/includes/bootstrap.inc on line 840.

The View tab lists:

This is a note.
I rolled 133432dd, the result is .

However, when I go back to edit the node again, I set the roll to "a" and got just

* warning: htmlspecialchars() expects parameter 1 to be string, array given in /var/www/d6/includes/bootstrap.inc on line 840.

Nothing changed on the View tab; it retains the 133432dd roll. Thinking perhaps I needed an integer, I switched tactics and to roll "100000000000":

* warning: implode(): Invalid arguments passed in /var/www/d6/sites/all/modules/dice_roller/dice_roller.roller.inc on line 25.
* warning: htmlspecialchars() expects parameter 1 to be string, array given in /var/www/d6/includes/bootstrap.inc on line 840.
* warning: htmlspecialchars() expects parameter 1 to be string, array given in /var/www/d6/includes/bootstrap.inc on line 840.

"I rolled 100000000000, the result is ." Numeric and alpha are both broken, so I'm not sure what to do from here.

On the code side, your docblock spacing is off in your section of database related functions. Each line of the docblock should have just one space before the asterisk. I saw this in .module and .inc.

There should be a space between the "Implementation of" and the comment of what the function does. re: hook_comment.

hook_content_extra_fields (). shouldn't have a space before the paren.

In your README, you list specific URLs for most locations, but then leave "on the admin page" for how to actually turn it on.

There are specific accepted examples for how a README should be written, things it should contain, and how it should be formatted. Morbus' style to match core is probably best. Same area for documentation for when you add descriptions to your node fields. http://drupal.org/node/632262

English pickyness in your .info file: "Provides an integrated, tamper-proof dice roller for nodes and comments."

Line 245 of dice_roller.module should be indented.

Many of your docblock sentences don't have periods on the end and should.

There's no point in having an empty default case in functions like your nodeapi implementation.

Space out your if statements, like at the bottom of dice_roller.roller.inc, drupal_strlen($extras) > 0

Line 311 of dice_roller.roller.inc has an extra space in implode(', ', $arr_rolls );.

Make your if statement spacing consistent. Line 253 of dice_roller.roller.inc has extra space in the paren where if ( $extra >= $hits ) should probably have those removed by the parentheses.

Add spaces on line 215 for ($i=0;$i<$number;$i++)

Maybe I just didn't analyze it close enough, but what's the point of the module_exists() in dice_roller_content_extra_fields()? In normal circumstances, that function is used to plugin to other modules if they're installed, not to check on the status of the very same module that's running.

Any reason for the extra space at the end of the query in _dice_roller_set_origin() or _dice_roller_get_roll()?

I saw multiple cases in dice_roller.roller.inc where variables were used like $func, $arr_funcs, lpara, $ctrl, and $err. As a general rule, don't abbreviate variable names. Spell out their usefulness so they can be self-documenting without extra mental translation.

dice-roller-basic-help.tpl.php says strings are copied versions of copyrighted text. Do you have written permission to redistribute under the GPL?

Bastlynn’s picture

Status: Needs work » Needs review
StatusFileSize
new12.24 KB

The intent is to eventually offer a suite of RPG related modules to handle dice rolling, character sheets, and possibly support specific game systems as well. There are also other RPG related modules from Drupal 5 that I may be speaking with the maintainer to coordinate updating to Drupal 6 in this effort as well. Hence - putting it into its own package.

The menu options have been removed in favor of moving the configuration to specific node content types. (Really good idea!)

Headings and messages have been changed to ufirst().

It looks like my templates had a bug in them that was preventing the help info and results from displaying properly. This was related to the error you were seeing. That's been fixed now and you should have much more clear directions on how to use the roller. In addition the failure state of bad data has been caught as well, so you'll get some feedback when a bad command gets put into the roller.

Docblocks fixed. Proper punctuation and spacing now in place.

Please let me know if I got the spacing between "Implementation of" and further explanation comments correct? I was guessing a little and moved the additional comment up to the same line. Let me know if that's what you were aiming for.

README file corrected for formatting.

.info file fixed for grammar.

Ln 245 fixed for indention.

Empty default case for switches removed.

Overlooked if statements are spaced properly now.

There actually wasn't any good reason to have module_exists(). Apparently, I entirely overlooked removing it when I took a look at the hook example.

SQL query spacing fixed. Originally I think I had an "order by" clause on the next line so the space was a leftover from that.

Variable names in the parser have been completely renamed for clarity.

And lastly (long list! :) ) - OpenRPG is released under GPL already according to their website information at: www.openrpg.com - Under 'About OpenRPG'. So I think it should be good from there. The parser and implementation of code is my own - only parts of the help file and the basic user interface concept is OpenRPG.

Let me know if there's anything else you spot.

deekayen’s picture

Status: Needs review » Fixed

I was unclear about the docblocks. There should be a blank newline after the initial single line description, not a space. I don't see that misunderstanding as a good reason to keep this from being approved. Look for your approval email shortly.

bushi’s picture

Category: task » bug
Priority: Normal » Major
Status: Fixed » Needs review

When trying to save roll on drupal 6.x

Parse error: syntax error, unexpected ';' in /home/szaijan/public_html/avatar/modules/dice_roller/dice_roller.roller.inc on line 27

Suggestion:
Help or readme should clarify relationship to other comment fields and also any relationship to integrated rich text editor (which was on by default in my dice roll text entry area, but turning on or off had no error effect).

happy to provide additional information.

mm status should not be fixed on the report.

avpaderno’s picture

Category: bug » task
Priority: Major » Normal
Status: Needs review » Fixed
Bastlynn’s picture

@Bushi - I've opened up an issue for this on the released module's issue queue so we can let the application request stay closed. You can find the issue here: http://drupal.org/node/879240 If you run into anything else, please add it to the queue and I'll get started on it. :)

Status: Fixed » Closed (fixed)
Issue tags: -Module review

Automatically closed -- issue fixed for 2 weeks with no activity.