[ABD] Dice MOD

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Locked
cycholka
Registered User
Posts: 3
Joined: Sat Sep 15, 2007 8:25 am

Re: [RC1] Dice MOD

Post by cycholka »

Nice mod. One highly annoying thing though, it fails (does not parse?) at utf language specific chars. Whenever one of those letters is included in message the tag result does not show.

Eg

This :

Code: Select all

Przyklad [dice]2d6[/dice]
will execute correctly

This :

Code: Select all

Przykład [dice]2d6[/dice]
won't show at all
Ragman
Registered User
Posts: 71
Joined: Wed Dec 08, 2004 7:06 pm

Re: [RC1] Dice MOD

Post by Ragman »

and the download link in the original post doesn't work.
coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [RC1] Dice MOD

Post by coppro »

first post wrote: You must copy-paste the URL, or else my provider will get angry at the referrer header and not work.
cycholka wrote:Nice mod. One highly annoying thing though, it fails (does not parse?) at utf language specific chars. Whenever one of those letters is included in message the tag result does not show.

Eg

This :

Code: Select all

Przyklad [dice]2d6[/dice]
will execute correctly

This :

Code: Select all

Przykład [dice]2d6[/dice]
won't show at all
I know what's causing the problem (that the regular expression parser can't detect the UTF8 characters), but I'd like to ask for an official answer to a that question.
cycholka
Registered User
Posts: 3
Joined: Sat Sep 15, 2007 8:25 am

Re: [RC1] Dice MOD

Post by cycholka »

Did some quick behavioral resarch. It seems that the mod fails only if the utf char is located in front of the tag. Chars inside the tag, or after it, don't seem to affect it. Out of following

Code: Select all

Przykład [dice]1d6[/dice]
won't execute but

Code: Select all

[dice=Przykład]1d6[/dice]
and

Code: Select all

[dice]1d6[/dice] Przykład 
will, so whatever's wrong must be wrong here :

Code: Select all

while (preg_match('#<!--READY-->\[dice(?:=(.+))?\]#U', $message, $matches, PREG_OFFSET_CAPTURE))
coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [RC1] Dice MOD

Post by coppro »

Actually, what's wrong is that the offsets calculated by the preg_match function to not take UTF8 into account. Thus, when I take the utf8_substr using the same offset, it gets calculated differently. Possible fixes include not using utf8-aware string functions (I don't think the mod would be affected) or counting the chars in UTF8 and using that offset instead. I've asked the MOD team about what they would prefer, but I haven't gotten a response yet.
cycholka
Registered User
Posts: 3
Joined: Sat Sep 15, 2007 8:25 am

Re: [RC1] Dice MOD

Post by cycholka »

You're right. It's enough to replace utf aware string functions from parse() in dice.php, everything works perfectly after that.
UbiquitousChe
Registered User
Posts: 4
Joined: Thu Oct 04, 2007 1:54 am

Re: [RC1] Dice MOD

Post by UbiquitousChe »

Hey guys,

I'm still very new with phpBB, and I'm guessing there's something really, really simple wrong.

I'm trying to install this mod, and certain lines that I'm supposed to be finding in one of the .php files aren't there. specifically, my ucp_pm_viewmessage.php is missing these lines:

Code: Select all

$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
There's probably a simple reason for this. I'm running phpBB3 RC5, if that means anything. Everything else was there.

Thoughts?
RedTrinity
Registered User
Posts: 1327
Joined: Sat May 06, 2006 3:32 am

Re: [RC1] Dice MOD

Post by RedTrinity »

Would love to see a working demo of this!
coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [RC1] Dice MOD

Post by coppro »

UbiquitousChe wrote:Hey guys,

I'm still very new with phpBB, and I'm guessing there's something really, really simple wrong.

I'm trying to install this mod, and certain lines that I'm supposed to be finding in one of the .php files aren't there. specifically, my ucp_pm_viewmessage.php is missing these lines:

Code: Select all

$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
There's probably a simple reason for this. I'm running phpBB3 RC5, if that means anything. Everything else was there.

Thoughts?
Probably because I haven't looked through since RC5 came out. It looks like those entire lines have been removed, though. There doesn't seem to be any loss of functionality,
UbiquitousChe
Registered User
Posts: 4
Joined: Thu Oct 04, 2007 1:54 am

Re: [RC1] Dice MOD

Post by UbiquitousChe »

That depends....

I installed the mod on my local test server, and tried out the sample code you gave us:

Code: Select all

[dice=Ability Scores]Str:4d6%1>6,Dex:4d6%1>6,Con:4d6%1>6,Int:4d6%1>6,Wis:4d6%1,Cha:4d6%1[/dice]
And I got the output:

Code: Select all

Rolling some dice:
   4d6 >6 dropping lowest 1: 13 (4, 3, 2, 6 drop 2)
   4d6 >6 dropping lowest 1: 15 (3, 1, 6, 6 drop 1)
   4d6 >6 dropping lowest 1: 8 (4, 2, 2, 1 drop 1)
   4d6 >6 dropping lowest 1: 8 (4, 2, 2, 2 drop 2)
   4d6 dropping lowest 1: 10 (2, 4, 4, 2 drop 2)
   4d6 dropping lowest 1: 12 (3, 3, 6, 3 drop 3)
