dice = [(print "What dice to throw? (type h for help or q to quit)\n"), gets.chomp.split("d")][1]
while dice != ["q"]
dice[0] = 1 if dice[0] == ""
if dice == ["h"]
print "Type ndm to toss m-sided dice n times, absence of n counts as n = 1.\nFor instance 2d6 means 2 throws of a 6-sided dice, d20 means 1 throw\nof a 20-sided dice etc.\n"
elsif dice == [] #to be able to press "Enter" without the annoying error message
dice = gets.chomp.split("d")
next
elsif dice.size != 2 or dice[0].to_i == 0 or dice[1].to_i == 0
print "Wrong command, baka! Type h for help.\n"
else #actual tossing
throw, dice = [], dice.map(&:to_i)
dice[0].times{throw += [rand(dice[1]) + 1]}
print throw, " sum ", throw.inject(:+), "\n"
end
dice = gets.chomp.split("d")