#!/usr/bin/perl -w use strict; my @sample=("3D6+","3D6","3D6+4","3D6+4x1000"); ##############################THE BIG, THE ONE my $rexp='^([1-9][0-9]*)[Dd]([1-9][0-9]*)(\+([1-9][0-9]*)(x([1-9][0-9] +*))?)?$'; my ($dtime,$dface,$foo,$addfact,$bar,$mulfact); foreach (@sample) { if (/$rexp/) { map{$_=0 if !defined($_)}($dtime,$dface,$foo,$addfact,$bar)=($ +1,$2,$3,$4,$5); $mulfact=(!defined($6))?1:$6; print "$_ is $dtime dices with $dface faces plus $addfact all +mult by $mulfact\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: D20 dice throw parser
by thor (Priest) on Dec 17, 2004 at 13:53 UTC | |
by Luca Benini (Scribe) on Dec 17, 2004 at 14:20 UTC | |
by thor (Priest) on Dec 17, 2004 at 15:47 UTC | |
by jryan (Vicar) on Dec 17, 2004 at 19:27 UTC | |
by jryan (Vicar) on Dec 17, 2004 at 19:03 UTC | |
by thor (Priest) on Dec 17, 2004 at 19:11 UTC |