About This File
####################################################################### ## StairAndSlides.tcl 1.0 (24/12/2020) ## ## ## ## Copyright 2008 - 2020 @ WwW.TCLScripts.NET ## ### ## ## / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ## ## ( T | C | L | S | C | R | I | P | T | S | . | N | E | T ) ## ## \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ ## ## ## ## [] ## ## [100] WINNER ## ## [] ## ## _____________ [] _____________ ____ ## ## ____________) [] (___________ / . .\ ## ## oo ! ! ! [] ' ! ! ! \ ---< ## ## .`\_/\_/\__ . . . [] ,! ! ! ! ! \ / ## ## ! ! ! [] ! ! snake _________/ / ## ## !___!_____!___[]_____'!_!__ -=:___________/ ## ## []__,_!_!_! ## ## []_!__!_!| ## ## ,[]_!__!_! ## ## ,! []_!__!| ## ## ,! ! []_!__! ## ## ! ! ! []_!| ## ## !! ! !|[]_| ## ## !!!._|_[] ## ## !!!|!_.[] ## ## !|!_!__[]!. ## ## !_!_!__[]! !. ## ## !_!_!__[]! ! `. ## ## |!_!__|]! ! ! `. ## ## |_!__|]! ! ! ! `. ## ## |____|_! ! ! ! ` ## ## |____|_! ! ! ! ## ## []____|_! ! ! ## ## []______|_! ! ## ## []________|_! [] ## ## ___start__________[]__________|____________[]______ ## ## ## ## ® BLaCkShaDoW Production ® ## ## ## ## PRESENTS ## ## ® ## #################### STAIRS AND SLIDES TCL ########################## ## ## ## DESCRIPTION: ## ## Who's fast and who's not? Roll the dice and avoid the snakes! ## ## ## ## The goal is to reach 100 points first. ## ## ## ## Ladders will take you up, but snakes will take you down! ## ## ## ## Tested on Eggdrop v1.8.4 (Debian Linux) Tcl version: 8.6.6 ## ## ## ####################################################################### ## ## ## INSTALLATION: ## ## ++ Edit the StairsAndSlides.tcl script and place it into ## ## your /scripts directory, ## ## ++ add "source scripts/StairsAndSlides.tcl" to your ## ## eggdrop config and rehash the bot. ## ## ## ####################################################################### ####################################################################### ## ## ## OFFICIAL LINKS: ## ## E-mail : BLaCkShaDoW[at]tclscripts.net ## ## Bugs report : http://www.tclscripts.net ## ## GitHub page : https://github.com/tclscripts/ ## ## Online help : irc://irc.undernet.org/tcl-help ## ## #TCL-HELP / UnderNet ## ## You can ask in english or romanian ## ## ## ## paypal.me/DanielVoipan = Please consider a donation. Thanks! ## ## ## ####################################################################### ## ## ## To activate: .chanset +stairs / .set #channel +stairs ## ## ## ## !stairs [?|help] - shows Stairs and Slides available commands. ## ## ## ## !stairs - starts the Stairs and Slides game. ## ## ## ## !join - join Stairs and Slides game. ## ## ## ## !dice - roll the dice. ## ## ## ## !stairs difficulty [easy|hard] - change game mode. ## ## ## ## !stairs lang [ro|en] - change game language. ## ## ## ## !stairs stop - stop the game, if running ## ## ## ## !stairs version - shows Stairs and Slides game version. ## ## ## ## !topXX [fastest/longest]- shows the top (ex !top10 or !top20 ## ## ## ## !sstat <nick/#> - shows stats for a nick or a place from TOP ## ## ## ####################################################################### ## ## ## LICENSE: ## ## This code comes with ABSOLUTELY NO WARRANTY. ## ## ## ## This program is free software; you can redistribute it and/or ## ## modify it under the terms of the GNU General Public License ## ## version 3 as published by the Free Software Foundation. ## ## ## ## This program is distributed WITHOUT ANY WARRANTY; ## ## without even the implied warranty of MERCHANTABILITY or ## ## FITNESS FOR A PARTICULAR PURPOSE. ## ## USE AT YOUR OWN RISK. ## ## ## ## See the GNU General Public License for more details. ## ## (http://www.gnu.org/copyleft/library.txt) ## ## ## ## Copyright 2008 - 2020 @ WwW.TCLScripts.NET ## ## ## ####################################################################### ####################################################################### ## CONFIGURATION FOR StairsAndSlides.TCL ## ####################################################################### ## #Set default char for commands set stairs(default_char) "!" ## #What flags can use !stairs stop, to stop the game (-|- for all) set stairs(stop_flags) "mn|MnOo" ## #Set here the default language (EN/RO) set stairs(default_lang) "EN" ## #Seconds to wait for the players to join set stairs(seconds_wait) "30" ## #How type of game the users should play ? (0 - easy ; 1 - hard) # easy - the users must arrive at cell number 100 or higher and they win # hard - the users must arrive exactly at cell number 100 to win, if the last dice # gets them on a cell +100 (like 104) they go to 100 then go back X places # (diference between +104 and 100) so they arrive at cell number 96. set stairs(game_type) "1" ## #Do you want to allow other users to join the game after it already started ? ( 0 - no ; 1 - yes) set stairs(game_after_join) "0" ## #How many seconds the bot should wait for the user to use dice (use !dice) set stairs(dice_wait) "30" ## #After how many forgotten !dice commands not used (consecutive) the user should be kicked from the game ? set stairs(dice_forget) "2" ## #How many dices to use ? (1 - 1 dice ; 2 - 2 dices) set stairs(dice_number) "2" ## #After game ends how many auto starts the game should have ? (0 for none) set stairs(auto_starts) "2" ## #How many seconds to be between the auto start tries ? set stairs(auto_starts_time) "20" ## #How many seconds to wait for the only user joined that joined the game to say "yes" #if he wants to play with the BOT ? set stairs(bot_play_time) "15" #Set here the type of hostname for users #1 - *!*@host #2 - *!ident@host #3 - user!ident@host #4 - user!*@* #5 - *!ident@* set stairs(user_host_type) "1" #Set webchan hosts #If is webchat host, the bot will take only ident set stairs(webchat_hosts) { "*.irccloud.com" "*!*@107.161.19.53" "*!*@107.161.19.109" "*!*@109.169.31.4" "*!*@109.169.29.95" "*!*@78.129.202.38" "*!*@64.62.228.82" "*!*@195.154.53.5" "*!*@212.83.148.225" "*!*@195.154.52.250" "*!*@207.192.75.252" "*!*@107.161.19.53" "*!*@192.184.10.9" "*!*@192.184.9.110" "*!*@tooting.irccloud.com" "*!*@192.184.8.73" "*!*@hathersage.irccloud.com" "*!*@ealing.irccloud.com" } ## #map of numbers set stairs_slides(num_map) { "1 2 3 4 5 6 7 8 9 10" "11 12 13 14 15 16 17 18 19 20" "21 22 23 24 25 26 27 28 29 30" "31 32 33 34 35 36 37 38 39 40" "41 42 43 44 45 46 47 48 49 50" "51 52 53 54 55 56 57 58 59 60" "61 62 63 64 65 66 67 68 69 70" "71 72 73 74 75 76 77 78 79 80" "81 82 83 84 85 86 87 88 89 90" "91 92 93 94 95 96 97 98 99 100" } ## #stairs and slides patterns # num1-num2 [snake -> num1-num2, go back from num1 to num2] [slide -> num1+num2, jump from num1 to num2] # You can add as many patterns as you want, the eggdrop with take a random one. ## set stairs(num_patterns) { "3+39 14+35 31+70 44+65 47+86 59+80 63+83 72+91 30-8 40-4 54-37 79-42 90-33 93-69 98-64" } ### # FLOOD PROTECTION #Set the number of minute(s) to ignore flooders, 0 to disable flood protection ### set stairs(ignore_prot) "1" ### # FLOOD PROTECTION #Set the number of requests within specifide number of seconds to trigger flood protection. # By default, 3:10, which allows for upto 3 queries in 10 seconds. 3 or more quries in 10 seconds would cuase # the forth and later queries to be ignored for the amount of time specifide above. ### set stairs(flood_prot) "3:5" ################################################################################ bind pub - $stairs(default_char)stairs stairs_slides:start bind pub - $stairs(default_char)join stairs_slides:join bind pub - $stairs(default_char)dice stairs_slides:dice bind pub - $stairs(default_char)sstat stairs_slides:stat bind nick - * stairs_slides:changenick bind pubm - * stairs_slides:bot_play_yes bind pubm - * stairs_slides:top bind time - "00 00 * * *" stairs_slides:month_reset setudef str stairs_lang setudef str stairs_difficulty setudef flag stairs set stairs(file) "stairsandslides.txt" if {![file exists $stairs(file)]} { set file [open $stairs(file) w] close $file } ### proc stairs_slides:month_reset {min hour day mon year} { global stairs_slides stairs if {[clock format [clock seconds] -format "%e"] == 1} { if {![info exists stairs_slides(month_reseted)]} { set stairs_slides(month_reseted) 1 stairs_slides:reset putlog "StairsAndSlide month reset succeded" } } elseif {[info exists stairs_slides(month_reseted)]} { unset stairs_slides(month_reseted) } } ### proc stairs_slides:reset {} { global stairs_slides stairs set file [open $stairs(file) w] close $file } ### proc stairs_slides:top {nick host hand chan arg} { global stairs_slides stairs if {![channel get $chan stairs]} { return } set command [lindex [split $arg] 0] set type [lindex [split $arg] 1] if {[string equal -nocase "fastest" $type]} { set type 1 } elseif {[string equal -nocase "longest" $type]} { set type 2 } else { set type 0 } set first_char [string index $command 0] if {[string equal -nocase $first_char $stairs(default_char)]} { set cmd [string tolower [string range $command 1 end]] if {[regexp -nocase {^(top)[0-9]+$} $cmd]} { set flood [stairs_slides:flood:prot $host $chan] if {$flood == 1} {return 0} set places [string map {"top" ""} $cmd] set top [stairs_slides:top_get $chan $places $type] if {$top == 0} { stairs_slides:say [list $places] "" $chan 39 0 } else { stairs_slides:say [list $places $top] "" $chan 38 0 } } } } ### proc stairs_slides:fastest {seconds chan} { global stairs_slides stairs set file [open $stairs(file) r] set read [read -nonewline $file] close $file array set top [list] set split_file [split $read "\n"] foreach line $split_file { set read_chan [lindex [split $line] 0] if {[string equal -nocase $read_chan $chan]} { set read_num [lindex [split $line] 4] set read_nick [lindex [split $line] 2] if {$read_num != "0"} { lappend top($read_num) $read_nick } } } if {[array size top] == 0} { return 0 } set counter 0 foreach i [lsort -integer -increasing [array names top]] { incr counter if {$counter == 1} { if {$seconds < $i} { set beat 1 } else { set beat 0 break } } } return $beat } ### proc stairs_slides:top_get {chan num type} { global stairs_slides stairs set file [open $stairs(file) r] set read [read -nonewline $file] close $file set split_file [split $read "\n"] set lang [string tolower [channel get $chan stairs_lang]] if {$lang == ""} { set lang [string tolower $stairs(default_lang)] } array set top [list] set counter 0 foreach line $split_file { set read_chan [lindex [split $line] 0] if {[string equal -nocase $read_chan $chan]} { set read_nick [lindex [split $line] 2] switch $type { 0 { set read_num [lindex [split $line] 3] } 1 { set read_num [lindex [split $line] 4] } 2 { set read_num [lindex [split $line] 5] } } if {$read_num != "0"} { incr counter lappend top($read_num) $read_nick } if {$counter == $num} { break } } } if {[array size top] == 0} { return 0 } else { set counter 0 set output "" foreach i [lsort -integer -decreasing [array names top]] { incr counter if {$type == 0} { lappend output "\#$counter [join $top($i) ", "] ($i $stairs($lang.lang.37))" } else { lappend output "\#$counter [join $top($i) ", "] ([stairs_slides:time_return $i])" } } if {$output == ""} {return 0} return [join $output] } } ### proc stairs_slides:stat_place {place chan} { global stairs_slides stairs set file [open $stairs(file) r] set read [read -nonewline $file] close $file set split_file [split $read "\n"] array set top [list] set counter 0 foreach line $split_file { set read_chan [lindex [split $line] 0] if {[string equal -nocase $read_chan $chan]} { set read_nick [lindex [split $line] 2] set read_num [lindex [split $line] 3] lappend top($read_num) $read_nick } } if {[array size top] == 0} { return 0 } set output 0 foreach i [lsort -integer -decreasing [array names top]] { incr counter if {[string equal -nocase $counter $place]} { set output $top($i) break } } return $output } ### proc stairs_slides:stat {nick host hand chan arg} { global stairs_slides stairs if {![channel get $chan stairs]} { return } set flood [stairs_slides:flood:prot $host $chan] if {$flood == 1} {return 0} set what [lindex [split $arg] 0] set place_search 0 if {$what == ""} {set what $nick} if {[regexp {^[0-9]+$} $what]} { set place_search 1 } set file [open $stairs(file) r] set read [read -nonewline $file] close $file set split_read [split $read "\n"] if {$place_search == 0} { set search [lsearch -nocase $split_read "$chan * $what *"] if {$search > -1} { set line [lindex $split_read $search] set read_host [lindex [split $line] 1] set read_nick [lindex [split $line] 2] set read_wins [lindex [split $line] 3] set read_shortest_time [stairs_slides:time_return [lindex [split $line] 4]] set read_longest_time [stairs_slides:time_return [lindex [split $line] 5]] set read_timewasted [stairs_slides:time_return [lindex [split $line] 6]] stairs_slides:say [list $read_nick $read_host $read_wins $read_shortest_time $read_longest_time $read_timewasted] "" $chan 35 0 } else { stairs_slides:say [list $what] "" $chan 36 0 } } else { set nicks [stairs_slides:stat_place $what $chan] if {$nicks == 0} { stairs_slides:say [list $what] "" $chan 40 0 return } foreach entry $nicks { set search [lsearch -nocase $split_read "$chan * $entry *"] if {$search > -1} { set line [lindex $split_read $search] set read_host [lindex [split $line] 1] set read_nick [lindex [split $line] 2] set read_wins [lindex [split $line] 3] set read_shortest_time [stairs_slides:time_return [lindex [split $line] 4]] set read_longest_time [stairs_slides:time_return [lindex [split $line] 5]] set read_timewasted [stairs_slides:time_return [lindex [split $line] 6]] stairs_slides:say [list $read_nick $read_host $read_wins $read_shortest_time $read_longest_time $read_timewasted] "" $chan 35 0 } else { stairs_slides:say [list $what] "" $chan 36 0 } } } } ### proc stairs_slides:save {chan host nick wins time timewasted} { global stairs_slides stairs set file [open $stairs(file) r] set read [read -nonewline $file] close $file set split_read [split $read "\n"] set search [lsearch -nocase $split_read "$chan $host *"] if {$search < 0} { set file [open $stairs(file) a] puts $file "$chan $host $nick $wins $time $time $timewasted" close $file } else { set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}] set temp "${stairs(file)}.$timestamp" set tempwrite [open $temp w] set shortest_time "" set longest_time "" set time_wasted "" foreach line $split_read { set read_chan [lindex [split $line] 0] set read_host [lindex [split $line] 1] if {[string equal -nocase $read_chan $chan] && [string equal -nocase $read_host $host]} { set read_wins [lindex [split $line] 3] set read_shortest_time [lindex [split $line] 4] set read_longest_time [lindex [split $line] 5] set read_timewasted [lindex [split $line] 6] if {$time < $read_shortest_time} { set shortest_time $time set longest_time $read_longest_time } elseif {$time > $read_shortest_time} { set shortest_time $read_shortest_time if {$time > $read_longest_time} { set longest_time $time } else {set longest_time $read_longest_time} } else { set shortest_time $read_shortest_time set longest_time $read_longest_time } set wins [expr $read_wins + $wins] set time_wasted [expr $read_timewasted + $timewasted] continue } else { puts $tempwrite $line } } puts $tempwrite "$chan $host $nick $wins $shortest_time $longest_time $time_wasted" close $tempwrite file rename -force $temp $stairs(file) } } ### proc stairs_slides:difficulty {chan} { global stairs_slides stairs set difficulty [channel get $chan stairs_difficulty] if {$difficulty == ""} { return $stairs(game_type) } elseif {[string equal -nocase $difficulty "easy"]} { return 0 } elseif {[string equal -nocase $difficulty "hard"]} { return 1 } else { return $stairs(game_type) } } ### proc stairs_slides:start {nick host hand chan arg} { global stairs_slides stairs if {![channel get $chan stairs]} { return } set flood [stairs_slides:flood:prot $host $chan] if {$flood == 1} {return 0} set what [lindex [split $arg] 0] set option [string tolower [lindex [split $arg] 1]] switch [string tolower $what] { difficulty { if {$option == ""} { stairs_slides:say [list $option] $nick $chan 46 1 return } if {[string equal -nocase "easy" $option]} { channel set $chan stairs_difficulty $option stairs_slides:say [list $option] $nick $chan 45 1 } elseif {[string equal -nocase "hard" $option]} { channel set $chan stairs_difficulty $option stairs_slides:say [list $option] $nick $chan 45 1 } else { stairs_slides:say [list $option] $nick $chan 44 1 } return } lang { if {$option == ""} { stairs_slides:say [list $option] $nick $chan 43 1 return } if {![info exists stairs($option.lang.1)]} { stairs_slides:say [list $option] $nick $chan 41 1 return } channel set $chan stairs_lang $option stairs_slides:say [list $option] $nick $chan 42 1 return } version { putserv "PRIVMSG $chan :\002$stairs(projectName) $stairs(version)\002 coded by $stairs(author) ($stairs(website))" return } stop { if {[matchattr $hand $stairs(stop_flags) $chan]} { stairs_slides:stop $chan return } } help { stairs_slides:say [list $option] $nick $chan 47 1 return } \? { stairs_slides:say [list $option] $nick $chan 47 1 return } } if {[info exists stairs_slides(no_autostart:$chan)]} { unset stairs_slides(no_autostart:$chan) } if {[info exists stairs_slides(game_start:$chan)]} { stairs_slides:say "" $nick $chan 2 1 return } foreach tmr [utimers] { if {[string match "*stairs_slides:autostart:now $chan*" [join [lindex $tmr 1]]]} { killutimer [lindex $tmr 2] } } set stairs_slides(game_start:$chan) 1 set stairs_slides(game_join:$chan) 1 stairs_slides:say "" $nick $chan 31 0 stairs_slides:say "" $nick $chan 1 0 utimer $stairs(seconds_wait) [list stairs_slides:check_enough $chan] } proc stairs_slides:stop {chan} { global stairs_slides stairs if {![info exists stairs_slides(game_start:$chan)]} { return } foreach tmr [utimers] { if {[string match "*stairs_slides:autostart:now $chan*" [join [lindex $tmr 1]]]} { killutimer [lindex $tmr 2] } if {[string match "*stairs_slides:no_bot_play $chan*" [join [lindex $tmr 1]]]} { killutimer [lindex $tmr 2] } if {[string match "*stairs_slides:no_dice * $chan*" [join [lindex $tmr 1]]]} { killutimer [lindex $tmr 2] } if {[string match "*stairs_slides:game_start_now * $chan*" [join [lindex $tmr 1]]]} { killutimer [lindex $tmr 2] } if {[string match "*stairs_slides:check_enough $chan*" [join [lindex $tmr 1]]]} { killutimer [lindex $tmr 2] } if {[string match "*stairs_slides:game_start $chan*" [join [lindex $tmr 1]]]} { killutimer [lindex $tmr 2] } } stairs_slides:unset $chan stairs_slides:say "" "" $chan 49 0 } ### proc stairs_slides:autostart {chan} { global stairs_slides stairs if {![info exists stairs_slides(autostart_num:$chan)]} { set stairs_slides(autostart_num:$chan) 0 } if {$stairs_slides(autostart_num:$chan) >= $stairs(auto_starts)} { unset stairs_slides(autostart_num:$chan) set stairs_slides(no_autostart:$chan) 1 return 0 } utimer $stairs(auto_starts_time) [list stairs_slides:autostart:now $chan] incr stairs_slides(autostart_num:$chan) } ### proc stairs_slides:autostart:now {chan} { global stairs_slides stairs set stairs_slides(game_start:$chan) 1 set stairs_slides(game_join:$chan) 1 stairs_slides:say "" "" $chan 31 0 stairs_slides:say "" "" $chan 1 0 utimer $stairs(seconds_wait) [list stairs_slides:check_enough $chan] } ### proc stairs_slides:no_bot_play {chan} { global stairs_slides stairs stairs_slides:say "" "" $chan 7 0 stairs_slides:unset $chan if {$stairs(auto_starts) > 0 && ![info exists stairs_slides(no_autostart:$chan)]} { stairs_slides:autostart $chan } return } ### proc stairs_slides:bot_play_yes {nick host hand chan arg} { global stairs_slides stairs botnick if {![info exists stairs_slides(game_start:$chan)]} {return} if {[info exists stairs_slides(bot_play:$chan)]} { set text [lindex [split $arg] 0] if {[string equal -nocase $text "yes"]} { set hostname [stairs_slides:host_return $stairs(user_host_type) $nick [getchanhost $nick $chan]] set entry [lindex $stairs_slides(players:$chan) 0] set read_hostname [lindex $entry 1] if {[string equal -nocase $hostname $read_hostname]} { foreach tmr [utimers] { if {[string match "*stairs_slides:no_bot_play $chan*" [join [lindex $tmr 1]]]} { killutimer [lindex $tmr 2] } } unset stairs_slides(bot_play:$chan) set bot_host [stairs_slides:host_return $stairs(user_host_type) $botnick [getchanhost $botnick $chan]] set id [stairs_slides:id $chan] lappend stairs_slides(players:$chan) [list $botnick $bot_host $id] stairs_slides:say [list $botnick] $nick $chan 5 0 set game_difficulty [stairs_slides:difficulty $chan] set lang [string tolower [channel get $chan stairs_lang]] if {$lang == ""} { set lang [string tolower $stairs(default_lang)] } if {$game_difficulty == 0} { set difficulty $stairs($lang.lang.32) } else { set difficulty $stairs($lang.lang.33) } set players [stairs_slides:players $chan] stairs_slides:say [list $difficulty] "" $chan 22 0 stairs_slides:say [list [llength $stairs_slides(players:$chan)] $players] "" $chan 9 0 utimer 4 [list stairs_slides:game_start $chan] } } } } ### proc stairs_slides:check_enough {chan} { global stairs_slides stairs if {![info exists stairs_slides(players:$chan)]} { if {$stairs(auto_starts) > 0} { if {[info exists stairs_slides(autostart_num:$chan)]} { if {$stairs_slides(autostart_num:$chan) >= $stairs(auto_starts)} { stairs_slides:say "" "" $chan 6 0 } else { stairs_slides:say "" "" $chan 8 0 } } else { stairs_slides:say "" "" $chan 8 0 } } else { stairs_slides:say "" "" $chan 6 0 } stairs_slides:unset $chan if {$stairs(auto_starts) > 0 && ![info exists stairs_slides(no_autostart:$chan)]} { stairs_slides:autostart $chan } return } if {[llength $stairs_slides(players:$chan)] < 2} { if {[info exists stairs_slides(game_join:$chan)]} { unset stairs_slides(game_join:$chan) } set stairs_slides(bot_play:$chan) 0 set entry [lindex $stairs_slides(players:$chan) 0] set read_nick [lindex $entry 0] stairs_slides:say [list $read_nick $stairs(bot_play_time)] $read_nick $chan 24 0 utimer $stairs(bot_play_time) [list stairs_slides:no_bot_play $chan] return } set game_difficulty [stairs_slides:difficulty $chan] set lang [string tolower [channel get $chan stairs_lang]] if {$lang == ""} { set lang [string tolower $stairs(default_lang)] } if {$game_difficulty == 0} { set difficulty $stairs($lang.lang.32) } else { set difficulty $stairs($lang.lang.33) } set players [stairs_slides:players $chan] stairs_slides:say [list $difficulty] "" $chan 22 0 stairs_slides:say [list [llength $stairs_slides(players:$chan)] $players] "" $chan 9 0 if {[info exists stairs_slides(game_join:$chan)]} { unset stairs_slides(game_join:$chan) } utimer 4 [list stairs_slides:game_start $chan] } ### proc stairs_slides:game_start {chan} { global stairs_slides if {[info exists stairs_slides(autostart_num:$chan)]} { unset stairs_slides(autostart_num:$chan) } set dicelist [stairs_slides:autodice $chan] stairs_slides:say [list [join $dicelist ", "]] "" $chan 10 0 set stairs_slides(game_start_time:$chan) [unixtime] utimer 5 [list stairs_slides:game_start_now 0 $chan] } ### proc stairs_slides:game_start_now {num chan} { global stairs_slides stairs botnick set entry [lindex $stairs_slides(players:$chan) $num] set stairs_slides(current_player_pos:$chan) $num set nickname [lindex $entry 0] set hostname [lindex $entry 1] set id [lindex $entry 2] if {![string equal -nocase $nickname $botnick]} { set stairs_slides(current_dice:$chan) $id if {![info exists stairs_slides(first_dice_show:$chan)] && $num == 0} { stairs_slides:say [list $nickname $stairs(dice_wait)] "" $chan 27 0 set stairs_slides(first_dice_show:$chan) 1 } else { stairs_slides:say [list $nickname $stairs(dice_wait)] "" $chan 12 0 } utimer $stairs(dice_wait) [list stairs_slides:no_dice $num $chan] } else { stairs_slides:bot_dice $id $chan } } ### proc stairs_slides:bot_dice {id chan} { global stairs_slides stairs botnick if {[info exists stairs_slides(current_dice:$chan)]} { unset stairs_slides(current_dice:$chan) } set dices [stairs_slides:dice_get] stairs_slides:save_dices $id $chan if {$stairs(dice_number) == 1} { set ivalue "[lindex $dices 0] [stairs_slides:special_text [stairs_slides:dice_image [lindex $dices 0]]]" set value [lindex $dices 0] set sum $value } else { foreach v [lindex $dices 0] { set i [stairs_slides:special_text [stairs_slides:dice_image $v]] lappend ivalue "$v $i" } set ivalue [join $ivalue] set value [lindex $dices 0] set sum [lindex $dices 1] } stairs_slides:advance $id $chan $sum $value $ivalue } ### proc stairs_slides:player_left {nick id chan} { global stairs_slides stairs stairs_slides:say [list $nick] "" $chan 25 0 stairs_slides:remove $chan $id set llength_players [llength $stairs_slides(players:$chan)] if {$llength_players < 2} { stairs_slides:say "" "" $chan 15 0 stairs_slides:unset $chan if {$stairs(auto_starts) > 0 && ![info exists stairs_slides(no_autostart:$chan)]} { stairs_slides:autostart $chan } } else { set inc [expr $num + 1] if {[lindex $stairs_slides(players:$chan) $inc] != ""} { utimer 3 [list stairs_slides:game_start_now $inc $chan] } else { utimer 3 [list stairs_slides:game_start_now 0 $chan] } } } ### proc stairs_slides:no_dice {num chan} { global stairs_slides stairs set new_penalty 0 set id $stairs_slides(current_dice:$chan) unset stairs_slides(current_dice:$chan) set nick [stairs_slides:get $chan $id 0] if {![onchan $nick $chan]} { stairs_slides:player_left $nick $id $chan return } stairs_slides:times $id $chan $stairs(dice_wait) if {![info exists stairs_slides(penalties:$chan)]} { lappend stairs_slides(penalties:$chan) [list $id "1"] stairs_slides:say [list $nick $stairs(dice_forget)] "" $chan 13 0 } else { set search [lsearch -nocase $stairs_slides(penalties:$chan) [list $id "*"]] if {$search < 0} { lappend stairs_slides(penalties:$chan) [list $id "1"] stairs_slides:say [list $nick $stairs(dice_forget)] "" $chan 13 0 } else { set entry [lindex $stairs_slides(penalties:$chan) $search] set penalty_nr [lindex $entry 1] incr penalty_nr if {$penalty_nr < $stairs(dice_forget)} { set stairs_slides(penalties:$chan) [lreplace $stairs_slides(penalties:$chan) $search $search] lappend stairs_slides(penalties:$chan) [list $id $penalty_nr] stairs_slides:say [list $nick $stairs(dice_forget)] "" $chan 13 0 } else { stairs_slides:say [list $nick] "" $chan 14 0 stairs_slides:remove $chan $id } } } if {![info exists stairs_slides(players:$chan)]} { return } set llength_players [llength $stairs_slides(players:$chan)] if {$llength_players < 2} { stairs_slides:say "" "" $chan 15 0 stairs_slides:unset $chan if {$stairs(auto_starts) > 0 && ![info exists stairs_slides(no_autostart:$chan)]} { stairs_slides:autostart $chan } } else { set inc [expr $num + 1] if {[lindex $stairs_slides(players:$chan) $inc] != ""} { utimer 4 [list stairs_slides:game_start_now $inc $chan] } else { utimer 4 [list stairs_slides:game_start_now 0 $chan] } } } ### proc stairs_slides:remove {chan id} { global stairs_slides set search [lsearch -nocase $stairs_slides(players:$chan) [list "*" "*" $id]] set stairs_slides(players:$chan) [lreplace $stairs_slides(players:$chan) $search $search] if {[info exists stairs_slides(penalties:$chan)]} { set search [lsearch -nocase $stairs_slides(penalties:$chan) [list $id "*"]] set stairs_slides(penalties:$chan) [lreplace $stairs_slides(penalties:$chan) $search $search] } if {[info exists stairs_slides(positions:$chan)]} { set search [lsearch -nocase $stairs_slides(positions:$chan) [list $id "*"]] set stairs_slides(positions:$chan) [lreplace $stairs_slides(positions:$chan) $search $search] } if {[info exists stairs_slides(dices:$chan)]} { set search [lsearch -nocase $stairs_slides(dices:$chan) [list $id "*"]] set stairs_slides(dices:$chan) [lreplace $stairs_slides(dices:$chan) $search $search] } if {[info exists stairs_slides(future_stairs_slides:$chan)]} { set search [lsearch -nocase $stairs_slides(future_stairs_slides:$chan) [list $id "*"]] set stairs_slides(future_stairs_slides:$chan) [lreplace $stairs_slides(future_stairs_slides:$chan) $search $search] } if {[info exists stairs_slides(times:$chan)]} { set search [lsearch -nocase $stairs_slides(times:$chan) [list $id "*"]] set stairs_slides(times:$chan) [lreplace $stairs_slides(times:$chan) $search $search] } } ### proc stairs_slides:dice_get {} { global stairs set dices "" set counter 0 set sum 0 if {$stairs(dice_number) == 1} { set dice [expr [rand 6] + 1] return [list $dice $dice] } else { while {$counter < 2} { set dice [expr [rand 6] + 1] set sum [expr $sum + $dice] lappend dices $dice incr counter } return [list $dices $sum] } } ### proc stairs_slides:autodice {chan} { global stairs_slides stairs set first_dice_winner 0 set dices "" set players_dice "" array set dice_order [list] foreach entry $stairs_slides(players:$chan) { set nickname [lindex $entry 0] set hostname [lindex $entry 1] if {[lsearch -nocase $players_dice $entry] < 0} { if {$stairs(dice_number) == 1} { set dice [expr [rand 6] + 1] } else { set dice1 [expr [rand 6] + 1] set dice2 [expr [rand 6] + 1] set dice [expr $dice1 + $dice2] } while 1 { if {[lsearch $dices $dice] < 0} { lappend dice_order($dice) $entry lappend dices $dice lappend players_dice $entry break } else { if {$stairs(dice_number) == 1} { set dice [expr [rand 6] + 1] } else { set dice1 [expr [rand 6] + 1] set dice2 [expr [rand 6] + 1] set dice [expr $dice1 + $dice2] } } } } } set dicelist "" unset stairs_slides(players:$chan) foreach a [lsort -integer -decreasing [array names dice_order]] { lappend stairs_slides(players:$chan) [join $dice_order($a)] set nickname [lindex [lindex $dice_order($a) 0] 0] lappend dicelist "$nickname \[$a\]" } return $dicelist } ### proc stairs_slides:unset {chan} { global stairs_slides if {[info exists stairs_slides(game_start:$chan)]} { unset stairs_slides(game_start:$chan) } if {[info exists stairs_slides(game_join:$chan)]} { unset stairs_slides(game_join:$chan) } if {[info exists stairs_slides(players:$chan)]} { unset stairs_slides(players:$chan) } if {[info exists stairs_slides(current_dice:$chan)]} { unset stairs_slides(current_dice:$chan) } if {[info exists stairs_slides(penalties:$chan)]} { unset stairs_slides(penalties:$chan) } if {[info exists stairs_slides(positions:$chan)]} { unset stairs_slides(positions:$chan) } if {[info exists stairs_slides(current_player_pos:$chan)]} { unset stairs_slides(current_player_pos:$chan) } if {[info exists stairs_slides(stairs_slide:$chan)]} { unset stairs_slides(stairs_slide:$chan) } if {[info exists stairs_slides(game_start_time:$chan)]} { unset stairs_slides(game_start_time:$chan) } if {[info exists stairs_slides(bot_play:$chan)]} { unset stairs_slides(bot_play:$chan) } if {[info exists stairs_slides(game_end_time:$chan)]} { unset stairs_slides(game_end_time:$chan) } if {[info exists stairs_slides(dices:$chan)]} { unset stairs_slides(dices:$chan) } if {[info exists stairs_slides(total_dices:$chan)]} { unset stairs_slides(total_dices:$chan) } if {[info exists stairs_slides(first_dice_show:$chan)]} { unset stairs_slides(first_dice_show:$chan) } if {[info exists stairs_slides(game_won:$chan)]} { unset stairs_slides(game_won:$chan) } if {[info exists stairs_slides(future_stairs_slides:$chan)]} { unset stairs_slides(future_stairs_slides:$chan) } if {[info exists stairs_slides(times:$chan)]} { unset stairs_slides(times:$chan) } } ### proc stairs_slides:dice {nick host hand chan arg} { global stairs_slides stairs if {![channel get $chan stairs]} { return } set flood [stairs_slides:flood:prot $host $chan] if {$flood == 1} {return 0} if {![info exists stairs_slides(game_start:$chan)]} { return } if {![info exists stairs_slides(players:$chan)]} { return } if {![info exists stairs_slides(current_dice:$chan)]} { return } set hostname [stairs_slides:host_return $stairs(user_host_type) $nick [getchanhost $nick $chan]] set search [lsearch $stairs_slides(players:$chan) [list "*" $hostname "*"]] if {$search < 0} {return} set entry [lindex $stairs_slides(players:$chan) $search] set f_hostname [lindex $entry 1] set f_nick [lindex $entry 0] set id [lindex $entry 2] if {![string equal $id $stairs_slides(current_dice:$chan)]} { return } if {[info exists stairs_slides(penalties:$chan)]} { set search [lsearch -nocase $stairs_slides(penalties:$chan) [list $id "*"]] set stairs_slides(penalties:$chan) [lreplace $stairs_slides(penalties:$chan) $search $search] } foreach tmr [utimers] { if {[string match "*stairs_slides:no_dice * $chan*" [join [lindex $tmr 1]]]} { killutimer [lindex $tmr 2] set seconds_remain [lindex $tmr 0] set diff [expr $stairs(dice_wait) - $seconds_remain] stairs_slides:times $id $chan $diff break } } if {[info exists stairs_slides(current_dice:$chan)]} { unset stairs_slides(current_dice:$chan) } set dices [stairs_slides:dice_get] stairs_slides:save_dices $id $chan if {$stairs(dice_number) == 1} { set ivalue "[lindex $dices 0] [stairs_slides:special_text [stairs_slides:dice_image [lindex $dices 0]]]" set value [lindex $dices 0] set sum $value } else { foreach v [lindex $dices 0] { set i [stairs_slides:special_text [stairs_slides:dice_image $v]] lappend ivalue "$v $i" } set ivalue [join $ivalue] set value [lindex $dices 0] set sum [lindex $dices 1] } stairs_slides:advance $id $chan $sum $value $ivalue } ### proc stairs_slides:get_times {id chan} { global stairs_slides stairs if {![info exists stairs_slides(times:$chan)]} { return 0 } set search [lsearch -nocase $stairs_slides(times:$chan) [list $id "*"]] if {$search > -1} { set entry [lindex $stairs_slides(times:$chan) $search] set read_seconds [lindex $entry 1] return $read_seconds } else { return 0 } } ### proc stairs_slides:times {id chan seconds} { global stairs_slides stairs if {![info exists stairs_slides(times:$chan)]} { lappend stairs_slides(times:$chan) [list $id $seconds] } else { set search [lsearch $stairs_slides(times:$chan) [list $id "*"]] if {$search > -1} { set entry [lindex $stairs_slides(times:$chan) $search] set read_seconds [lindex $entry 1] set seconds [expr $read_seconds + $seconds] set stairs_slides(times:$chan) [lreplace $stairs_slides(times:$chan) $search $search] lappend stairs_slides(times:$chan) [list $id $seconds] } else { lappend stairs_slides(times:$chan) [list $id $seconds] } } } ### proc stairs_slides:save_dices {id chan} { global stairs_slides stairs if {![info exists stairs_slides(dices:$chan)]} { lappend stairs_slides(dices:$chan) [list $id 1] } else { set search [lsearch $stairs_slides(dices:$chan) [list $id "*"]] if {$search > -1} { set found [lindex $stairs_slides(dices:$chan) $search] set current_dice [lindex $found 1] incr current_dice set stairs_slides(dices:$chan) [lreplace $stairs_slides(dices:$chan) $search $search] lappend stairs_slides(dices:$chan) [list $id $current_dice] } else { lappend stairs_slides(dices:$chan) [list $id 1] } } if {![info exists stairs_slides(total_dices:$chan)]} { set stairs_slides(total_dices:$chan) 1 } else { set stairs_slides(total_dices:$chan) [expr $stairs_slides(total_dices:$chan) + 1] } } ### proc stairs_slides:get_dices {id chan} { global stairs_slides stairs if {![info exists stairs_slides(dices:$chan)]} { return 0 } else { set search [lsearch $stairs_slides(dices:$chan) [list $id "*"]] if {$search > -1} { set found [lindex $stairs_slides(dices:$chan) $search] set current_dice [lindex $found 1] return $current_dice } else {return 0} } } ### proc stairs_slides:advance {id chan sum value ivalue} { global stairs_slides stairs set current_pos $stairs_slides(current_player_pos:$chan) set nick [stairs_slides:get $chan $id 0] if {![info exists stairs_slides(positions:$chan)]} { lappend stairs_slides(positions:$chan) [list $id $sum] set next_sum $sum set current_sum $sum set search [lsearch $stairs_slides(positions:$chan) [list $id "*"]] } else { set search [lsearch $stairs_slides(positions:$chan) [list $id "*"]] if {$search > -1} { set found [lindex $stairs_slides(positions:$chan) $search] set current_sum [lindex $found 1] set next_sum [expr $current_sum + $sum] } else { set next_sum $sum set current_sum $sum lappend stairs_slides(positions:$chan) [list $id $sum] set search [lsearch $stairs_slides(positions:$chan) [list $id "*"]] } } set game_difficulty [stairs_slides:difficulty $chan] if {$game_difficulty == 0} { incr current_pos if {$next_sum < 100} { if {$stairs(dice_number) == 1} { stairs_slides:say [list $nick $ivalue $sum] $nick $chan 17 0 } else { stairs_slides:say [list $nick $ivalue $sum] $nick $chan 16 0 } set status [stairs_slides:advance:pos $search $chan $next_sum $current_sum] set jump_to [lindex $status 1] set status [lindex $status 0] set seconds 4 if {$status > -1} { set future_stairs_slides [stairs_slides:future_stairs_slides $id $nick $jump_to $chan] set seconds 6 } else { set future_stairs_slides [stairs_slides:future_stairs_slides $id $nick $next_sum $chan] } if {$future_stairs_slides == 1} { set seconds [expr $seconds + 2] } if {[lindex $stairs_slides(players:$chan) $current_pos] != ""} { utimer $seconds [list stairs_slides:game_start_now $current_pos $chan] } else { utimer $seconds [list stairs_slides:game_start_now 0 $chan] } } else { stairs_slides:winner $id $chan $next_sum $value } } else { if {$next_sum < 100} { incr current_pos if {$stairs(dice_number) == 1} { stairs_slides:say [list $nick $ivalue $ivalue] $nick $chan 17 0 } else { stairs_slides:say [list $nick $ivalue $sum] $nick $chan 16 0 } set status [stairs_slides:advance:pos $search $chan $next_sum $current_sum] set jump_to [lindex $status 1] set status [lindex $status 0] set seconds 4 if {$status > -1} { set future_stairs_slides [stairs_slides:future_stairs_slides $id $nick $jump_to $chan] set seconds 6 } else { set future_stairs_slides [stairs_slides:future_stairs_slides $id $nick $next_sum $chan] } if {$future_stairs_slides == 1} { set seconds [expr $seconds + 2] } if {[lindex $stairs_slides(players:$chan) $current_pos] != ""} { utimer $seconds [list stairs_slides:game_start_now $current_pos $chan] } else { utimer $seconds [list stairs_slides:game_start_now 0 $chan] } } elseif {$next_sum == 100} { stairs_slides:winner $id $chan $next_sum $value } elseif {$next_sum > 100} { if {$stairs(dice_number) == 1} { stairs_slides:say [list $nick $ivalue $ivalue] $nick $chan 17 0 } else { stairs_slides:say [list $nick $ivalue $sum] $nick $chan 16 0 } set dif [expr $next_sum - 100] set down [expr 100 - $dif] set seconds 7 stairs_slides:getback $search $chan $down $dif $next_sum set future_stairs_slides [stairs_slides:future_stairs_slides $id $nick $down $chan] if {$future_stairs_slides == 1} { set seconds [expr $seconds + 2] } incr current_pos if {[lindex $stairs_slides(players:$chan) $current_pos] != ""} { utimer $seconds [list stairs_slides:game_start_now $current_pos $chan] } else { utimer $seconds [list stairs_slides:game_start_now 0 $chan] } } } } ### proc stairs_slides:winner {id chan pos value} { global stairs_slides stairs botnick set broke_fastest 0 set usertime [stairs_slides:get_times $id $chan] set stairs_slides(game_won:$chan) 1 set stairs_slides(game_end_time:$chan) [unixtime] set nick [stairs_slides:get $chan $id 0] set hostname [stairs_slides:get $chan $id 1] set gametime [expr $stairs_slides(game_end_time:$chan) - $stairs_slides(game_start_time:$chan)] if {[isbotnick $nick]} { stairs_slides:save $chan $hostname $nick 1 0 $gametime } else { set broke_fastest [stairs_slides:fastest $usertime $chan] stairs_slides:save $chan $hostname $nick 1 $usertime $gametime } set dices [stairs_slides:get_dices $id $chan] set gametime [stairs_slides:time_return $gametime] set totaldices $stairs_slides(total_dices:$chan) if {$stairs(dice_number) == 1} { set values "$value [stairs_slides:special_text [stairs_slides:dice_image $value]]" } else { foreach v $value { set i [stairs_slides:special_text [stairs_slides:dice_image $v]] lappend values "$v $i" } set values [join $values] } stairs_slides:say [list $nick $values] $nick $chan 23 0 if {$broke_fastest == 1} { stairs_slides:say [list $nick] $nick $chan 48 0 } stairs_slides:say [list $nick $dices] $nick $chan 34 0 stairs_slides:say [list $totaldices $gametime] $nick $chan 4 0 stairs_slides:unset $chan } ### proc stairs_slides:getback {pos chan next dif last} { global stairs_slides stairs set entry [lindex $stairs_slides(positions:$chan) $pos] set id [lindex $entry 0] set nick [stairs_slides:get $chan $id 0] set stairs_num [stairs_slides:get_stair_slide $id $chan 0] set slides_num [stairs_slides:get_stair_slide $id $chan 1] set stairs_slides(positions:$chan) [lreplace $stairs_slides(positions:$chan) $pos $pos] lappend stairs_slides(positions:$chan) [list $id $next] stairs_slides:say [list $nick $dif $last $next] $nick $chan 21 0 stairs_slides:say [list $nick $next $stairs_num $slides_num] $nick $chan 19 0 } ### proc stairs_slides:future_stairs_slides {id nick pos chan} { global stairs_slides stairs if {$stairs(dice_number) == 1} { set future_places 6 } else { set future_places 12 } set counter 0 set stairs_list "" set slides_list "" for {set i 1} {$i <= 100} {incr i} { if {$i > $pos} { incr counter set check_stair_slide [stairs_slides:check $i] set status [lindex $check_stair_slide 0] set jump_to [lindex $check_stair_slide 1] if {$status == 0} { lappend stairs_list [list \002$i\002 [stairs_slides:special_text "→"] $jump_to[stairs_slides:special_text "↑"]] } elseif {$status == 1} { lappend slides_list [list \002$i\002 [stairs_slides:special_text "→"] $jump_to[stairs_slides:special_text "↓"]] } if {$counter == $future_places} { break } } } if {$stairs_list == "" && $slides_list == ""} { return 0 } elseif {$slides_list != "" && $stairs_list == ""} { set status [stairs_slides:last_future_stairs_slides $id $chan $slides_list] set slides_list [join $slides_list ", "] if {$status == 1} { stairs_slides:say [list $nick $slides_list] "" $chan 28 0 } } elseif {$stairs_list != "" && $slides_list == ""} { set status [stairs_slides:last_future_stairs_slides $id $chan $stairs_list] set stairs_list [join $stairs_list ", "] if {$status == 1} { stairs_slides:say [list $nick $stairs_list] "" $chan 29 0 } } else { set stairs_list [join $stairs_list ", "] set slides_list [join $slides_list ", "] lappend text $stairs_list lappend text $slides_list set status [stairs_slides:last_future_stairs_slides $id $chan $text] set text [join $text ", "] if {$status == 1} { stairs_slides:say [list $nick $text] "" $chan 30 0 } } return 1 } ### proc stairs_slides:last_future_stairs_slides {id chan text} { global stairs_slides stairs if {![info exists stairs_slides(future_stairs_slides:$chan)]} { lappend stairs_slides(future_stairs_slides:$chan) [list $id $text] return 1 } else { set search [lsearch $stairs_slides(future_stairs_slides:$chan) [list $id "*"]] if {$search > -1} { set entry [lindex $stairs_slides(future_stairs_slides:$chan) $search] set read_text [lindex $entry 1] if {![string equal -nocase $text $read_text]} { set stairs_slides(future_stairs_slides:$chan) [lreplace $stairs_slides(future_stairs_slides:$chan) $search $search] lappend stairs_slides(future_stairs_slides:$chan) [list $id $text] return 1 } else { return 0 } } else { lappend stairs_slides(future_stairs_slides:$chan) [list $id $text] return 1 } } } ### proc stairs_slides:advance:pos {pos chan places last_place} { global stairs_slides stairs set entry [lindex $stairs_slides(positions:$chan) $pos] set id [lindex $entry 0] set stairs_slides(positions:$chan) [lreplace $stairs_slides(positions:$chan) $pos $pos] set check_stair_slide [stairs_slides:check $places] set status [lindex $check_stair_slide 0] set nick [stairs_slides:get $chan $id 0] set jump_to [lindex $check_stair_slide 1] set stairs_num [stairs_slides:get_stair_slide $id $chan 0] set slides_num [stairs_slides:get_stair_slide $id $chan 1] switch $status { 0 { set stairs_num [stairs_slides:add_stair_slide $id $chan 0] stairs_slides:say [list $nick $places $jump_to] $nick $chan 18 0 } 1 { set slides_num [stairs_slides:add_stair_slide $id $chan 1] stairs_slides:say [list $nick $places $jump_to] $nick $chan 20 0 } } if {$status != "-1"} { stairs_slides:say [list $nick $jump_to $stairs_num $slides_num] $nick $chan 19 0 lappend stairs_slides(positions:$chan) [list $id $jump_to] } else { stairs_slides:say [list $nick $places $stairs_num $slides_num] $nick $chan 19 0 lappend stairs_slides(positions:$chan) [list $id $places] } if {$status != "-1"} { return [list $status $jump_to] } else { return $status } } ### proc stairs_slides:time_return {get_time} { global stairs_slides stairs if {$get_time == "0" || $get_time == ""} { return "N/A" } set days [expr $get_time/86400] set hours [expr [expr $get_time/3600] % 24]; set minutes [expr [expr $get_time / 60] % 60] set seconds [expr $get_time % 60] if {$days == "0"} { if {$hours == "0"} { if {$minutes > 0} { return "${minutes}m:${seconds}s" } else { return "${seconds}s" } } else { if {$minutes > 0} { return "${hours}h:${minutes}m" } else { return "${hours}h" } } } else { if {$hours > 0} { return "${days}d:${hours}h" } else { return "${days}d" } } } ### proc stairs_slides:get_stair_slide {id chan type} { global stairs_slides stairs if {![info exists stairs_slides(stairs_slide:$chan)]} { return 0 } set search [lsearch $stairs_slides(stairs_slide:$chan) [list $id $type "*"]] if {$search < 0} { return 0 } set entry [lindex $stairs_slides(stairs_slide:$chan) $search] set last_num [lindex $entry 2] return $last_num } ### proc stairs_slides:add_stair_slide {id chan type} { global stairs_slides stairs if {![info exists stairs_slides(stairs_slide:$chan)]} { lappend stairs_slides(stairs_slide:$chan) [list $id $type 1] return 1 } else { set search [lsearch $stairs_slides(stairs_slide:$chan) [list $id $type "*"]] if {$search > -1} { set entry [lindex $stairs_slides(stairs_slide:$chan) $search] set last_num [lindex $entry 2] incr last_num set stairs_slides(stairs_slide:$chan) [lreplace $stairs_slides(stairs_slide:$chan) $search $search] lappend stairs_slides(stairs_slide:$chan) [list $id $type $last_num] return $last_num } else { lappend stairs_slides(stairs_slide:$chan) [list $id $type 1] return 1 } } } ### proc stairs_slides:check {pos} { global stairs_slides stairs set llength_patters [llength $stairs(num_patterns)] set rand_pattern [lindex $stairs(num_patterns) [rand $llength_patters]] set search_stair [lsearch $rand_pattern "${pos}+*"] if {$search_stair > -1} { set return [lindex $rand_pattern $search_stair] set split_return [split $return "+"] set where [lindex $split_return 1] return [list 0 $where] } set search_slide [lsearch $rand_pattern "${pos}-*"] if {$search_slide > -1} { set return [lindex $rand_pattern $search_slide] set split_return [split $return "-"] set where [lindex $split_return 1] return [list 1 $where] } return "-1" } ### proc stairs_slides:players {chan} { global stairs_slides stairs set nicknames "" foreach entry $stairs_slides(players:$chan) { set nickname [lindex $entry 0] lappend nicknames $nickname } return [join $nicknames ", "] } ### proc stairs_slides:join {nick host hand chan arg} { global stairs_slides stairs if {![channel get $chan stairs]} { return } if {![info exists stairs_slides(game_start:$chan)]} {return} if {![info exists stairs_slides(game_join:$chan)] && $stairs(game_after_join) == 0} { return } if {[info exists stairs_slides(game_won:$chan)]} {return} set hostname [stairs_slides:host_return $stairs(user_host_type) $nick [getchanhost $nick $chan]] set id [stairs_slides:id $chan] if {![info exists stairs_slides(players:$chan)]} { lappend stairs_slides(players:$chan) [list $nick $hostname $id] stairs_slides:say [list $nick] $nick $chan 5 0 } else { set search [lsearch $stairs_slides(players:$chan) [list "*" $hostname "*"]] if {$search > -1} { stairs_slides:say "" $nick $chan 3 1 return } set players_num [llength $stairs_slides(players:$chan)] if {$stairs(dice_number) == 1} { if {$players_num == 6} { stairs_slides:say [list $nick] $nick $chan 26 0 return } } else { if {$players_num == 12} { stairs_slides:say [list $nick] $nick $chan 26 0 return } } lappend stairs_slides(players:$chan) [list $nick $hostname $id] stairs_slides:say "" $nick $chan 4 1 stairs_slides:say [list $nick] $nick $chan 5 0 } if {[info exists stairs_slides(autostart_num:$chan)]} { unset stairs_slides(autostart_num:$chan) } } ### proc stairs_slides:id {chan} { global stairs_slides if {![info exists stairs_slides(players:$chan)]} { return 1 } set numbers "" set current_num 0 set found_it 0 foreach entry $stairs_slides(players:$chan) { set num [lindex $entry 2] lappend numbers $num } while {$found_it == 0} { incr current_num if {[lsearch $numbers $current_num] < 0} { set found_it 1 } } return $current_num } ### proc stairs_slides:get {chan id type} { global stairs_slides if {![info exists stairs_slides(players:$chan)]} { return 0 } set return "" foreach entry $stairs_slides(players:$chan) { set nick [lindex $entry 0] set hostname [lindex $entry 1] set num [lindex $entry 2] if {[string equal $id $num]} { if {$type == 0} { set return $nick break } elseif {$type == 1} {set return $hostname ; break} } } return $return } ### proc stairs_slides:say {text nick chan num type} { global stairs_slides stairs set lang [channel get $chan stairs_lang] if {$lang == ""} { set lang [string tolower $stairs(default_lang)] } set counter 0 set replace(%chan%) $chan foreach t $text { incr counter set replace(%msg.$counter%) $t } if {$type == 1} { putserv "NOTICE $nick :[string map [array get replace] $stairs($lang.lang.$num)]" } else { set text [string map [array get replace] $stairs($lang.lang.$num)] foreach t [stairs_slides:wordwrap $text 400] { putserv "PRIVMSG $chan :$t" } } } ### proc stairs_slides:host_return {type user host} { global stairs set ident [lindex [split $host "@"] 0] set uhost [lindex [split $host @] 1] set check_webchat [stairs_slides:check_webchat $host] if {$check_webchat == "1"} { set type 5 } switch $type { 1 { return "*!*@$uhost" } 2 { return "*!$ident@$uhost" } 3 { return "$user!$ident@$uhost" } 4 { return "$user!*@*" } 5 { return "*!$ident@*" } } } ### proc stairs_slides:check_webchat {host} { global stairs set webchat_found 0 set host "*!$host" foreach h $stairs(webchat_hosts) { if {[string match -nocase $h $host]} { set webchat_found 1 break } } return $webchat_found } ### proc stairs_slides:dice_image {num} { global stairs_slides stairs switch $num { 1 { return "⚀" } 2 { return "⚁" } 3 { return "⚂" } 4 { return "⚃" } 5 { return "⚄" } 6 { return "⚅" } } } proc stairs_slides:changenick {nick host hand chan newnick} { global stairs_slides stairs if {![channel get $chan stairs]} { return } if {![info exists stairs_slides(game_start:$chan)]} { return } if {![info exists stairs_slides(players:$chan)]} { return } set hostname [stairs_slides:host_return $stairs(user_host_type) $nick [getchanhost $nick $chan]] set search [lsearch $stairs_slides(players:$chan) [list "*" $hostname "*"]] if {$search > -1} { set id [lindex [lindex $stairs_slides(players:$chan) $search] 2] set stairs_slides(players:$chan) [lreplace $stairs_slides(players:$chan) $search $search] set stairs_slides(players:$chan) [linsert $stairs_slides(players:$chan) $search [list $newnick $hostname $id]] } } ### proc stairs_slides:wordwrap {str {len 100} {splitChr { }}} { set out [set cur {}]; set i 0 foreach word [split [set str][unset str] $splitChr] { if {[incr i [string len $word]]>$len} { lappend out [join $cur $splitChr] set cur [list $word] set i [string len $word] } { lappend cur $word } incr i } lappend out [join $cur $splitChr] } ### proc stairs_slides:special_text {string} { global stairs_slides stairs set map {} foreach {entity number} [regexp -all -inline {&#(\d+);} $string] { lappend map $entity [format \\u%04x [scan $number %d]] } set string [string map [subst -nocomm -novar $map] $string] return $string } ### proc stairs_slides:flood:prot {host chan} { global stairs_slides stairs set number [scan $stairs(flood_prot) %\[^:\]] set timer [scan $stairs(flood_prot) %*\[^:\]:%s] if {[info exists stairs_slides(flood:$host:$chan:act)]} { return 1 } foreach tmr [utimers] { if {[string match "*stairs_slides:remove:flood $host $chan*" [join [lindex $tmr 1]]]} { killutimer [lindex $tmr 2] } } if {![info exists stairs_slides(flood:$host:$chan)]} { set stairs_slides(flood:$host:$chan) 0 } incr stairs_slides(flood:$host:$chan) utimer $timer [list stairs_slides:remove:flood $host $chan] if {$stairs_slides(flood:$host:$chan) > $number} { set stairs_slides(flood:$host:$chan:act) 1 utimer [expr $stairs(ignore_prot) * 60] [list stairs_slides:expire:flood $host $chan] return 1 } else { return 0 } } ### set stairs(projectName) "StairsAndSlides" set stairs(author) "BLaCkShaDoW" set stairs(website) "wWw.TCLScriptS.NeT" set stairs(version) "v1.0" ### proc stairs_slides:remove:flood {host chan} { global stairs_slides if {[info exists stairs_slides(flood:$host:$chan)]} { unset stairs_slides(flood:$host:$chan) } } ### proc stairs_slides:expire:flood {host chan} { global stairs_slides if {[info exists stairs_slides(flood:$host:$chan:act)]} { unset stairs_slides(flood:$host:$chan:act) } } ## #Language # English set stairs(en.lang.1) "\[ \002S\002tairs and \002S\002lides \] You have \002${stairs(seconds_wait)}s\002 to \002${stairs(default_char)}join\002" set stairs(en.lang.2) "\[ \002S\002tairs and \002S\002lides \] already started.." set stairs(en.lang.3) "You already joined \[ \002S\002tairs and \002S\002lides \]" set stairs(en.lang.4) "\[ \002S\002tairs & \002S\002lides \] total \002%msg.1%\002 rolled dice in \002%msg.2%\002" set stairs(en.lang.5) "\002%msg.1%\002 joins \[\002S\002tairs and \002S\002lides \]" set stairs(en.lang.6) "no players, game stopped." set stairs(en.lang.7) "not enough players, next game in \002${stairs(auto_starts_time)}s\002" set stairs(en.lang.8) "no players, next game in \002${stairs(auto_starts_time)}s\002" set stairs(en.lang.9) "\002%msg.1%\002 players this round: %msg.2%" set stairs(en.lang.10) "\[\002S\002tairs and \002S\002lides \] First dice is on the house! \002Auto dice\002 results: %msg.1%" set stairs(en.lang.11) "not enough players, game stopped." set stairs(en.lang.12) "play continues with \002%msg.1%\002. You have \002${stairs(dice_wait)}s\002 to use \002${stairs(default_char)}dice\002 and show your dice talent." set stairs(en.lang.13) "\002%msg.1%\002 idles and is skipped." set stairs(en.lang.14) "\002%msg.1%\002 has been idle \002$stairs(dice_forget)\002 times in a row and is removed from game." set stairs(en.lang.15) "no players, no winner... recycling" set stairs(en.lang.16) "\002%msg.1%\002 throws the dices..and the luck shows : %msg.2%. That means that %msg.1% advances \002%msg.3%\002 places." set stairs(en.lang.17) "\002%msg.1%\002 throws the dice..and the luck shows : %msg.2%. That means that %msg.1% advances \002%msg.3%\002 places." set stairs(en.lang.18) "Hurray ! it seems that the luck is with \002%msg.1%\002. He stepped on place nr. %msg.2% and encounter a \002stair\002 that jumps him directly to place nr. \002%msg.3%\002" set stairs(en.lang.19) "Current place for you %msg.1% --- \002%msg.2%\002 \[STAIRS: %msg.3% ; SLIDES: %msg.4%\]" set stairs(en.lang.20) "Oh not :\( ! bad luck for \002%msg.1%\002. He stepped on place nr. \002%msg.2%\002 and encounter a \002slide\002 that takes him down directly to place nr. \002%msg.3%\002" set stairs(en.lang.21) "Sorry for \002%msg.1%\002, he passed over \002100\002 with (%msg.2% positions) at \002%msg.3%\002 so now is going back to place nr. \002%msg.4%\002." set stairs(en.lang.22) "Welcome to \[ \002S\002tairs and \002S\002lides \] \[Difficulty mode: %msg.1%\]" set stairs(en.lang.23) "\002%msg.1%\002 rolls %msg.2% and wins \[ \002S\002tairs and \002S\002lides \]" set stairs(en.lang.24) "Just \002%msg.1%\002 joined. Play with me ? Answer \002yes\002. %msg.2% seconds remaining." set stairs(en.lang.25) "\002%msg.1%\002 left the channel and is removed from \[ \002S\002tairs and \002S\002lides \]" set stairs(en.lang.26) "players reached... try next round, \002%msg.1%\002" set stairs(en.lang.27) "\002%msg.1%\002 plays first. You have %msg.2% seconds to use \002$stairs(default_char)dice\002 to show your dice talent." set stairs(en.lang.28) "Better be carefull \002%msg.1%\002, it looks like that you have ahead some \002slides\002: %msg.2%" set stairs(en.lang.29) "Your future sounds good \002%msg.1%\002, it looks like that you have ahead some \002stairs\002: %msg.2%" set stairs(en.lang.30) "Mixed feelings about your future \002%msg.1%\002, it looks like that you have ahead some \002stairs\002 and \002slides\002: %msg.2%" set stairs(en.lang.31) "\[ \002S\002tairs and \002S\002lides \] by \002TCL\002scriptS.NeT" set stairs(en.lang.32) "easy" set stairs(en.lang.33) "hard" set stairs(en.lang.34) "\[ \002S\002tairs & \002S\002lides \] \002%msg.1%\002 wins with \002%msg.2%\002 rolled dice" set stairs(en.lang.35) "\002%msg.1%\002 \[%msg.2%\] (wins: \002%msg.3%\002 ; fastest win: \002%msg.4%\002 ; longest: \002%msg.5%\002) ; time wasted: \002%msg.6%\002" set stairs(en.lang.36) "no stats about \002%msg.1%\002." set stairs(en.lang.37) "wins" set stairs(en.lang.38) "TOP \002%msg.1%\002: %msg.2%" set stairs(en.lang.39) "no users in TOP\002%msg.1%\002" set stairs(en.lang.40) "no stats about place number \002\#%msg.1%\002." set stairs(en.lang.41) "Language %msg.1% doesnt exists." set stairs(en.lang.42) "Set language \002%msg.1%\002 as default." set stairs(en.lang.43) "Use \002$stairs(default_char)\002stairs \002lang\002 <lang>" set stairs(en.lang.44) "Use as difficulty modes \002easy\002 sau \002hard\002" set stairs(en.lang.45) "Set as difficulty mode \002%msg.1%\002." set stairs(en.lang.46) "Use \002$stairs(default_char)\002stairs \002difficulty\002 <easy>/<hard>" set stairs(en.lang.47) "HELP: \002$stairs(default_char)stairs\002 - starts game ; \002$stairs(default_char)dice\002 - throw the dice ; \002$stairs(default_char)topXX\002 \[fastest/longest\] - show the top (ex \002$stairs(default_char)top10\002) ; \002$stairs(default_char)sstat\002 <nick/\#> (view stats for a <nick> or place)" set stairs(en.lang.48) "\002%msg.1%\002 broke the \002Fast Win Record\002" set stairs(en.lang.49) "game stopped." set stairs(ro.lang.1) "\[ \002S\002erpi si \002S\002cari \] Ai la dispozitie \002${stairs(seconds_wait)}s\002 sa te inscrii cu \002${stairs(default_char)}join\002" set stairs(ro.lang.2) "\[ \002S\002erpi si \002S\002cari \] a pornit deja.." set stairs(ro.lang.3) "Te-ai inscris deja in \[ \002S\002erpi si \002S\002cari \]." set stairs(ro.lang.4) "\[ \002S\002erpi si \002S\002cari \] \002%msg.1%\002 zaruri aruncate in \002%msg.2%\002" set stairs(ro.lang.5) "\002%msg.1%\002 se alatura \[ \002S\002erpi si \002S\002cari \]" set stairs(ro.lang.6) "nu sunt jucatori, joc oprit." set stairs(ro.lang.7) "nu sunt destui jucatori, urmatorul joc in \002${stairs(auto_starts_time)}s\002" set stairs(ro.lang.8) "nu sunt jucatori, urmatorul joc in ${stairs(auto_starts_time)}s" set stairs(ro.lang.9) "\002%msg.1%\002 jucatori prezenti: %msg.2%" set stairs(ro.lang.10) "\[ \002S\002erpi si \002S\002cari \] Primele aruncari din partea casei ! Rezultate \002zaruri\002: %msg.1%" set stairs(ro.lang.11) "nu sunt destui jucatori, joc oprit." set stairs(ro.lang.12) "jocul continua cu \002%msg.1%\002. Ai la dispozitie \002${stairs(dice_wait)}s\002 sa folosesti \002${stairs(default_char)}dice\002 pentru a ne arata talentul." set stairs(ro.lang.13) "\002%msg.1%\002 intarzie si este sarit." set stairs(ro.lang.14) "\002%msg.1%\002 a intarziat de \002$stairs(dice_forget)\002 ori la rand si este scos din joc." set stairs(ro.lang.15) "nu sunt destui jucatori, niciun jucator... reincerc" set stairs(ro.lang.16) "\002%msg.1%\002 arunca zarurile..si norocul arata : %msg.2%. Asta inseamna ca %msg.1% avanseaza \002%msg.3%\002 locuri." set stairs(ro.lang.17) "\002%msg.1%\002 arunca zarul..si norocul arata : %msg.2%. Asta inseamna ca %msg.1% avanseaza \002%msg.3%\002 locuri." set stairs(ro.lang.18) "Fericire mare ! se pare ca norocul este cu \002%msg.1%\002. A picat pe locul nr. \002%msg.2%\002 unde a gasit o \002scara\002 care il duce direct la locul nr. \002%msg.3%\002" set stairs(ro.lang.19) "Locul curent pentru %msg.1% --- \002%msg.2%\002 \[SCARI: %msg.3% ; SERPI: %msg.4%\]" set stairs(ro.lang.20) "Oh nu :\( ! ghinion pentru \002%msg.1%\002. A picat pe locul nr. %msg.2% unde a gasit un \002sarpe\002 care l-a speriat si l-a trimis in spate la locul nr. \002%msg.3%\002" set stairs(ro.lang.21) "Imi pare rau pentru \002%msg.1%\002, a trecut peste \002100\002 cu (%msg.2% locuri) la \002%msg.3%\002 si acum e trimis in spate la locul nr. \002%msg.4%\002." set stairs(ro.lang.22) "Bine ati venit la \[ \002S\002erpi si \002S\002cari \] \[Mod dificultate: %msg.1%\]" set stairs(ro.lang.23) "\002%msg.1%\002 arunca %msg.2% si castiga \[ \002S\002erpi si \002S\002cari \]" set stairs(ro.lang.24) "Doar \002%msg.1%\002 s-a alaturat. Vrei sa te joci cu mine ? Raspunde cu \002yes\002. Ai %msg.2%s la dispozitie." set stairs(ro.lang.25) "\002%msg.1%\002 a parasit canalul si este scos din jocul \[ \002S\002tairs and \002S\002lides \]" set stairs(ro.lang.26) "toate locurile ocupate... incearca urmatorul joc, \002%msg.1%\002" set stairs(ro.lang.27) "\002%msg.1%\002 arunca primul. Ai la dispozitie %msg.2%s sa folosesti \002$stairs(default_char)dice\002 pentru a ne arata talentul." set stairs(ro.lang.28) "Ai grija \002%msg.1%\002, se pare ca ai in fata cativa \002serpi\002: %msg.2%" set stairs(ro.lang.29) "Viitorul suna bine \002%msg.1%\002, se pare ca ai in fata cateva \002scari\002: %msg.2%" set stairs(ro.lang.30) "Sentimente mixe pentru \002%msg.1%\002, se pare ca ai in fata cateva \002scari\002 si cativa \002serpi\002: %msg.2%" set stairs(ro.lang.31) "\[ \002S\002erpi si \002S\002cari \] de \002TCL\002scriptS.NeT" set stairs(ro.lang.32) "usor" set stairs(ro.lang.33) "greu" set stairs(ro.lang.34) "\[ \002S\002erpi si \002S\002cari \] \002%msg.1%\002 castiga cu \002%msg.2%\002 zaruri aruncate" set stairs(ro.lang.35) "\002%msg.1%\002 \[%msg.2%\] (castiguri: \002%msg.3%\002 ; cel mai scurt castig: \002%msg.4%\002 ; cel mai lung: \002%msg.5%\002) ; timp jucat: \002%msg.6%\002" set stairs(ro.lang.36) "nu sunt statistici pentru \002%msg.1%\002." set stairs(ro.lang.37) "castig." set stairs(ro.lang.38) "TOP \002%msg.1%\002: %msg.2%" set stairs(ro.lang.39) "nu sunt useri in TOP\002%msg.1%\002" set stairs(ro.lang.40) "nu sunt statistici pentru locul \002\#%msg.1%\002." set stairs(ro.lang.41) "Limba \002%msg.1%\002 nu exista." set stairs(ro.lang.42) "Am setat limba \002%msg.1%\002 ca fiind cea standard." set stairs(ro.lang.43) "Foloseste \002$stairs(default_char)\002stairs \002lang\002 <lang>" set stairs(ro.lang.44) "Foloseste ca moduri de dificultate \002easy\002 sau \002hard\002" set stairs(ro.lang.45) "Am setat mod de dificultate \002%msg.1%\002." set stairs(ro.lang.46) "Foloseste \002$stairs(default_char)\002stairs \002difficulty\002 <easy>/<hard>" set stairs(ro.lang.47) "AJUTOR: \002$stairs(default_char)stairs\002 - porneste jocul ; \002$stairs(default_char)dice\002 - arunca zarurile ; \002$stairs(default_char)topXX\002 \[fastest/longest\] - arata topul (ex \002$stairs(default_char)top10\002) ; \002$stairs(default_char)sstat\002 <nick/\#> (vizualizare statisici pentru <nick> sau loc)" set stairs(ro.lang.48) "\002%msg.1%\002 a depasit recordul de \002Cel mai rapid castig\002" set stairs(ro.lang.49) "joc oprit." putlog "\002$stairs(projectName) $stairs(version)\002 coded by $stairs(author) ($stairs(website)): Loaded.." ############## ########################################################## ## END # ##########################################################