Example #1
0
 private void UnoDraw(CommandArgs args)
 {
     if (UnoGame.state == "active" && UnoGame.isPlaying(args.Player.Index, args.Player.Name) && UnoGame.isCurrentTurn(args.Player.Index, args.Player.Name) && !UnoGame.players[UnoGame.turnindex].hasdrawn)
     {
         UnoGame.broadcast(args.Player.Name + " draws a card.");
         var drawnCard = Deck.DrawCard(UnoGame.turnindex);
         args.Player.SendSuccessMessage("[Uno] You have drawn: {0}", drawnCard);
         UnoGame.players[UnoGame.turnindex].hasdrawn = true;
     }
     else if (UnoGame.state != "active" || !UnoGame.isPlaying(args.Player.Index, args.Player.Name))
     {
         args.Player.SendErrorMessage("[Uno] You are not in a game!");
     }
     else if (!UnoGame.isCurrentTurn(args.Player.Index, args.Player.Name))
     {
         args.Player.SendErrorMessage("[Uno] It is not your turn!");
     }
     else if (UnoGame.players[UnoGame.turnindex].hasdrawn)
     {
         args.Player.SendErrorMessage("[Uno] You have already drawn! You must {0}pass if you cannot play a card!", TShock.Config.CommandSpecifier);
     }
     else
     {
         args.Player.SendErrorMessage("[Uno] An error occured.");
         TShock.Log.Error("An error with Uno occurred!");
     }
 }
Example #2
0
        public static void goToNextTurn(bool skip = false, int drawcards = 0)
        {
            if (!(playerleave && turnindex > players.Count - 1))
            {
                players[turnindex].hasdrawn = false;
            }

            if (forward)
            {
                if (turnindex + 1 >= players.Count)
                {
                    turnindex = 0;
                }
                else if (!playerleave)
                {
                    turnindex++;
                }
            }
            else
            {
                if (turnindex <= 0)
                {
                    turnindex = players.Count - 1;
                }
                else
                {
                    turnindex--;
                }
            }

            playerleave = false;

            if (skip)
            {
                return;
            }

            if (drawcards != 0)
            {
                for (int i = 0; i < drawcards; i++)
                {
                    Deck.DrawCard(turnindex);
                }
            }

            broadcast("It is now " + players[turnindex].tsplayer.Name + "'s turn!");
            if (Deck.faceup.value == "wild" || Deck.faceup.value == "wdr4")
            {
                players[turnindex].tsplayer.SendMessage("[Uno] It is now your turn! The current card is " + Deck.faceup.ToOutput() + ". The current color is " + Deck.color.ToString() + ".", Color.ForestGreen);
            }
            else
            {
                players[turnindex].tsplayer.SendMessage("[Uno] It is now your turn! The current card is " + Deck.faceup.ToOutput() + ".", Color.ForestGreen);
            }
            string hand = string.Join(", ", players[turnindex].hand.Select(p => p));

            players[turnindex].tsplayer.SendMessage("[Uno] Your current cards are: " + hand, Color.ForestGreen);
            players[turnindex].tsplayer.SendMessage("[Uno] You have one minute to play a card ({0}play <card> [color]) or draw a card ({0}draw).".SFormat(TShock.Config.CommandSpecifier), Color.ForestGreen);
            turnTimer.Enabled = true;
        }
Example #3
0
 private static void EndOfTurn(object sender, ElapsedEventArgs args)
 {
     players[turnindex].tsplayer.SendMessage("[Uno] You ran out of time! You are now drawing a card and passing your turn.", Color.ForestGreen);
     if (!players[turnindex].hasdrawn)
     {
         Deck.DrawCard(turnindex);
     }
     broadcast(players[turnindex].tsplayer.Name + " has timed out and automatically draws a card.");
     goToNextTurn();
 }