IceChat Forums

IceChat 7 => IceChat 7 Scripts => Topic started by: DocBeat on November 15, 2008, 09:59:11 AM

Title: Card Game Scripts
Post by: DocBeat on November 15, 2008, 09:59:11 AM
Quote
Does anyone have any script for card games like draw poker or UNO?

I've played UNO on IRC a few times (it was installed on a mIRC bot) and it works very nice for as many players as you want (very cool if you are bored of trivia)
and it has the following features:

1)Players !join and with !deal the game begins.Other players may type "!join" too while the game is being played (with the disadvantage of having all 7 cards while others have discarded some) and the current
players may !quit (if only one is left he/she is declared the winner and gains points like in trivia).

2)Players discard their cards:   "!play c <number or type or color for colorchange>"
where c is a color initial : c={b,y,r,g,w}
for blue yellow red green and white,number={0,1,2,3,4,5,6,7,8,9} and type={S,R,d2} where S stands for skip ('throw' it and the next player loses his/her turn), R for reverse ('throw' it and reverse the turn of the players)
and d2 for draw two ('throw it' and the next player draws two cards).
The S and R cards only work for games of 3 or more players (they are used as normal color cards for two player game).

Examples:
Code: [Select]
!play y 1
!play r d2 (for discarding a red "draw two cards" card)
!play w b (for playing a white card and changing color to blue)
!play b R  (for playing a blue Reverse card)

There is also a special card wd4 (white draw 4)
Example:
!play wd4 y
Throw the wd4 ( next player draws 4 cards and loses his/her turn) and turn the color yellow.

3)Players !draw 1 card if they want or if they don't have anything else to play.After that they
!pass or !play.

4)Notices are sent (it's best to receive them in your console) to every player whenever their turn comes.The notice includes information
about the turns (who plays next and who plays after the next etc.) the number of cards each player has and your current cards.Also you get notice for every card you draw.

Code: [Select]
Example:
--Botname-- Next: | Player2 - 7 Cards | Player3 - 7 Cards | Player4 - 7 Cards
--Botname-- [6][9][1][S][7][R][W]

5)Announcements in Game:
"Uno! Player1 has one card left!" (after throwing his/her card before the last card)
"Player1 was Skipped! Player2's turn." (when one uses the S card)
"Top Card: [ cardnamehere ]" (on every turn when one has to throw a card)
"Player1 Draws Two and is Skipped! Player2's turn." (when before Player1's turn an S card was used)

6)15 different Cards: [ 0 ] [1][2][3][4][5][6][7][8][9][ S ][R][D2][W][WD4]

Example of game session:
Code: [Select]
<@Bot> Player1 was Skipped! Player2's turn.
<@Bot> Top Card: [S]
<@Player2> !play wd4 g
<@Bot> Player3 draws 4 cards and is skipped!
<@Bot> Player4's turn.
<@Bot> Top Card: [*]
<@Player4> !draw
<@Bot> Player4 draws a card.
<@Player4> !pass
<@Bot> Player4 passes his/her turn.Player1's turn.
<@Player1> !play g S
<@Bot> Uno! Player1 has one card left!
<@Bot> Player2 was Skipped! Player3's turn.
<@Bot> Top Card: [S]

Of course color is added where needed for better functionality ("[ * ]" without color wouldn't mean much...)
It would be nice if anyone is interested in coding it  :lol:
Title: Re: Card Game Scripts
Post by: DocBeat on November 15, 2008, 03:31:40 PM
An update to how the rules are:

1)[ S ] card works for two players too.The one who uses it plays again ([R] still works as a normal card).
2)[D2] makes the next player get skipped and also draw two cards (same with WD4 but two cards less penalty in this case and it can only be used with same color as the top card while WD4 can be used everywhere).
Title: Re: Card Game Scripts
Post by: Snerf on November 15, 2008, 05:02:08 PM
I think someone already made a UNO script, but I am not sure if it was made in IceChat.
Title: Re: Card Game Scripts
Post by: DocBeat on November 16, 2008, 08:28:01 AM
Ok i found the script i was talking about (yeah someone has made a script for mIRC)

