MyBB Community Forums

Full Version: Cheat-Proof Dice Roller for Play-by-Post RPG
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Note: I have looked at a few dice rollers here and on MyBBCentral, as well as the SMF forums, but thus far haven't found anything capable of replacing the roller I'm already using on my current host. I'm reposting this here (from MyBBCentral) in the hopes of soliciting coders who might not be on that site.

SYNOPSIS: I need a dice roller for my Pathfinder RPG Play-by-Post. The mod needs to be able to parse the #d# syntax (i.e. 1d20, 3d6) like a the mathematical operand it is, and it needs to be possible to sum the results of multiple die rolls and modifiers in the same statement (i.e. 1d8+4+2d6). In addition to this, it needs to be cheat proof.

Yes, I am willing to pay for this, and would like some estimates on a fair amount from anyone with the skills needed to make it a reality.

DETAILED REQUIREMENTS
Input/Output: There are two different approaches I can see here. One is to add die rolls to posts thru inline BBCode (this being the method I currently use), the other would be to add a separate form for die rolls to the post window. For the inline method, please see this post on the Paizo Publishing forums (i.e. where I currently run my game).

Inline BBCode Example:
Current Syntax: [ooc]Longbow [dice]1d20+10 + 1 + 1d6 [/dice] point blank shot, mythic surge [/ooc]
Current Output: Longbow 1d20 + 10 + 1 + 1d6 ⇒ (13) + 10 + 1 + (4) = 28 point blank shot, mythic surge
Desired Syntax: [dice="Longbow"]1d20+10 + 1 {point blank shot} + 1d6 {mythic surge}[/dice]
Desired Output: Longbow 1d20 + 10 + 1 + 1d6 ⇒ (13) + 10 + 1 point blank shot + 4 mythic surge

Form Example:
The other method I can visualize is to display a second textarea strictly for die rolls below the main textarea on the new/edit post template. Here, the user could type in their rolls and modifiers as above, except all of the output would be kept within a spoiler that the users could not directly edit. If the user needed to go back and add/remove rolls from this post, the prior output would be saved and quoted similar to how some of the edit reason and version history mods work. It IS desireable for users to be able to edit a post to add/remove rolls since a particularly good attack result might indicate a critical hit (which would mean an additional roll to confirm the crit, and also more damage dice, etc.), of the GameMaster might want a player to make a roll that they forgot ("Hey, you were trying to sweet-talk that informant, but you forgot to make a Diplomacy check.")

Part of the reason why I would want a second textarea for dice rolls (rather than having dynamically-added form fields for individual rolls) is that there are MANY instances in which it is necessary to reuse prior rolls. For instance, when the group enters a new room, I'll roll Perception for everyone in the group by typing "prtp" and my ShortKeys app will output the roll syntax for everyone in the group without me needing to manually enter every last roll and modifier by hand.

Usage Examples: Note that on the forums I'm linking to, users cannot modify the color of text. Out-of-Character text is always blue, and die rolls are always green. I have already modded my own forums to remove the ability for users to change the color of their text, so forging rolls by emulating the output won't be an issue.

Multiple Die Rolls in the same attack: page=200#9963
Multiple NPCs attacking in the same post: 200#9968
Die Roll Syntax and Preview:
[Image: 20130428040221%21Screenshot.png]

Now I'm not saying the implementation on Paizo is perfect, in fact there are a few things it can't do such as dropping lowest from a set, taking the better of two rolls, or any other such logic-based conditions. One improvement I personally would desire would be the ability to label individual bonuses so that they appear in the actual roll instead of having to manually note them in the out of character text (see my inline example above).

Cheat Prevention: Follow are some additional consideration where legit usage and preventing cheating are concerned.
  • For any given roll, randomization must take place ONLY the first time that die roll is previewed or posted!
    Why? This is because player and the GM will first preview their rolls to get an idea if they have succeeded or failed on an attempt before narrating the results in the story. If a swing and a hit on the preview gets rerandomized as a miss when they click submit, edit, or preview subsequent times, then they'll never be able to have their writing match the actual rolls.
    How? I'd imagine that an extra table would need to be added to the database. Whenever a die roll is generated, it is permanently tracked there. Rolls would need to be keyed per-account per thread.
  • Once a particular type of roll is added, if the user attempts to remove and readd it later, or cancel their post and then start over that roll result should be remembered.
    Why? Let's say a character make a Diplomacy attempt to bribe an official and they I roll so badly that not only was the bribe unsuccessful, the official is now angry and liable to send them to jail. Players should not be able to cancel or delete the post and have that bad roll disappear. Similarly, they shouldn't be able to evade the bad roll by adding a 'junk' post (with an out-of-character question, or a joke or something) and then reattempting the roll in a subsequent post. Likewise, they shouldn't be able to go and make that post in a completely different thread and have the bad roll show up there instead.
    How? Like above, could be stored in a database table and keyed to a particular forum account on a per-thread basis. If they preview a d20, a d8, another d20 and a d6 roll and decide to omit the second d20 and the d6, the dice roller should remember what those results were the next time that use makes a roll with a d20 and a d6 in it.

EXTRA FEATURES
The above is what I absolutely need. Following are a few additional ideas that would be nice, but aren't deal-breakers.

Roll Twice, Take the Better/Worse Result: There are many abilities that allow characters to roll twice and take the better result. Similarly there are some attacks that can force some to make all rolls twice taking the worse result. It would be nice to have some way of doing this on a per-die basis.
Examples:
  • Roll a d20 two times, show both results, but only sum the better result.
    Desired Input: [dice]2d20>1 + 10 + 1d6 [/dice]
    Desired Output: 2d20>1 + 10 + 1d6 ⇒ (13,2) + 10 + (4) = 27
  • Roll a d20 two times, show both results, but only sum the worse result.
    Desired Input: [dice]2d20<1 + 10 + 1d6 [/dice]
    Desired Output: 2d20<1 + 10 + 1d6 ⇒ (2,13) + 10 + (4) = 16
  • Roll a d6 four times keep the three best rolls
    Desired Input: [dice]4d6>3[/dice]
    Desired Output: 4d6<3 ⇒ (6,5,2,1) = 13

Quote to Reuse Rolls: There are LOTS of times when players and GMs alike will need to re-use rolls. It would be nice to be able to click a "quote" button next to someone's rolls and get back the BBCode needed to reproduce those rolls. (On Paizo when you quote rolls, you only get the output, not the BBCode. It would be great to improve upon that.)