Teh soors:
Code: Select all
Randomize Timer()
dice$ = "1d20+3"
//dice$ = "1d20-5"
//dice$ = "4d8+10"
For i = 1 To 20
Print "Rolling "+dice+": "++RollDice(dice)
Next i
WaitKey
Function RollDice(die$)
If Left(die,1) = "d" Then die = "1" + die
Dim roll$(2)
roll(0) = GetWord(die,1,"d")
roll(1) = GetWord(die,2,"d")
ppos = InStr(roll(1),"+")
mpos = InStr(roll(1),"-")
'bonus%, total%
If ppos > 0
bonus = Int(Mid(roll(1), ppos+1, Len(roll(1))-ppos))
roll(1) = Left(roll(1), ppos-1)
ElseIf mpos > 0
bonus = Int(Mid(roll(1), mpos, Len(roll(1))-mpos+1))
roll(1) = Left(roll(1), mpos-1)
EndIf
For i = 1 To Int(roll(0))
total=total+ Rand(Int(roll(1)))
Next i
Return total + bonus
End Function