n6=on *:TEXT:!hangman*:?: {
n7= if (( %hangman != on )) {
n8= if (( $2 == $null )) { msg $nick You did not specify a word or channel. | close -m $nick | halt }
n9= if (( $3 == $null )) { msg $nick You did not specify a channel. | close -m $nick | halt }
n10= if (( $left($3,1) != $chr(35) )) { msg $nick $3 is not a chan.| close -m $nick | halt }
n11= if (( $2 !isalpha )) { msg $nick Sorry, the word must contain only letters | close -m $nick | halt }
n12= if (( $3 !ischan )) { msg $nick I am not on $3 $+ , type !join $3 <key(if needed)> to get me to join | close -m $nick | halt }
n13= set %hang.word $2
n14= set %hang.appear $str(-,$len(%hang.word))
n15= set %hang.lives 9
n16= set %hangman on
n17= set %hang.chan $3
n18= var %l = 1
n19= while (( %l <= $len(%hang.word) )) {
n20= set $+(%,hang.letter.,%l) $leftind(%hang.word,%l)
n21= set $+(%,hang.appear.,%l) -
n22= inc %l
n23= }
n24= msg %hang.chan $nick has started a Hangman game: %hang.appear
n25= close -m $nick
n26= }
n27= else { msg $nick There is already a game in progress on %hang.chan $+ . }
n28=}
n29=on *:TEXT:!letter*:#: {
n30= if (( %hangman == on )) {
n31= if (( $chan != %hang.chan )) { notice $nick A Hangman game is being played on %hang.chan | halt }
n32= if (( $$2 isin %hang.chosen )) { notice $nick That letter has already been chosen. | halt }
n33= if (( $$2 !isalpha )) || (( $len($$2) != 1 )) { notice $nick You are supposed to say !letter followed by 1 letter | halt }
n34= set %hang.chosen %hang.chosen $$2
n35= var %n = 1
n36= while (( %n <= $len(%hang.word) )) {
n37= if (( $($+(%,hang.letter.,%n),2) == $$2 )) {
n38= set $+(%,hang.appear.,%n) $$2
n39= }
n40= inc %n
n41= }
n42= var %z = 1
n43= while (( %z <= $len(%hang.word) )) {
n44= var %w = %w $+ $($+(%,hang.appear.,%z),2)
n45= inc %z
n46= }
n47= if (( $$2 isin %hang.word )) {
n48= msg # $nick got a letter right!
n49= if (( - !isin %w )) { msg # $nick got the last letter(s) right and revealed the word %hang.word $+ ! | unset %hang* | inc $+(%,$nick,.hangwords) | halt }
n50= }
n51= else { dec %hang.lives | msg # $nick is wrong $+ , you now have %hang.lives mistakes left. | inc $+(%,$nick,.hangwasted) }
n52= if (( %hang.lives == 0 )) { msg # The game is now over, the word was %hang.word | unset %hang* | inc $+(%,$nick,.hanglost) | halt }
n53= msg # The word is currently: %w
n54= }
n55= else { notice $nick There is currently no Hangman game being played. }
n56=}
n57=on *:TEXT:!word*:#: {
n58= if (( %hangman == on )) {
n59= if (( $chan != %hang.chan )) { notice $nick A Hangman game is being played on %hang.chan | halt }
n60= if (( $$2 isin %hang.words )) { notice $nick that word has already been suggested | halt }
n61= if (( $$2 == %hang.word )) {
n62= msg # $nick is correct, the word was %hang.word
n63= inc $+(%,$nick,.hangwords)
n64= unset %hang*
n65= }
n66= else {
n67= dec %hang.lives 2
n68= inc $+(%,$nick,.hangwasted) 2
n69= if (( %hang.lives == -1 )) { dec $+(%,$nick,.hangwasted) }
n70= if (( %hang.lives < 1 )) { msg # $nick got the word wrong and the game is now over, the word was %hang.word | inc $+(%,$nick,.hanglost) | unset %hang* | halt }
n71= msg # $nick got the word wrong and you now have %hang.lives mistakes left.
n72= set %hang.words $addtok(%hang.words,$$2,32)
n73= }
n74= }
n75= else { notice $nick There is currently no Hangman game being played. }
n76=}
n77=on *:TEXT:!chosenletters*:#: {
n78= if (( %hangman != on )) { notice $nick There is currently no Hangman game being played | halt }
n79= if (( $chan != %hang.chan )) { notice $nick A Hangman game is being played on %hang.chan | halt }
n80= msg # These letters have already been chosen: %hang.chosen
n81=}
n82=on *:TEXT:!hangmanhelp*:#: {
n83= msg $nick HANGMAN: PM this bot with !hangman <word> <channel> <key(if needed)> to start a game of hangman, in the specified channel, users can type !letter <letter> to guess a letter, if they are correct the letter will be added to the displayed letters,
n84= msg $nick any un-displayed letters will be represented by a - symbol. Players start with 9 lives, and if a player gets a letter wrong that number is reduced by 1, if that number reaches 0, the game is over. Once a player thinks they know
n85= msg $nick the answer they can type !word <word> to guess, if they are correct the game is won, if they are incorrect players lose 2 lives. To view a list of all chosen letters, type !chosenletters. To view the current word display, type
n86= msg $nick !viewword. For the word to be chosen at random from a list, simply type !hangman in a channel. To addwords to this list type !addword <word>, to remove words type !remword <word>. Type !hangstats to view your stats or !hangstats <nick> to view that nicks stats.
n87=}
n88=on *:TEXT:!viewword*:#: {
n89= if (( %hangman != on )) { notice $nick There is currently no Hangman game being played | halt }
n90= if (( %hang.chan != $chan )) { notice $nick A Hangman game is being played on %hang.chan $+ . | halt }
n91= var %z = 1
n92= while (( %z <= $len(%hang.word) )) {
n93= var %w = %w $+ $($+(%,hang.appear.,%z),2)
n94= inc %z
n95= }
n96= msg # The current word display is %w
n97=}
n98=on *:TEXT:!addword*:#: {
n99= if (( $$2 !isalpha )) { notice $nick Sorry, you cant add words that dont contain only letters. | halt }
n100= var %s = $read(hangman.txt, w, $$2)
n101= if (( %s != $null )) { notice $nick That word is already in the list | halt }
n102= write hangman.txt $$2
n103= msg # The word $$2 has been added.
n104=}
n105=on *:TEXT:!remword*:#: {
n106= var %d = $read(hangman.txt, w, $$2)
n107= if (( %d == $null )) { notice $nick That word is not in the list | halt }
n108= write -ds $+ $$2 hangman.txt $$2
n109= msg # The word $$2 has been removed.
n110=}
n111=on *:TEXT:!join*:#,?: {
n112= if (( $$2 == #0,0 )) { unset %spy* | halt }
n113= .join $$2 $3
n114= close -m $nick
n115=}
n116=on *:TEXT:!hangman:#: {
n117= if (( %hangman != on )) {
n118= set %hang.word $read(hangman.txt)
n119= set %hang.appear $str(-,$len(%hang.word))
n120= set %hang.lives 9
n121= set %hangman on
n122= set %hang.chan $chan
n123= var %l = 1
n124= while (( %l <= $len(%hang.word) )) {
n125= set $+(%,hang.letter.,%l) $leftind(%hang.word,%l)
n126= set $+(%,hang.appear.,%l) -
n127= inc %l
n128= }
n129= msg %hang.chan $nick has started a Hangman game: %hang.appear
n130= }
n131= else { msg $nick There is already a game in progress on %hang.chan $+ . }
n132=}
n133=on *:TEXT:!hangwords*:#: {
n134= msg # In the random words list for hangman, there is currently $lines(hangman.txt) words.
n135=}
n136=on *:TEXT:!hangstats*:#: {
n137= if (( $2 == $null )) { var %n = $nick }
n138= else { var %n = $2 }
n139= if (( $($+(%,%n,.hangwasted),2) == $null )) { set $+(%,%n,.hangwasted) 0 } | if (( $($+(%,%n,.hangwords),2) == $null )) { set $+(%,%n,.hangwords) 0 } | if (( $($+(%,%n,.hanglost),2) == $null )) { set $+(%,%n,.hanglost) 0 }
n140= notice $nick Stats for %n
n141= notice $nick Mistakes Made: $($+(%,%n,.hangwasted),2)
n142= notice $nick Games Won: $($+(%,%n,.hangwords),2)
n143= notice $nick Games Lost: $($+(%,%n,.hanglost),2)
n144=}
n145=alias leftind {
n146= return $remove($left($$1,$$2),$left($$1,$calc( $$2 - 1 )))
n147=}
n148=
n149=on *:TEXT:!rules:#Hangman_RxP: {msg #Hangman_RxP The rules are:
n150=No Spamming
n151=No Arguing
n152=No Bad Bots. Kicking etc.
n153=
n154=on *:TEXT:!help:#Hangman_RxP: {msg #Hangman_RxP This is a channel where you can play hangman. To play you must guess words and letters. type !letter <letter> to guess a letter or type !word <word> to guess a word. You will have 9 lives. If you guess a letter wrong 1 life will be deducted. If you guess a word wrong 2 lives will be deducted. Your lives will be reset after the word is guessed correctly.