Simple Snakes & Ladder game.
!play to start the game
!roll to roll the dice
!players to get a list of players
Designed to run on a bot in a channel
Currently set up so that the person that types !roll has to calculate their new position based upon their current position and the roll of the dice.
Modified to allow for play in multiple channels and/or over multiple networks. The players are no longer voiced, when they type play, but are added to a variable containing the players names.
Please note that if there are a lot of players in a single room, keeping track of the players in this method could generate a line too long error.
Edited Sept 26 to correct some variables and missing brackets. Has been tested with 4 players per room, and 2 rooms per network, over 2 networks.
Code edited to correct a small error which caused some of the working variables to not be unset at the end of the game.
on @*:text:!play:#:{
set $+(%,players.,$network,.,$chan) $addtok($($+(%,players.,$network,.,$chan),2),$nick,32)
set $+(%,position.,$network,.,$chan,.,$nick) 1
}
on *:text:!players:#:{
describe # Current players are $sorttok($($+(%,players.,$network,.,$chan),2),32)
}
on *:text:!roll:#:{
if ($($+(%,nick.,$network,.,$chan),2)) { .msg $nick Please wait for $($+(%,players.,$network,.,$chan),2) to answer their question }
else {
set $+(%,head,.,$network,.,$chan) $r($calc($($+(%,position.,$network,.,$chan,.,$nick),2) + 1),100)
set $+(%,tail,.,$network,.,$chan) $iif($r(0,1),$r($calc($($+(%,position.,$network,.,$chan,.,$nick),2) - 1),1),$r($calc($($+(%,position.,$network,.,$chan,.,$nick),2) + 2),100))
set $+(%,d1,.,$network,.,$chan) $r(1,6)
set $+(%,d2,.,$network,.,$chan) $r(1,6)
describe # watches $nick roll a $($+(%,d1,.,$network,.,$chan),2) and a $($+(%,d2,.,$network,.,$chan),2)
set $+(%,nick.,$network,.,$chan) $nick
answer $network $chan $nick
}
}
alias answer {
describe $2 asks $3 What is $($+(%,position.,$1,.,$2,.,$3),2) + $($+(%,d1,.,$1,.,$2),2) + $($+(%,d2,.,$1,.,$2),2) ?
}
on *:text:*:#:{
if ($nick == $($+(%,nick.,$network,.,$chan),2)) && $istok($($+(%,players.,$network,.,$chan),2),$nick,32) && ($1 == $calc($($+(%,position.,$network,.,$chan,.,$nick),2) + $($+(%,d1,.,$network,.,$chan),2) + $($+(%,d2,.,$network,.,$chan),2))) {
unset $+(%,nick.,$network,.,$chan)
set $+(%,position.,$network,.,$chan,.,$nick) $1
if ($($+(%,position.,$network,.,$chan,.,$nick),2) == $($+(%,head,.,$network,.,$chan),2)) {
describe # watches $nick $iif($($+(%,head,.,$network,.,$chan),2) > $($+(%,tail,.,$network,.,$chan),2),slide down the snake,climbs up the ladder) from $($+(%,position.,$network,.,$chan,.,$nick),2) to $($+(%,tail,.,$network,.,$chan),2)
set $+(%,position.,$network,.,$chan,.,$nick) $($+(%,tail,.,$network,.,$chan),2)
}
if ($($+(%,position.,$network,.,$chan,.,$nick),2) >= 100) {
.msg # $nick has won
unset $+(%,*,.,$network,.,$chan,*)
}
else {
describe # watches $nick move up to position $($+(%,position.,$network,.,$chan,.,$nick),2)
}
}
elseif ($nick == $($+(%,nick.,$network,.,$chan),2)) && ($istok($($+(%,players.,$network,.,$chan),2),$nick,32)) {
.msg $chan Sorry $nick $+ , but that is incorrect. You stay at $($+(%,position.,$network,.,$chan,.,$nick),2)
unset $+(%,nick.,$network,.,$chan)
}
}