All pastes #375813 Raw Edit

Unnamed

public text v1 · immutable
#375813 ·published 2007-02-28 17:08 UTC
rendered paste body
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; zen UNO script verson 1.0 ;;
;; - by skauert © 2007       ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


; Setup stuff
; -----------

alias uno_setup {
  ; Enable script?
  set %uno_opt_enable 1

  ; Command character
  set %uno_opt_cmd .

  ; Colors
  set %uno_opt_c1 7
  set %uno_opt_c2 14

  ; Who's the super user?
  set %uno_opt_sop skauert

  ; Minimum amount of players
  set %uno_opt_minplayers 2

  ; Show color letter in cards?
  set %uno_opt_showletter 0

  ; Allow only the game starter to stop the game
  set %uno_opt_gamelock 1

  ; Allow players to leave?
  set %uno_opt_allowleave 1

  ; Make players who falsely call UNO draw 2 cards?
  set %uno_opt_penalize 1

  ; Force players to play a card if they can?
  set %uno_opt_mustplay 1

  ; Allow combos?
  set %uno_opt_combos 1

  ; Allow cuts?
  set %uno_opt_cuts 1

  ; How many full idle turns to allow before the player is kicked (0 to disable)
  set %uno_opt_forcekick 3

  ; Time limit for playing a card? (Set to 0 to disable and any other value to adjust the time period)
  set %uno_opt_playtime 60

  ; Time limit for game signups? (Set to 0 to disable and any other value to adjust the time period)
  set %uno_opt_signuptime 120

  ; Just some cards (You probably don't want to change this)
  set %uno_opt_regcards 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 S S S D2 D2 D2 R R R
  set %uno_opt_speccards W W W W WD4 WD4 WD4 WD4
}


; Remotes
; -------

on *:text:$(%uno_opt_cmd $+ *):#: {
  if (%uno_opt_enable == 1) {
    var %command = $mid($$1, 2)

    if (%command == colortest) { uno_colortest $nick $chan }
    if (%command == config)    { uno_config    $nick $2- }
    if (%command == commands)  { uno_commands  $nick $chan }
    if (%command == startuno)  { uno_start     $nick $chan }
    if (%command == stopuno)   { uno_stop      $nick }
    if (%command == beginuno)  { uno_begin     $nick }
    if (%command == join)      { uno_join      $nick }
    if (%command == leave)     { uno_leave     $nick }
    if (%command == play)      { uno_play      $nick $2- }
    if (%command == uno)       { uno_play      $nick uno $2- }
    if (%command == draw)      { uno_draw      $nick }
    if (%command == pass)      { uno_pass      $nick }
    if (%command == turn)      { uno_turn      $nick }
    if (%command == showcards) { uno_showcards $nick }
    if (%command == count)     { uno_count     $nick }
  }
}

on *:nick: {
  if ($uno_findplayer($nick) != $null) {
    hadd $+(uno.players.,$hget(uno.players,$uno_findplayer($nick))) name $newnick
  }
}


; System aliases
; --------------

alias uno_tablesize {
  var %name = $$1, %i = 1, %j = 0

  while (%i <= $hget(%name).size) {
    if ($hget(%name,%i) == $null) {
      break
    }

    inc %i
    inc %j
  }

  return %j
}

alias uno_unsetvars {
  unset %uno_game_starter
  unset %uno_game_chan
  unset %uno_game
  unset %pid_uid
  unset %uno_cards_drawn
  unset %uno_cards_played
  unset %uno_current_player
  unset %uno_drawn
  unset %uno_reverse
  unset %uno_game_signup
}

alias uno_freetables {
  hfree -w uno.*
}

alias uno_findplayer {
  var %player = $$1, %i = 1
  while (%i <= $uno_playercount) {
    if ($hget($+(uno.players.,$hget(uno.players,%i)),name) == %player) {
      return %i
    }

    inc %i
  }

  return $null
}

alias uno_addplayer {
  var %pid = $$1
  hadd uno.players $calc($uno_playercount + 1) %pid
}

alias uno_delplayer {
  var %pid = $$1, %upid

  if ($hget(uno.players,%pid) != $null) {
    %upid = $hget(uno.players,%pid)
    hdel uno.players %pid
    hfree uno.players. $+ %upid
  }

  uno_ordertable
}

