##################################################################################################
## ##
## Author: Justdabomb2 <email:
edngravy@sbcglobal.net> ##
## Script: Slap Jack Script ##
## Version: v1.0 ##
## Date: 11/13/2006 ##
## Tested with: Eggdrop v1.6.18 ##
## ##
## Commands: !slapjack - Start a new game of slapjack. ##
## !joinsj - Join the current game of slapjack. ##
## !checkcards - Check the card count. ##
## !slap - Slap the current card. ##
## ##
## ##
## Installation: ##
## 1. Save in your script directory as "slapjack.tcl". ##
## 2. add line "source scripts/slapjack.tcl to the bottom of your eggdrop ##
## configuration file. ##
## 3. Rehash or restart your bot, and type "!slapjack" in the channel. ##
## ##
## ##
## You do NOT need to change anything in this script (besides what it tells you to change in ##
## the installation), it should work the way it is right now. ##
## ##
## Newer versions on this script will be if I decide something should be added or a bug ##
## needs to be fixed. ##
## ##
## If you notice any problems with the script, please e-mail them to me at ##
##
edngravy@sbcglobal.net ##
## (although, I haven't played around with TCL scripting since 2006, so I don't remember too ##
## much about it, very sorry. I just though I should upload this since it was the last ##
## script I ever made.) ##
## ##
## ~Thank you! ##
## ##
##################################################################################################
set sjrandcols {
"15"
"4"
}
set cardstouse {
"A" "A" "A" "A"
"1" "1" "1" "1"
"2" "2" "2" "2"
"3" "3" "3" "3"
"4" "4" "4" "4"
"5" "5" "5" "5"
"6" "6" "6" "6"
"7" "7" "7" "7"
"8" "8" "8" "8"
"9" "9" "9" "9"
"10" "10" "10" "10"
"J" "J" "J" "J"
"Q" "Q" "Q" "Q"
"K" "K" "K" "K"
}
set sjwinmsgs {
"Good job"
"Congratulations"
"Wowzers"
"Now win again"
}
set sjcanslap 0
set sjonoroff 0
set sjplayers 0
set sjonround 0
set sjjustwon 0
set sjcheck 0
set sjplayerone ""
set sjplayertwo ""
set sjoncmd "on"
set sjoffcmd "off"
set sjcreator "Justdabomb2"
set sjkickmsg "Good Job!"
set jacksign "J"
set sjplayeronecards 26
set sjplayertwocards 26
set pileamount 0
set playeronecards ""
set playertwocards ""
bind pub - !slapjack activate:slapjack
bind pub - !joinsj join:slapjack
bind pub - !checkcards sjcheck:cards
bind pub - !slap slap:card
proc activate:slapjack {nick host hand chan args} {
global sjonoroff sjoncmd sjoffcmd sjcreator sjplayerone sjplayertwo sjplayers pileamount sjplayeronecards sjplayertwocards
set command [lindex [split $args] 0]
if { $command != "" } {
if { [string tolower $command] == [string tolower $sjoncmd] } {
if { $sjonoroff == 0 } {
set sjonoroff 1
putquick "PRIVMSG $chan :8,1Slap Jack 4,1by 9,1$sjcreator15,1 has just been turned on by 10,1$nick15,1."
putquick "PRIVMSG $chan :15,1Type 8,1!joinsj 15,1to join the round."
putquick "PRIVMSG $chan :15,1The game will start in9,1 30 15,1seconds."
utimer 30 "start:slapjack $nick $host $hand $chan $args"
} else {
putquick "PRIVMSG $chan :15,1Slap Jack is already on."
}
}
if { [string tolower $command] == [string tolower $sjoffcmd] } {
if { $sjonoroff == 1 } {
set sjonoroff 0
set sjplayers 0
set pileamount 0
set sjplayerone ""
set sjplayertwo ""
set sjplayeronecards 26
set sjplayertwocards 26
putquick "PRIVMSG $chan :15,1Slap Jack has just been turned off by 10,1$nick15,1."
} else {
putquick "PRIVMSG $chan :15,1Slap Jack is already off."
}
}
} else {
putquick "PRIVMSG $chan :15,1Type 8,1!slapjack on 15,1or 8,1!slapjack off15,1."
}
}
proc join:slapjack {nick host hand chan args} {
global sjonoroff sjplayers sjplayerone sjplayertwo
if { $sjonoroff == 1 } {
if { $sjplayers == 0 } {
set sjplayerone $nick
set sjplayers 1
putquick "PRIVMSG $chan :10,1$nick 15,1has joined the current game."
putquick "PRIVMSG $chan :15,1Type 8,1!joinsj 15,1if you want to join."
return
}
if { $sjplayers == 1 } {
if { [string tolower $nick] == [string tolower $sjplayerone] } {
putquick "PRIVMSG $chan :10,1$nick, 15,1you have already joined."
} else {
set sjplayertwo $nick
set sjplayers 2
putquick "PRIVMSG $chan :10,1$nick 15,1has joined the current game."
putquick "PRIVMSG $chan :15,1The game will start very shortly."
return
}
}
if { $sjplayers == 2 } {
if { [string tolower $nick] == [string tolower $sjplayerone] || [string tolower $nick] == [string tolower $sjplayertwo] } {
putquick "PRIVMSG $chan :10,1$nick, 15,1you have already joined."
} else {
putquick "PRIVMSG $chan :15,1Sorry 10,1$nick15,1, the current round is full."
return
}
}
} else {
putquick "PRIVMSG $chan :15,1Slap Jack has not been turned on yet."
}
}
proc start:slapjack {nick host hand chan args} {
global sjonoroff sjplayers sjplayerone sjplayertwo
if { $sjonoroff == 1 } {
if { $sjplayers == 2 } {
putquick "PRIVMSG $chan :15,1Slap Jack has beens started. Type 8,1!slap15,1 as fast as you can when you see a Jack."
putquick "PRIVMSG $chan :15,1The players are: 10,1$sjplayerone 15,1and 10,1$sjplayertwo15,1."
utimer 5 "sjshow:cards $nick $host $hand $chan $args"
} else {
putquick "PRIVMSG $chan :15,1There needs to be9,1 2 15,1players to start Slap Jack."
set sjonoroff 0
set sjplayers 0
set sjplayerone ""
}
}
}
proc sjshow:cards {nick host hand chan args} {
global sjonoroff sjplayerone sjplayertwo jacksign cardstouse sjcanslap sjcheck
global sjplayeronecards sjplayertwocards pileamount sjrandcols sjjustwon
utimer 1 "sjcheck:players $nick $host $hand $chan $args"
if { $sjcheck == 1 } {
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1is out of cards!"
utimer 1 "sjshow:winner $nick $host $hand $chan $args"
return
}
if { $sjcheck == 2 } {
putquick "PRIVMSG $chan :10,1$sjplayertwo 15,1is out of cards!"
utimer 1 "sjshow:winner $nick $host $hand $chan $args"
}
if { $sjcheck == 0 } {
if { $sjonoroff == 1 } {
set sjcardone [lindex $cardstouse [rand [llength $cardstouse]]]
set sjcardtwo [lindex $cardstouse [rand [llength $cardstouse]]]
set sjcardonecol [lindex $sjrandcols [rand [llength $sjrandcols]]]
set sjcardtwocol [lindex $sjrandcols [rand [llength $sjrandcols]]]
set sjplayeronecards [expr $sjplayeronecards-1]
set sjplayertwocards [expr $sjplayertwocards-1]
set pileamount [expr $pileamount+2]
set sjjustwon 0
putquick "PRIVMSG $chan :15,1|=-$sjcardonecol,1 $sjcardone 15,1-$sjcardtwocol,1 $sjcardtwo 15,1-=| : Card Pile =9,1 $pileamount "
if { [string tolower $sjcardone] == [string tolower $jacksign] || [string tolower $sjcardtwo] == [string tolower $jacksign] } {
set sjcanslap 1
} else {
utimer 3 "sjshow:cards $nick $host $hand $chan $args"
}
set sjcardone ""
set sjcardtwo ""
}
}
}
proc slap:card {nick host hand chan args} {
global sjcanslap sjplayerone sjplayertwo sjwinmsgs sjkickmsg sjonround
global sjplayeronecards sjplayertwocards pileamount sjjustwon sjonoroff
if { $sjonoroff == 1 } {
if { $sjcanslap == 1 } {
if { [string tolower $nick] == [string tolower $sjplayerone] || [string tolower $nick] == [string tolower $sjplayertwo] } {
set sjwinmsg [lindex $sjwinmsgs [rand [llength $sjwinmsgs]]]
set sjcanslap 0
if { [string tolower $nick] == [string tolower $sjplayerone] } {
putquick "PRIVMSG $chan :10,1$sjplayerone 11,1has won this round! $sjwinmsg"
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1gets the cards from the pile."
set sjplayeronecards [expr $sjplayeronecards+$pileamount]
set pileamount 0
if { $sjonround == 0 } {
set sjonround 1
set sjjustwon 1
putquick "PRIVMSG $chan :15,1That is the end of round13,1 115,1."
putquick "PRIVMSG $chan :15,1The current standings are:"
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1has9,1 $sjplayeronecards 15,1- 10,1$sjplayertwo 15,1has9,1 $sjplayertwocards "
putquick "PRIVMSG $chan :15,1The next round will start in9,1 15 15,1seconds."
utimer 15 "sjshow:cards $nick $host $hand $chan $args"
return
}
if { $sjonround == 1 } {
set sjonround 2
set sjjustwon 1
putquick "PRIVMSG $chan :15,1That is the end of round13,1 215,1."
putquick "PRIVMSG $chan :15,1The current standings are:"
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1has9,1 $sjplayeronecards 15,1- 10,1$sjplayertwo 15,1has9,1 $sjplayertwocards "
putquick "PRIVMSG $chan :15,1The next round will start in9,1 15 15,1seconds."
utimer 15 "sjshow:cards $nick $host $hand $chan $args"
return
}
if { $sjonround == 2 } {
set sjonround 3
set sjjustwon 1
putquick "PRIVMSG $chan :15,1That is the end of round13,1 315,1."
putquick "PRIVMSG $chan :15,1The current standings are:"
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1has9,1 $sjplayeronecards 15,1- 10,1$sjplayertwo 15,1has9,1 $sjplayertwocards "
putquick "PRIVMSG $chan :15,1The next round will start in9,1 15 15,1seconds."
utimer 15 "sjshow:cards $nick $host $hand $chan $args"
return
}
if { $sjonround == 3 } {
set sjonround 4
set sjjustwon 1
putquick "PRIVMSG $chan :15,1That is the end of round13,1 415,1."
putquick "PRIVMSG $chan :15,1The current standings are:"
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1has9,1 $sjplayeronecards 15,1- 10,1$sjplayertwo 15,1has9,1 $sjplayertwocards "
putquick "PRIVMSG $chan :15,1The next round will start in9,1 15 15,1seconds."
utimer 15 "sjshow:cards $nick $host $hand $chan $args"
return
}
if { $sjonround == 4 } {
set sjonround 5
set sjjustwon 1
utimer 1 "sjshow:winner $nick $host $hand $chan $args"
}
}
if { [string tolower $nick] == [string tolower $sjplayertwo] } {
putquick "PRIVMSG $chan :10,1$sjplayertwo 11,1has won this round! $sjwinmsg"
putquick "PRIVMSG $chan :10,1$sjplayertwo 15,1gets the cards from the pile."
set sjplayertwocards [expr $sjplayertwocards+$pileamount]
set pileamount 0
if { $sjonround == 0 } {
set sjonround 1
set sjjustwon 1
putquick "PRIVMSG $chan :15,1That is the end of round13,1 115,1."
putquick "PRIVMSG $chan :15,1The current standings are:"
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1has9,1 $sjplayeronecards 15,1- 10,1$sjplayertwo 15,1has9,1 $sjplayertwocards "
putquick "PRIVMSG $chan :15,1The next round will start in9,1 15 15,1seconds."
utimer 15 "sjshow:cards $nick $host $hand $chan $args"
return
}
if { $sjonround == 1 } {
set sjonround 2
set sjjustwon 1
putquick "PRIVMSG $chan :15,1That is the end of round13,1 215,1."
putquick "PRIVMSG $chan :15,1The current standings are:"
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1has9,1 $sjplayeronecards 15,1- 10,1$sjplayertwo 15,1has9,1 $sjplayertwocards "
putquick "PRIVMSG $chan :15,1The next round will start in9,1 15 15,1seconds."
utimer 15 "sjshow:cards $nick $host $hand $chan $args"
return
}
if { $sjonround == 2 } {
set sjonround 3
set sjjustwon 1
putquick "PRIVMSG $chan :15,1That is the end of round13,1 315,1."
putquick "PRIVMSG $chan :15,1The current standings are:"
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1has9,1 $sjplayeronecards 15,1- 10,1$sjplayertwo 15,1has9,1 $sjplayertwocards "
putquick "PRIVMSG $chan :15,1The next round will start in9,1 15 15,1seconds."
utimer 15 "sjshow:cards $nick $host $hand $chan $args"
return
}
if { $sjonround == 3 } {
set sjonround 4
set sjjustwon 1
putquick "PRIVMSG $chan :15,1That is the end of round13,1 415,1."
putquick "PRIVMSG $chan :15,1The current standings are:"
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1has9,1 $sjplayeronecards 15,1- 10,1$sjplayertwo 15,1has9,1 $sjplayertwocards "
putquick "PRIVMSG $chan :15,1The next round will start in9,1 15 15,1seconds."
utimer 15 "sjshow:cards $nick $host $hand $chan $args"
return
}
if { $sjonround == 4 } {
set sjonround 5
set sjjustwon 1
utimer 1 "sjshow:winner $nick $host $hand $chan $args"
}
}
} else {
putquick "PRIVMSG $chan :10,1$nick, 15,1you aren't even part of this round."
putquick "KICK $chan $nick :$sjkickmsg"
}
} else {
if { [string tolower $nick] == [string tolower $sjplayerone] || [string tolower $nick] == [string tolower $sjplayertwo] } {
if { [string tolower $nick] == [string tolower $sjplayerone] } {
if { $sjjustwon == 1 } {
putquick "NOTICE $nick :10,1$sjplayertwo 15,1slapped the Jack before you."
} else {
set sjplayertwocards [expr $sjplayertwocards+$pileamount]
set pileamount 0
putquick "PRIVMSG $chan :4,1You hit the pile when there wasn't a jack! 4,1$sjplayertwo get the cards in the pile."
}
}
if { [string tolower $nick] == [string tolower $sjplayertwo] } {
if { $sjjustwon == 1 } {
putquick "NOTICE $nick :10,1$sjplayerone 15,1slapped the Jack before you."
} else {
set sjplayeronecards [expr $sjplayeronecards+$pileamount]
set pileamount 0
putquick "PRIVMSG $chan :4,1You hit the pile when there wasn't a jack! 4,1$sjplayerone get the cards in the pile."
}
}
} else {
putquick "PRIVMSG $chan :10,1$nick, 15,1you aren't even part of this round."
putquick "KICK $chan $nick :$sjkickmsg"
}
}
} else {
if { $sjjustwon == 1 } {
if { [string tolower $nick] == [string tolower $sjplayerone] || [string tolower $nick] == [string tolower $sjplayertwo] } {
if { [string tolower $nick] == [string tolower $sjplayerone] } {
putquick "NOTICE $nick :10,1$sjplayertwo 15,1slapped the Jack before you."
}
if { [string tolower $nick] == [string tolower $sjplayertwo] } {
putquick "NOTICE $nick :10,1$sjplayerone 15,1slapped the Jack before you."
}
} else {
putquick "PRIVMSG $chan :10,1$nick, 15,1you aren't even part of this round."
putquick "KICK $chan $nick :$sjkickmsg"
}
} else {
putquick "PRIVMSG $chan :15,1Slap jack isn't on right now."
}
}
}
proc sjshow:winner {nick host hand chan args} {
global sjplayerone sjplayertwo sjplayeronecards sjplayertwocards pileamount sjonoroff sjwinmsgs sjplayers sjonround
set sjwinmsg [lindex $sjwinmsgs [rand [llength $sjwinmsgs]]]
if { $sjplayeronecards > $sjplayertwocards } {
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1has won the game! $sjwinmsg "
putquick "PRIVMSG $chan :15,1Score : 10,1$sjplayerone 15,1=9,1 $sjplayeronecards 15,1cards - 10,1$sjplayertwo 15,1=9,1 $sjplayertwocards "
set sjplayeronecards 26
set sjplayertwocards 26
set pileamount 0
set sjonoroff 0
set sjplayers 0
set sjonround 0
utimer 10 "turnoff:justwon $nick $host $hand $chan $args"
return
}
if { $sjplayeronecards < $sjplayertwocards } {
putquick "PRIVMSG $chan :10,1$sjplayertwo 15,1has won the game! $sjwinmsg "
putquick "PRIVMSG $chan :15,1Score : 10,1$sjplayerone 15,1=9,1 $sjplayeronecards 15,1cards - 10,1$sjplayertwo 15,1=9,1 $sjplayertwocards "
set sjplayeronecards 26
set sjplayertwocards 26
set pileamount 0
set sjonoroff 0
set sjplayers 0
set sjonround 0
utimer 10 "turnoff:justwon $nick $host $hand $chan $args"
return
}
if { $sjplayeronecards == $sjplayertwocards } {
putquick "PRIVMSG $chan :15,1The game was a draw!"
putquick "PRIVMSG $chan :15,1Score : 10,1$sjplayerone 15,1=9,1 $sjplayeronecards 15,1cards - 10,1$sjplayertwo 15,1=9,1 $sjplayertwocards "
set sjplayeronecards 26
set sjplayertwocards 26
set pileamount 0
set sjplayers 0
set sjonoroff 0
set sjonround 0
utimer 10 "turnoff:justwon $nick $host $hand $chan $args"
}
}
proc sjcheck:cards {nick host hand chan args} {
global sjonoroff sjplayerone sjplayertwo sjplayeronecards sjplayertwocards pileamount
if { $sjonoroff == 1 } {
putquick "PRIVMSG $chan :10,1$sjplayerone 15,1has9,1 $sjplayeronecards 15,1cards."
putquick "PRIVMSG $chan :10,1$sjplayertwo 15,1has9,1 $sjplayertwocards 15,1cards."
putquick "PRIVMSG $chan :15,1There are9,1 $pileamount 15,1cards in the card pile."
} else {
putquick "PRIVMSG $chan :15,1Slap Jack isn't on right now."
}
}
proc sjcheck:players {nick host hand chan args} {
global sjplayeronecards sjplayertwocards sjcheck
if { $sjplayeronecards <= 0 || $sjplayertwocards <= 0 } {
if { $sjplayeronecards <= 0 } {
set sjcheck 1
}
if { $sjplayertwocards <= 0 } {
set sjcheck 2
}
} else {
set sjcheck 0
}
}
proc turnoff:justwon {nick host hand chan args} {
global sjjustwon sjplayerone sjplayertwo sjonround
set sjjustwon 0
set sjplayerone ""
set sjplayertwo ""
set sjonround 0
}
putlog "Justdabot's Slap Jack Script Loaded"