7
7
*/
8
8
class EZDice {
9
9
// Magic dice & modifier matching regex
10
- private const REGEX_DICE = '/(?<operator>[\+-]?)\s*(?:(?:(?<number>\d+)*[dD](?<type>(?:\d+|[%fF]))(?:-(?<drop>[LlHh])(?<dquantity >\d+)?)?)|(?<mod>[0-9]\d*))/ ' ;
10
+ private const REGEX_DICE = '/(?<operator>[\+-]?)\s*(?:(?:(?<number>\d+)*[dD](?<type>(?:\d+|[%fF]))(?:-(?<drop>[LlHh])(?<dropAmount >\d+)?)?)|(?<mod>[0-9]\d*))/ ' ;
11
11
private const REGEX_DICE_SINGLE = '/(?<number>\d+)*[dD](?<type>(?:[1-9]\d*|[%fF]))/ ' ;
12
12
13
13
// Stores information on last roll
@@ -209,7 +209,7 @@ private function countAndValidateDiceGroups(string $diceStr): int|false
209
209
210
210
private function processGroup (array $ group ): void
211
211
{
212
- // Scaler makes the output postive or negative
212
+ // Scaler makes the output positive or negative
213
213
$ isNegative = ($ group ['operator ' ] == '- ' );
214
214
$ scaler = ($ isNegative ? -1 : 1 );
215
215
@@ -261,7 +261,7 @@ private function processGroup(array $group): void
261
261
} else { // Dropping high, so sort ascending
262
262
sort ($ results , SORT_NUMERIC );
263
263
}
264
- $ dropQuantity = min ($ group ['dquantity ' ] ?? 1 , $ number );
264
+ $ dropQuantity = min ($ group ['dropAmount ' ] ?? 1 , $ number );
265
265
for ($ i =0 ; $ i < $ dropQuantity ; $ i ++) {
266
266
$ droppedResult = array_pop ($ results );
267
267
$ this ->addState ($ type , $ droppedResult , $ isNegative , true );
@@ -287,7 +287,7 @@ private function resetResultValues(): void
287
287
}
288
288
289
289
/**
290
- * Generates the psudo -random number for dice rolls.
290
+ * Generates the pseudo -random number for dice rolls.
291
291
*
292
292
* @param int $max the highest number on the dice. Roll is 1 - $max (inclusive).
293
293
*
0 commit comments