alias uno_ordertable {
  var %i = 1, %j = 1
  hfree -w temp
  hmake temp

  while (%i <= $hget(uno.players).size) {
    if ($hget(uno.players,%i) != $null) {
      hadd temp %j $hget(uno.players,%i)
      inc %j
    }
    inc %i
  }

  hfree uno.players
  hmake uno.players

  %i = 1
  while (%i <= $hget(temp).size) { 
    hadd uno.players %i $hget(temp,%i)
    inc %i
  }
}

alias uno_playercount {
  var %i = 1
  while ($hget(uno.players,%i) != $null) {
    inc %i
  }

  return $iif(%i == 1, 0, $calc(%i - 1))
}

alias uno_makedeck {
  var %t = 1, %d = 1, %i
  hfree -w uno.cards
  hmake uno.cards 200

  while (%d <= 4) {
    %i = 1
    while (%i <= $gettok(%uno_opt_regcards,0,32)) {
      hadd uno.cards %t $iif(%d == 1, R_, $iif(%d == 2, G_, $iif(%d == 3, B_, $iif(%d == 4, Y_, 0_)))) $+ $gettok(%uno_opt_regcards,%i,32)
      inc %i
      inc %t
    }
    inc %d
  }

  %i = 1
  while (%i <= $gettok(%uno_opt_speccards,0,32)) {
    hadd uno.cards %t $+(X_,$gettok(%uno_opt_speccards,%i,32))
    inc %i
    inc %t
  }
}

alias uno_getplayerinfo {
  var %pid = $$1, %info = $$2
  return $hget($+(uno.players.,$hget(uno.players,%pid)),%info)
}

alias uno_translatecard {
  var %card = $$1, %c, %n

  if (%card == X_WD4) {
    return 14[4W12D08414]
  }
  else {
    %c = $gettok(%card, 1, 95)
    %n = $gettok(%card, 2, 95)

    return  $+ $replace(%c,R,4,G,3,B,12,Y,8,X,14) $+ $chr(91) $+ $iif(%uno_opt_showletter == 1, $lower(%c), $null) $+ %n $+ $chr(93) $+ 
  }
}

alias uno_drawcard {
  var %pid = $$1, %i = 1, %j, %card, %cstr
  var %amount = $iif($2 == $null, 1, $2)

  %cstr = $+(,%uno_opt_c1) $+ You receive card $+ $iif(%amount == 1, $null, s) $+ : $+ $chr(160)

  while (%i <= %amount) {
    :docard
    %card = $rand(1, $uno_tablesize(uno.cards))

    %j = 1
    while (%j <= $gettok(%uno_cards_drawn, 0, 59)) {
      if (%card == $gettok(%uno_cards_drawn, %j, 59)) {
        goto docard
      }

      inc %j
    }

    if (%uno_cards_drawn != $null) {
      %uno_cards_drawn = %uno_cards_drawn $+ ;
    }

    %uno_cards_drawn = %uno_cards_drawn $+ %card
    hadd uno.players. $+ $hget(uno.players,%pid) cards $hget($+(uno.players.,$hget(uno.players,%pid)), cards) $+ $iif($hget($+(uno.players.,$hget(uno.players,%pid)), cards) != $null, $chr(59), $null) $+ %card

    %cstr = %cstr $+ $uno_translatecard($hget(uno.cards,%card)) $+ $chr(160)

    inc %i
  }

  .notice $uno_getplayerinfo(%pid, name) %cstr
}

alias uno_playcard {
  var %nick = $$1, %card = $$2

  if (%uno_cards_played == $null) {
    %uno_cards_played = %card
  }
}

alias uno_allowcard {
  var %c1 = $$1, %c2 = $$2
  var %cut = $3

  var %c1c = $gettok($hget(uno.cards,%c1),1,95)
  var %c2c = $gettok($hget(uno.cards,%c2),1,95)
  var %c1n = $gettok($hget(uno.cards,%c1),2,95)
  var %c2n = $gettok($hget(uno.cards,%c2),2,95)

  if (%cut != 1) {
    if ($3 > 1) {
      if (%c1n == %c2n && %uno_opt_combos == 1) {
        if (%c1n != W && %c1n != WD4) {
          return 1
        }
      }
    }
    else {
      if (%c1c == %c2c) {
        return 1
      }
      if (%c1n == %c2n) {
        return 1
      }
      if (%c1n == W || %c1n == WD4) {
        return 1
      }
    }
  }
  else {
    if ((%c1c == %c2c && %c1n == %c2n) || (%c1n == WD4 && %c2n == WD4) || (%c1n == W && %c2n == W)) {
      return 1
    }
  }

  return 0
}

