Version 1.3
How to play Apples to Apples in general
http://www.com-www.com/applestoapples/applestoapples-rules-official-partyset.html
Necessary .txt files
apples.txt (Nouns)
apples2.txt (Adjectives)
Set-up
Download the 2 txt files linked above and place them in your mIRC directory. If you don't know what that directory is: //echo -a $mircdir
Paste the code below into an empty remote file and enjoy :D
Commands
!apples - Starts the game set up, waits for 8 players or somebody to say !go
!join - Joins the game while waiting, cannot (yet) join while the game is going
!go <n>- Starts the game for all players who have !joined to n points, !go with no number is 7 points
!play <card> - Currently set up as a PM to the script holder, use this to play your card. Example: !play Apples -This would play the card Apples, assuming you had that card.
!hand - Notifies you of your hand (you are automatically shown each round however)
!leave - If you are in a game and want to remain in the channel but you want to stop playing, use this.
!end - Ends the game
!choose <card> - If you are the judge, use this to choose the winning card.
!remove <nick> - In the rare occasion somebody leaves and is not removed (only happens if they Ping out and don't return) operators in the channel can use this to remove them from the game.
Notes
- I am new to using tokens so I realize my usage of them is probably weird/terrible, feedback is definitely appreciated. And the rest of my code probably isn't superb either. I'm really looking forward to getting constructive criticism on my code because I know it's nowhere near optimal but I don't exactly know how I could/should improve it
- The game currently just ignores the round if a judge does not choose a card after 60 seconds, I'm not sure how I should deal with that case because it is bound to happen but for now that's what happens.
- !play is currently set to be messaged in a PM. If you want to put this on your own client it can get very annoying getting a ton of PM's, so to change it simply substitute "%chan.ATA" for "?" in the on TEXT event for !play.
- That's all I can think of for now, enjoy!
Update Log
Version 1.1: Minor bugs fixed, added ability to join mid-game, other minor tweaks.
I also made the game end after somebody gets 7 points which is how I am used to playing...if you really don't want it this way you can just remove the last if statement of the !choose on TEXT event.
Version 1.2: Added tons more cards, added !remove feature, change $reads to $freads to improve speed, few other minor alterations. Added !go <n> to go to a certain number of points, default is 7 with !go.
Version 1.3: More minor edits since the last version, like !remove to remove somebody from the game in case they become inactive. Also fixed the bug where the game wouldn't work if somebody has a - in their nick.
;IRC Apples to Apples
;created by tv3636
;5/28/09
;Version 1.3
on *:LOAD:/ATAsetchan $?="Enter the channel you would like to play Apples to Apples in. (Including #)"
alias ATAsetchan { set %chan.ATA $1 | echo -a %chan.ATA is now the active channel for Apples to Apples }
alias ATAgethand {
var %ATA.hand
var %ATA.counter = 0
while (%ATA.counter < 7) {
%ATA.hand = %ATA.hand $+ $getcard $+ *
inc %ATA.counter
}
return %ATA.hand
}
alias getcard {
var %ATA.randnum = $rand(1,%ATA.len1)
.fseek -l apples %ATA.randnum
var %ATA.getcardout = $fread(apples)
while (%ATA.randnum isin %ATA.usedcards) {
%ATA.randnum = $rand(1,%ATA.len1)
.fseek -l apples %ATA.randnum
%ATA.getcardout = $fread(apples)
}
set %ATA.usedcards %ATA.usedcards %ATA.randnum
return %ATA.getcardout
}
on *:TEXT:!apples:%chan.ATA:{
if (%ATA.waiting != $true && %ATA.gameon != $true) {
set %ATA.waiting $true
set %ATA.waitinglist $nick
set %ATA.players 1
msg %chan.ATA 04Starting a game of Apples to Apples, say !join to join and !go to start the game. 4-8 players.
}
}
on *:TEXT:!join:%chan.ATA:{
if (%ATA.waiting == $true && $nick !isin %ATA.waitinglist) {
set %ATA.waitinglist %ATA.waitinglist $nick
inc %ATA.players
msg %chan.ATA Current Players: %ATA.waitinglist
if (%ATA.players == 8) { set %ATA.pointsneeded 7 | ATAgamestart }
}
if (%ATA.waiting == $false && $nick !isin %ATA.waitinglist && %ATA.players < 8) {
set %ATA.waitinglist %ATA.waitinglist $nick
inc %ATA.players
msg %chan.ATA $nick has joined!
ATAdeal $nick
ATAmsghand $nick
}
}
alias ATAgamestart {
.fopen apples apples.txt
.fopen apples2 apples2.txt
set %ATA.len1 $lines(apples.txt)
set %ATA.len2 $lines(apples2.txt)
set %ATA.waiting $false
set %ATA.gameon $true
var %ATA.counter = 1
while (%ATA.counter <= $numtok(%ATA.waitinglist,32) ) {
ATAdeal $gettok(%ATA.waitinglist,%ATA.counter,32)
.timerATA $+ %ATA.counter 1 %ATA.counter ATAmsghand $gettok(%ATA.waitinglist,%ATA.counter,32)
inc %ATA.counter
}
msg %chan.ATA Game to %ATA.pointsneeded points is beginning, to play a card: /msg $me !play <card>
.timerATA 1 %ATA.counter ATAround
}
on *:TEXT:!go*:%chan.ATA:{
if (%ATA.waiting == $true && $nick isin %ATA.waitinglist) {
if ($2 != $null && $calc($2) > 0) set %ATA.pointsneeded $2
else set %ATA.pointsneeded 7
ATAgamestart
}
else if (%ATA.waiting == $true) .notice $nick Sorry, you must be in the game to start it.
}
on *:TEXT:!end:%chan.ATA:{
ATAgameend
}
alias ATAgameend {
if (%ATA.gameon == $true || %ATA.waiting == $true) {
msg %chan.ATA $ATAscores
unset %ATA.*
.timerata* off
msg %chan.ATA Game over!
.fclose apples apples.txt
.fclose apples2 apples2.txt
}
}
on *:TEXT:!play *:?:{
if (%ATA.playable == $true && $findtok(%ATA. [ $+ [ $nick ] ],$2-,1,42) != $null && $nick !isin %ATA.played) {
if ($nick != %ATA.judge) {
var %ATA.tempcard = $2-
.notice $nick Played card $2- successfully!
set %ATA.played %ATA.played $+ $nick $+ * $+ $2- $+ *
inc %ATA.cardsplayed
var %useless = $read(apples.txt,w,$2-)
set %ATA.usedcards $replace(%ATA.usedcards,$chr(32) $+ $readn $+ $chr(32),$chr(32))
set %ATA. [ $+ [ $nick ] ] $reptok(%ATA. [ $+ [ $nick ] ],%ATA.tempcard,$getcard,1,42)
}
else .notice $nick You can't play a card this round, you're the judge!
if (%ATA.cardsplayed == %ATA.players) ATAround2
}
else if ($findtok(%ATA. [ $+ [ $nick ] ],$2-,1,42) == $null && %ATA.gameon == $true) .notice $nick You don't have this card!
}
on *:TEXT:!choose *:%chan.ATA:{
if ($nick == %ATA.judge && %ATA.playable == $false && * $+ $2- $+ * isin %ATA.played && %ATA.chosen != $true) {
var %ATA.hold = $2-
var %ATA.tempnick = $gettok(%ATA.played,$calc($findtok(%ATA.played,%ATA.hold,1,42) - 1),42)
tokenize 42 %ATA. [ $+ [ %ATA.tempnick ] ]
msg %chan.ATA 01,09 $+ %ATA.adjective $+ must describe 01,04 $+ %ATA.hold $+ well, 1 point for %ATA.tempnick $+ !
set %ATA. [ $+ [ %ATA.tempnick ] ] $puttok(%ATA. [ $+ [ %ATA.tempnick ] ],$calc($1 + 1),1,42)
set %ATA.chosen $true
if ($calc($1 + 1) == %ATA.pointsneeded) {
msg %chan.ATA Game over, %ATA.tempnick wins!
ATAgameend
}
else ATAround3
}
}
on *:TEXT:!hand:%chan.ATA:{
ATAmsghand $nick
}
alias ATAdeal {
var %ATA.tempname = $1
set %ATA. [ $+ [ %ATA.tempname ] ] 0 $+ * $+ $ATAgethand
}
alias ATAmsghand {
var %ATA.tempname = $1
tokenize 42 %ATA. [ $+ [ %ATA.tempname ] ]
.notice %ATA.tempname Your Hand: 01,04 $+ $2 $+ $+ , 01,04 $+ $3 $+ $+ , 01,04 $+ $4 $+ $+ , 01,04 $+ $5 $+ $+ , 01,04 $+ $6 $+ $+ , 01,04 $+ $7 $+ $+ , 01,04 $+ $8 $+
}
alias ATAround {
unset %ATA.played
set %ATA.cardsplayed 0
set %ATA.chosen $false
ATAchoosejudge
var %ATA.randnum = $rand(1,%ATA.len2)
.fseek -l apples2 %ATA.randnum
set %ATA.adjective $fread(apples2)
msg %chan.ATA The word for this round is 01,09 $+ %ATA.adjective $+ and the judge for this round is %ATA.judge $+ .
set %ATA.playable $true
.timerataround 1 60 ATAround2
}
alias ATAround2 {
set %ATA.playable $false
set %ATA.played2 Cards Played:
var %x = 1
while (%x <= $numtok(%ATA.played,42)) {
if ($calc(%x % 2) == 0) set %ATA.played2 %ATA.played2 01,04 $+ $gettok(%ATA.played,%x,42) $+ ,
inc %x
}
msg %chan.ATA $left(%ATA.played2,-1)
if ($timer(ataround) != $null) .timerataround off
.notice %ATA.judge Please choose a winning card by saying !choose <card>
.timerataround2 1 60 ATAround3
}
alias ATAround3 {
if ($timer(ataround2) != $null) .timerataround2 off
.timerataround3 1 20 ATAround
var %ATA.counter = 1
msg %chan.ATA $ATAscores
while (%ATA.counter <= $numtok(%ATA.waitinglist,32) ) {
.timerATA $+ %ATA.counter 1 %ATA.counter ATAmsghand $gettok(%ATA.waitinglist,%ATA.counter,32)
inc %ATA.counter
}
}
alias ATAchoosejudge {
if (%ATA.judgenumber == $null) {
set %ATA.judgenumber $rand(1,%ATA.players)
}
if (%ATA.judgenumber < %ATA.players) inc %ATA.judgenumber
else set %ATA.judgenumber 1
set %ATA.judge $gettok(%ATA.waitinglist,%ATA.judgenumber,32)
}
alias ATAscores {
var %ATA.count = 1
var %ATA.scorestring = ~
while (%ATA.count <= %ATA.players) {
var %ATA.holdnick = $gettok(%ATA.waitinglist,%ATA.count,32)
tokenize 42 %ATA. [ $+ [ %ATA.holdnick ] ]
%ATA.scorestring = %ATA.scorestring %ATA.holdnick $+ : $1 ~
inc %ATA.count
}
return Scores: %ATA.scorestring
}
alias ATAleftgame {
if ($1 == %ATA.judge) {
msg %chan.ATA The judge has left, a new round is beginning!
ATAround
}
var %ATA.nickhold = $1
if ($findtok(%ATA.played,%ATA.nickhold,1,42) != $null) set %ATA.played $deltok(%ATA.played,$findtok(%ATA.played,%ATA.nickhold,1,42)-$calc($findtok(%ATA.played,%ATA.nickhold,1,42) + 1),42)
tokenize 32 %ATA.waitinglist
if ($1 != %ATA.nickhold) set %ATA.waitinglist $remove(%ATA.waitinglist,$chr(32) $+ %ATA.nickhold)
else set %ATA.waitinglist $remove(%ATA.waitinglist,%ATA.nickhold $+ $chr(32))
unset %ATA. [ $+ [ %ATA.nickhold ] ]
dec %ATA.players
}
on *:QUIT:{
if ($nick isin %ATA.waitinglist && Ping Timeout !isin $1- && peer !isin $1-) ATAleftgame $nick
}
on *:PART:%chan.ATA:{
if ($nick isin %ATA.waitinglist) ATAleftgame $nick
}
on *:TEXT:!leave:%chan.ATA:{ if ($nick isin %ATA.waitinglist) { ATAleftgame $nick | msg %chan.ATA $nick has left the game } }
on *:NICK:{
if ($nick isin %ATA.waitinglist) {
if ($nick == %ATA.judge) set %ATA.judge $newnick
set %ATA.waitinglist $replace(%ATA.waitinglist,$nick,$newnick)
if ($nick isin %ATA.played) set %ATA.played $replace(%ATA.played,$nick,$newnick)
set %ATA. [ $+ [ $newnick ] ] %ATA. [ $+ [ $nick ] ]
unset %ATA. [ $+ [ $nick ] ]
}
}
on *:TEXT:!remove *:%chan.ATA:{ if ($2 isin %ATA.waitinglist && $nick isin %ATA.waitinglist && $nick isop %chan.ATA) { msg %chan.ATA $2 has been removed from the game | ATAleftgame $2 } }