Charmander

(probably) finished Liar's Dice

Jul 27th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 6.00 KB | None | 0 0
  1. on *:text:.ldrules:#: {
  2.   notice $nick Each player has two choices during his turn: make a higher bid, or challenge the previous bid as being wrong. The player may bid an increased quantity of any face, or the same quantity of a higher face.
  3.   notice $nick If the current player thinks the previous player's bid is wrong, he challenges it, and then all dice are revealed to determine whether the bid was valid. If the number of the relevant face revealed is at least as high as the bid, then the bid is valid, in which case the bidder wins.
  4.   notice $nick Commands:
  5.   notice $nick 12.ldstart: start a new game.
  6.   notice $nick 12.ldjoin: join a game that is in the signups phase.
  7.   notice $nick 12.ldbid <quantity> <face>: make a bid.
  8.   notice $nick 12.ldbs: call the current bidder a liar.
  9.   notice $nick 12.ldspot: challenge the bid as spot-on.
  10.   notice $nick 12.ldinfo: get info on the current game.
  11.   notice $nick 12.lddice: get your dice rolls resent to you.
  12.   if ($findtok($enders,$nick,32)) {
  13.     notice $nick Administrator Commands:
  14.     notice $nick 07.ldskip: end the signups phase.
  15.     notice $nick 07.ldend: completely end the game.
  16.     notice $nick 07.ldadd: adds a player to the game.
  17.   }
  18. }
  19. alias enders return Charmander Mafe ShakeItUp quinn Engineer
  20. on *:text:.ldskip:#: {
  21.   if (%ld.round != on && %ldld == on && $findtok($enders,$nick,32)) {
  22.     .timer* off
  23.     trans
  24.   }
  25. }
  26. on *:text:.ldstart:#: {
  27.   set %ldchan #
  28.   if (%ldld != on) {
  29.     set %ldld on
  30.     msg # A Liar's Dice game was started by $+(12,$nick,,.) To join, type 12.ldjoin.
  31.     msg # Signups end in 1230 seconds!
  32.     .timer 1 30 trans
  33.     addplayer
  34.   }
  35.   else msg # There is already a game going on!
  36. }
  37. alias trans {
  38.   if ($numtok(%ld.players,32) >= 2) {
  39.     set %ld.round on
  40.     set %ld.it $gettok(%ld.players,$r(1,$numtok(%ld.players,32)),32)
  41.     msg %ldchan Time has ended or the signups phase was skipped, and it is time to bid! $+(12,%ld.it,,) will go first!
  42.   }
  43.   else {
  44.     msg %ldchan Not enough players! Game over.
  45.     unset %ld*
  46.     halt
  47.   }
  48.   tokenize 32 %ld.players
  49.   var %ld.count 1
  50.   while ($0 >= %ld.count) {
  51.     notice $ [ $+ [ %ld.count ] ] Your dice rolls are $+(12,%ld.dice [ $+ [ $ [ $+ [ %ld.count ] ] ] ],,.)
  52.     inc %ld.count
  53.   }
  54.   msg %ldchan To bid, type 12.ldbid <quantity> <face>.
  55. }
  56. on *:text:.ldjoin:#:if (!%ld.round && !$findtok(%ld.players,$nick,32) && %ldld == on) addplayer
  57. on $*:text:/^(\.ldbid (\d|\d\d) \d)$/Si:#: {
  58.   if ((%ld.it == $nick) && (%ld.round == on) && ((!%ld.bid) || ($2 >= $gettok(%ld.bid,1,32) && $3 > $gettok(%ld.bid,2,32)) || ($2 > $gettok(%ld.bid,1,32) && $3 <= $gettok(%ld.bid,2,32)))) {
  59.     set %ld.bid $2 $3
  60.     set %ld.person $nick
  61.     set %ld.lie $iif($findtok(%ld.total,$3,0,32) >= $2,true,false)
  62.     msg # $+(12,$nick,) claims there are $+(12,$2,) dice numbered $+(12,$3,,!)
  63.     setturn
  64.   }
  65. }
  66. on *:text:.ldbs:#: {
  67.   if (%ld.person != $nick && %ld.person && %ld.it == $nick && %ld.round == on) {
  68.     set %ld.winner $iif(%ld.lie == false,$nick,%ld.person)
  69.     msg # $+(12,%ld.winner,) wins the round!
  70.     inc %ld2. [ $+ [ %ld.winner ] ]
  71.     var %ld.count 1
  72.     while (%ld.count <= $var(%ld2.*,0)) {
  73.       set %ld.score %ld.score $+(12,$right($($var(%ld2.*,%ld.count).name),-5),,:,$chr(32),07,$var(%ld2.*,%ld.count).value,)
  74.       inc %ld.count
  75.     }
  76.     msg # %ld.score
  77.     inc %ld3
  78.     if (%ld2. [ $+ [ %ld.winner ] ] == 5) {
  79.       msg # $+(12,%ld3,) rounds played; $+(12,%ld.winner,) wins!
  80.       unset %ld*
  81.     }
  82.     else {
  83.       msg # Starting game $+(12,$calc(%ld3 + 1),,!)
  84.       set %ld.ld on
  85.       msg # A Liar's Dice game was started! To join, type 12.ldjoin.
  86.       msg # Signups end in 1230 seconds!
  87.       .timer 1 30 trans
  88.     }
  89.     unset %ld.*
  90.   }
  91. }
  92. on *:text:.lddice:#:if ($findtok(%ld.players,$nick,32)) notice $nick $+(12,$nick,'s) dice are $+(12,%ld.dice [ $+ [ $nick ] ],,!)
  93. on *:text:.ldend:#: {
  94.   if (%ldld == on && $findtok($enders,$nick,32)) {
  95.     msg # The game was ended by $+(12,$nick,,.) To start a new game, type 12.ldstart.
  96.     unset %ld*
  97.     halt
  98.   }
  99. }
  100. alias setturn {
  101.   if ($findtok(%ld.players,%ld.it,32) == $numtok(%ld.players,32)) set %ld.it $gettok(%ld.players,1,32)
  102.   else set %ld.it $gettok(%ld.players,$calc($findtok(%ld.players,%ld.it,32)+1),32)
  103.   msg %ldchan It is now $+(12,%ld.it,,'s) turn!
  104. }
  105. on *:text:.ldinfo:#:if (%ldld == on) msg # Bid: $+(12,$iif(%ld.bid != $null,%ld.bid,0 0),,s) $chr(124) Turn: $+(12,%ld.it,) $chr(124) Players: $+(12,%ld.players,) $chr(124) Phase: $+(12,$iif(%ld.round == on,Bidding,Signups),)
  106. alias addplayer {
  107.   if (!$findtok(%ld.players,$1,32)) {
  108.     msg %ldchan $+(12,$iif($1,$1,$nick),) has joined the game!
  109.     set %ld.players %ld.players $iif($1,$1,$nick)
  110.     set %ld.dice [ $+ [ $iif($1,$1,$nick) ] ] $sorttok($r(1,6) $r(1,6) $r(1,6) $r(1,6) $r(1,6),32,n)
  111.     set %ld.total %ld.total %ld.dice [ $+ [ $iif($1,$1,$nick) ] ]
  112.     if (%ld.round == on) notice $1 Your dice rolls are $+(12,%ld.dice [ $+ [ $1 ] ])
  113.   }
  114. }
  115. on *:text:.ldspot:#: {
  116.   if (%ld.it == $nick && %ld.bid) {
  117.     set %ld.winner $iif($findtok(%ld.total,$gettok(%ld.bid,2,32),0,32) == $gettok(%ld.bid,1,32),$nick,%ld.person)
  118.     msg # $+(12,%ld.winner,) wins the round!
  119.     inc %ld2. [ $+ [ %ld.winner ] ]
  120.     var %ld.count 1
  121.     while (%ld.count <= $var(%ld2.*,0)) {
  122.       set %ld.score %ld.score $+(12,$right($($var(%ld2.*,%ld.count).name),-5),,:,$chr(32),07,$var(%ld2.*,%ld.count).value,)
  123.       inc %ld.count
  124.     }
  125.     msg # %ld.score
  126.     inc %ld3
  127.     if (%ld2. [ $+ [ %ld.winner ] ] == 5) {
  128.       msg # $+(12,%ld3,) rounds played; $+(12,%ld.winner,) wins!
  129.       unset %ld*
  130.     }
  131.     else {
  132.       msg # Starting game $+(12,$calc(%ld3 + 1),,!)
  133.       set %ld.ld on
  134.       msg # A Liar's Dice game was started! To join, type 12.ldjoin.
  135.       msg # Signups end in 1230 seconds!
  136.       .timer 1 30 trans
  137.     }
  138.     unset %ld.*
  139.   }
  140. }
  141. on $*:text:\.ldadd +/Si:#: {
  142.   if (%ldld == on && $findtok($enders,$nick,32) && !$3) {
  143.     addplayer $2
  144.   }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment