~chiefnoah/spellbook

0d4564bde920cfa14fcaa8a50ceeabc9d308dbc3 — Noah Pederson 1 year, 3 months ago b5c09a2
Fixes bugs, adds test
1 files changed, 18 insertions(+), 2 deletions(-)

M magic.fs
M magic.fs => magic.fs +18 -2
@@ 86,11 86,27 @@ end-struct mage-struct
: with-dedicated-tool ( w -- w ) 2 - ;
\ Death Spells

: roll-dice ( -- w ) 10 random 1+ ;

: 10-again ( w -- w ) 10 = if 1 else 0 then ;

: 9-again ( w -- w ) 9 >= if  1 else 0 then ;

: 8-again ( w -- w ) 8 >= if  1 else 0 then ;

\G Rolls n dice, calculating successes (8+) and re-rolling 10s
: roll-10again ( n -- w ) 0 do random ;
: roll-10again ( n -- w )
    0
    begin
        roll-dice ( #dice successes roll ) ." roll: " dup . cr
        \ reuse 8-again to check for successes, as it's the same check
        dup 8-again ( #dice successes roll success? )
        rot + swap ( #dice successes roll )
        10-again rot + ( successes #dice )
        1- dup -rot 0=
    until swap drop ;

\G Decay: age an object, lowering durability
\G +1 Reach: Decrease structure instead
\G Source: MtAw2 p129
death-arcanum 2 spell deckkay
death-arcanum 2 spell decay