Is that right? I was expecting 'Ability Scores', and the 'Str:', 'Dex:', etc labels to show up somewhere.... Is that just something that gets passed through to the rolls table?

Also, I've made a half hearted effort at breaking the mod, and no luck so far. Seems pretty robust without those code sections.

I'm just worried that something vital's been left out that could break the site I'm working on if someone puts in something really stupid for the input.
coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [RC1] Dice MOD

Post by coppro »

Putting

Code: Select all

[dice=Ability Scores]Str:4d6%1>6,Dex:4d6%1>6,Con:4d6%1>6,Int:4d6%1>6,Wis:4d6%1,Cha:4d6%1[/dice]
gives me the following result

Code: Select all

[dice=Ability Scores]Str 4d6 >6 dropping lowest 1:  6, 4, 3, 3 drop 3 >6 = 13
Dex 4d6 >6 dropping lowest 1:  5, 3, 6, 1 drop 1 >6 = 14
Con 4d6 >6 dropping lowest 1:  6, 2, 6, 3 drop 2 >6 = 15
Int 4d6 >6 dropping lowest 1:  5, 6, 6, 4 drop 4 >6 = 17
Wis 4d6 dropping lowest 1:  6, 1, 6, 2 drop 1 = 14
Cha 4d6 dropping lowest 1:  4, 3, 1, 1 drop 1 = 8[/dice]
Now, the bit with only the first four having ">6" is a mistake in the tag, but I definitely see it. Also, all that parsing is in the dice.php file, and so shouldn't matter depending on the distribution.

However, if you're using this with a template that doesn't have special templating, it seems that the names don't show up in the default template. If you want it, add the following text:

Code: Select all

<span style='text-decoration: underline'>{NAME}</span> 
(don't forget the trailing space) to the very beginning of the 'dice_roll' and 'dice_drop' values near line 250 of dice.php.

I highly recommend you add a dice.html file to your style, though, as the default templating is ugly and simplistic (and is only there in case a more style-specific form isn't available.)
UbiquitousChe
Registered User
Posts: 4
Joined: Thu Oct 04, 2007 1:54 am

Re: [RC1] Dice MOD

Post by UbiquitousChe »

Hey, thanks for the response. I'll bear that in mind, and have a proper play with the mod over the next few days.

Even without a pretty template, it's still and awesome mod. :D
UbiquitousChe
Registered User
Posts: 4
Joined: Thu Oct 04, 2007 1:54 am

Re: [RC1] Dice MOD

Post by UbiquitousChe »

Hey again. I put the mod over to a live site. After a few little syntax errors on my part, I seemed to have everything working.

Then someone who didn't understand the d20 system tried to input 4d2000000000%1>8.

I fixed it with a little bit of error checking code in the parse function that set the number of sides to 1 if it was outside a given range. I chose the range of 1 to 100 (inclusive). Not tricky to fix once you know what's wrong, but since that error broke the thread itself and it was impossible to check what the input was until after I'd fixed it, it would have been tricky to diagnose if I hadn't been lucky.
blueace1
Registered User
Posts: 9
Joined: Fri Oct 01, 2004 6:04 pm

Re: [RC1] Dice MOD

Post by blueace1 »

Hi,

Before to install this MOD, I would like to have some information about the "fraud" point of view.
I means, with the Dice MOD for phpBB2 it was very/too easy to "cheat".

1) if I put [dice]1d6[/dice] what will I see if I edit my post later ? only that or the result will be added (coded or not) (like [dice]1d6=76876876876[/dice]
This was an easy way to fraud in phpBB2, directly putting the result (even if coded) in the BBcode

2) if I write 1 BBCode, then edit my post, delete it and put another one identical, what will happen ?

3) If I write 10 BBCode, then I edit my post and delete the 9 worst, what will happen ?
coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [RC1] Dice MOD

Post by coppro »

blueace1 wrote:Hi,

Before to install this MOD, I would like to have some information about the "fraud" point of view.
I means, with the Dice MOD for phpBB2 it was very/too easy to "cheat".

1) if I put [dice]1d6[/dice] what will I see if I edit my post later ? only that or the result will be added (coded or not) (like [dice]1d6=76876876876[/dice]
This was an easy way to fraud in phpBB2, directly putting the result (even if coded) in the BBcode
You will only see the original dice tag ([dice]1d6[/dice]) in the post box; if you preview, the result will be randomly generated each time (even if you already have a result).
2) if I write 1 BBCode, then edit my post, delete it and put another one identical, what will happen ?

3) If I write 10 BBCode, then I edit my post and delete the 9 worst, what will happen ?
You will get the same result. The MOD stores the results based on the offset of the post; only deleting a post can remove the data (but then, if someone has e-mail notification, they may notice something suspicious).
Locked

Return to “[3.0.x] Abandoned MODs”