A simple number guess game using a randomly generated number.
To start: !num
To guess: !num guess
Also keeps track of the number of correct guesses each person has made
Added Apr. 29, 2005:
!max number --- Sets the maximum number and auto-configures the minium number
!min number --- Sets the minimum number and auto-configures the maximum number
Either or both can be used
Also modified the start part of the code per suggestion by xDaeMoN
Modified Sept. 25, 2005 to prevent someone from setting new high/low amounts while a game is in progress
on *:text:!max &:*:{
if (!%num) {
set %high $2
set %low $iif($int($calc($2/2)) < %low,$v1,$v2)
}
else .msg $nick Game in progress
}
on *:text:!min &:*:{
if (!%num) {
set %low $2
set %high $iif($calc($2 * 2) > %high,$v1,$v2)
}
else .msg $nick Game in progress
}
on *:TEXT:!num*:#:{
if (!$2) && (%num) {
.msg $nick Number Guess Game is Active
.msg $nick To enter a guess use !num <your guess>
}
elseif (!$2) {
set %num on
set %low $iif(!%low,$r(1,$calc($ctime / 2)),%low)
set %high $iif(!%high,$r($calc(%low + 1),$ctime),%high)
var %avg = $r(%low,%high)
describe # The mystery number is between 4 %low and 4 %high
}
elseif $2 == %avg {
describe # congratulates 4 $nick for guessing the mystery number in 5 $duration($calc($ctime - %start)))
inc %num.correct. $+ $nick
describe # You have now correctly guessed %num.correct. $+ $nick mystery numbers correctly
unset %high
unset %low
unset %num
}
else {
if ($2 >= %low) && ($2 <= %high) { $iif(%avg < $2, %low = $2, %high = $2) }
describe # The mystery number is between 4 %low and 4 %high
}
}