Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '#####################
- '# UNI script v 1.0 #
- '# Author: Morio #
- '#####################
- 'Commands:
- '!uno - starts a new game (if a game is not being played at the moment)
- '!join - join a game
- '!play - play a card
- '!draw - draw a card from the deck
- '!pass - pass over your turn to the next player (can only be done if you have already drawn a card from the deck
- '!stop - stops the game (for the gamestarter and operators only)
- '!help - shows a list of commands
- Dim Players,TotalCards,CardsInDeck,UnoChannel,GameStarter,NewString,CardOnTop,CardsOnTable,Playerlist,Turn,HasDrawn,HasStarted
- Set Players = CreateObject("Scripting.Dictionary")
- 'all cards found in a deck
- TotalCards = "p:0,p:1,p:1,p:2,p:2,p:3,p:3,p:4,p:4,p:5,p:5,p:6,p:6,p:7,p:7,p:8,p:8,p:9,p:9,p:dr2,p:dr2,p:r,p:r,p:s,p:s,b:0,b:1,b:1,b:2,b:2,b:3,b:3,b:4,b:4,b:5,b:5,b:6,b:6,b:7,b:7,b:8,b:8,b:9,b:9,b:dr2,b:dr2,b:r,b:r,b:s,b:s,r:0,r:1,r:1,r:2,r:2,r:3,r:3,r:4,r:4,r:5,r:5,r:6,r:6,r:7,r:7,r:8,r:8,r:9,r:9,r:dr2,r:dr2,r:r,r:r,r:s,r:s,g:0,g:1,g:1,g:2,g:2,g:3,g:3,g:4,g:4,g:5,g:5,g:6,g:6,g:7,g:7,g:8,g:8,g:9,g:9,g:dr2,g:dr2,g:r,g:r,g:s,g:s,y:0,y:1,y:1,y:2,y:2,y:3,y:3,y:4,y:4,y:5,y:5,y:6,y:6,y:7,y:7,y:8,y:8,y:9,y:9,y:dr2,y:dr2,y:r,y:r,y:s,y:s,wild,wild,wild,wild,wd4,wd4,wd4,wd4"
- 'put the cards to the deck
- CardsInDeck = TotalCards
- UnoChannel = ""
- PlayerList = ""
- HasStarted = False
- Turn = 0
- HasDrawn = False
- Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
- Message = LCase(Message)
- If not Channel = "#lru" then Exit Sub 'can be used to make the script work on a specific channel only (recommended)
- If UnoChannel = "" then
- CardOnTop = ""
- If Message = "!uno" then
- UnoChannel = Channel
- GameStarter = Nickname
- HasStarted = False
- SendCommand "/msg " & Channel & " " & Nickname & " started a game of uno. Type !join to join. The game will start in 30s",ServerNumber
- 'start the game after 30s
- SendCommand "/timer unotimer 1 30 /! PlayUNO " & "newgame|" & UnoChannel & "|" & ServerNumber & "|newgame"
- 'shuffle the deck
- ArrayShuffle Split(TotalCards,","), True
- CardsInDeck = NewString
- End If
- Else
- If Not Channel = UnoChannel then Exit Sub
- If Message = "!join" then AddUnoPlayer Nickname,Channel,ServerNumber 'joining the game
- If Left(Message,6) = "!play " and Len(Message) > 6 then 'playing a card
- If Not Nickname = GetCurrentPlayer(Turn) then Exit Sub
- If Players.exists(Nickname) then
- Card = Mid(Message,7)
- Card = Replace(Card, " ", "")
- If Left(Card,1) = "w" then
- Card = Left(Card, Len(Card)-1) & " " & Right(Card, 1)
- End If
- If Card = "newgame" then Exit Sub
- If Not Left(Card,1) = "w" then
- Card = Left(Card,1) & ":" & Mid(Card,2)
- End If
- PlayUNO Nickname,Channel,ServerNumber,Card
- Else
- SendCommand "/msg " & Channel & " " & Nickname & ": you haven't joined the game yet, type !join to join",ServerNumber
- End If
- ElseIf Message = "!draw" and HasDrawn = False then 'drawing a card from the deck
- If Not Nickname = GetCurrentPlayer(Turn) then Exit Sub
- NewCard = GetNewCards(1)
- Players.item(Nickname) = Players.item(Nickname) & "," & NewCard
- HasDrawn = True
- If Not NewCard = "" then
- SendCommand "/notice " & Nickname & " --- You drew: " & AddColors(NewCard),ServerNumber
- Else
- SendCommand "/msg " & Channel & " Not enough cards in the deck, use !pass to pass your turn",ServerNumber
- End If
- ElseIf Message = "!pass" then 'passing your turn
- If Not Nickname = GetCurrentPlayer(Turn) then Exit Sub
- If HasDrawn = True then
- If Nickname = Kitsune then
- SendCommand "/msg " & Channel & " " & Nickname & " Passes hizzle turzzle. Next in turn: " & GetCurrentPlayer(Turn+1),ServerNumber
- SendCommand "/notice " & GetCurrentPlayer(Turn+1) & " --- Your cards: " & AddColors(Players.item(GetCurrentPlayer(Turn+1))),ServerNumber
- Else SendCommand "/msg " & Channel & " " & Nickname & " Passes his turn. Next in turn: " & GetCurrentPlayer(Turn+1),ServerNumber
- SendCommand "/notice " & GetCurrentPlayer(Turn+1) & " --- Your cards: " & AddColors(Players.item(GetCurrentPlayer(Turn+1))),ServerNumber
- End If
- Turn = Turn + 1
- HasDrawn = False
- Else
- SendCommand "/msg " & Channel & " " & Nickname & ": You need to !draw before you can !pass",ServerNumber
- End If
- ElseIf Message = "!cards" then 'wiev your cards
- Plays = False
- AllPlayers = Players.keys
- For i = 0 to UBound(AllPlayers)
- If Nickname = AllPlayers(i) then
- Plays = True
- Exit For
- End If
- Next
- If Plays = True then
- SendCommand "/notice " & Nickname & " --- Your cards are: " & AddColors(Players.item(Nickname)),ServerNumber
- Else
- SendCommand "/notice " & Nickname & " --- you are not in the game, type !join to join",ServerNumber
- End If
- ElseIf Message = "!count" then 'show how many cards each player has
- AllPlayers = Players.keys
- PlayerCount = ""
- For i = 0 to UBound(AllPlayers)
- NumberOfCards = UBound(Split(Players.item(AllPlayers(i)),",")) + 1
- If PlayerCount = "" then
- PlayerCount = AllPlayers(i) & ": " & NumberOfCards
- Else
- PlayerCount = PlayerCount & ", " & AllPlayers(i) & ": " & NumberOfCards
- End If
- Next
- SendCommand "/msg " & Channel & " [" & PlayerCount & "]",ServerNumber
- ElseIf Message = "!turn" then 'show whose turn it is
- SendCommand "/msg " & Channel & " Current turn: " & GetCurrentPlayer(Turn),ServerNumber
- ElseIf Message = "!quit" then 'quit the game
- AllPlayers = Players.keys
- For i = 0 to UBound(AllPlayers)
- If AllPlayers(i) = Nickname then RemoveUNOPlayer Nickname,UnoChannel,ServerNumber
- Next
- ElseIf Message = "!card" and HasStarted = True then 'show the top card on the table
- If InStr(CardsOnTable,",") > 0 then
- TopCard = Left(CardsOnTable,InStr(CardsOnTable,",")-1)
- Else
- TopCard = CardsOnTable
- End If
- If Mid(TopCard,3,1) = "w" then
- CardColor = Left(TopCard,1)
- CardType = Mid(TopCard,3)
- if CardColor = "b" then
- NewColor2 = "1,12 BLUE "
- Elseif CardColor = "g" then
- NewColor2 = "1,9 GREEN "
- Elseif CardColor = "y" then
- NewColor2 = "1,8 YELLOW "
- Elseif CardColor = "r" then
- NewColor2 = "1,4 RED "
- Elseif CardColor = "p" then
- NewColor2 = "1,13 PINK "
- End If
- SendCommand "/msg " & Channel & " The Card on top is: " & GetLongCardName(CardType) & " and the color is: " & NewColor2,ServerNumber
- Else
- SendCommand "/msg " & Channel & " The Card on top is: " & GetLongCardName(TopCard)
- End If
- ElseIf Message = "!stop" and (Nickname = GameStarter or IsOp(Nickname,Channel,ServerNumber))then 'stop the game (gamestarter and operators only)
- SendCommand "/msg " & Channel & " Game stopped by: " & Nickname,ServerNumber
- GameOver Nickname,Channel,False,ServerNumber
- If HasStarted = False then SendCommand "/timer unotimer off",ServerNumber
- ElseIf Message = "!help" then
- SendCommand "/notice " & Nickname & " --- Commands available: !uno, !join, !play, !draw, !pass, !stop",ServerNumber
- End If
- End If
- End Sub
- 'when changing nickname, your cards are transferred to the new nick, and your turn in the game is preserved
- Sub ONNICK(NewNick,OldNick,ServerNumber)
- AllPlayers = Players.keys
- PlayerList = ""
- For i = 0 to UBound(AllPlayers)
- If AllPlayers(i) = OldNick then
- Players.add NewNick, Players.item(OldNick)
- Players.remove(OldNick)
- If OldNick = GameStarter then GameStarter = NewNick
- If PlayerList = "" then
- PlayerList = NewNick
- Else
- PlayerList = PlayerList & "," & NewNick
- End If
- Else
- If PlayerList = "" then
- PlayerList = AllPlayers(i)
- Else
- PlayerList = PlayerList & "," & AllPlayers(i)
- End If
- End If
- Next
- End Sub
- 'if you part the channel you quit the game
- Sub ONPART(Nickname,Host,Channel,Reason,ServerNumber)
- AllPlayers = Players.keys
- For i = 0 to UBound(AllPlayers)
- If AllPlayers(i) = Nickname then
- RemoveUNOPlayer Nickname,UnoChannel,ServerNumber
- End If
- Next
- End Sub
- 'if you quit from the server, you quit the game
- Sub ONQUIT(Nickname,Host,Reason,ServerNumber)
- AllPlayers = Players.keys
- For i = 0 to UBound(AllPlayers)
- If AllPlayers(i) = Nickname then
- RemoveUNOPlayer Nickname,UnoChannel,ServerNumber
- End If
- Next
- End Sub
- 'if you get kicked, you quit the game
- Sub ONKICK(Nickname,Host,Channel,WhoKicked,Reason,ServerNumber)
- AllPlayers = Players.keys
- For i = 0 to UBound(AllPlayers)
- If AllPlayers(i) = Nickname then
- RemoveUNOPlayer Nickname,UnoChannel,ServerNumber
- End If
- Next
- End Sub
- 'this sub adds a new player to the game
- Sub AddUNOPlayer(Nickname,Channel,ServerNumber)
- If Not Players.exists(Nickname) then 'if he hasn't joined yet
- NewPlayerCards = GetNewCards(7) 'draw 7 cards from the top of the deck
- If Not NewPlayerCards = "" then
- Players.add Nickname, NewPlayerCards
- SendCommand "/msg " & UnoChannel & " " & Nickname & " joined the game",ServerNumber
- SendCommand "/notice " & Nickname & " --- Your cards are: " & AddColors(NewPlayerCards)
- If PlayerList = "" then
- PlayerList = Nickname
- Else
- PlayerList = PlayerList & "," & Nickname 'add the player to the playerlist
- End If
- Else 'if there aren't enough cards for the player to join, he can't join
- SendCommand "/msg " & Channel & " " & Nickname & ": There are not enough cards left in the deck for you to join",ServerNumber
- Player.remove Nickname
- End If
- Else
- End If
- End Sub
- 'this sub removes a player from the game
- Sub RemoveUNOPlayer(Nickname,Channel,ServerNumber)
- CardsInDeck = CardsInDeck & "," & Players.item(Nickname) 'put the players cards to the bottom of the deck
- Players.remove(Nickname)
- AllPlayers = Split(PlayerList,",") 'remove the player from the playerlist
- NewPlayerList = ""
- NicknameInTurn = False
- For i = 0 to UBound(AllPlayers)
- If Not AllPlayers(i) = Nickname then
- If NewPlayerList = "" then
- NewPlayerList = AllPlayers(i)
- Else
- NewPlayerList = NewPlayerList & "," & AllPlayers(i)
- End If
- Else
- If GetCurrentPlayer(Turn) = AllPlayers(i) then 'if the player was in turn when leaving the game, pass the turn to the next player
- NicknameInTurn = True
- End If
- End If
- Next
- SendCommand "/msg " & Channel & " Removed " & Nickname & " from the game",ServerNumber
- PlayerList = NewPlayerList
- If HasStarted = True then
- If UBound(Split(PlayerList,",")) = 0 then 'if there is only one player left in the game at any time, the game ends
- SendCommand "/msg " & Channel & " Not enough player to continue game. Game terminated",ServerNumber
- Gameover Nickname,Channel,False,ServerNumber
- End If
- If NicknameInTurn = True then
- SendCommand "/msg " & Channel & " Next in turn: " & GetCurrentPlayer(Turn)
- SendCommand "/notice " & GetCurrentPlayer(Turn) & " --- You cards are: " & AddColors(Players.item(GetCurrentPlayer(Turn))),ServerNumber
- End If
- End If
- End Sub
- 'this function handles drawing cards from the deck
- Function GetNewCards(NumberOfCards)
- if Not UBound(Split(CardsInDeck,",")) + UBound(Split(CardsOnTable,",")) +1 > NumberOfCards then 'if there aren't enough cards, we do nothing
- If NumberOfCards = 7 or NumberOfCards = 1 then
- GetNewCards = ""
- Exit Function
- Else
- NumberOfCards = UBound(Split(CardsInDeck,",")) + UBound(Split(CardsOnTable,","))
- End If
- End If
- NewCards = ""
- For i = 0 to NumberOfCards-1
- If InStr(CardsInDeck,",") > 0 then
- Card = Left(CardsInDeck,InStr(CardsInDeck,",")-1)
- CardsInDeck = Mid(CardsInDeck,InStr(CardsInDeck,",")+1)
- Else 'if we take the last card from the deck, we take the already played cards and shuffle them and make them the new deck
- Card = CardsInDeck
- If InStr(Mid(CardsOnTable,InStr(CardsOnTable,",")+1),",") > 0 then
- ArrayShuffle Split(Mid(CardsOnTable,InStr(CardsOnTable,",")+1),","), True
- CardsInDeck = NewString
- Else
- CardsInDeck = Mid(CardsOnTable,InStr(CardsOnTable,",")+1)
- End If
- CardsOnTable = Left(CardsOnTable,InStr(CardsOnTable,",")-1)
- End If
- If NewCards = "" then
- NewCards = Card
- Else
- NewCards = NewCards & "," & Card
- End If
- Next
- GetNewCards = NewCards
- End Function
- 'this function adds color to the cards in your hand
- Function AddColors(CardSequence)
- ColoredCards = ""
- CardArr = Split(CardSequence,",")
- For i = 0 to UBound(CardArr)
- if Left(CardArr(i),1) = "b" then
- CardArr(i) = "1,12" & " " & Mid(CardArr(i),3) & " "
- Elseif Left(CardArr(i),1) = "g" then
- CardArr(i) = "1,9" & " " & Mid(CardArr(i),3) & " "
- Elseif Left(CardArr(i),1) = "y" then
- CardArr(i) = "1,8" & " " & Mid(CardArr(i),3) & " "
- Elseif Left(CardArr(i),1) = "r" then
- CardArr(i) = "1,4" & " " & Mid(CardArr(i),3) & " "
- Elseif Left(CardArr(i),1) = "p" then
- CardArr(i) = "1,13" & " " & Mid(CardArr(i),3) & " "
- ElseIf CardArr(i) = "wild" then
- CardArr(i) = "1,12 w1,9i1,8l1,4d "
- ElseIf CardArr(i) = "wd4" then
- CardArr(i) = "1,12 1,9w1,8d41,4 "
- End If
- If ColoredCards = "" then
- ColoredCards = CardArr(i)
- Else
- ColoredCards = ColoredCards & " " & CardArr(i)
- End If
- Next
- AddColors = ColoredCards
- End Function
- 'this sub shuffles an array
- Sub ArrayShuffle(arr,MakeString)
- Randomize
- Dim index
- Dim newIndex
- Dim firstIndex
- Dim itemCount
- Dim tmpValue
- firstIndex = LBound(arr)
- itemCount = UBound(arr) - LBound(arr) + 1
- For index = UBound(arr) To LBound(arr) + 1 Step -1
- ' evaluate a random index from LBound to INDEX
- newIndex = firstIndex + Int(Rnd * itemCount)
- ' swap the two items
- tmpValue = arr(index)
- arr(index) = arr(newIndex)
- arr(newIndex) = tmpValue
- ' prepare for next iteration
- itemCount = itemCount - 1
- Next
- If MakeString = True then
- NewString = ""
- For i = 0 to UBound(arr)
- If NewString = "" then
- NewString = arr(i)
- Else
- NewString = NewString & "," & arr(i)
- End If
- Next
- End If
- End Sub
- 'this function converts the card code into the real name of the card
- Function GetLongCardName(Card)
- if Left(Card,1) = "b" then
- Color = "1,12 BLUE "
- Elseif Left(Card,1) = "g" then
- Color = "1,9 GREEN "
- Elseif Left(Card,1) = "y" then
- Color = "1,8 YELLOW "
- Elseif Left(Card,1) = "r" then
- Color = "1,4 RED "
- Elseif Left(Card,1) = "p" then
- Color = "1,13 PINK "
- End If
- If IsNumeric(Mid(Card,3)) then
- GetLongCardName = Color & "NUMBER " & Mid(Card,3) & " "
- ElseIf Mid(Card,3) = "dr2" then
- GetLongCardName = Color & "DRAW TWO "
- ElseIf Mid(Card,3) = "r" then
- GetLongCardName = Color & "REVERSE "
- ElseIf Mid(Card,3) = "s" then
- GetLongCardName = Color & "SKIP "
- End If
- If Card = "wild" then
- GetLongCardName = "1,12 w1,9i1,8l1,4d "
- ElseIf Card = "wd4" then
- GetLongCardName = "1,12 WILD1,9 DRA1,8W FO1,4UR "
- End If
- GetLongCardName = GetLongCardName & ""
- End Function
- 'this function checks if the player has the card he is trying to play
- Function CheckHasCard(Nickname,Card)
- CheckHasCard = False
- NicknameCards = Players.item(Nickname)
- If InStr(NicknameCards,",") > 0 then
- CardArr = Split(NicknameCards,",")
- For i = 0 to UBound(CardArr)
- If CardArr(i) = Card then
- CheckHasCard = True
- Exit For
- End If
- Next
- Else
- If NicknameCards = Card then CheckHasCard = True
- End If
- End Function
- 'this function checks if the card the player is trying to play, can be played
- Function CanBePut(ColorOnTable,TypeOnTable,ColorOfCard,TypeOfCard)
- CanBePut = False
- If ColorOfCard = "w" then
- CanBePut = True
- Exit Function
- Elseif ColorOnTable = ColorOfCard then
- CanBePut = True
- Exit Function
- Elseif TypeOnTable = TypeOfCard then
- CanBePut = True
- Exit Function
- End If
- End Function
- 'this function returns the current player
- Function GetCurrentPlayer(AssignedTurn)
- TotalPlayers = Split(PlayerList,",")
- If AssignedTurn = UBound(TotalPlayers) + 1 then AssignedTurn = 0
- If AssignedTurn = UBound(TotalPlayers) + 2 then AssignedTurn = 1
- GetCurrentPlayer = TotalPlayers(AssignedTurn)
- End Function
- 'this function removes a card from a player, and returns the number of cards the player has left
- Function RemoveCard(Nickname,Card)
- NicknameCards = Players.Item(Nickname)
- If InStr(NicknameCards,",") > 0 then
- CardArr = Split(NicknameCards,",")
- Found = False
- NicknameCards = ""
- For i = 0 to UBound(CardArr)
- If Found = False then
- If Not CardArr(i) = Card then
- If NicknameCards = "" then
- NicknameCards = CardArr(i)
- Else
- NicknameCards = NicknameCards & "," & CardArr(i)
- End If
- Else
- Found = True
- End If
- Else
- If NicknameCards = "" then
- NicknameCards = CardArr(i)
- Else
- NicknameCards = NicknameCards & "," & CardArr(i)
- End If
- End If
- Next
- Players.item(Nickname) = NicknameCards
- If InStr(NicknameCards,",") > 0 then
- RemoveCard = UBound(Split(NicknameCards,","))+1
- Else
- RemoveCard = 1
- End If
- Else
- RemoveCard = 0
- Players.item(Nickname) = ""
- Exit Function
- End If
- End Function
- 'this sub ends the game
- Sub GameOver(Winner,Channel,Win,ServerNumber)
- If Win = True then
- SendCommand "/msg " & Channel & " " & Winner & " has won the game",ServerNumber
- End If
- UnoChannel = ""
- GameStarter = ""
- PlayerList = ""
- HasStarted = False
- Players.RemoveAll
- End Sub
- 'this sub is where the actual magic happens
- Sub PlayUNO(Nickname,Channel,ServerNumber,Card)
- If Card = "newgame" then
- If UBound(Split(PlayerList,",")) < 1 then 'if only one player has joined before the game starts, the game is terminated
- SendCommand "/msg " & Channel & " Not enough players to start a game. Game terminated",ServerNumber
- GameOver Nickname,Channel,False,ServerNumber
- Exit Sub
- End If
- HasStarted = True
- CardOnTop = Left(CardsInDeck,InStr(CardsInDeck,",")-1)
- CanStart = False
- CardsInDeck = Mid(CardsInDeck,InStr(CardsInDeck,",")+1)
- Do While CanStart = False
- If CardOnTop = "wd4" then 'the game can not start with a wild draw 4 card
- CardsInDeck = CardsInDeck & "," & CardOnTop
- CardOnTop = Left(CardsInDeck,InStr(CardsInDeck,",")-1)
- Else
- CanStart = True
- End If
- Loop
- If CardOnTop = "wild" then 'if the first card is a wild card, the starting color is random
- TopColor = Int(rnd * 5) + 1
- If TopColor = 1 then
- NewColor = "r"
- NewColor2 = "1,4 RED "
- ElseIf TopColor = 2 then
- NewColor = "g"
- NewColor2 = "1,9 GREEN "
- ElseIf TopColor = 3 then
- NewColor = "b"
- NewColor2 = "1,16 BLUE "
- ElseIf TopColor = 4 then
- NewColor = "y"
- NewColor2 = "1,8 YELLOW "
- ElseIf TopColor = 5 then
- NewColor = "p"
- NewColor2 = "1,13 PINK "
- End If
- SendCommand "/msg " & Channel & " The play order is: " & PlayerList,ServerNumber
- SendCommand "/msg " & Channel & " Game started, the first card is: " & GetLongCardName(CardOnTop) & " and the color is: " & NewColor2,ServerNumber
- SendCommand "/msg " & Channel & " Next in turn: " & GetCurrentPlayer(Turn),ServerNumber
- CardsOnTable = NewColor & ":" & CardOnTop
- Else
- TypeOfCard = Mid(CardOnTop,3)
- SendCommand "/msg " & Channel & " The playing order is: " & PlayerList,ServerNumber
- SendCommand "/msg " & Channel & " Game started, the first card is: " & GetLongCardName(CardOnTop),ServerNumber
- If TypeOfCard = "s" then 'the first card is a skip card
- SendCommand "/msg " & Channel & " " & GetCurrentPlayer(Turn) & " is skipped, next in turn: " & GetCurrentPlayer(Turn+1),ServerNumber
- Turn = Turn + 1
- ElseIf TypeOfCard = "r" then 'the first card is reverse
- TotalPlayers = Split(PlayerList,",")
- PlayerList = ""
- for i = UBound(TotalPlayers) to 0 Step -1
- If PlayerList = "" then
- PlayerList = TotalPlayers(i)
- Else
- PlayerList = PlayerList & "," & TotalPlayers(i)
- End If
- Next
- SendCommand "/msg " & Channel & " Next in turn: " & GetCurrentPlayer(Turn),ServerNumber
- ElseIf TypeOfCard = "dr2" then 'the first card is draw 2
- SendCommand "/msg " & Channel & " " & GetCurrentPlayer(Turn) & " Draws 2 cards and is skipped. Next in turn: " & GetCurrentPlayer(Turn+1),ServerNumber
- DrawnCards = GetNewCards(2)
- Players.item(GetCurrentPlayer(Turn)) = Players.item(GetCurrentPlayer(Turn)) & "," & DrawnCards
- SendCommand "/notice " & GetCurrentPlayer(Turn) & " --- You drew: " & AddColors(DrawnCards),ServerNumber
- Turn = Turn + 1
- Else
- SendCommand "/msg " & Channel & " Next in turn: " & GetCurrentPlayer(Turn),ServerNumber
- End If
- CardsOnTable = CardOnTop
- End If
- Else
- If Left(Card,1) = "w" and InStr(Card," ") = 0 then
- SendCommand "/msg " & Channel & " " & Nickname & ": Please assign a color when playing this card (!play card p/r/g/b/y)",ServerNumber
- Exit Sub
- ElseIf Left(Card,1) = "w" and InStr(Card," ") > 0 and Len(Card) > InStr(Card," ") then
- Card = Replace(Card,":","")
- NewColor = Mid(Card,InStr(Card," ")+1)
- If Not (NewColor = "p" or NewColor = "r" or NewColor = "g" or NewColor = "b" or NewColor = "y") then
- SendCommand "/msg " & Channel & " Invalid color: " & NewColor,ServerNumber
- Exit Sub
- Else
- Card = Left(Card,InStr(Card," ")-1)
- if NewColor = "b" then
- NewColor2 = "1,12 BLUE "
- Elseif NewColor = "g" then
- NewColor2 = "1,9 GREEN "
- Elseif NewColor = "y" then
- NewColor2 = "1,8 YELLOW "
- Elseif NewColor = "r" then
- NewColor2 = "1,4 RED "
- Elseif NewColor = "p" then
- NewColor2 = "1,13 PINK "
- End If
- End If
- End If
- If CheckHasCard(Nickname,Card) = True then
- ColorOnTable = Left(CardsOnTable,1)
- If InStr(CardsOnTable,",") > 0 then
- TypeOnTable = Mid(CardsOnTable,InStr(CardsOnTable,":")+1,InStr(CardsOnTable,",")-InStr(CardsOnTable,":")-1)
- Else
- TypeOnTable = Mid(CardsOnTable,3)
- End If
- ColorOfCard = Left(Card,1)
- TypeOfCard = Mid(Card,3)
- If CanBePut(ColorOnTable,TypeOnTable,ColorOfCard,TypeOfCard) = True then
- If Mid(CardsOnTable,3,4) = "wild" or Mid(CardsOnTable,3,3) = "wd4" then CardsOnTable = Mid(CardsOnTable,3)
- CardsLeft = RemoveCard(Nickname,Card)
- HasDrawn = False
- CardsOnTable = Card & "," & CardsOnTable
- If TypeOfCard = "s" then 'player played a skip card
- SendCommand "/msg " & Channel & " " & Nickname & " played: " & GetLongCardName(Card),ServerNumber
- If CardsLeft = 0 then
- GameOver Nickname,Channel,True,ServerNumber
- Exit Sub
- ElseIf CardsLeft = 1 then
- SendCommand "/msg " & Channel & " " & Nickname & " has UNO",ServerNumber
- End If
- SendCommand "/msg " & Channel & " " & GetCurrentPlayer(Turn+1) & " is skipped. Next in turn: " & GetCurrentPlayer(Turn+2),ServerNumber
- Turn = Turn + 2
- ElseIf TypeOfCard = "dr2" then 'player played a draw 2 card
- SendCommand "/msg " & Channel & " " & Nickname & " played: " & GetLongCardName(Card),ServerNumber
- If CardsLeft = 0 then
- GameOver Nickname,Channel,True,ServerNumber
- Exit Sub
- ElseIf CardsLeft = 1 then
- SendCommand "/msg " & Channel & " " & Nickname & " has UNO",ServerNumber
- End If
- SendCommand "/msg " & Channel & " " & GetCurrentPlayer(Turn+1) & " Draws 2 cards and is skipped. Next in turn: " & GetCurrentPlayer(Turn+2),ServerNumber
- DrawnCards = GetNewCards(2)
- If Not DrawnCards = "" then
- Players.item(GetCurrentPlayer(Turn+1)) = Players.item(GetCurrentPlayer(Turn+1)) & "," & DrawnCards
- SendCommand "/notice " & GetCurrentPlayer(Turn+1) & " --- You drew: " & AddColors(DrawnCards),ServerNumber
- Else
- SendCommand "/msg " & Channel & " Not enough cards in the deck",ServerNumber
- End If
- Turn = Turn + 2
- ElseIf TypeOfCard = "r" then 'player played a reverse card
- If UBound(Split(PlayerList,",")) > 1 then
- TotalPlayers = Split(PlayerList,",")
- PlayerList = ""
- for i = UBound(TotalPlayers) to 0 Step -1
- If PlayerList = "" then
- PlayerList = TotalPlayers(i)
- Else
- PlayerList = PlayerList & "," & TotalPlayers(i)
- End If
- Next
- Turn = UBound(TotalPlayers)-Turn + 1
- Else
- Turn = Turn + 2
- End If
- SendCommand "/msg " & Channel & " " & Nickname & " played: " & GetLongCardName(Card),ServerNumber
- If CardsLeft = 0 then
- GameOver Nickname,Channel,True,ServerNumber
- Exit Sub
- ElseIf CardsLeft = 1 then
- SendCommand "/msg " & Channel & " " & Nickname & " has UNO",ServerNumber
- End If
- SendCommand "/msg " & Channel & " Next in turn: " & GetCurrentPlayer(Turn),ServerNumber
- ElseIf ColorOfCard = "w" then
- CardsOnTable = NewColor & ":" & CardsOnTable
- If Card = "wild" then 'player played a wild card
- SendCommand "/msg " & Channel & " " & Nickname & " played: " & GetLongCardName(Card) & " New color: " & NewColor2,ServerNumber
- If CardsLeft = 0 then
- GameOver Nickname,Channel,True,ServerNumber
- Exit Sub
- ElseIf CardsLeft = 1 then
- SendCommand "/msg " & Channel & " " & Nickname & " has UNO",ServerNumber
- End If
- SendCommand "/msg " & Channel & " Next in turn: " & GetCurrentPlayer(Turn+1),ServerNumber
- Turn = Turn + 1
- ElseIf Card = "wd4" then 'player played a wild draw 4 card
- SendCommand "/msg " & Channel & " " & Nickname & " played: " & GetLongCardName(Card) & " New color: " & NewColor2,ServerNumber
- If CardsLeft = 0 then
- GameOver Nickname,Channel,True,ServerNumber
- Exit Sub
- ElseIf CardsLeft = 1 then
- SendCommand "/msg " & Channel & " " & Nickname & " has UNO",ServerNumber
- End If
- SendCommand "/msg " & Channel & " " & GetCurrentPlayer(Turn+1) & " Draws 4 cards and is skipped. Next in turn: " & GetCurrentPlayer(Turn+2),ServerNumber
- DrawnCards = GetNewCards(4)
- If Not DrawnCards = "" then
- Players.item(GetCurrentPlayer(Turn+1)) = Players.item(GetCurrentPlayer(Turn+1)) & "," & DrawnCards
- SendCommand "/notice " & GetCurrentPlayer(Turn+1) & " --- You drew: " & AddColors(DrawnCards),ServerNumber
- Else
- SendCommand "/msg " & Channel & " Not enough cards in the deck",ServerNumber
- End If
- Turn = Turn + 2
- End If
- Else
- SendCommand "/msg " & Channel & " " & Nickname & " played: " & GetLongCardName(Card),ServerNumber
- If CardsLeft = 0 then
- GameOver Nickname,Channel,True,ServerNumber
- Exit Sub
- ElseIf CardsLeft = 1 then
- SendCommand "/msg " & Channel & " " & Nickname & " has UNO",ServerNumber
- End If
- SendCommand "/msg " & Channel & " Next in turn: " & GetCurrentPlayer(Turn+1),ServerNumber
- Turn = Turn + 1
- End If
- SendCommand "/notice " & GetCurrentPlayer(Turn) & " --- Your cards are: " & AddColors(Players.item(GetCurrentPlayer(Turn))),ServerNumber
- Else
- SendCommand "/msg " & Channel & " " & Nickname & ": You can not play that card",ServerNumber
- End If
- Else
- SendCommand "/msg " & Channel & " " & Nickname & ": You do not have that card",ServerNumber
- End If
- End If
- End Sub
Add Comment
Please, Sign In to add comment