Features:
•   108 Card Standard Uno Deck
•   Anyone can start Uno by typing !Uno
•   Only player who started the game and Ops can stop Uno by typing !UnoStop
•   Anyone can join by typing Join (not !Join) even after cards have been delt.
•   Anyone can quit by typing !Quit
•   Leaving the channel removes the user from the game.
•   Leaving the network removes the user from the game.
•   Getting kicked from a channel removes the user from the game.
•   User can change nicks during game play.
•   2-10 Players can play.
•   Person to start game (person who typed !Uno) starts game with !Deal once 2 or more people join.
•   7 cards dealt to each player to start the game.
•   Use !Play <Card Color [b,g,r,y]> <Card Number/Letter [0-9,S,D2,R]>
•   Use !Play <Wild/Wild Draw 4 [w,wd4]> <color [b,g,r,y]>
•   Words are excepted during play. (Typing “!Play Blue Five” and “!play b 5” are the same)
•   !CardCount to see how many cards the other players have.
•   !Score & !Score <Nick>
•   Colors, Letters, Numbers, Words are accepted except for Wild Draw Fours which must be !play WD4 <color> or !play WildDraw4 <color> or !play WildDrawFour <color>
•   User quits, their points are still added to winner’s score.
•   User quits, their cards are added back into deck.
•   Shows cards that have been drawn, not all cards.
•   Scores and Number of games played saved to text file so you can unload without losing rankings.
•   !UnoTop10 to see the top 10 players.
•   !Rank (Average Points per Game, Points and Games)
Title: Re: Card Game Scripts
Post by: DocBeat on November 16, 2008, 08:33:08 AM
mIRC Remote(part1):
Code: [Select]
/* This section contains the help contents for IRC Uno Commands.
!Uno - Use this command in an active Uno channel to start a game of IRC Uno.
Join - Use this command to join a game after someone has typed !Uno
!Deal - If you started a game with !Uno you will be informed to use this command to deal the cards after 1-9 other players join.
!Play - Use !Play <color> <card> to play standard cards, 0-9, Reverse, Skip, DrawTwo. Use !Play W <color> to play a wild and !Play WD4 to play a wild draw for. (Colors, numbers and words are accepted values. Red, r, five, 5, d2, drawtwo, etc.. are all accepted values.)
!Draw - Use this if none of your cards play to draw a card off of the top of the deck.
!Pass - If enabled use this to pass if your drawn card cannot play.
!UnoTop10 <Option> - Type this to see the top 10 players. Options: Average, Games, Points
!Score - Type !Score to see your score, type !Score <Nick> to see someone else's score.
!TopCard - Missed which card was on top? This command will reshow it.
!ShowCards - Missed your cards? This command will let you look again.
!UnoStop - Stops Uno, Ops and the player who started the game are allowed to stop it.
!Quit - Tired of the game? !Quit will remove you.
!Players - Who's playing Uno? Type !Players to find out.
!Rank - If enabled this command will tell you how you rank.
!Count - Tells you how many cards each player has.
*/
;----------------------------------------------------------------------
on *:load: {
  echo -a 0,1---=) 4Loaded 11{15IRC-Uno11} 9by 11{15Lost.Lion@gmail.com11} 0(=---
  if (!$exists(" $+ $scriptdir $+ Uno.txt $+ ")) {
    echo -a 0,1" $+ $scriptdir $+ Uno.txt $+ " not found, creating now.
    write -l1 " $+ $scriptdir $+ Uno.txt $+ " !PlayerList!
    write -l2 " $+ $scriptdir $+ Uno.txt $+ " !Options!.1.0.1.0.0.0.1.0.0
    write -l3 " $+ $scriptdir $+ Uno.txt $+ " !Channels!,#Uno
    write -l4 " $+ $scriptdir $+ Uno.txt $+ " 0
    if (!$exists(" $+ $scriptdir $+ Uno.txt $+ ")) {
      echo -a 0,1" $+ $scriptdir $+ Uno.txt $+ " was not sucessfully created, please make sure $scriptdir is not write-protected and reload Uno.mrc.
      halt
    }
    else {
      echo -a 0,1" $+ $scriptdir $+ Uno.txt $+ " was sucessfully created.
    }
  }
  echo -a 0,1Right click in any Channel or type 4/UnoOptions0 for options.
  unoreset
}
;----------------------------------------------------------------------
on *:text:!deal:%iuno.c2: {
  if ($network == %iuno.np) {
    if (%iuno.dl != 1) {
      if ($nick == %iuno.fp) {
        if ($numtok(%iuno.u,46) >= 2) {
          var %iuno.s 1
          while (%iuno.s <= 7) {
            var %iuno.v 2
            while (%iuno.v <= $numtok(%iuno.u,46)) {
              set %iuno.h. $+ $gettok(%iuno.u,%iuno.v,46) $instok(%iuno.h. [ $+ [ $gettok(%iuno.u,%iuno.v,46) ] ] ,$gettok(%iuno.d,1,46),-0,46)
              set %iuno.d $deltok(%iuno.d,1,46)
              inc %iuno.v
            }
            set %iuno.h. $+ %iuno.fp $instok(%iuno.h. [ $+ [ %iuno.fp ] ] ,$gettok(%iuno.d,1,46),-0,46)
            set %iuno.d $deltok(%iuno.d,1,46)
            inc %iuno.s
          }
          set %iuno.dl 1
          while ($pos($gettok(%iuno.d,1,46),w,0)) {
            set %iuno.d $instok(%iuno.d,$gettok(%iuno.d,1,46),$rand(1,$numtok(%iuno.d,46)),46)
            set %iuno.d $deltok(%iuno.d,1,46)
          }
          set %iuno.dp $instok(%iuno.dp,$gettok(%iuno.d,1,46),1,46)
          set %iuno.d $deltok(%iuno.d,1,46)
          set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
          set %iuno.u $deltok(%iuno.u,1,46)
          if ($pos($gettok(%iuno.dp,1,46),S,1)) {
            skip $network $gettok(%iuno.u,1,46)
          }
          elseif ($pos($gettok(%iuno.dp,1,46),D2,1)) {
            drawtwo $network $gettok(%iuno.u,1,46)
          }
          elseif ($pos($gettok(%iuno.dp,1,46),R,1)) {
            reverse $network $nick
          }
          else {
            showtopcard $network $chan
            unomsg $network $chan $gettok(%iuno.u,1,46) $+ 's turn.
            unocards $network $gettok(%iuno.u,1,46)
          }
        }
        else {
          unomsg $network $chan Sorry but you need 2 people to play.
        }
      }
      else {
        unomsg $network $chan Sorry but %iuno.fp needs to deal.
      }
    }
    else {
      unomsg $network $chan Uno has already been delt.
    }
  }
}
;----------------------------------------------------------------------
on *:text:join:%iuno.c2: {
  if ($network == %iuno.np) {
    if ($numtok(%iuno.u,46) < 10) {
      if (%iuno.dl != 1) {
        set %iuno.u $addtok(%iuno.u,$nick,46)
        unomsg $network $chan $nick is Uno player $chr(35) $+ $findtok(%iuno.u,$nick,1,46)
        unomsg3 $network %iuno.fp There are now $numtok(%iuno.u,46) players for Uno, type !deal in %iuno.c2 to start the game.
      }
      else {
        if (!$findtok(%iuno.u,$nick,46)) {
          set %iuno.u $addtok(%iuno.u,$nick,46)
          unomsg $network $chan Dealing $nick into current Uno game.
          var %iuno.jt 1
          while (%iuno.jt <= 7) {
            if (!$numtok(%iuno.d,46)) {
              set %iuno.ud %iuno.dp
              unset %iuno.dp
              set %iuno.dp $gettok(%iuno.ud,1,46)
              set %iuno.ud $deltok(%iuno.ud,1,46)
              unomsg $network $chan Shuffling discard pile
              newunodeck x
            }
            set %iuno.h. $+ $nick $instok( %iuno.h. [ $+ [ $nick ] ] ,$gettok(%iuno.d,1,46),-0,46)
            set %iuno.d $deltok(%iuno.d,1,46)
            inc %iuno.jt
          }
          unocards $network $nick
        }
        else {
          unomsg $network $chan Hey $nick $+ , you're already playing.
        }
      }
    }
    else {
      unomsg $network $chan Sorry $nick but 10 users are already playing.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!unostop:%iuno.c2: {
  if ($network == %iuno.np) {
    if ($nick == %iuno.fp || $nick isop %iuno.c2) {
      unomsg $network $chan $nick has stopped IRC-Uno: Type !Uno to begin anew.
      unoreset
    }
    else {
      unomsg $network $chan Only %iuno.fp may stop the current game, type !quit to leave the game.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!uno:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    set %iuno.color $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),2,46)
    set %iuno.rank $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),3,46)
    set %iuno.draw $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),4,46)
    set %iuno.comm $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),5,46)
    set %iuno.c $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",3),2-,44)
    unocolors
    if (!%iuno.fp) {
      set %iuno.fp $nick
      set %iuno.c2 $chan
      set %iuno.np $network
      set %iuno.abv m.b.g.m.y.s.d2.d2.r.0.1.2.3.4.5.6.7.8.9
      set %iuno.words r.Blue.Green.Red.Yellow.Skip.Draw2.DrawTwo.Reverse.Zero.One.Two.Three.Four.Five.Six.Seven.Eight.Nine
      newunodeck
      set %iuno.u $addtok(%iuno.u,$nick,46)
      unomsg $network $chan IRC-Uno Started: Type join to join in.
    }
    else {
      unomsg3 $network %iuno.fp An Uno game has already been started in %iuno.c2 $+ .
    }
    unset %iuno.t.u
  }
}
;----------------------------------------------------------------------
on *:text:!play W*D* *:%iuno.c2: {
  if ($network == %iuno.np) {
    if (($2 == WD4) || ($2 == WildDrawFour) || ($2 == WildDraw4)) {
      if (!$findtok(%iuno.abv,$3,46)) set %iuno.pv $gettok(%iuno.abv,$findtok(%iuno.words,$3,46),46)
      elseif ($3 == r) set %iuno.pv m
      else set %iuno.pv $3
      if ($nick == $gettok(%iuno.u,1,46)) {
        if ($pos(%iuno.h. [ $+ [ $nick ] ],zWD4,1)) {
          if ((%iuno.udc != 1) || ((%iuno.udc == 1) && ($pos($gettok(%iuno.h. [ $+ [ $nick ] ],$numtok(%iuno.h. [ $+ [ $nick ] ],46),46),zWD4,1)))) {
            if (%iuno.pv == b || %iuno.pv ==  g || %iuno.pv ==  m || %iuno.pv ==  y ) {
              set %iuno.dp $instok(%iuno.dp,[ %iuno.pv ] $+ $chr(42),1,46)
              set %iuno.h. [ $+ [ $nick ] ] $remtok(%iuno.h. [ $+ [ $nick ] ],zWD4,1,46)
              if ($numtok(%iuno.h. [ $+ [ $nick ] ],46) == 1) unomsg $network $chan  $+ %iuno.cr $+ U $+ %iuno.cy $+ n $+ %iuno.cb $+ o $+ %iuno.cg $+ !  $+ %iuno.fc $+ $nick has one card left!
              set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
              set %iuno.u $deltok(%iuno.u,1,46)
              if (%iuno.pv == b) set %iuno.pv Blue.
              if (%iuno.pv == g) set %iuno.pv Green.
              if (%iuno.pv == m) set %iuno.pv Red.
              if (%iuno.pv == y) set %iuno.pv Yellow.
              if (%iuno.udc) unset %iuno.udc
              var %iuno.d4 1
              while (%iuno.d4 <= 4) {
                if (!$numtok(%iuno.d,46)) {
                  set %iuno.ud %iuno.dp
                  unset %iuno.dp
                  set %iuno.dp $gettok(%iuno.ud,1,46)
                  set %iuno.ud $deltok(%iuno.ud,1,46)
                  unomsg $network $chan Shuffling discard pile
                  newunodeck x
                }
                set [ %iuno.h. [ $+ [ $gettok(%iuno.u,1,46) ] ] ] $instok(%iuno.h. [ $+ [ $gettok(%iuno.u,1,46) ] ],$gettok(%iuno.d,1,46),-0,46)
                set %iuno.d $deltok(%iuno.d,1,46)
                inc %iuno.d4
              }
              unset %iuno.d4
              unomsg $network $chan $gettok(%iuno.u,1,46) draws 4 cards and is skipped!
              drawncards $network $gettok(%iuno.u,1,46) 4
              set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
              set %iuno.u $deltok(%iuno.u,1,46)
              if (!$numtok(%iuno.h. [ $+ [ $nick ] ],46)) {
                score $network $nick
              }
              else {
                unomsg $network $chan $gettok(%iuno.u,1,46) $+ 's turn.
                showtopcard $network $chan
                unocards $network $gettok(%iuno.u,1,46)
              }
            }
            else {
              unomsg $network $chan Please specify a color $nick $+ . !play WD4 [b,g,r,y]
            }
          }
          else {
            unomsg $network $chan Sorry $nick but you must play the card you've drawn or !Pass.
          }
        }
        else {
          unomsg $network $chan You don't have that card $nick $+ .
        }
      }
    }
  }
}
;----------------------------------------------------------------------
on *:text:!play W*:%iuno.c2: {
  if ($network == %iuno.np) {
    if (!$findtok(%iuno.abv,$3,46)) set %iuno.pv $gettok(%iuno.abv,$findtok(%iuno.words,$3,46),46)
    elseif ($3 == r) set %iuno.pv m
    else set %iuno.pv $3
    if ($nick == $gettok(%iuno.u,1,46)) {
      if ($poscs(%iuno.h. [ $+ [ $nick ] ],ZW,1)) {
        if ((%iuno.udc != 1) || ((%iuno.udc == 1) && ($poscs($gettok(%iuno.h. [ $+ [ $nick ] ],$numtok(%iuno.h. [ $+ [ $nick ] ],46),46),ZW,1)))) {
          if (%iuno.pv == b || %iuno.pv == g || %iuno.pv == m || %iuno.pv == y ) {
            set %iuno.dp $instok(%iuno.dp,[ %iuno.pv ] $+ $chr(42),1,46)
            set %iuno.h. [ $+ [ $nick ] ] $remtok(%iuno.h. [ $+ [ $nick ] ],ZW,1,46)
            if ($numtok(%iuno.h. [ $+ [ $nick ] ],46) == 1) unomsg $network $chan  $+ %iuno.cr $+ U $+ %iuno.cy $+ n $+ %iuno.cb $+ o $+ %iuno.cg $+ !  $+ %iuno.fc $+ $nick has one card left!
            if (!$numtok(%iuno.h. [ $+ [ $nick ] ],46)) {
              score $network $nick
            }
            else {
              set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
              set %iuno.u $deltok(%iuno.u,1,46)
              if (%iuno.udc) unset %iuno.udc
              if (%iuno.pv == b) set %iuno.pv Blue.
              if (%iuno.pv == g) set %iuno.pv Green.
              if (%iuno.pv == m) set %iuno.pv Red.
              if (%iuno.pv == y) set %iuno.pv Yellow.
              unomsg $network $chan $nick changed the color to %iuno.pv $gettok(%iuno.u,1,46) $+ 's turn.
              showtopcard $network $chan
              unocards $network $gettok(%iuno.u,1,46)
            }
          }
          else {
            unomsg $network $chan Please specify a color $nick $+ . !play W [b,g,r,y]
          }
        }
        else {
          unomsg $network $chan Sorry $nick but you must play the card you've drawn or !Pass.
        }
      }
      else {
        unomsg $network $chan You don't have that card $nick $+ .
      }
    }
  }
}
;----------------------------------------------------------------------
on *:text:!play *:%iuno.c2: {
  if ($network == %iuno.np) {
    if (!$findtok(%iuno.abv,$2,46)) set %iuno.pv $gettok(%iuno.abv,$findtok(%iuno.words,$2,46),46)
    elseif ($2 == r) set %iuno.pv m
    else set %iuno.pv $2
    if (!$findtok(%iuno.abv,$3,46)) set %iuno.px $gettok(%iuno.abv,$findtok(%iuno.words,$3,46),46)
    else set %iuno.px $3
    set %iuno.pvx %iuno.pv $+ %iuno.px
    if ($nick == $gettok(%iuno.u,1,46)) {
      if ($findtok(%iuno.h. [ $+ [ $nick ] ],%iuno.pvx,0,46)) {
        if (($pos($gettok(%iuno.dp,1,46),[ %iuno.pv ],1)) || (($pos($gettok(%iuno.dp,1,46),[ %iuno.px ],1)) && ($iif($pos($gettok(%iuno.dp,1,46),D2,1),$iif($pos(%iuno.pvx,D2,1),$true,$false),$true)))) {
          if ((%iuno.udc != 1) || ((%iuno.udc == 1) && ($pos($gettok(%iuno.h. [ $+ [ $nick ] ],$numtok(%iuno.h. [ $+ [ $nick ] ],46),46),%iuno.pvx,1)))) {
            set %iuno.dp $instok(%iuno.dp,$upper(%iuno.pvx),1,46)
            set %iuno.h. [ $+ [ $nick ] ] $remtok(%iuno.h. [ $+ [ $nick ] ],%iuno.pvx,1,46)
            if ($numtok(%iuno.h. [ $+ [ $nick ] ],46) == 1) unomsg $network $chan  $+ %iuno.cr $+ U $+ %iuno.cy $+ n $+ %iuno.cb $+ o $+ %iuno.cg $+ !  $+ %iuno.fc $+ $nick has one card left!
            set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
            set %iuno.u $deltok(%iuno.u,1,46)
            if ($numtok(%iuno.h. [ $+ [ $nick ] ],46)) {
              if ($pos($gettok(%iuno.dp,1,46),S,1)) {
                skip $network $gettok(%iuno.u,1,46)
              }
              elseif ($pos($gettok(%iuno.dp,1,46),D2,1)) {
                drawtwo $network $gettok(%iuno.u,1,46)
              }
              elseif ($pos($gettok(%iuno.dp,1,46),R,1)) {
                reverse $network $nick
              }
              else {
                unomsg $network $chan $gettok(%iuno.u,1,46) $+ 's turn.
                showtopcard $network $chan
                unocards $network $gettok(%iuno.u,1,46)
              }
            }
            else {
              score $network $nick
            }
            if (!$numtok(%iuno.h. [ $+ [ $nick ] ],46)) {
              score $network $nick
            }
            if (%iuno.udc) unset %iuno.udc
          }
          else {
            unomsg $network $chan Sorry $nick but you must play the card you've drawn or !Pass.
          }
        }
        else {
          unomsg $network $chan Sorry but that card doesn't play $nick $+ .
        }
      }
      else {
        unomsg $network $chan You don't have that card $nick $+ .
      }
    }
  }
}
;----------------------------------------------------------------------
on *:text:!draw:%iuno.c2: {
  if ($network == %iuno.np) {
    if ($nick == $gettok(%iuno.u,1,46)) {
      if (%iuno.udc != 1) {
        if (!$numtok(%iuno.d,46)) {
          set %iuno.ud %iuno.dp
          unset %iuno.dp
          set %iuno.dp $gettok(%iuno.ud,1,46)
          set %iuno.ud $deltok(%iuno.ud,1,46)
          unomsg $network $chan Shuffling discard pile
          newunodeck x
        }
        set %iuno.h. $+ $nick $instok( %iuno.h. [ $+ [ $nick ] ] ,$gettok(%iuno.d,1,46),-0,46)
        set %iuno.d $deltok(%iuno.d,1,46)
        if (%iuno.draw == 1) set %iuno.udc 1
        drawncards $network $gettok(%iuno.u,1,46) 1
        unomsg $network $chan $nick draws a card.
      }
      else {
        unomsg $network $chan $nick you must play the card you drew or !Pass
      }
    }
  }
}
;----------------------------------------------------------------------
on *:text:!TopCard:%iuno.c2: {
  if ($network == %iuno.np) showtopcard $network $chan
}
;----------------------------------------------------------------------
on *:text:!pass:%iuno.c2: {
  if ($network == %iuno.np) {
    if ($nick == $gettok(%iuno.u,1,46)) {
      if (%iuno.draw == 1) {
        if (%iuno.udc == 1) {
          set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
          set %iuno.u $deltok(%iuno.u,1,46)
          unomsg $network $chan $nick passes, $gettok(%iuno.u,1,46) $+ 's turn.
          showtopcard $network $chan
          unocards $network $gettok(%iuno.u,1,46)
          unset %iuno.udc
        }
        else {
          unomsg $network $chan $nick you must draw before you can pass.
        }
      }
      else {
        unomsg $network $chan $nick you must draw until you can play.
      }
    }
  }
}
;----------------------------------------------------------------------
on *:text:!UnoTop10*:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    if (%iuno.tt == 1) {
      if ($2 == Points) filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter2 */*
      elseif ($2 == Games) filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter3 */*
      else filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter */*
      unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ Uno Top 10 for $iif($2 == Points,Total Points,$iif($2 == Games,Games Played,Average Points Per Game $chr(40) $+ Points/Games $+ $chr(41))) is:
      set %iuno.ptv.n $network
      write -il1 " $+ $scriptdir $+ UnoTop.txt $+ " [Top10]
      write -il12 " $+ $scriptdir $+ UnoTop.txt $+ " [EndTop10]
      play -aq5m1tTop10 unomsg3 $nick " $+ $scriptdir $+ UnoTop.txt $+ " 1000
      write -dl1 " $+ $scriptdir $+ UnoTop.txt $+ "
      write -dl12 " $+ $scriptdir $+ UnoTop.txt $+ "
    }
    else {
      unomsg3 $network $nick Sorry but !UnoTop10 is disabled.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!Rank:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    if (%iuno.rank == 1) {
      filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter2 */*
      if ($read(" $+ $scriptdir $+ UnoTop.txt $+ ", nw, $nick *)) {
        set %iuno.r.t $read(" $+ $scriptdir $+ UnoTop.txt $+ ", nw, $nick *)
        set %iuno.r.p $readn
        filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter3 */*
        set %iuno.r.t $read(" $+ $scriptdir $+ UnoTop.txt $+ ", nw, $nick *)
        set %iuno.r.g $readn
        filter -ffac " $+ $scriptdir $+ Uno.txt $+ " " $+ $scriptdir $+ UnoTop.txt $+ " unofilter */*
        set %iuno.r.t $read(" $+ $scriptdir $+ UnoTop.txt $+ ", nw, $nick *)
        set %iuno.r.a $readn
        unomsg3 $network $nick Your IRC Uno Rankings: %iuno.r.a / %iuno.r.p / %iuno.r.g
        unomsg3 $network $nick (Points per Game / Total Points / Total Games)
      }
      else {
        unomsg3 $network $nick Sorry but you are currently unranked, play Uno to get into the rankings!
      }
    }
    else {
      unomsg3 $network $nick Sorry but individual ranks are disabled.
    }
  }
}
Title: Re: Card Game Scripts
Post by: DocBeat on November 16, 2008, 08:36:37 AM
mIRC Remote (part2)
Code: [Select]
;----------------------------------------------------------------------
on *:text:!score:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    if (%iuno.sco == 1) {
      if ($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$nick)) unomsg3 $network $nick You have $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$nick),1,47) total points and $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$nick),2,47) games played.
      else unomsg3 $network $nick No score saved.
    }
    else {
      unomsg3 $network $nick !Score has been disabled.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!score *:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    if (%iuno.scon == 1) {
      if ($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$2)) unomsg3 $network $nick $2 has $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$2),1,47) total points and $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$2),2,47) games played.
      else unomsg3 $network $nick No score saved for $2
    }
    else {
      unomsg3 $network $nick !Score <Nick> has been disabled.
    }
  }
}
;----------------------------------------------------------------------
on *:text:!showcards:%iuno.c2: {
  if ($network == %iuno.np) unocards $network $nick
}
;----------------------------------------------------------------------
on *:text:!quit:%iuno.c2: {
  if (($findtok(%iuno.u,$nick,46)) && ($network == %iuno.np)) runoplayer $network $nick
}
;----------------------------------------------------------------------
on *:text:!players:%iuno.c2: {
  if ($network == %iuno.np) {
    unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ Current Uno Players are:
    unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ $replace(%iuno.u,.,$chr(32))
  }
}
;----------------------------------------------------------------------
on *:text:!Commands:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    set %iuno.cmnd !Uno, Join, !Deal, !Play <color> <card>, !Play [W/WD4] <color>, !Draw, !Pass, !UnoTop10, !Score, !Score <nick>, !TopCard, !ShowCards, !UnoStop, !Quit, !Players, !Rank, !Count
    unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ Commands for IRC Uno are: %iuno.cmnd
    unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ Type !Help <Command> for more information on a command.
    unset %iuno.cmnd
  }
}
;----------------------------------------------------------------------
on *:text:!Help*:%iuno.c: {
  if ($chanvalid($chan,$network))  {
    set %iuno.cmnd !Uno.Join.!Deal.!Play.!Draw.!Pass.!UnoTop10.!Score.!TopCard.!ShowCards.!UnoStop.!Quit.!Players.!Rank.!Count
    if (!$findtok(%iuno.cmnd,$2,1,46)) {
      unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ Sorry but I cannot find any help for that command.
    }
    else {
      set %iuno.line $findtok(%iuno.cmnd,$2,1,46) + 1
      unomsg3 $network $nick  $+ %iuno.fc $+ , $+ %iuno.bc $+ $Read(" $+ $scriptdir $+ Uno.mrc $+ ", %iuno.line)
      unset %iuno.line
    }
    unset %iuno.cmnd
  }
}
;----------------------------------------------------------------------
on *:text:!Count:%iuno.c2: {
  set %iuno.cnt.tmp 1
  set %iuno.cnt.rp Card Count:
  while (%iuno.cnt.tmp <= $numtok(%iuno.u,46)) {
    set %iuno.cnt.rp %iuno.cnt.rp $+ $chr(32) $+ $gettok(%iuno.u,%iuno.cnt.tmp,46) $numtok(%iuno.h. [ $+ [ $gettok(%iuno.u,%iuno.cnt.tmp,46) ] ],46) :
    inc %iuno.cnt.tmp
  }
  unomsg3 $network $nick %iuno.cnt.rp
  unset %iuno.cnt.*
}
;----------------------------------------------------------------------
on *:KICK:%iuno.c: {
  if (($findtok(%iuno.u,$knick,46)) && ($network == %iuno.np)) runoplayer $network $knick
}
;----------------------------------------------------------------------
on *:NICK: {
  if ($network == %iuno.np)  {
    if ($findtok(%iuno.u,$nick,1,46)) {
      set %iuno.u $reptok(%iuno.u,$nick,$newnick,1,46)
      if ($nick == %iuno.fp) {
        set %iuno.fp $newnick
      }
      set %iuno.h. [ $+ [ $newnick ] ] %iuno.h. [ $+ [ $nick ] ]
      unset %iuno.h. [ $+ [ $nick ] ]
    }
  }
}
;----------------------------------------------------------------------
on *:PART:%iuno.c2: {
  if (($findtok(%iuno.u,$nick,46)) && ($network == %iuno.np)) runoplayer $network $nick
}
;----------------------------------------------------------------------
on *:QUIT: {
  if (($findtok(%iuno.u,$nick,46)) && ($network == %iuno.np)) runoplayer $network $nick
}
;----------------------------------------------------------------------
alias chanvalid {
  if (%iuno.mn == 0) return $true
  elseif ((%iuno.mn == 1) && ($findtok(%iuno.c. [ $+ [ $2 ] ],$1,1,46))) return $true
  else return $false
}
;----------------------------------------------------------------------
alias score {
  unomsg $1 %iuno.c2 We have a winner! Go $2
  set %iuno.u $deltok(%iuno.u,$findtok(%iuno.u,$2,1,46),46)
  var %iuno.sc 1
  var %iuno.cs $numtok(%iuno.u,46)
  while (%iuno.sc <= %iuno.cs) {
    addplayerscoreb $gettok(%iuno.u,%iuno.sc,46)
    inc %iuno.sc
  }
  addplayerscore $2
  unomsg $1 %iuno.c2 $2 gains %iuno.t.u points. For a total of %iuno.t.k points, and a total of $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$2),2,47) games played.
  unoreset
}
;----------------------------------------------------------------------
alias unocid {
  if ($isid) {
    var %e = return $+($chr(3),$color(info),$!unocid: Error -)
    if ($version < 6.0) %e multi-server capability was only added in version 6.0
    if (!$len($1)) %e you must specify a network, server, or wildcarded string as first parameter.
    if (!$regex($ticks,$2,/^-?\d+-?(?:-\d+)?$/)) %e second param should either be a number or a range.
    var %n = $iif($3 isnum 1-15,$3,1), %params = $1 $iif($3 !isnum,$3)
    set -u %result
    scon -at $+ %n unocid % $+ params
    return $gettok(%result,$2,32)
  }
  if ($1 iswm $server) || ($istok($server $network,$1,32)) {
    if ($2) && ($me !ison $2) return
    set -u %result %result $cid
  }
}
;----------------------------------------------------------------------
alias unomsg {
  if ($unocid($1,1,$2)) {
    scid $ifmatch
    msg $2  $+ %iuno.fc $+ , $+ %iuno.bc $+ $3-
    scid -r
  }
}
;----------------------------------------------------------------------
alias unomsg2 {
  if ($unocid($1,1,$2)) {
    scid $ifmatch
    msg $2  $+ %iuno.fc $+ , $+ %iuno.bc $+ $3-
    scid -r
  }
}
;----------------------------------------------------------------------
alias unomsg3 {
  if ($play($1).status) {
    set %iuno.um3n %iuno.ptv.n
    set %iuno.um3c $1
    set %iuno.um3m $2-
  }
  else {
    set %iuno.um3n $1
    set %iuno.um3c $2
    set %iuno.um3m $3-
  }
  if ($unocid(%iuno.um3n,1,%iuno.c2)) {
    scid $ifmatch
    if (%iuno.comm == 0) notice %iuno.um3c  $+ %iuno.fc $+ , $+ %iuno.bc $+ $iif($play(%iuno.um3c).status,$chr(35) $+ $play(%iuno.um3c).pos $+ $chr(32)) $+ %iuno.um3m
    if (%iuno.comm == 1) msg %iuno.um3c  $+ %iuno.fc $+ , $+ %iuno.bc $+ $iif($play(%iuno.um3c).status,$chr(35) $+ $play(%iuno.um3c).pos $+ $chr(32)) $+ %iuno.um3m
    scid -r
  }
}
;----------------------------------------------------------------------
alias runoplayer {
  if ($2 == %iuno.fp) {
    set %iuno.u $deltok(%iuno.u,$findtok(%iuno.u,$2,46),46)
    if ($numtok(%iuno.u,46) <= 1) {
      if ($numtok(%iuno.u,46) != 0) {
        addplayerscoreb $2
        addplayerscore $gettok(%iuno.u,1,46)
        unomsg $1 %iuno.c2 $gettok(%iuno.u,1,46) gains %iuno.t.u points. For a total of %iuno.t.k points, and a total of $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$gettok(%iuno.u,1,46)),2,47) games played.
        unoreset
      }
      else {
        unomsg $1 %iuno.c2 No one is playing Uno t.t Type !Uno to begin anew.
        unoreset
      }
    }
    else {
      set %iuno.fp $gettok(%iuno.u,1,46)
      unomsg $1 %iuno.c2 $2 was removed from the current Uno game.
      unomsg $1 %iuno.c2 %iuno.fp is now in control of the current Uno game.
      unomsg3 $1 %iuno.fp You may now stop Uno by typing !unostop into %iuno.c2
      unomsg $network $chan $gettok(%iuno.u,1,46) $+ 's turn.
      showtopcard $network $chan
      unocards $network $gettok(%iuno.u,1,46)
      if (%iuno.dl == 1) {
        set %iuno.t.x 1
        set %iuno.t.r $numtok(%iuno.h. [ $+ [ $2 ] ],46)
        while (%iuno.t.r >= %iuno.t.x) {
          set %iuno.d $instok(%iuno.d,$gettok(%iuno.h. [ $+ [ $2 ] ],%iuno.t.x,46),$rand(1,$numtok(%iuno.d,46)),46)
          inc %iuno.t.x
        }
        addplayerscoreb $2
        unset %iuno.h. [ $+ [ $2 ] ]
      }
    }
  }
  elseif ($findtok(%iuno.u,$2,0,46)) {
    set %iuno.u $deltok(%iuno.u,$findtok(%iuno.u,$2,1,46),46)
    if ($numtok(%iuno.u,46) <= 1) {
      if ($numtok(%iuno.u,46) != 0) {
        addplayerscoreb $2
        addplayerscore $gettok(%iuno.u,1,46)
        unomsg $1 %iuno.c2 $gettok(%iuno.u,1,46) gains %iuno.t.u points. For a total of %iuno.t.k points, and a total of $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$gettok(%iuno.u,1,46)),2,47) games played.
        unoreset
      }
      else {
        unomsg $1 %iuno.c2 No one is playing Uno t.t Type !Uno to begin anew.
        unoreset
      }
    }
    else {
      unomsg $1 %iuno.c2 $2 was removed from the current Uno game.
      unomsg $network $chan $gettok(%iuno.u,1,46) $+ 's turn.
      showtopcard $network $chan
      unocards $network $gettok(%iuno.u,1,46)
      if (%iuno.dl == 1) {
        set %iuno.t.x 1
        set %iuno.t.r $numtok(%iuno.h. [ $+ [ $2 ] ],46)
        while (%iuno.t.r >= %iuno.t.x) {
          set %iuno.d $instok(%iuno.d,$gettok(%iuno.h. [ $+ [ $2 ] ],%iuno.t.x,46),$rand(1,$numtok(%iuno.d,46)),46)
          inc %iuno.t.x
        }
        addplayerscoreb $2
        unset %iuno.h. [ $+ [ $2 ] ]
      }
    }
  }
}
;----------------------------------------------------------------------
alias addplayerscore {
  set %iuno.t.q $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1),2,47)
  inc %iuno.t.q
  write -l1 " $+ $scriptdir $+ Uno.txt $+ " $addtok($read(" $+ $scriptdir $+ Uno.txt $+ ",1),$1,46)
  if (!$read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1)) write " $+ $scriptdir $+ Uno.txt $+ " $1 0/0
  set %iuno.t.r $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1),1,47)
  set %iuno.t.k $calc(%iuno.t.r + %iuno.t.u)
  $eval(write -s $+ $1 " $+ $scriptdir $+ Uno.txt $+ " $1 %iuno.t.k $+ $chr(47) $+ %iuno.t.q)
}
;----------------------------------------------------------------------
alias addplayerscoreb {
  set %iuno.h. [ $+ [ $1 ] ] $remove(%iuno.h. [ $+ [ $1 ] ],b,g,m,y,z,D4)
  set %iuno.t.s $replace(%iuno.h. [ $+ [ $1 ] ],.,+,S,20,D2,20,R,20,W,50)
  set %iuno.t.s $calc(%iuno.t.s)
  write -l1 " $+ $scriptdir $+ Uno.txt $+ " $addtok($read(" $+ $scriptdir $+ Uno.txt $+ ",1),$1,46)
  if (!$read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1)) write " $+ $scriptdir $+ Uno.txt $+ " $1 0/0
  set %iuno.t.a $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1),2,47)
  inc %iuno.t.a
  set %iuno.t.u $calc(%iuno.t.s + %iuno.t.u)
  $eval(write -s $+ $1 " $+ $scriptdir $+ Uno.txt $+ " $1 $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",s,$1),1,47) $+ $chr(47) $+ %iuno.t.a)
}
;----------------------------------------------------------------------
alias unocards { /* Network, Nick */
  if (%iuno.h. [ $+ [ $2 ] ]) {
    set %iuno.ch. [ $+ [ $2 ] ] $sorttok(%iuno.h. [ $+ [ $2 ] ],46,a)
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],b,$eval($chr(3) $+ %iuno.cb $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],g,$eval($chr(3) $+ %iuno.cg $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],m,$eval($chr(3) $+ %iuno.cr $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],y,$eval($chr(3) $+ %iuno.cy $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],z,$eval($chr(3) $+ %iuno.cw $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
    set %iuno.ch. [ $+ [ $2 ] ] $replace(%iuno.ch. [ $+ [ $2 ] ],.,$chr(93) $+ $chr(3))
    set %iuno.ch. [ $+ [ $2 ] ] %iuno.ch. [ $+ [ $2 ] ] $+ $chr(93)
    unomsg3 $1 $2 %iuno.d4.s %iuno.ch. [ $+ [ $2 ] ]
  }
  else {
    echo -s Uno error - User $2 does not have any cards.
  }
}
;----------------------------------------------------------------------
alias showtopcard {  /* Network, Channel */
  set %iuno.dc $gettok(%iuno.dp,1,46)
  set %iuno.dc $replace(%iuno.dc,b,$eval($chr(3) $+ %iuno.cb $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.dc $replace(%iuno.dc,g,$eval($chr(3) $+ %iuno.cg $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.dc $replace(%iuno.dc,m,$eval($chr(3) $+ %iuno.cr $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.dc $replace(%iuno.dc,y,$eval($chr(3) $+ %iuno.cy $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.dc $replace(%iuno.dc,z,$eval($chr(3) $+ %iuno.cw $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.dc $replace(%iuno.dc,.,$chr(93) $+ $chr(3))
  unomsg $1 $2 Top Card: %iuno.dc $+ $chr(93)
  var %iuno.cc 2
  set %iuno.cl Next:
  while (%iuno.cc <= $numtok(%iuno.u,46)) {
    set %iuno.cl %iuno.cl $chr(124) $gettok(%iuno.u,%iuno.cc,46) - $numtok(%iuno.h. [ $+ [ $gettok(%iuno.u,%iuno.cc,46) ] ],46) Cards
    inc %iuno.cc
  }
  unomsg3 $1 $gettok(%iuno.u,1,46)  $+ %iuno.fc $+ , $+ %iuno.bc $+ %iuno.cl
}
;----------------------------------------------------------------------
alias unoreset {
  unset %iuno.*
  set %iuno.color $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),2,46)
  set %iuno.rank $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),3,46)
  set %iuno.draw $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),4,46)
  set %iuno.comm $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),5,46)
  set %iuno.rwt $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),6,46)
  set %iuno.tt $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),7,46)
  set %iuno.sco $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),8,46)
  set %iuno.scon $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),9,46)
  set %iuno.mn $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",2),10,46)
  set %iuno.c $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",3),2-,44)
  set %iuno.as $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",4),1,32)
  if (%iuno.as > 0) {
    set %iuno.networks $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",4),2,32)
    set %iuno.as3 $gettok($read(" $+ $scriptdir $+ Uno.txt $+ ",4),3-,32)
  }
  set %iuno.as.c 1
  while (%iuno.as.c <= %iuno.as) {
    set %iuno.c. [ $+ [ $gettok(%iuno.networks,%iuno.as.c,44) ] ] $gettok(%iuno.as3,%iuno.as.c,32)
    inc %iuno.as.c
  }
  unocolors
}
;----------------------------------------------------------------------
alias newunodeck {
  if (!$1) set %iuno.ud b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.b1.b2.b3.b4.b5.b6.b7.b8.b9.g0.g1.g2.g3.g4.g5.g6.g7.g8.g9.g1.g2.g3.g4.g5.g6.g7.g8.g9.m0.m1.m2.m3.m4.m5.m6.m7.m8.m9.m1.m2.m3.m4.m5.m6.m7.m8.m9.y0.y1.y2.y3.y4.y5.y6.y7.y8.y9.y1.y2.y3.y4.y5.y6.y7.y8.y9.bD2.bD2.gD2.gD2.mD2.mD2.yD2.yD2.bS.bS.gS.gS.yS.yS.mS.mS.bR.bR.gR.gR.yR.yR.mR.mR.ZW.ZW.ZW.ZW.zWD4.zWD4.zWD4.zWD4
  if ($1) {
    set %iuno.ud $replace(%iuno.ud,b $+ $chr(42),$chr(42),g $+ $chr(42),$chr(42),m $+ $chr(42),$chr(42),y $+ $chr(42),$chr(42))

    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),ZW,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),ZW,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),ZW,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),ZW,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),zWD4,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),zWD4,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),zWD4,1,46)
    if ($findtok(%iuno.ud,$chr(42),0,46)) set %iuno.ud $reptok(%iuno.ud,$chr(42),zWD4,1,46)
  }
  var %iuno.it $numtok(%iuno.ud,46)
  unset %iuno.d
  var %iuno.i = 1
  while (%iuno.i <= %iuno.it) {
    var %iuno.r $rand(1,$numtok(%iuno.ud,46))
    set %iuno.d $instok(%iuno.d,$gettok(%iuno.ud,%iuno.r,46),-0,46)
    set %iuno.ud $deltok(%iuno.ud,%iuno.r,46)
    inc %iuno.i
  }
  unset %iuno.ud
}
;----------------------------------------------------------------------
alias skip {
  set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
  set %iuno.u $deltok(%iuno.u,1,46)
  unomsg $1 %iuno.c2 $2 was Skipped! $gettok(%iuno.u,1,46) $+ 's turn.
  showtopcard $1 %iuno.c2
  unocards $1 $gettok(%iuno.u,1,46)
}
;----------------------------------------------------------------------
alias drawtwo {
  var %iuno.d2v 1
  while (%iuno.d2v <= 2) {
    if (!$numtok(%iuno.d,46)) {
      set %iuno.ud %iuno.dp
      unset %iuno.dp
      set %iuno.dp $gettok(%iuno.ud,1,46)
      set %iuno.ud $deltok(%iuno.ud,1,46)
      unomsg $1 %iuno.c2 Shuffling discard pile
      newunodeck x
    }
    set %iuno.h. [ $+ [ $2 ] ] $instok(%iuno.h. [ $+ [ $2 ] ],$gettok(%iuno.d,1,46),-0,46)
    set %iuno.d $deltok(%iuno.d,1,46)
    inc %iuno.d2v
  }
  set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
  set %iuno.u $deltok(%iuno.u,1,46)
  unomsg $1 %iuno.c2 $2 Draws Two and is Skipped! $gettok(%iuno.u,1,46) $+ 's turn.
  showtopcard $1 %iuno.c2
  drawncards $network $2 2
  unocards $1 $gettok(%iuno.u,1,46)
}
Title: Re: Card Game Scripts
Post by: DocBeat on November 16, 2008, 08:38:46 AM
mIRC Remote last part (part3) :
Code: [Select]
;----------------------------------------------------------------------
alias unocolors {
  if (%iuno.color == 1) {
    set %iuno.cb 12
    set %iuno.cg 9
    set %iuno.cw 0
    set %iuno.fc 0
    set %iuno.bc 1
  }
  else {
    set %iuno.cb 2
    set %iuno.cg 3
    set %iuno.cw 1
    set %iuno.fc 1
    set %iuno.bc 0
  }
  set %iuno.cr 4
  set %iuno.cy 8
}
;----------------------------------------------------------------------
alias drawncards {
  set %iuno.t.m $numtok(%iuno.h. [ $+ [ $2 ] ],46)
  set %iuno.t.l $gettok(%iuno.h. [ $+ [ $2 ] ],%iuno.t.m,46)
  set %iuno.t.j $3
  while (%iuno.t.j > 1) {
    dec %iuno.t.m
    set %iuno.t.l %iuno.t.l $+ $chr(46) $+ $gettok(%iuno.h. [ $+ [ $2 ] ],%iuno.t.m,46)
    dec %iuno.t.j
  }
  set %iuno.t.l $replace(%iuno.t.l,b,$eval($chr(3) $+ %iuno.cb $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.t.l $replace(%iuno.t.l,g,$eval($chr(3) $+ %iuno.cg $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.t.l $replace(%iuno.t.l,m,$eval($chr(3) $+ %iuno.cr $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.t.l $replace(%iuno.t.l,y,$eval($chr(3) $+ %iuno.cy $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.t.l $replace(%iuno.t.l,z,$eval($chr(3) $+ %iuno.cw $+ $chr(44) $+ %iuno.bc $+ $chr(91)))
  set %iuno.t.l $replace(%iuno.t.l,.,$chr(93) $+ $chr(3))
  set %iuno.t.l %iuno.t.l $+ $chr(93)
  unomsg3 $1 $2  $+ %iuno.fc $+ , $+ %iuno.bc $+ Drawn Card(s): %iuno.t.l
}
;----------------------------------------------------------------------
alias reverse { /* Network, Nick */
  var %iuno.ri 2
  while (%iuno.ri <= $numtok(%iuno.u,46)) {
    set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,%iuno.ri,46),1,46)
    inc %iuno.ri
    set %iuno.u $deltok(%iuno.u,%iuno.ri,46)
  }
  if ((%iuno.rwt == 1) && ($numtok(%iuno.u,46) == 2)) {
    set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
    set %iuno.u $deltok(%iuno.u,1,46)
  }
  set %iuno.u $instok(%iuno.u,$gettok(%iuno.u,1,46),-0,46)
  set %iuno.u $deltok(%iuno.u,1,46)
  unomsg $1 %iuno.c2 $2 Reversed it! $gettok(%iuno.u,1,46) $+ 's turn.
  showtopcard $1 %iuno.c2
  unocards $1 $gettok(%iuno.u,1,46)
}
;----------------------------------------------------------------------
alias chanpop {
  did -r UnoOptions 10
  didtok UnoOptions 10 44 %iuno.c
  did -c UnoOptions 10 1
}
;----------------------------------------------------------------------
alias chanpop2 {
  did -r UnoOptions 43
  if (!$1) didtok UnoOptions 43 46 %iuno.c. [ $+ [ $did(53).text ] ]
  if ($1) didtok UnoOptions 43 46 %iuno.c. [ $+ [ $did(40).text ] ]
  did -c UnoOptions 43 1
  if (!$1) did -c UnoOptions 40 $findtok($didtok(UnoOptions,40,44),$did(53).text,1,44)
}
;----------------------------------------------------------------------
alias unofilter { ;Average per Game
  if ($calc($gettok($1,2,32)) > $calc($gettok($2,2,32))) return -1
  if ($calc($gettok($1,2,32)) < $calc($gettok($2,2,32))) return 1
  if ($calc($gettok($1,2,32)) == $calc($gettok($2,2,32))) return 0
}
;----------------------------------------------------------------------
alias unofilter2 { ;Total Points
  if ($gettok($gettok($1,2,32),1,47) > $gettok($gettok($2,2,32),1,47)) return -1
  if ($gettok($gettok($1,2,32),1,47) < $gettok($gettok($2,2,32),1,47)) return 1
  if ($gettok($gettok($1,2,32),1,47) == $gettok($gettok($2,2,32),1,47)) return 0
}
;----------------------------------------------------------------------
alias unofilter3 { ;Total Games
  if ($gettok($gettok($1,2,32),2,47) > $gettok($gettok($2,2,32),2,47)) return -1
  if ($gettok($gettok($1,2,32),2,47) < $gettok($gettok($2,2,32),2,47)) return 1
  if ($gettok($gettok($1,2,32),2,47) == $gettok($gettok($2,2,32),2,47)) return 0
}
;----------------------------------------------------------------------
alias UnoOptions {
  dialog -ma UnoOptions UnoOptions
}
;----------------------------------------------------------------------
alias mnunoupdate {
  set %iuno.networks $didtok(UnoOptions,40,44)
  set %iuno.tv.c 1
  while (%iuno.tv.c <= $numtok(%iuno.networks,44)) {
    set %iuno.tv2.c 1
    while (%iuno.tv2.c <= $numtok(%iuno.c. [ $+ [ $gettok(%iuno.networks,%iuno.tv.c,44) ] ],46)) {
      set %iuno.c $addtok(%iuno.c,$gettok(%iuno.c. [ $+ [ $gettok(%iuno.networks,%iuno.tv.c,44) ] ],%iuno.tv2.c,46),44)
      inc %iuno.tv2.c
    }
    inc %iuno.tv.c
  }
}
;----------------------------------------------------------------------
dialog -l UnoOptions {
  title "IRC Uno by Lost.Lion@gmail.com"
  size -1 -1 300 328
  option pixels notheme
  tab "Options", 6, 1 1 299 300
  tab "Network Options", 38
  tab "Variations", 27
  tab "About", 7
  button "Apply", 1, 220 300 70 25, ok
  button "UnLoad", 23, 7 265 70 25, tab 6
  button "ReLoad", 24, 78 265 70 25, tab 6
  button "Reset", 25, 149 265 70 25, tab 6
  button "Open Uno.txt", 26, 220 265 72 25, tab 6
  button "Remove Network", 47, 158 168 87 20, tab 38 disable
  button "Add Channel", 48, 7 66 87 20, tab 38 disable
  button "Remove Channel", 49, 158 121 87 20, tab 38 disable
  button "Add Channel", 39, 5 32 87 20, tab 6
  button "Remove Channel", 50, 145 74 87 20, tab 6
  button "Cancel", 46, 141 300 65 25
  box "Color Scheme", 8, 5 95 140 55, tab 6
  box "User Communications", 20, 145 95 140 55, tab 6
  box "Rank System", 32, 5 150 140 55, tab 6
  box "Score System", 34, 145 150 140 55, tab 6
  text "Uno Channel(s)", 9, 145 33 84 17, tab 6 center
  text "Uno for mIRC created by Lost.Lion@gmail.com", 11, 6 24 289 17, tab 7
  text "Version 1.13", 12, 6 40 100 17, tab 7
  text "Find me at irc.rizon.net channel #Lovely Nick KovuKun", 14, 5 83 290 17, tab 7
  text "Special Thanks To:", 15, 5 122 291 17, tab 7 center
  text "superlady of #lovely for giving me many ideas and lots of support.", 16, 5 141 291 30, tab 7 center
  text "All the members of #lovely for putting up with the testing and for joining in to help find the bugs.", 17, 5 172 291 30, tab 7 center
  text "RG for making the Dialog Editor and Script Editor that I am Using.", 18, 5 203 291 30, tab 7 center
  text "Networks", 41, 7 150 100 17, tab 38
  text "Channels", 42, 7 103 100 17, tab 38
  text "IRC Uno uses $findcid ($unocid) by FiberOPtics", 44, 5 253 291 17, tab 7 center
  link "http://www.mirc.net", 13, 6 56 146 17, tab 7
  link "http://www.mircscripts.org/users/RG", 19, 58 234 185 17, tab 7
  link "http://www.mirc.net/user/FiberOPtics", 45, 58 272 186 17, tab 7
  radio "Black Background", 4, 7 113 107 17, tab 6 group
  radio "White Background", 5, 7 129 107 17, tab 6
  radio "Notice", 21, 148 113 57 17, tab 6 group
  radio "Message", 22, 148 129 64 17, tab 6
  check "Enable !Rank", 3, 7 168 100 17, tab 6
  check "Reverse acts like Skip with 2 Players", 28, 5 45 196 17, tab 27
  check "Enable !UnoTop10", 33, 7 183 111 17, tab 6
  check "Enable !Score", 36, 147 168 100 17, tab 6
  check "Enable !Score <nick>", 37, 147 184 126 17, tab 6
  check "Enable Multi-Network", 35, 7 26 118 17, tab 38
  check "1 !Draw then !Pass", 2, 5 27 117 17, tab 27
  check "All Networks", 54, 145 68 100 17, tab 38 disable
  check "Cards Dealt Face Up", 29, 5 81 124 17, tab 27 disable
  check "!Play or Lose (No !Draw)", 30, 5 99 140 17, tab 27 disable
  check "DrawTwo/DrawFours Accumulate", 31, 5 117 185 17, tab 27 disable
  check "Wild Draw 4 Doesn't Skip Player", 55, 5 63 195 17, tab 27 disable
  combo 10, 145 51 138 70, tab 6 drop sort
  combo 40, 7 168 149 70, tab 38 drop sort disable
  combo 43, 7 121 149 70, tab 38 drop sort disable
  edit "#Channel", 51, 5 51 138 20, tab 6
  edit "#Channel", 52, 7 47 138 20, tab 38 disable
  edit "Network", 53, 145 47 138 20, tab 38 disable
}
;----------------------------------------------------------------------
on *:dialog:UnoOptions:init:0: {
  if (%iuno.draw == 1) did -c UnoOptions 2
  if (%iuno.rank == 1) did -c UnoOptions 3
  if (%iuno.color == 1) did -c UnoOptions 4
  if (%iuno.color == 2) did -c UnoOptions 5
  if (%iuno.comm == 0) did -c UnoOptions 21
  if (%iuno.comm == 1) did -c UnoOptions 22
  if (%iuno.rwt == 1) did -c UnoOptions 28
  if (%iuno.tt == 1) did -c UnoOptions 33
  if (%iuno.sco == 1) did -c UnoOptions 36
  if (%iuno.scon == 1) did -c UnoOptions 37
  if (%iuno.mn == 1) {
    did -c UnoOptions 35
    didtok UnoOptions 40 44 %iuno.networks
    didtok UnoOptions 43 46 %iuno.c. [ $+ [ $gettok(%iuno.networks,1,44) ] ]
    did -c UnoOptions 40 1
    did -c UnoOptions 43 1
    did -b UnoOptions 39,51,10,50
    did -e UnoOptions 52,53,48,54,43,49,40,47
  }
  chanpop
}
;----------------------------------------------------------------------
on *:dialog:UnoOptions:sclick:23: {
  dialog -x UnoOptions
  unload -rs " $+ $scriptdir $+ Uno.mrc $+ "
}
on *:dialog:UnoOptions:sclick:24: {
  dialog -x UnoOptions
  reload -rs " $+ $scriptdir $+ Uno.mrc $+ "
}
on *:dialog:UnoOptions:sclick:25: {
  dialog -x UnoOptions
  unoreset
}
on *:dialog:UnoOptions:sclick:26: {
  dialog -x UnoOptions
  run " $+ $scriptdir $+ Uno.txt $+ "
}
on *:dialog:UnoOptions:sclick:46: {
  dialog -x UnoOptions
}
on *:dialog:UnoOptions:sclick:39: {
  set %iuno.c $addtok(%iuno.c,$did(51).text,44)
  chanpop
}
on *:dialog:UnoOptions:sclick:50: {
  set %iuno.c $remtok(%iuno.c,$did(10,1).seltext,44)
  did -d UnoOptions 10 $did(10).sel
  chanpop
}
on *:dialog:UnoOptions:sclick:48: {
  if ($did(54).state == 1) {
    set %iuno.c.all $addtok(%iuno.c.all,$did(52).text,46)
    did -r UnoOptions 53
    did -a UnoOptions 53 All
  }
  else {
    set %iuno.c. [ $+ [ $did(53).text ] ] $addtok(%iuno.c. [ $+ [ $did(53).text ] ],$did(52).text,46)
  }
  if (!$findtok($didtok(UnoOptions,40,46),$did(53).text,46)) {
    did -a UnoOptions 40 $did(53).text
  }
  mnunoupdate
  chanpop2
}
on *:dialog:UnoOptions:sclick:49: {
  set %iuno.c. [ $+ [ $did(40).seltext ] ] $remtok(%iuno.c. [ $+ [ $did(40).seltext ] ],$did(43).seltext,46)
  if ($numtok( %iuno.c. [ $+ [ $did(40).seltext ] ],46) == 0) {
    unset %iuno.c. [ $+ [ $did(40).seltext ] ]
    did -d UnoOptions 40 $did(40).sel
  }
  did -c UnoOptions 40 1
  chanpop2 X
}
on *:dialog:UnoOptions:sclick:47: {
  unset %iuno.c. [ $+ [ $did(40).seltext ] ]
  did -d UnoOptions 40 $did(40).sel
  set %iuno.networks $remtok(%iuno.networks,$did(40).seltext,1,44)
  chanpop2
}
on *:dialog:UnoOptions:sclick:40: {
  chanpop2 X
}
on *:dialog:UnoOptions:sclick:35: {
  if ($did(35).state == 1) {
    did -r UnoOptions 40,43
    didtok UnoOptions 40 44 %iuno.networks
    didtok UnoOptions 43 46 %iuno.c. [ $+ [ $gettok(%iuno.networks,1,44) ] ]
    did -c UnoOptions 40 1
    did -c UnoOptions 43 1
    did -b UnoOptions 39,51,10,50
    did -e UnoOptions 52,53,48,54,43,49,40,47
  }
  else {
    did -e UnoOptions 39,51,10,50
    did -b UnoOptions 52,53,48,54,43,49,40,47
  }
}
;----------------------------------------------------------------------
on *:dialog:UnoOptions:close:*: {
  set %iuno.draw $did(2).state
  set %iuno.rank $did(3).state
  set %iuno.rwt $did(28).state
  set %iuno.tt $did(33).state
  set %iuno.sco $did(36).state
  set %iuno.scon $did(37).state
  set %iuno.mn $did(35).state
  if ($did(4).state == 1) set %iuno.color 1
  else set %iuno.color 2
  if ($did(21).state == 1) set %iuno.comm 0
  else set %iuno.comm 1
  unocolors
  write -l3 " $+ $scriptdir $+ Uno.txt $+ " !Channels! $+ $chr(44) $+ %iuno.c
  write -l2 " $+ $scriptdir $+ Uno.txt $+ " !Options! $+ $chr(46) $+ %iuno.color $+ $chr(46) $+ %iuno.rank $+ $chr(46) $+ %iuno.draw $+ $chr(46) $+ %iuno.comm $+ $chr(46) $+ %iuno.rwt $+ $chr(46) $+ %iuno.tt $+ $chr(46) $+ %iuno.sco $+ $chr(46) $+ %iuno.scon $+ $chr(46) $+ %iuno.mn
  unset %iuno.c
  if (%iuno.mn == 0) set %iuno.c $didtok(UnoOptions,10,44)
  else {
    mnunoupdate
  }
  set %iuno.lfc 1
  set %iuno.lft $numtok(%iuno.networks,44) $+ $chr(32) $+ %iuno.networks
  while (%iuno.lfc <= $numtok(%iuno.networks,44)) {
    set %iuno.lft $addtok(%iuno.lft,%iuno.c. [ $+ [ $gettok(%iuno.networks,%iuno.lfc,44) ] ],32)
    inc %iuno.lfc
  }
  write -l4 " $+ $scriptdir $+ Uno.txt $+ " %iuno.lft
  unset %iuno.lfc
  unset %iuno.lft
}
;----------------------------------------------------------------------
menu channel {
  Uno Options: UnoOptions
}
;----------------------------------------------------------------------
on *:unload: {
  unset %iuno.*
  echo -a 0,1--=) 4UnLoaded 11{15IRC-Uno11} 9by 11{15Lost.Lion@gmail.com11} 0(=--
}

mIRC Variables:
Code: [Select]
%iuno.color 1
%iuno.rank 1
%iuno.draw 1
%iuno.comm 0
%iuno.rwt 0
%iuno.tt 1
%iuno.sco 1
%iuno.scon 1
%iuno.mn 0
%iuno.as 0
%iuno.as.c 1
%iuno.cb 12
%iuno.cg 9
%iuno.cw 0
%iuno.fc 0
%iuno.bc 1
%iuno.cr 4
%iuno.cy 8
%iuno.c #Uno
Sorry for the huge code paste the script was really big  - this were the remotes and variables [unmodified].If anyone is good at mIRC scripting he may try his/her skills and convert it for icechat usage  :lol:
Title: Re: Card Game Scripts
Post by: Morio on November 16, 2008, 01:21:45 PM
I could take a shot at this.

So far I only have the stuff for randomly selecting and removing 7 cards from the deck (which would happen every time a person joins a game)

I'm not even gonna look at those mirc scripts, I won't gat anything out of the anyway, but I'll try to keep you updated about the project
Title: Re: Card Game Scripts
Post by: Morio on November 17, 2008, 12:13:39 PM
This is just a short reply to keep you updated.

The project is a bit bigger than I thought (lots of things that need to be checked and such)

This is what I Have:
-players can join
-players are dealt 7 cards at the start (assuming there is 7 cards in the deck)
-the order of players is random
-players can put cards only on their own turn
-you can only put the cards you are allowed to put in a certain situation
-the cards you put are removed from your hand
-the game ends if someone gets rid of all his cards

Still to do:
-add full functionality to the 'draw 2' and 'wild draw 4 cards
-add a !draw command for when you don't have any cards to put
-add some other commands such as !showcards, !count, !pass and a few others
-reshuffle the deck if all cards get picked up
Title: Re: Card Game Scripts
Post by: DocBeat on November 17, 2008, 05:25:40 PM
Sounds quite a big progress to me , good job   :-)
Title: Re: Card Game Scripts
Post by: Snerf on November 17, 2008, 05:36:48 PM
Definately something that will be added to the Main Script Downloads.
Title: Re: Card Game Scripts
Post by: Morio on November 18, 2008, 05:47:46 AM
Now I seem to have a functioning UNO script, It still needs some cleaning and a few added functions, but it fulfills most of the stuff on your list.

-The game gets activated when someone types !uno
-30s later the game starts
-at least 2 players must have joined during this time for the game to start
-when you join you get 7 cards from the top of the deck
-you put cards with the command !play card (color)
-if you don't have any cards to put you draw a new card with the !draw command
-if you still have no card to put after the !draw command you can pass over your turn to the next player with the !pass command
-every time it's your turn your cards are showed to you
-whenever you are made to draw cards, only the drawn cards are shown
-changing nicknames is allowed
-leaving the channel (in any way) removes the player from the game
-the gamestarter or an operator can stop the game at any time with a !stop command
-if there at some point after the game has started is only one player the game ends
-if the cards in the deck run out, the cards that have been put on the table (except the top card) are shuffled and made into a new deck
-you can quit the game with a !quit command
-the command !cards shows you your cards
-the command !card shows the top card
-the command !count shows how may card each player has
-when a player has only one card left the script announce is by saying: "Nickname has UNO"



I have a couple questions about the first card though, right now it's treated almost as a number or wild card, but if it happens to be, let's say a wild draw four card, should the first person then draw 4 cards, and such? Right now it just randomly selects a color and the play continues as if it was a wild card.
Title: Re: Card Game Scripts
Post by: DocBeat on November 18, 2008, 05:46:08 PM
Which card do you mean by "first card"? - as for the wild draw 4 card [WD4] it should work like this:
The next player draws four cards and he/she is skipped.
Example:
----------------------------------------------------------------------
Player one throws his WD4 and chooses yellow as top color.
Player two loses his turn and draws four cards.
Player three's turn : he has to throw a yellow card or change color again.
----------------------------------------------------------------------
(for two player game:player one throws wd4 and chooses color the other
draws four cards and player one plays again)

The [W] card - Example:
----------------------------------------------------------------------
Player one throws his W and changes top color.
Next player has to throw a card of the same color player one has chosen.
----------------------------------------------------------------------

When the d2 card is thrown the next player loses his/her turn (is skipped) and draws
two cards.For two player game the one who used d2 plays again and the
other draws two cards.

When the S card is used the next player loses his/her turn (gets skipped).
For two player game the player who used the S card plays again.

R reverses the turns of the players and for two player game
you choose in UNO options whether it should be used as a
normal card otherwise it does the same as the S card.

One note:Whenever a player's turn comes he shall receive notice about
his current deck and also about the turns of players to play next and the number of cards they own.

Example:
--Botname-- Next: | Player2 - 7 Cards | Player3 - 7 Cards | Player4 - 7 Cards
--Botname-- [6][9][1][ S ][7][R][W]
Title: Re: Card Game Scripts
Post by: Morio on November 18, 2008, 11:23:21 PM
with the "first card" i meant the card that is dealt from the top of the deck when the game is started, should the player that is chosen to start the game, suffer from that card?

the "reverse" card, will always reverse the player order, no options for that.

The reason for not showing the number of cards that each player has, is that I want to reduce the information that can automatically be sent at once. Right now the maximum number of lines sent at once is 4, sending the number of cards would increase this to 5.

I found the rules for the game: http://en.wikipedia.org/wiki/Uno_(game)#Official_rules I will try to implement as many of those as possible.

Also the player running the script will not be able to play, and that will not change, because he would have an advantage, as he can see the other players cards.
Title: Re: Card Game Scripts
Post by: DocBeat on November 19, 2008, 08:14:09 AM
No it doesn't make the first player draw any cards.
If the first card is D2 the first player doesn't draw cards he/she just throws another D2 card or a card of the same color.
If the first card is S or R the same thing (throw same card or same color).

If the first card is WD4 the first player doesn't draw any cards.
However,when first card is WD4 or W i can't remember if it is up to the first player to choose the color
of the card to play or if it is randomly selected.

In any case the first card is treated as color,number or type and it doesn't cause any 'damage'.
Title: Re: Card Game Scripts
Post by: DocBeat on November 19, 2008, 08:40:24 AM
"After the dealer has been selected, seven cards are dealt to each player, and the top card of the stock is exposed to start the discard pile. If the exposed card has a special ability, it is treated as if the dealer played that card, and the special effect occurs (i.e., skip, draw two, reverse, or wild). If the exposed card is a wild draw four, however, it is returned to the deck and the next card is exposed. Play begins with the person to the left of the dealer, i.e. clockwise"

That's from the UNO rules in the wiki link you posted.Weird i have never played uno that way.Seems like WD4 can't be the first card.
Title: Re: Card Game Scripts
Post by: Morio on November 19, 2008, 09:41:00 AM
Ok, I did some changes for the first card. Now it act like there's a "dealer" (a person not actually in the game, but his turn is before the first player), and that this dealer puts the first card, so if it's a Draw 2, the first player draws two cards and such.

The script is pretty much done, I just need to test it a bit more, add some kind of !help command, and add a few comments to the code, so that it's a bit easier to modify, in case you want to make some changes to the rules
Title: Re: Card Game Scripts
Post by: Morio on November 19, 2008, 01:15:20 PM
A couple small changes again, the playing order is now tha same order that players join the game, because shuffling the order caused some weird problem. Also if there are only 2 players, the reverse card now works as a skip card.

I hope Dark`Star doesn't mind me sharing this screenshot of the game in action (he did win the game after all): http://darkstar.necrolounge.org/shots/2008-11-19_0007.png
Title: Re: Card Game Scripts
Post by: DocBeat on November 19, 2008, 04:01:09 PM
Ok few questions (they don't have to do with the script itself but mostly about the installation).

You installed the script on "Morio" and played as "Moriobot".I know little stuff about irc bots and it seems like i'll have to use one if i want to play using your uno script...or not.

Well one of the things i'd like to know is how the bot  has a different hostmask than yours (as i've noticed almost every time i see a bot and its owner)- does it connect to the server via a proxy?
I was once told to do a research on socket bots to find my answer.Sometimes the hostmask is completely different than the owner's some other times only the less significant part of it is different:

@different.same.same

So what happens?Why would the hostmask be different while both the bot and owner are connecting from the same location using the same chat client & without using a proxy in the case above (cuz if it was a proxy the two hostmasks would be completely different unless the proxy server is of the same ISP same country etc. right?)
Sorry to sound so noobish.

What i had in mind is to load the script in icechat (that would be my bot) and then join the same channel using other chat client so that i can play too (of course i'll have same hostmask  :-( ).
I'll be able to play that way right or is there any easier way  :?
Title: Re: Card Game Scripts
Post by: Snerf on November 19, 2008, 04:22:14 PM
You can run the script from your client. The nickname he used is irrelevant. No idea how you think the bot had a different host mask, unless it simply was not authed to Q. All this script is, is running inside IceChat, and connecting to whatever IRC Server and room you wish.

You would not have a different host name, unless you were connecting the two clients from 2 different locations, or you are purposely connecting one through a BNC or whatever.

Now, alot of ppl do not run bots from their own pc's but instead from a Shell Account, thus the totally different host names. But this is not the case with IceChat, as it can not be run from a shell account, as its not really a "bot", it is a client, running some kind of a bot script.

Two totally different things, as its the piece of software that is running and connecting, is what is determined as to if it is really a bot, or just a client, with a script running.

Hope that cleara it up a bit.
Title: Re: Card Game Scripts
Post by: DocBeat on November 19, 2008, 06:52:01 PM
I know the nick moriobot is irrelevant lol.It's just  that so far i have noticed  that all people who have bots (for various tasks in their channel etc.) have different hostmasks from their bots.They must be using irc bouncers right?
And sometimes the hostmask is not totally different:

Bot's Mask:          @ED8BFC99.D3FD7F49.F0258043.IP
Bot Owner's Mask: @AC5144B1.D3FD7F49.F0258043.IP

If i am not mistaken those are called socket bots which i don't know much about.

And as for the Shell Accounts you mentioned that explains me why the bot doesn't disconnect when the owner gets a 'ping timeout'.

Thnx for da help Snerf i can't wait to see Morio's script in downloads section whenever it is ready   :-D

I'm planning to install UNO in icechat and join a channel while the script is running.However,in order to participate in the game i can't be the one with the script running.When the script is loaded in icechat all my connections to servers will be affected by it.So...in order to play i need to connect to the server using another client right?-or is there any other way to do it?
Title: Re: Card Game Scripts
Post by: Morio on November 19, 2008, 10:00:52 PM
if you are running the script, and want to play the game too, you will have to run multiple instances of icechat.

The script should be ready for download in a couple of days
Title: Re: Card Game Scripts
Post by: Snerf on November 19, 2008, 10:40:42 PM
Those hosts are random ones generated by IRC services, to hide people's IP Addresses.
Title: Re: Card Game Scripts
Post by: Morio on November 25, 2008, 09:36:19 AM
The script is finally finished and uploaded to the download section of this site.

If you have any questions about the script, feel free to ask
Title: Re: Card Game Scripts
Post by: A_K1TTEN on November 26, 2008, 10:44:25 AM
alright, well i can get the game to start, get people to join, get the cards delt... but we cant play the cards, haha. we have tried !play y 7, !play 7 y, !play yellow 7, and every combination of that, and cant figure it out... what do we do? OH and we can do all the other commands.
Title: Re: Card Game Scripts
Post by: DarkStar on November 26, 2008, 10:48:58 AM
!play y7, I believe.
Title: Re: Card Game Scripts
Post by: A_K1TTEN on November 26, 2008, 10:50:45 AM
yup thats it, just after i posted my last post, i figured it out, haha
Title: Re: Card Game Scripts
Post by: A_K1TTEN on November 26, 2008, 09:18:42 PM
The script is AWESOME!!! im in a room with 100+ people, and its hectic! haha but tons of fun!
Title: Re: Card Game Scripts
Post by: DocBeat on December 01, 2008, 04:15:54 AM
Nice job Morio i enjoyed playing with friends  :-D
Title: Re: Card Game Scripts
Post by: DocBeat on December 01, 2008, 05:38:18 AM
Do you think that sometime you will be able to go for a 'draw poker' script?-i'll provide you with the main idea:


For 2-8 players.Players may !join or !quit anytime and they can also change nicks while playing.
When a player joins the game he/she receives a specific amount of money/chips (credits) and five cards.

A deck of 53 cards:
hearts, spades,diamonds and clubs

each suit has 13 cards: 2,3,4,5,6,7,8,9,10,JACK,QUEEN,KING,ACE
(in an order of the weakest to the strongest)
and also a wild joker card which represents any card - the lucky player to have it decides what card it will be.


1)Before the players receive their cards, an ante is placed.The ante: a small compulsory bet is made by all the players.How much credits the ante will be that is up to the creator of the script  :-P

2)Players pick up the cards and look at them and then decide if they wish to stay in the game.
If so, a bet must now be placed.
Once all bets are called the first round of betting is complete.
First betting interval: the player to the dealer's left has the right to !bet first; if he does not bet the other players (always to the left - no left or right in a chatroom  :-P) may bet in turn.

When a player's turn to bet comes the FIRST time of the round he/she has three options:

-To "!call" that bet- this means that they must contribute money into the pot so that their contribution matches the bet placed by the previous player.
-To "!raise" the bet value.
-if they do not feel confident they could "!fold" and drop out of the game (Thus,not contribute any money into the pot, but also lose any chance of winning the pot).

If the bet was raised a player has to !call (bet) for second time and agree with the final bet or !fold (he/she can not !raise it again)

After one or two turns of arranging the bet end the players finally place their credits.

3)Players may now choose to exchange any number of cards from their
hand (0-5). This is known as 'the draw'.Exchanging no cards is known as "stand pat".

4)Once the draw is complete a second round of betting takes place.

5)If all bets are called there is a showdown.
The winner is the player with the highest ranking hand.
If only one player remains (ie. no showdown) they will win the pot without having to
expose their cards.


A player wins the tournament when all other players run out of credits.

notes:
Sometimes in home games there is a limit of cards that players may discard (up to three cards),
but professional games usually let you discard all five.
The wild joker card may not be used (depends on preferences i guess).
Title: Re: Card Game Scripts
Post by: DocBeat on December 01, 2008, 05:52:20 AM
Poker Hand Ranking (highest to weakest list):

Five of a Kind
Only possible way to achieve this is by using a wild card (joker).For example:Having four aces and turning your joker into the fifth ace.

Royal Flush
The five highest cards, the 10 through the Ace, all five of the same
suit. A royal flush is actually an ace-high straight flush. Which suit it
is doesn't matter in poker. Two people with royal flushes would tie.

Straight Flush
Any five cards of the same suit in consecutive numerical order.

Four of a Kind
Four cards of the same denomination.

Full House
Any three cards of the same denomination, plus any pair of a
different denomination. Ties are broken first by the three of a kind,
then the pair.Example: three sevens and two threes.

Flush
Any five non-consecutive cards of the same suit.

Straight
Any five consecutive cards of mixed suits. Ace can be high or low.

Three of a Kind
Three cards of the same denomination.

Two Pair
Any two cards of the same denomination, plus any other two cards
of the same denomination. If both hands have the same high pair, the
second pair wins. If both pairs tie, the high card wins.

Pair
Any two cards of the same denomination. In a tie, the high card wins.

High Card
If no other hand is achieved, the highest card held wins.

source: http://www.pokerpages.com/pokerinfo/rank/index.htm (http://www.pokerpages.com/pokerinfo/rank/index.htm)

Title: Re: Card Game Scripts
Post by: Morio on December 01, 2008, 06:42:35 AM
A lot of the stuff from the uno script could be applied to this one too.

There should be a max 5 player limit though (just to make sure there are enough cards for everyone 5 x 5 x 2 = 50, total number of cards: 53 with joker)

The function for checking your hand might be a bit complicated, but very doable, you just have to find out a good order to check the hand, to minimize the work. Like first check for flush, if true you can skip pair, three of a kind, full house etc. then check for five of a kind, then 4 of a kind then 3 of a kind, then full house, then pair, two pairs. And as there are only 10 possible straights, one could make a loop for checking all of them, without slowing down the script a lot.

The betting part might actually be the most complicated thing.

I might take a shot at this when I have the time and inspiration
Title: Re: Card Game Scripts
Post by: DocBeat on December 01, 2008, 07:12:01 PM
Yeah indeed it has stuff that could be taken from uno associated with player turns,players receiving cards from the deck,players joining,dropping out of game and changing names,card drawing etc.

Good to hear that hand rankings and checking hand isn't as big issue as i thought.I imagined it would be far more difficult than the betting part.The loop for Straights kills 3 birds with one rock by checking for the 10 possible straights it also finds if there will be any Straight Flushes or Royal Flushes since all 3 ranks demand five consecutive cards.

Again,well done for uno  :-) i'm sure it will be fun too playing draw poker if one day you decide to begin making the script.
Title: Re: Card Game Scripts
Post by: Morio on December 06, 2008, 05:41:29 AM
Ok, I started working on this script, although I haven't had a lot of time to write it yet.

I right now you can join the game and throw away cards and get new cards to replace them.

I also have a basic function for checking the hand (it got a bit more complicated than I had expected, but it's working pretty well atm) but I might rewrite it in case I decide to sort the cards (which would make the checking faster, but then again I'd have a function that sorts the cards, so I don't know if it would be any faster) which would make it easier to check for the highest cards
Title: Re: Card Game Scripts
Post by: DocBeat on December 11, 2008, 04:51:50 AM
I just remembered that some people who play using the wild card consider the "five of a kind" to be one rank above the "four of a kind" and not the highest one.I was trying to think how hard it is to get it compared to the straight flush and yea i think straight flush and royal flush are more difficult to get...

It's up to the one who makes the script to decide :P
Title: Re: Card Game Scripts
Post by: Morio on December 11, 2008, 06:20:07 AM
The first version of the script will probably not have the Joker card at all, because I haven't figured out a good(fast) way to check for the card
Title: Re: Card Game Scripts
Post by: Atreus on January 29, 2009, 12:54:03 PM
Oy, Morio, I've been using this script for a while, with it mostly working ( a few bugs having to do with people parting) and now it's grown from a small problem to a consistent pain in the ***.  Eevery tiem a new game starts (30 seconds after !uno), i get an error, every time:
154320  ->> ERROR:modScriptFunctions:Function:RunScript:0 Error Number:450 : Wrong number of arguments or invalid property assignment

BEcause of this error, it does not say the order/card that starts the game.  It's a complete pain.  The script i'm using is basically vanilla with three modifications: !pl is interchangable with !play, !dr is interchangable with !draw, and it's only allowed to be played on #uno.


I also got this error randomly:
194420  ->> ERROR:modScriptFunctions:Function:RunScript:0 Error Number:9 : Subscript out of range: 'AssignedTurn'
but only every once is a long while
Title: Re: Card Game Scripts
Post by: Snerf on January 29, 2009, 01:02:22 PM
Those are actually IceChat Errors, and not script errors.
I would have to see the script and see what is causing it.
Title: Re: Card Game Scripts
Post by: Atreus on January 29, 2009, 01:06:16 PM
Those are actually IceChat Errors, and not script errors.
I would have to see the script and see what is causing it.

It's the uno script that's under ice7 scripts on the site.  http://www.icechat.net/site/index.php?irc-client=icechat7scripts // the secodn script.

Offtopic, but that !seen script is terribly complicated...  the one i use is simply a lot of sub ON*'s
Title: Re: Card Game Scripts
Post by: Morio on January 29, 2009, 09:22:12 PM
Atreus: you don't happen to have a pretty new version of icechat 9 do you? If that is the case, you need to fix one line in the script, in the OnText sub the second 'SendCommand' line should look like this:
Code: [Select]
SendCommand "/timer unotimer 1 30 /! PlayUNO " & "newgame | "  & UnoChannel & " | " & ServerNumber & " | newgame"

About the !seen script. The one on the site is basically a bunch of ONJOIN, ONPART etc subs, and a scanning sub. But nick changes and quitting require some special care, since they are network specific, not channel specific.
Title: Re: Card Game Scripts
Post by: Atreus on January 30, 2009, 07:54:08 AM
Atreus: you don't happen to have a pretty new version of icechat 9 do you?
Yes O.o  Okay, then...  I see the difference in the script; there's spaces.  I'mma guessin' that Ice9 handles subs differently when used with /!
About the !seen script. The one on the site is basically a bunch of ONJOIN, ONPART etc subs, and a scanning sub. But nick changes and quitting require some special care, since they are network specific, not channel specific.
I just do:
Code: [Select]
Sub ONNICK(NewNick,OldNick,ServerNumber)
ntime=getidentifier("$now")
writeinifile "seen.ini",servernumber & " times",newnick,ntime
writeinifile "seen.ini",servernumber & " times",oldnick,""
writeinifile "seen.ini",servernumber & " reasons",nickname,"changing their nick from " & oldnick
writeinifile "seen.ini",servernumber & " reasons",oldnick,""
End Sub
and
Code: [Select]
Sub ONQUIT(Nickname,Host,Reason,ServerNumber)
ntime=getidentifier("$now")
writeinifile "seen.ini",servernumber & " times",nickname,ntime
writeinifile "seen.ini",servernumber & " reasons",nickname,"quitting"
End Sub

And basically my whole code goes like that.  I'm planning to change it from servernumber to a variable of getidentifier("$network") or somethign like that ($network may depend on the open window, not where the quit/nickchange was)
Title: Re: Card Game Scripts
Post by: DarkStar on January 30, 2009, 08:03:38 AM
Atreus: to make $network specific to the network the event happened on, use GetIdentifier("$network", ServerNumber)