alias uno_findcardbyalias {
  var %i = 1
  while (%i <= $uno_tablesize(uno.cards)) {
    if ($hget(uno.cards,%i) == $upper($$1)) {
      return %i
    }

    inc %i
  }

  return 0
}

alias uno_next_player {
  $iif(%uno_reverse == 0, inc, dec) %uno_current_player

  if (%uno_reverse == 0) {
    if (%uno_current_player > $uno_playercount) {
      set %uno_current_player 1
    }
  }
  else {
    if (%uno_current_player < 1) {
      set %uno_current_player $uno_playercount
    }
  }
}
alias uno_checksignuptime {
  var %time = $calc($ctime - 5)

  if (%time == $calc(%uno_game_signup - 300)) {
    msg %uno_game_chan $+(,%uno_opt_c2) $+ 5 $+(,%uno_opt_c1) $+ minutes until game start.
  }
  if (%time == $calc(%uno_game_signup - 120)) {
    msg %uno_game_chan $+(,%uno_opt_c2) $+ 2 $+(,%uno_opt_c1) $+ minutes until game start.
  }
  if (%time == $calc(%uno_game_signup - 60)) {
    msg %uno_game_chan $+(,%uno_opt_c2) $+ 60 $+(,%uno_opt_c1) $+ seconds until game start.
  }
  if (%time == $calc(%uno_game_signup - 30)) {
    msg %uno_game_chan $+(,%uno_opt_c2) $+ 30 $+(,%uno_opt_c1) $+ seconds until game start.
  }
  if (%time == $calc(%uno_game_signup - 15)) {
    msg %uno_game_chan $+(,%uno_opt_c2) $+ 15 $+(,%uno_opt_c1) $+ seconds until game start.
  }
  if (%time >= %uno_game_signup) {
    .timer45525 off

    if ($uno_playercount < %uno_opt_minplayers) {
      msg %uno_game_chan $+(,%uno_opt_c1) $+ Not enough players signed up. Terminating game.
      uno_unsetvars
      uno_freetables
    }
    else {
      uno_begin %uno_opt_sop
    }
  }
}

alias uno_force_pass {
  if (%uno_game == 2 && %uno_opt_playtime != 0) {
    var %p = %uno_current_player
    var %pn = $uno_getplayerinfo(%p, name)

    hinc uno.players. $+ $hget(uno.players,%p) forcepass

    uno_pass $uno_getplayerinfo(%p, name) 1

    if (%uno_opt_forcekick != 0) {
      if ($uno_getplayerinfo(%p, forcepass) > %uno_opt_forcekick) {
        uno_delplayer %p

        if (%nick == %uno_game_starter && $uno_playercount > 0) {
          set %uno_game_starter $uno_getplayerinfo($rand(1, $uno_playercount), name)
          %newstr = ( $+ $+(,%uno_opt_c2) $+ %uno_game_starter $+(,%uno_opt_c1) $+ is now the new game leader)
        }

        msg %uno_game_chan $+(,%uno_opt_c2) $+ %pn $+(,%uno_opt_c1) $+ has been kicked out of the game due to inactivity. $iif($len(%newstr) > 0, %newstr, $null)

        if ($uno_playercount == 1) {
          uno_stop %uno_opt_sop NOPL
        }
      }
    }
  }
}

alias uno_reshuffle {
  if ($gettok(%uno_cards_played,0,59) > 50) {
    msg %uno_game_chan $+(,%uno_opt_c1) $+ Reshuffling deck.
    set %uno_cards_played $gettok(%uno_cards_played,-1,59)

    var %i = 101
    while (%i <= 108) {
      if ($upper($gettok($hget(uno.cards,%i),1,95)) != X) {
        hadd uno.cards %i X_ $+ $upper($gettok($hget(uno.cards,%i),2,95))
      }

      inc %i
    }
  }
}


; DEBUG aliases
; -------------

