All pastes #241036 Raw Edit

Mine

public text v1 · immutable
·published 2006-11-06 00:07 UTC
rendered paste body
on *:text:!startgame:%chans: {
  if (%game) {
    /notice $nick A game is already in progress. To find the progress made, please type !progress
    halt
  }
  /set %game on
  /set %num $numtok(%words,46)
  /set %word $rand(0,%num)
  /set %word $gettok(%words,%word,46)
  /set %numlet $len(%word)
  /set %num 1
  /set %totguess $round($calc($len(%word) * 1.4),0)
  :a
  if (%num > %numlet) { goto next | halt }
  else { 
    /set %figured %figured _ 
    /inc %num
    goto a
    halt
  }
  :next
  /set %numguess 0
  /msg # The word is %figured
  /msg $chan You have used %numguess out of %totguess guesses.
  /msg # To guess, type !guess LETTER
  /breakapart %word
}

on *:text:!guess *:%chans: {
  if (%game) {
    if ($len($2) > 1) { /notice $nick Please guess only 1 character | halt }
    if ($istok(%guessed,$2,46)) { /notice $nick $2 has already been guessed | halt }
    if (%numguess >= %totguess) { /notice $nick Please solve the word! | halt }   
    /inc %numguess
    /set %guessed $addtok(%guessed,$2,46)
    if ($istok(%bword,$2,46) == $true) {       
      /set %a 1
      while ($findtok(%bword,$2,0,46) >= %a) {
        /set %loco $findtok(%bword,$2,%a,46)
        /set %figured $puttok(%figured,$2,%loco,32)
        /inc %a

      }
      /msg $chan %figured
    }
    else {
      /msg $chan $2 is not in the word. There have been %numguess out of the %totguess you get. | halt
    }
  }
  if (%numguess >= %totguess) {
    /msg $chan You have used all %totguess guesses. To win, please type !solve <word you think it is>
  }
  else {
    /msg $chan You have used %numguess out of %totguess guesses. Eigther solve the word, or guess again
    else {
      /notice $nick No game in progress. Please type !startgame
    }
  }
}
alias endgame {
  /unset %game
  /unset %loco
  /unset %figured
  /unset %word
  /unset %bword
  /unset %guessed
  /unset %numguess
  /unset %totguess

}
on *:text:!solve *:%chans: {
  if (%game) {
    /inc %numguess 1
    if ($2 == %word) {
      /msg $chan Yes! %word was the correct answer! To start another game, type !startgame
      /endgame
    }
    else {
      if (%numguess > %totguess) {
        /msg $chan You unsucessfully guessed the word in 10 tries. The word was %word $+ . To start another game, type !startgame
        /endgame
      }
      else {
        /msg $chan Nope, $2 is not the word. Keep guessing letters, or try to solve again. You have only used %numguess guesses.
      }
    } 
  }
  else {
    /notice $nick Sorry, no game in progress! Type !startgame
  }
}

on *:text:!progress:%chans: {
  if (%game) {
    /msg $chan So far, with %numguess out of %totguess guesses, you have gotten %figured
  }
  else {
    /notice $nick Sorry, no game in progress. Please type !stargame
  }
}

alias breakapart {
  var %idx = 0, %new
  while (%idx < $len($1)) {
    inc %idx
    if (%new) {
      %new = %new $+ . $+ $mid($1,%idx,1)
    }
    else {
      /set %new $mid($1,%idx,1)
    }
  }
  /set %bword %new
  /unset %new
}

on *:text:!commands:%chans: {
  /notice $nick Commands: !startgame   !progress   !solve <word>   !guess <letter>
  /notice $nick Word will be non-case sensitive. Only letters will be in the word. There MAY BE a space in the word, which is denoted by a / (you may type !guess /)
}
alias addhangword {
  if ($istok(%words,$1,46)) {
    /echo -a $1 is already in the words
    halt
  }
  /set %words $addtok(%words,$1,46)
  /echo -a $1 has been added
}
alias delhangword {
  if ($istok(%words,$1,46)) {
    /set %words $remtok(%words,$1,1,46)
    /echo -a $1 has been deleted
    halt
  }
  /echo -a $1 is not in your word list
}
alias addchan {
  if ($chr(35) !isin $1) { /echo -a Please enter a valid channel | halt }  
  if ($istok(%chans,$1,44)) {
    /echo -a $1 is already in the channels
    halt
  }
  /set %chans $addtok(%chans,$1,44)
  /echo -a $1 has been added to the channels list. List of channels: %chans
}
alias delchan {
  if ($istok(%chans,$1,44)) {
    /set %chans $remtok(%chans,$1,1,44)
    /echo -a $1 has been deleted. List of working channels: %chans
    halt
  }
  /echo -a $1 is not in your channel list.
}
menu channel {
  .Hangman
  .Add word:/addhangword $?="What word do you want to add?"
  .Delete word: /delhangword $?="What word do you want to delete?"
  .View words: /set %w $replace(%words,.,$chr(44) $chr(32)) | echo -a Your words are %w | /unset %w
  .Add channel: /addchan $?="What channel do you want to add?"
  .Delete channel: /delchan $?="What channel do you want to delete?"
  .View channels: /echo -a List of channels: %chans
}