Page 6 of 12

Re: [RC1] Dice MOD

Posted: Sat Sep 22, 2007 9:06 am
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

Re: [RC1] Dice MOD

Posted: Sat Sep 22, 2007 4:53 pm
by Ragman
and the download link in the original post doesn't work.

Re: [RC1] Dice MOD

Posted: Sat Sep 22, 2007 11:56 pm
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.

Re: [RC1] Dice MOD

Posted: Sun Sep 23, 2007 6:39 am
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))

Re: [RC1] Dice MOD

Posted: Thu Sep 27, 2007 1:02 am
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.

Re: [RC1] Dice MOD

Posted: Wed Oct 03, 2007 6:36 am
by cycholka
You're right. It's enough to replace utf aware string functions from parse() in dice.php, everything works perfectly after that.

Re: [RC1] Dice MOD

Posted: Thu Oct 04, 2007 2:22 am
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?

Re: [RC1] Dice MOD

Posted: Thu Oct 04, 2007 3:48 am
by RedTrinity
Would love to see a working demo of this!

Re: [RC1] Dice MOD

Posted: Fri Oct 05, 2007 1:43 am
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,

Re: [RC1] Dice MOD

Posted: Fri Oct 05, 2007 4:45 am
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.

Re: [RC1] Dice MOD

Posted: Sat Oct 06, 2007 3:53 am
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.)

Re: [RC1] Dice MOD

Posted: Sun Oct 07, 2007 9:43 am
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

Re: [RC1] Dice MOD

Posted: Mon Oct 15, 2007 8:14 am
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.

Re: [RC1] Dice MOD

Posted: Fri Oct 19, 2007 6:06 pm
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 ?

Re: [RC1] Dice MOD

Posted: Fri Oct 19, 2007 11:29 pm
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).