hanelyp / fancydice

dice extension for phpbb3.1
6 stars 7 forks source link

string only dice #4

Open Jym77 opened 8 years ago

Jym77 commented 8 years ago

OK, not really an issue (I think) but rather an usage question… I try to roll a die whose "values" are strings (mostly to concatenate them into image paths, as done in the smilies example). If I try to use directly [dice]["foo","bar"][/dice](or any variant I could think off), then I have no result. If I define a die spec to be foolist => ["foo","bar"] I can now roll [dice]foolist[/dice] and it works as expected.

In my use case, the list will be changing over time (elements are removed after being drawn), thus I cannot use a spec for the whole list and I have to use a custom list at each roll. What is the correct syntax to get [dice]["foo","bar"][/dice] working?

Note that [dice]"foo"[/dice] does not produce any result either.

hanelyp commented 8 years ago

Trying to do something like dealing cards from a deck? The code isn't really designed to support that, though, with difficulty, you might do something with a generator for each deck state.

[dice]["foo","bar"][/dice] should be correct syntax. ... presuming the braces break the bbcode parsing. But I'm not getting expected results on preview. And submit exposes a previously unknown crash bug in my test install. [dice]"foo"[/dice] is valid syntax, and produces expected results on preview, but also exposes the crash bug on post submit.

Looks like I have some debugging ahead of me.

Jym77 commented 8 years ago

Yes, I am trying to draw cards from a deck, inspired by what they do here : https://boardgamegeek.com/thread/1339436/random-supply-deck (and for the excact same use-case but I am not sure I can reuse their code and a search for dice roller for phpBB lead me here) A generator for each deck stack is not a feasible solution, with 10 cards in the deck, there are a thousand different deck state… No way I'll code this…

Interestingly, in my case, [dice]"foo"[/dice] does not give any result. (fresh install of phpBB 3.1.9 from last week with only your extension installed so far, I don't have control of the webserver it's running on, but it seem to be running PHP 5.6.23 built on Jul 26 2016 (I have a bunch more info on the PHP version if you want it).

So far, my idea to circumvent the problem is to rename my images of cards "card1", "card2", … and then I can use [dice]card[1,2,6,7][/dice] for a particular state of the deck (this is basically what I've already done for rolling custom dice and including images named "red1", "red2", … So I know this works). This is, however, a bit less convenient to use because once an item is removed from the deck I have to remember that "bar" is actually "card6" and prepare the next draw as [dice]card[1,2,7][/dice] while it is a bit more manageable if after drawing "bar" I just have to remove "bar" from the list…