alias uno_printdeck {
  var %t = 1, %d = 1, %i, %str

  while (%d <= 4) {
    %i = 1
    %str =  $+ $iif(%d == 1, 4, $iif(%d == 2, 3, $iif(%d == 3, 12, $iif(%d == 4, 8, 0))))

    while (%i <= $gettok(%uno_opt_regcards,0,32)) {
      %str = %str $+ $hget(uno.cards,%t) $+ $chr(160)
      inc %i
      inc %t
    }

    echo -a %str
    inc %d
  }

  %i = 1
  %str = 14

  while (%i <= $gettok(%uno_opt_speccards,0,32)) {
    %str = %str $+ $hget(uno.cards,%t) $+ $chr(160)
    inc %i
  }

  echo -a %str
}

alias uno_printplayers {
  var %i = 1

  while (%i <= $uno_playercount) {
    echo -a %i $+ . $uno_getplayerinfo(%i, name) $chr(91) $+ $hget(uno.players,%i) $+ $chr(93) ( $+ $uno_getplayerinfo(%i, forcepass) $+ ) - $uno_getplayerinfo(%i, cards)
    inc %i
  }
}

alias uno_colortest {
  if ($$1 == %uno_opt_sop) {
    msg $$2 $+(,%uno_opt_c1) $+ A color test was requested by $+(,%uno_opt_c2) $+ $$1 $+ $+(,%uno_opt_c1) $+ !
  }
}

alias uno_cardsplayed {
  echo -a Cards played: $gettok(%uno_cards_played,0,59)
}

; UNO aliases
; -----------

alias uno_config {
  var %nick = $$1, %i = 1

  if (%nick == %uno_opt_sop || %nick == %uno_game_starter) {
    if ($2 == list) {
      .notice %nick  $+ $+(,%uno_opt_c1) $+ Configuration list:

      while (%i <= $var(%uno_opt_*,0)) {
        .notice %nick $chr(160) $chr(160) $chr(160) $+(,%uno_opt_c2) $+ $var(%uno_opt_*,%i) - $eval($var(%uno_opt_*,%i),2)
        inc %i
      }

      .notice %nick $+(,%uno_opt_c1) $+ End of list.
    }

    if ($2 == set) {
      if ($var($3) == 1 && uno_opt isin $3) {
        if ($4 != $null) {
          set $iif($mid($3,1,1) != $chr(37), $chr(37), $null) $+ $3 $4-
          .notice %nick $+(,%uno_opt_c1) $+ Successfully set $+(,%uno_opt_c2) $+ $iif($mid($3,1,1) != $chr(37), $chr(37), $null) $+ $3 $+ $+(,%uno_opt_c1) to: $+(,%uno_opt_c2) $+ $4-

          if ($lower($replace($3,$chr(37),$null)) == uno_opt_playtime) {
            if ($4 == 0) {
              .timer45524 off
            }
          }
        }
        else {
          .notice %nick $+(,%uno_opt_c1) $+ No value specified.
        }
      }
      else {
        .notice %nick $+(,%uno_opt_c1) $+ Variable $+(,%uno_opt_c2) $+ $iif($mid($3,1,1) != $chr(37), $chr(37), $null) $+ $3 $+(,%uno_opt_c1) $+ does not exist.
      }
    }
  }
}
alias uno_commands {
  msg $2  $+ $+(,%uno_opt_c1) $+ UNO commands: $+ $+(,%uno_opt_c2) $+(%uno_opt_cmd,startuno) $+(%uno_opt_cmd,stopuno) $+(%uno_opt_cmd,join) $+(%uno_opt_cmd,leave) $+(%uno_opt_cmd,play) $+(%uno_opt_cmd,uno) $+(%uno_opt_cmd,draw) $+(%uno_opt_cmd,turn) $+(%uno_opt_cmd,pass) $+(%uno_opt_cmd,showcards) $+(%uno_opt_cmd,count)
}

alias uno_start {
  var %nick = $$1, %chan = $$2

  if (%uno_game != 1) {
    uno_setup

    set %uno_game 1
    set %uno_game_starter %nick
    set %uno_game_chan %chan
    set %pid_uid 1

    uno_freetables
    hmake uno.players

    msg %chan $+(,%uno_opt_c1) $+ A game of UNO has been started by $+ $+(,%uno_opt_c2) %nick $+ $+(,%uno_opt_c1) $+ ! To join, type $+ $+(,%uno_opt_c2) $+(%uno_opt_cmd,join) $+(,%uno_opt_c1) $+ and wait for the game to start.
    uno_join %nick

    if (%uno_opt_signuptime != 0) {
      set %uno_game_signup $calc($ctime + %uno_opt_signuptime)
      .timer45525 $calc(%uno_opt_signuptime + 5) 1 uno_checksignuptime
    }
  }
  else {
    msg %chan $+(,%uno_opt_c1) $+ A game of UNO is already in progress.
  }
}

