For use with channel #cliques
To change the channel that this script is associated with, replace every occurence of "#cliques" with "#your-channel-here"
You could probably change the clique names as well- color names can get boring. Use the same method as changing the channel name (find/replace).
Usage:
"!start [x [a b c]]" starts the game, will have x number of days (rounds), and uses clique names a, b, and c. If you don't provide the game with a b and c, the defaults are Red Gold and Blue. If you don't provide the game with x, the default is 5.
*** IMPORTANT: If you wish to supply clique names (a b c), you MUST supply the length of the game (x) as well.
The second time you type "!start", the game will be initialized and joining will be closed off.
Typing "join" joins you into the game and adds you to the list of players. This must be said after the first "!start" and before the second one.
After this, the players must send you/the bot the name of the clique they'd like to join. Once all have submitted, the game will progress.
I've added in a failsafe for players leaving the room (often due to a ping timeout/broken pipe/etc.), so if a player leaves the room, the game will eject him/her from the game and make sure that it doesn't freeze up.
If, for some reason, the bot happens to freeze up, use the command "/endclique" to display the latest scores and unset all variables.
To simply reset all variables, type "/endclique 1".
Update log:
v1.13: blue_tetris asked for more credit than one line of the code.
v1.12: Variable help at beginning added, variables cleaned up
v1.1: Support for custom cliques, error fixes
v1.0: Official Hawkee.com release.
/*
CliqueBot 1.13 - by Gforce20 (aka Jeremified) @ irc.waypasteleven.com and irc.teklinks.org
http://www.hawkee.com/snippet/4045/
Game concept by blue_tetris (with Creative Commons 3.0 license http://doiop.com/cc3 )
Detailed rules: http://metanet.2.forumer.com/index.php?showtopic=21609
Variables all start with %clique*, except for %cliqError, which is different so that
the game doesn't reset it when it resets all the other variables (fixed a bug).
%cliqueState defines the game's position. 0/null: off, 1: starting, 2: awaiting input, 3: results
%cliqueSize defines the number of players in the game.
%cliqueDay defines the current day.
%cliqueEnd defines the number of the last day.
%cliqueGroup(One|Two|Thr) defines the names of the cliques.
%cliqueStarter defines who started the game.
%cliquePlayer<Nickname> is set to 1 when a player is playing.
%cliqueNumber<number> is set to the player's nickname, and the number increases relative to %cliqueSize for each player.
%cliqueLoyal<Nickname> is set to 1 when a player was loyal the last round, and 0 when the player wasn't.
%cliqueMember<Nickname> defines the last clique the player was a member of.
%cliqueJoined<Nickname> defines whether the player has joined a clique in the current round or not.
%cliqueJoinSize defines how many players have joined a clique in a certain round.
%clique(One|Two|Thr)Msg defines the message that will be relayed to the player, after he has decided his clique for the round.
%clique(One|Two|Thr)Size defines how many people have joined a specific clique.
%clique(One|Two|Thr)Members lists the members of each group, and is used simply to display the names publicly.
%cliqueScore(One|Two|Thr) defines how many points each group's members receive.
%cliqueIncreasing is used solely for finding each player's number while calculating scores.
%cliqueIncNick (related to %cliqueIncreasing) is used while calculating scores.
%cliqueScore<Nickname> defines the player's score.
%cliquePeer(One|Two|Thr) defines the peer pressure points for each group.
%cliqueDisplaying serves the same purpose as %cliqueIncreasing, except it is used at the end of the game.
%cliqueDisNick serves the same purpose as %cliqueIncNick, except it is used at the end of the game.
%cliqueFindNumber serves the same purpose as %cliqueIncreasing, except it is used only when somebody leaves in midgame.
*/
on *:TEXT:!start*:#cliques: {
if ( %cliqueState == 0 || %cliqueState == $null ) {
set %cliqError 0
set %cliqueState 1
set %cliqueSize 0
set %cliqueDay 1
set %cliqueEnd 5
set %cliqueGroupOne 4Red
set %cliqueGroupTwo 7Gold
set %cliqueGroupThr 12Blue
if ( $2 != $null ) set %cliqueEnd $2
if ( $3 != $null ) set %cliqueGroupOne $3
if ( $4 != $null ) set %cliqueGroupTwo $4
if ( $5 != $null ) set %cliqueGroupThr $5
if ( $6 != $null ) {
set %cliqError 1
endclique 2
}
if ( $2 < 2 ) {
set %cliqError 1
endclique 3
}
if ( $3 != $null && $5 == $null ) {
set %cliqError 1
endclique 4
}
if ( $2 > 50 ) {
set %cliqError 1
endclique 5
}
if ( %cliqError != 1 ) {
set %cliqueStarter $nick
topic #cliques Cliques - by Dave Boutwell $chr(124) Game is open! Type join to get in.
msg #cliques 6A game of clique is about to begin! Type join to enter the current game.
msg #cliques 6 $nick $+ , type !start again when there are enough players.
}
if ( %cliqueState == 1 && %cliqueSize >= 6 && $nick == %cliqueStarter ) {
set %cliqueState 2
topic #cliques Cliques - by Dave Boutwell $chr(124) Game is currently in session.
msg #cliques 6The game has been initialized! Join a clique with few other members for more points.
msg #cliques 6To join a clique, send me a query stating the name of the clique you'd like to join.
msg #cliques 6Please do not include anything else in your message besides the name of the clique.
msg #cliques 6When all the players have joined a clique, the clique members will be revealed.
msg #cliques 6The cliques are %cliqueGroupOne $+ 6, %cliqueGroupTwo $+ 6, and %cliqueGroupThr $+ 6. Start joining!
}
if ( %cliqueState == 2 && %cliqueSize < 6 && $nick == %cliqueStarter ) msg #cliques 6You need at least 6 people to play.
}
}
on *:TEXT:join:#cliques: {
if ( %cliqueState == 1 && %cliquePlayer [ $+ [ $nick ] ] != 1 ) {
inc %cliqueSize
set %cliquePlayer [ $+ [ $nick ] ] 1
set %cliqueNumber [ $+ [ %cliqueSize ] ] $nick
set %cliqueLoyal [ $+ [ $nick ] ] 0
mode #cliques +v $nick
}
}
on *:TEXT:!end:#cliques: if ( %cliqueState == 1 && $nick == %cliqueStarter ) endclique 1
on *:TEXT:*:?: {
if ( %cliqueState == 2 ) {
if ( $1 == %cliqueGroupOne && %cliqueJoined [ $+ [ $nick ] ] != 1 ) {
set %cliqueOneMsg You have joined the %cliqueGroupOne clique.
if ( %cliqueMember [ $+ [ $nick ] ] == %cliqueGroupOne ) {
set %cliqueLoyal [ $+ [ $nick ] ] 1
set %cliqueOneMsg You have chosen to stay loyal to the %cliqueGroupOne clique.
}
set %cliqueMember [ $+ [ $nick ] ] %cliqueGroupOne
inc %cliqueJoinSize
inc %cliqueOneSize
set %cliqueOneMembers %cliqueOneMembers $+ $chr(44) $+ $nick
set %cliqueJoined [ $+ [ $nick ] ] 1
msg $nick %cliqueOneMsg
if ( %cliqueJoinSize == %cliqueSize ) {
set %cliqueState 3
cliquethree
}
}
if ( $1 == %cliqueGroupTwo && %cliqueJoined [ $+ [ $nick ] ] != 1 ) {
set %cliqueTwoMsg You have joined the %cliqueGroupTwo clique.
if ( %cliqueMember [ $+ [ $nick ] ] == %cliqueGroupTwo ) {
set %cliqueLoyal [ $+ [ $nick ] ] 1
set %cliqueTwoMsg You have chosen to stay loyal to the %cliqueGroupTwo clique.
}
set %cliqueMember [ $+ [ $nick ] ] %cliqueGroupTwo
inc %cliqueJoinSize
inc %cliqueTwoSize
set %cliqueTwoMembers %cliqueTwoMembers $+ $chr(44) $+ $nick
set %cliqueJoined [ $+ [ $nick ] ] 1
msg $nick %cliqueTwoMsg
if ( %cliqueJoinSize == %cliqueSize ) {
set %cliqueState 3
cliquethree
}
}
if ( $1 == %cliqueGroupThr && %cliqueJoined [ $+ [ $nick ] ] != 1 ) {
set %cliqueThrMsg You have joined the %cliqueGroupThr clique.
if ( %cliqueMember [ $+ [ $nick ] ] == %cliqueGroupThr ) {
set %cliqueLoyal [ $+ [ $nick ] ] 1
set %cliqueThrMsg You have chosen to stay loyal to the %cliqueGroupThr clique.
}
set %cliqueMember [ $+ [ $nick ] ] %cliqueGroupThr
inc %cliqueJoinSize
inc %cliqueThrSize
set %cliqueThrMembers %cliqueThrMembers $+ $chr(44) $+ $nick
set %cliqueJoined [ $+ [ $nick ] ] 1
msg $nick %cliqueThrMsg
if ( %cliqueJoinSize == %cliqueSize ) {
set %cliqueState 3
cliquethree
}
}
if ( $1 == LOYAL && %cliqueJoined [ $+ [ $nick ] ] != 1 ) {
set %cliqueLoyal [ $+ [ $nick ] ] 1
inc %cliqueJoinSize
if ( %cliqueMember [ $+ [ $nick ] ] == %cliqueGroupOne ) {
inc %cliqueOneSize
set %cliqueOneMembers %cliqueOneMembers $+ $chr(44) $+ $nick
}
if ( %cliqueMember [ $+ [ $nick ] ] == %cliqueGroupTwo ) {
inc %cliqueTwoSize
set %cliqueTwoMembers %cliqueTwoMembers $+ $chr(44) $+ $nick
}
if ( %cliqueMember [ $+ [ $nick ] ] == %cliqueGroupThr ) {
inc %cliqueThrSize
set %cliqueThrMembers %cliqueThrMembers $+ $chr(44) $+ $nick
}
set %cliqueJoined [ $+ [ $nick ] ] 1
msg $nick You have chosen to stay loyal to the %cliqueMember [ $+ [ $nick ] ] clique.
if ( %cliqueJoinSize == %cliqueSize ) {
set %cliqueState 3
cliquethree
}
}
}
}
alias cliquethree {
msg #cliques 6Everyone has joined a clique! Here are the results:
set %cliqueScoreOne $calc( $calc( $calc( %cliqueSize - %cliqueOneSize ) ^ 2 ) * $calc( %cliqueDay + 1 ) )
set %cliqueScoreTwo $calc( $calc( $calc( %cliqueSize - %cliqueTwoSize ) ^ 2 ) * $calc( %cliqueDay + 1 ) )
set %cliqueScoreThr $calc( $calc( $calc( %cliqueSize - %cliqueThrSize ) ^ 2 ) * $calc( %cliqueDay + 1 ) )
msg #cliques 6The %cliqueGroupOne 6clique ( $+ $right(%cliqueOneMembers,$calc($len(%cliqueOneMembers)-1)) $+ ) gained %cliqueScoreOne points.
msg #cliques 6The %cliqueGroupTwo 6clique ( $+ $right(%cliqueTwoMembers,$calc($len(%cliqueTwoMembers)-1)) $+ ) gained %cliqueScoreTwo points.
msg #cliques 6The %cliqueGroupThr 6clique ( $+ $right(%cliqueThrMembers,$calc($len(%cliqueThrMembers)-1)) $+ ) gained %cliqueScoreThr points.
set %cliqueIncreasing 1
unset %cliqueLoyalty
:increasescore
set %cliqueIncNick %cliqueNumber [ $+ [ %cliqueIncreasing ] ]
if ( %cliqueLoyal [ $+ [ %cliqueIncNick ] ] == 1 ) set %cliqueLoyalty %cliqueLoyalty $+ $chr(32) $+ %cliqueIncNick
set %cliqueLoyal [ $+ [ %cliqueIncNick ] ] 0
set %cliqueJoined [ $+ [ %cliqueIncNick ] ] 0
set %cliqueIncMember %cliqueMember [ $+ [ %cliqueIncNick ] ]
set %cliqueScore [ $+ [ %cliqueIncNick ] ] $calc( %cliqueScore [ $+ [ %cliqueIncNick ] ] + $calc( %cliqueScore [ $+ [ %cliqueIncMember ] ] + %cliquePressure [ $+ [ %cliqueIncMember ] ] ) )
inc %cliqueIncreasing
if ( %cliqueNumber [ $+ [ %cliqueIncreasing ] ] != $null ) goto increasescore
msg #cliques 6The loyal members were: %cliqueLoyalty
set %cliquePeerOne $calc( $calc( $calc( %cliqueOneSize ^ 2 ) - %cliqueSize ) * %cliqueDay )
set %cliquePeerTwo $calc( $calc( $calc( %cliqueTwoSize ^ 2 ) - %cliqueSize ) * %cliqueDay )
set %cliquePeerThr $calc( $calc( $calc( %cliqueThrSize ^ 2 ) - %cliqueSize ) * %cliqueDay )
set %cliqueState 2
cliquetwo
}
alias cliquetwo {
inc %cliqueDay
set %cliqueJoinSize 0
set %cliqueOneSize 0
set %cliqueTwoSize 0
set %cliqueThrSize 0
unset %cliqueOneMembers
unset %cliqueTwoMembers
unset %cliqueThrMembers
if ( %cliqueDay == %cliqueEnd ) msg #cliques 6THIS IS THE FINAL DAY!
if ( %cliqueDay > %cliqueEnd ) endclique
if ( %cliqueDay <= %cliqueEnd && %cliqueDay > 1 ) {
msg #cliques 6It is day %cliqueDay $+ . If you wish, you may change your clique again, the
msg #cliques 6same way you joined a clique the first time. You may also stay loyal to your group.
if ( %cliqueDay == 2 ) {
msg #cliques 6However, there is now peer pressure! Loyalty earns you a certain number of points
msg #cliques 6for each group. The numbers are as follow:
}
if ( %cliqueDay > 2 ) msg #cliques 6The peer pressure is as follows:
msg #cliques %cliqueGroupOne $+ 6: %cliquePeerOne
msg #cliques %cliqueGroupTwo $+ 6: %cliquePeerTwo
msg #cliques %cliqueGroupThr $+ 6: %cliquePeerThr
msg #cliques 6Join your clique of choice- to remain loyal, type your current clique or "Loyal" in the query.
}
}
alias endclique {
if ( $1 == $null ) {
set %cliqueDisplaying 1
:displaying
set %cliqueDisNick %cliqueNumber [ $+ [ %cliqueDisplaying ] ]
msg #cliques 6Score for %cliqueDisNick $+ : %cliqueScore [ $+ [ %cliqueDisNick ] ]
inc %cliqueDisplaying
if ( %cliqueNumber [ $+ [ %cliqueDisplaying ] ] != $null ) goto displaying
topic #cliques Cliques - by Dave Boutwell $chr(124) Game is available- type !start [# of days [clique1 clique2 clique3]] to start.
msg #cliques 6The game has ended.
}
if ( $1 == 1 ) msg #cliques 6The game has been forcibly shut down.
if ( $1 == 2 ) msg #cliques 6Error: Too many parameters. !start [no. of rounds [clique1 clique2 clique3]]
if ( $1 == 3 ) msg #cliques 6Error: Bad parameter. The number of rounds must be greater than one.
if ( $1 == 4 ) msg #cliques 6Error: Bad parameter. Must have three cliques: !start [no. of rounds [clique1 clique2 clique3]]
if ( $1 == 5 ) msg #cliques 6Error: Bad parameter. The number of rounds must be fewer than fifty.
unset %clique*
set %cliqueState 0
}
on *:PART:#cliques: {
if ( %cliqueState != 0 && %cliqueState != $null && %cliquePlayer [ $+ [ $nick ] ] != $null ) {
dec %cliqueSize
unset %cliquePlayer [ $+ [ $nick ] ]
set %cliqueFindNumber 0
:findnumber
inc %cliqueFindNumber
if ( %cliqueNumber [ $+ [ %cliqueFindNumber ] ] != $nick ) goto findnumber
unset %cliqueNumber [ $+ [ %cliqueFindNumber ] ]
:shiftnumbers
if ( %cliqueNumber [ $+ [ $calc( %cliqueFindNumber + 1 ) ] ] == $null ) goto doneshift
set %cliqueNumber [ $+ [ %cliqueFindNumber ] ] %cliqueNumber [ $+ [ $calc( %cliqueFindNumber + 1 ) ] ]
inc %cliqueFindNumber
goto shiftnumbers
:doneshift
unset %cliqueNumber [ $+ [ %cliqueFindNumber ] ]
if ( %cliqueJoinSize == %cliqueSize ) {
set %cliqueState 3
cliquethree
}
}
}
on *:JOIN:#cliques: if ( $nick == $me ) topic #cliques Cliques - by Dave Boutwell $chr(124) Game is available- type !start [# of days [clique1 clique2 clique3]] to start.