Snakes & Ladders

By RusselB on Sep 22, 2005

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)
  }
}

Comments

Sign in to comment.
criminal   -  Mar 08, 2008

Can you change it pls? :\ if someone parts the channel it still says he is in the game so ... :\
and !endgame or something
cause it\'s al long game ^-^ they might get bored and stop.

BUT! it\'s very nice! keep it up

 Respond  
Zachery   -  Sep 28, 2005

(20:56) M|574k3n watches Zach roll a 3 and a 3
(20:56)
M|574k3n asks Zach What is 1 + 3 + 3 ?
(20:56) 7
hmmz?

 Respond  
RusselB   -  Sep 26, 2005

There should always be 3 numbers that need to be added together. Your current position, the value of the first die, and the value of the second die.

 Respond  
Zachery   -  Sep 25, 2005

it doesn\'t work when it asks me what is 5 + 6
i say 11
nothuing

 Respond  
RusselB   -  Sep 24, 2005

I\'msure I could figure out something. I\'ll work on it and probably post an update within 24 hours.

 Respond  
Zachery   -  Sep 23, 2005

very good :D hmm is there a way 4 it to be stored in an ini file since all pplz on my chan are +v

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.