coin: wrap an if statement

This commit is contained in:
Přemysl Eric Janouch 2014-08-02 15:50:30 +02:00
parent 5bedd3918c
commit e8ddf5e58c

View File

@ -97,7 +97,11 @@ while {[gets stdin line] != -1} {
set input [string range $input [string length $prefix] end]
if {$input == "coin"} {
if {rand() < 0.5} { pmrespond "Heads." } else { pmrespond "Tails." }
if {rand() < 0.5} {
pmrespond "Heads."
} else {
pmrespond "Tails."
}
} elseif {[regexp {^dice( +|$)(.*)} $input -> _ args]} {
if {! [string is integer -strict $args] || $args <= 0} {
pmrespond "Invalid or missing number."