alias uno_stop {
  var %nick = $$1, %okstop

  if ($2 == NOPL) {
    msg %uno_game_chan $+(,%uno_opt_c1) $+ The game has been stopped due to all players leaving.
    uno_unsetvars
    uno_freetables

    halt
  }

  if (%uno_game == 1) {
    if (%uno_opt_gamelock == 1) {
      if (%nick == %uno_game_starter || %nick == %uno_opt_sop) {
        %okstop = 1
      }
    }
    else {
      %okstop = 1
    }
  }
  else if (%uno_game == 2 && %nick == %uno_opt_sop) {
    %okstop = 1
  }

  if (%okstop == 1) {
    msg %uno_game_chan $+(,%uno_opt_c1) $+ The UNO game has been stopped by $+ $+(,%uno_opt_c2) %nick $+ 7!
    uno_unsetvars
    uno_freetables
  }
}

alias uno_begin {
  var %nick = $$1, %i = 1

  if ($uno_playercount < %uno_opt_minplayers) {
    msg %uno_game_chan $+(,%uno_opt_c1) $+ The game needs at least $+(,%uno_opt_c2) $+ %uno_opt_minplayers $+ $+(,%uno_opt_c1) players to start.
    halt
  }

  if ((%uno_game == 1 && (%uno_game_starter == %nick || %nick == %uno_opt_sop)) || $2 == TIMEUP) {
    set %uno_game 2
    uno_makedeck
    uno_playcard Dealer $rand(1, 100)

    msg %uno_game_chan $+(,%uno_opt_c1) $+ The game of UNO is now starting. Players are being handed their cards.

    while (%i <= $uno_playercount) {
      uno_drawcard %i 7
      inc %i
    }

    set %uno_current_player $rand(1, $uno_playercount)
    set %uno_drawn 0
    set %uno_reverse 0

    msg %uno_game_chan $+(,%uno_opt_c1) $+ Top card: $uno_translatecard($hget(uno.cards,%uno_cards_played))
    msg %uno_game_chan $+(,%uno_opt_c1) $+ Current player: $+(,%uno_opt_c2) $+ $uno_getplayerinfo($hget(uno.players,%uno_current_player), name)

    .timer45525 off

    if (%uno_opt_playtime != 0) {
      .timer45524 1 %uno_opt_playtime uno_force_pass
    }
  }
}

alias uno_join {
  var %nick = $$1, %pid = %pid_uid 

  if (%uno_game == 2) {
    .notice %nick $+(,%uno_opt_c1) $+ The game has already started.
  }
  else {
    if ($uno_findplayer(%nick) != $null) {
      .notice %nick $+(,%uno_opt_c1) $+ You're already in the game.
    }
    else {
      uno_addplayer %pid

      hmake uno.players. $+ %pid
      hadd uno.players. $+ %pid name %nick
      hadd uno.players. $+ %pid ingame 1
      hadd uno.players. $+ %pid cards $null
      hadd uno.players. $+ %pid forcepass 0

      msg %uno_game_chan $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ has joined the game.
    }
  }

  inc %pid_uid
}

alias uno_leave {
  if ($uno_findplayer($$1) != $null) {
    var %nick = $$1, %pid = $uno_findplayer($$1), %newstr, %leaveok = 0

    if (%uno_game == 1) {
      if ($hget(uno.players,%pid) != $null) {
        %leaveok = 1
      }
    }
    else if (%uno_game == 2) {
      if (%uno_opt_allowleave == 1) {
        %leaveok = 1
      }
    }

    if (%leaveok == 1) {
      uno_delplayer %pid

      if (%nick == %uno_game_starter && $uno_playercount > 0) {
        set %uno_game_starter $uno_getplayerinfo($rand(1, $uno_playercount), name)
        %newstr = ( $+ $+(,%uno_opt_c2) $+ %uno_game_starter $+(,%uno_opt_c1) $+ is now the new game leader)
      }

      msg %uno_game_chan $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ has left the game. $iif($len(%newstr) > 0, %newstr, $null)

      if (%uno_game == 1) {
        if ($uno_playercount == 0) {
          uno_stop %nick NOPL
        }
      }
      else if (%uno_game == 2) {
        if ($uno_playercount == 1) {
          uno_stop %nick NOPL
        }
      }
    }
  }
}

