Rolisteam / DiceParser

Powerful dice Roller is used as discord bot, irc bot, cli tool and inside Rolisteam : 1d20+4, 1L[head,arm,leg,belly,chest], 1d6+1d8, 8+5*3
http://www.rolisteam.org/
GNU General Public License v3.0
125 stars 31 forks source link

For loop? #46

Closed lekyryu closed 5 years ago

lekyryu commented 5 years ago

Is there a way to do a for loop?

20th anniversary WoD rules have 10s on specialties counting as 2 successes and 1s taking the whole dice away.

I.e. a 4d10 that throws 1,1,10,10

Should be 0 successes as the ones cancel the tens even if they have specialties.

What I tried doing was a for roll that for each one it would take one successful result starting from the lowest number to the highest

obiwankennedy commented 5 years ago

You can easily manage this 20th anniversary WoD but you need another approach. I write down in multi line format with comment for better understanding.

4d10; # roll dice $1c10; # count 10s $1c1; # count 1s $1c[>=6&<10]; # count success but does not count 10s $2-$3; # substract the 1s count to 10s count $5i:[>0]{$5}{0}; # useful if 1s take away only 10s $6+$6+$4; # sum twice the 10s rest and the successes count. $7i:[>0]{"$7 Successes [%2]"}{"You fail [%2]"} # display

so now in one line:

!4d10;$1c10;$1c1;$1c[>=6&<10];$2-$3;$5i:[>0]{$5}{0};$6+$6+$4;$7i:[>0]{"$7 Successes [%2]"}{"You fail [%2]"}

then you may want to make macro:

!macro ([0-9]+)w([0-9]+) \1d10;$1c10;$1c1;$1c[>=\2&<10];$2-$3;$5i:[>0]{$5}{0};$6+$6+$4;$7i:[>0]{"$7 Successes [%2]"}{"You fail [%2]"} 1

To call it: !4w6 First parameter is the number of dice, the second is the difficulty.

lekyryu commented 5 years ago

I think it isn't activating the $-2-$3 part as it's not taking away successes with ones

Iker LarreaToday at 6:44 AM !4d10;$1c10;$1c1;$1c[>=6&<10];$2-$3;$5i:[>0]{$5}{0};$6+$6+$4;$7i:[>0]{"$7 Successes [%2]"}{"You fail [%2]"} TroileBOTToday at 6:44 AM 2 Successes [9,5,1,9]

Edit: Further testing lands me this as well !4d10;$1c10;$1c1;$1c[>=6&<10];$2-$3;$5i:[>0]{$5}{0};$6+$6+$4;$7i:[>0]{"$7 Successes [%2]"}{"You fail [%2]"} DiceParserBOTToday at 10:05 AM

1 Successes [7,1,10,1]

Where it calculated 3 successes (one for the 7 and two for the 10), removed two for each 1, when it should have showed 0 successes by removing both the 7 and 10 before counting the 10 for two.

Edit 2: I've been working on this some more but it seems the real issue is that you can't activate an IF on a $X besides $1. Every other number it causes the command to be ignored. Also there doesn't seem to exist an & or AND command

Edit 3: I'm in a rabbit hole now. The IFs statement do work on $X and the & command does exist. What doesn't seem to work is an if statement that compares two previous results. IE $3i:[>0&$4>0]

obiwankennedy commented 5 years ago

yes, if only compare value in front of him.

I did not try my examples, I just make them as i would do it. But your second example, is normal because I was not sure 1s remove only 10s or 10s first and then normal successes. I have to fix the command to manage that. Are there any other rules I should know about ?

obiwankennedy commented 5 years ago

!4d10;$1c10;$1c1;$1c[>=6&<10];$2-$3;$5i:[>0]{$5}{0};$6+$6+$4;$7i:[>0]{"$7 Successes [%2][$1,$2,$3,$4,$5,$6,$7]"}{"You fail [%2][$1,$2,$3,$4,$5,$6,$7]"}

1 Successes [5,3,8,3][19,0,0,1,0,0,1

This example is correct, right ?

obiwankennedy commented 5 years ago

2 Successes [8,5,1,8][22,0,1,2,-1,0,2]

This example is wrong given your rules. Let's fix it.

obiwankennedy commented 5 years ago

!4d10;$1c10;$1c1;$1c[>=6&<10];$2-$3;$5i:[>0]{$5+$5}{$5};$6+$4;$7i:[>0]{"$7 Successes [%2][$1,$2,$3,$4,$5,$6,$7]"}{"You fail [%2]"}

(I fixed the command)

1 Successes [1,8,10,3] -- Inner result [22,1,1,1,0,0,1]

it seems correct to me.

4 Successes [5,8,7,10] -- Inner result [30,1,0,2,1,2,4]

Right ?