alias uno_play {
  if (%uno_game == 2) {
    if ($uno_findplayer($$1) != $null && ($uno_findplayer($$1) == %uno_current_player || %uno_opt_cuts == 1)) {
      var %nick = $$1, %fcard, %str, %foundcard, %playok = 1, %uno = $iif($2 == uno, 1, 0), %pid = $uno_findplayer(%nick)
      var %cards = $lower($iif($2 == uno, $$3-, $$2-))
      var %ctopc = $iif($chr(59) isin %uno_cards_played, $gettok(%uno_cards_played,$gettok(%uno_cards_played,0,59),59), %uno_cards_played)
      var %fstring = a, %fstr, %w = 0, %wcok = 1, %cut = 0

      if ($uno_findplayer($$1) != %uno_current_player) {
        %uno_current_player = %pid
        %cut = 1
      }
      else {
        %cut = 0
      }

      if (%nick != $uno_getplayerinfo(%uno_current_player, name)) {
        .notice %nick $+(,%uno_opt_c1) $+ It's not your turn!
        halt
      }

      var %i = 1, %j
      while (%i <= $gettok(%cards,0,32)) {
        %fcard = $iif($mid($gettok(%cards,%i,32),1,1) == w, X_, $+($upper($mid($gettok(%cards,%i,32),1,1)),_)) $+ $upper($iif($mid($gettok(%cards,%i,32),1,1) == w, $gettok(%cards,%i,32), $mid($gettok(%cards,%i,32),2)))

        if ($uno_allowcard(%ctopc, $uno_findcardbyalias(%fcard), %cut) == 0 && ($lower($gettok(%cards,1,32)) != w && $mid($lower($gettok(%cards,1,32)),1,3) != wd4)) {
          %playok = 0
        }
        else {
          %j = 1
          %foundcard = 0

          while (%j <= $gettok($uno_getplayerinfo(%pid, cards),0,59)) {
            if (%fcard == $hget(uno.cards, $gettok($uno_getplayerinfo(%pid, cards),%j,59)) && $findtok(%fstring,$gettok($uno_getplayerinfo(%pid, cards),%j,59),0,59) == 0) {
              %foundcard = $gettok($uno_getplayerinfo(%pid, cards),%j,59)
              break
            }

            inc %j
          }

          if (%foundcard == 0 && ($lower($gettok(%cards,1,32)) != w && $lower($gettok(%cards,1,32)) != wd4)) {
            %playok = 0
          }
          else {
            if ($gettok($hget(uno.cards,%foundcard),1,95) == X) {
              if ($lower($gettok($1-,$gettok($1-,0,32),32)) != r && $lower($gettok($1-,$gettok($1-,0,32),32)) != g && $lower($gettok($1-,$gettok($1-,0,32),32)) != b && $lower($gettok($1-,$gettok($1-,0,32),32)) != y) {
                %wcok = 0
              }
              else {
                %w = $upper($gettok($1-,$gettok($1-,0,32),32))
              }
            }
          }

          if (%foundcard != 0) {
            %ctopc = %foundcard

            if (%fstring == a) {
              %fstring = $null
            }

            %fstring = %fstring $+ $iif($len(%fstring) < 1, $null, $chr(59)) $+ %foundcard
          }
        }

        inc %i
      }

      if (%playok == 0) {
        .notice %nick $+(,%uno_opt_c1) $+ You cannot play that card $+ $iif($gettok(%cards,0,32) == 1, $null, -combination) $+ .
      }
      else {
        if (%wcok != 1) {
          .notice %nick $+(,%uno_opt_c1) $+ You need to specify what color to change into.
        }
        else {
          if (%cut == 1) {
            msg %uno_game_chan $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ has performed a cut!!
          }

          %i = 1
          while (%i <= $gettok(%fstring, 0, 59)) {
            %fstr = %fstr $+ $iif($len(%fstr) < 1, $null, $chr(160)) $+ $uno_translatecard($hget(uno.cards,$gettok(%fstring,%i,59)))
            inc %i
          }
          msg %uno_game_chan $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ played card $+ $iif(%i == 2, $null, s) $+ : %fstr

          %i = 1
          while (%i <= $gettok(%fstring, 0, 59)) {
            %uno_cards_played = %uno_cards_played $+ ; $+ $gettok(%fstring,%i,59)
            hadd $+(uno.players.,$hget(uno.players,$uno_findplayer(%nick))) cards $deltok($uno_getplayerinfo($uno_findplayer(%nick), cards), $findtok($uno_getplayerinfo($uno_findplayer(%nick), cards), $gettok(%fstring,%i,59), 1, 59), 59)

            if ($upper($gettok($hget(uno.cards,$gettok(%fstring,%i,59)),2,95)) == S) {
              uno_next_player
              msg %uno_game_chan $+(,%uno_opt_c2) $+ $uno_getplayerinfo(%uno_current_player, name) $+ 's $+(,%uno_opt_c1) $+ turn was skipped!
            }
            if ($upper($gettok($hget(uno.cards,$gettok(%fstring,%i,59)),2,95)) == D2) {
              uno_next_player
              msg %uno_game_chan $+(,%uno_opt_c2) $+ $uno_getplayerinfo(%uno_current_player, name) $+(,%uno_opt_c1) $+ was forced to draw 2 cards. In addition, their turn was skipped!
              uno_drawcard %uno_current_player 2
            }
            if ($upper($gettok($hget(uno.cards,$gettok(%fstring,%i,59)),2,95)) == R) {
              msg %uno_game_chan $+(,%uno_opt_c1) $+ Order is now reversed!
              set %uno_reverse $iif(%uno_reverse == 1, 0, 1)
            }
            if ($upper($gettok($hget(uno.cards,$gettok(%fstring,%i,59)),2,95)) == WD4) {
              uno_next_player
              msg %uno_game_chan 4W3i12l8d 4D3r12a8w 4F3o12u8r $+ $+(,%uno_opt_c1) $+ !! $+(,%uno_opt_c2) $+ $uno_getplayerinfo(%uno_current_player, name) $+ $+(,%uno_opt_c1) was forced to draw 4 cards. In addition, their turn was skipped!
              hadd uno.cards $gettok(%fstring,%i,59) %w $+ _WD4
              uno_drawcard %uno_current_player 4
            }
            if ($upper($gettok($hget(uno.cards,$gettok(%fstring,%i,59)),2,95)) == W) {
              hadd uno.cards $gettok(%fstring,%i,59) %w $+ _W
            }

            inc %i
          }

          if ($gettok($uno_getplayerinfo($uno_findplayer(%nick), cards),0,59) == 1) {
            if ($len($gettok($uno_getplayerinfo($uno_findplayer(%nick), cards),1,59)) > 0) {
              if (%uno != 1) {
                msg %uno_game_chan $+(,%uno_opt_c1) $+ Unfortunately, $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ forgot to call UNO and is forced to draw 2 cards.
                uno_drawcard $uno_findplayer(%nick) 2
              }
              else {
                msg %uno_game_chan $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ called UNO!
              }
            }
            else {
              uno_wingame %nick
            }
          }

          if ($gettok($uno_getplayerinfo($uno_findplayer(%nick), cards),0,59) == $null) {
            uno_wingame %nick
          }

          if (%uno == 1 && $gettok($uno_playerinfo(%pid, cards),0,59) > 2) {
            if (%uno_opt_penalize == 1) {
              msg %uno_game_chan $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ called UNO, but doesn't have 1 card left. $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ is forced to draw 2 cards.
              uno_drawcard $uno_findplayer(%nick) 2
            }
          }

          uno_next_player

          msg %uno_game_chan $+(,%uno_opt_c1) $+ Top card: $uno_translatecard($hget(uno.cards,$gettok(%uno_cards_played,$gettok(%uno_cards_played,0,59),59)))
          msg %uno_game_chan $+(,%uno_opt_c1) $+ Current player: $+(,%uno_opt_c2) $+ $uno_getplayerinfo($hget(uno.players,%uno_current_player), name)

          uno_showcards $uno_getplayerinfo($hget(uno.players,%uno_current_player), name)
          set %uno_drawn 0

          uno_reshuffle

          if (%uno_opt_playtime != 0) {
            .timer45524 1 %uno_opt_playtime uno_force_pass
          }
        }
      }
    }
  }
}

alias uno_draw {
  if (%uno_game == 2) {
    var %nick = $$1

    if ($uno_findplayer(%nick) != $null && $uno_findplayer(%nick) == %uno_current_player) {
      if (%uno_drawn == 0) {
        set %uno_drawn 1
        uno_drawcard $uno_findplayer(%nick) 1
        .timer45524 off
      }
      else {
        .notice %nick $+(,%uno_opt_c1) $+ You cannot draw another card this turn.
      }
    }
  }
}

alias uno_pass {
  if (%uno_game == 2) {
    var %nick = $$1, %i = 1, %passok = 1, %forced = $iif($2 == $null, 0, 1)
    var %ctopc = $iif($chr(59) isin %uno_cards_played, $gettok(%uno_cards_played,$gettok(%uno_cards_played,0,59),59), %uno_cards_played)

    if ($uno_findplayer(%nick) != $null && $uno_findplayer(%nick) == %uno_current_player) {
      if (%uno_opt_mustplay == 1 && %forced != 1) {
        while (%i <= $gettok($uno_getplayerinfo($uno_findplayer(%nick), cards),0,59)) {
          if ($uno_allowcard(%ctopc, $gettok($uno_getplayerinfo($uno_findplayer(%nick), cards),%i,59)) == 1, 0) {
            %passok = 0
          }

          inc %i
        }
      }

      if (%passok == 0) {
        msg %uno_game_chan $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ is trying to cheat!! Play your card, fool!
      }
      else {
        msg %uno_game_chan $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ passes.
        uno_next_player

        msg %uno_game_chan $+(,%uno_opt_c1) $+ Top card: $uno_translatecard($hget(uno.cards,$gettok(%uno_cards_played,$gettok(%uno_cards_played,0,59),59)))
        msg %uno_game_chan $+(,%uno_opt_c1) $+ Current player: $+(,%uno_opt_c2) $+ $uno_getplayerinfo($hget(uno.players,%uno_current_player), name)

        uno_showcards $uno_getplayerinfo($hget(uno.players,%uno_current_player), name)
        set %uno_drawn 0

        if (%uno_opt_playtime != 0) {
          .timer45524 1 %uno_opt_playtime uno_force_pass
        }
      }
    }
  }
}

alias uno_showcards {
  if (%uno_game == 2) {
    var %nick = $$1, %pid, %cstr, %i = 1

    if ($uno_findplayer(%nick) != $null) {
      %pid = $uno_findplayer(%nick)
      %cstr = 7Your card $+ $iif($gettok($uno_getplayerinfo(%pid, cards),0,59) != 1, s, $null) $+ : $+ $chr(160)

      while (%i <= $gettok($uno_getplayerinfo(%pid, cards),0,59)) {
        %cstr = %cstr $+ $uno_translatecard($hget(uno.cards,$gettok($uno_getplayerinfo(%pid, cards),%i,59))) $+ $chr(160)
        inc %i
      }

      .notice %nick %cstr
    }
  }
}

alias uno_count {
  if (%uno_game == 2) {
    var %nick = $$1, %i = 1, %str

    %str = $+(,%uno_opt_c1) $+ Player cards: $+(,%uno_opt_c2)

    while (%i <= $uno_playercount) {
      if (%i != 1) {
        %str = %str $+ , $+ $chr(160)
      }

      %str = %str $+ $uno_getplayerinfo(%i, name) ( $+ $gettok($uno_getplayerinfo(%i, cards),0,59) $+ )

      inc %i
    }

    .notice %nick %str
  }
}

alias uno_wingame {
  var %nick = $$1
  msg %uno_game_chan $+(,%uno_opt_c1) $+ Victory!! $+(,%uno_opt_c2) $+ %nick $+(,%uno_opt_c1) $+ has won the game!

  uno_unsetvars
  uno_freetables
}

alias uno_turn {
  msg %uno_game_chan $+(,%uno_opt_c1) $+ Top card: $uno_translatecard($hget(uno.cards,$gettok(%uno_cards_played,$gettok(%uno_cards_played,0,59),59)))
  msg %uno_game_chan $+(,%uno_opt_c1) $+ Current player: $+(,%uno_opt_c2) $+ $uno_getplayerinfo($hget(uno.players,%uno_current_player), name)
}