예제 #1
0
파일: UnoMain.cs 프로젝트: Vednix/Uno
        private void UnoView(CommandArgs args)
        {
            if (UnoGame.state != "active")
            {
                args.Player.SendErrorMessage("No ongoing game of Uno to view!");
                return;
            }

            if (!UnoGame.isPlaying(args.Player.Index))
            {
                for (int i = 0; i < UnoGame.watchers.Count; i++)
                {
                    if (UnoGame.watchers[i].Index == args.Player.Index)
                    {
                        UnoGame.watchers.RemoveAt(i);
                        args.Player.SendSuccessMessage("You are no longer viewing the game of Uno.");
                        return;
                    }
                }
                UnoGame.watchers.Add(args.Player);
                args.Player.SendSuccessMessage("You are now viewing the game of Uno!");
            }
            else
            {
                args.Player.SendErrorMessage("You're already playing in the game!");
            }
        }
예제 #2
0
파일: UnoMain.cs 프로젝트: Vednix/Uno
 private void OnLeave(LeaveEventArgs args)
 {
     if (UnoGame.state != "inactive" && UnoGame.isPlaying(args.Who))
     {
         UnoGame.LeaveGame(args.Who);
     }
 }
예제 #3
0
파일: UnoMain.cs 프로젝트: Vednix/Uno
 private void UnoPass(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 + " passes " + (args.Player.TPlayer.Male ? "his" : "her") + " turn.");
         args.Player.SendSuccessMessage("[Uno] You have passed your turn.");
         UnoGame.turnTimer.Enabled = false;
         UnoGame.goToNextTurn();
     }
     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 must {0}draw before you can {0}pass!", TShock.Config.CommandSpecifier);
     }
     else
     {
         args.Player.SendErrorMessage("[Uno] An error occured.");
         TShock.Log.Error("An error with Uno occurred!");
     }
 }
예제 #4
0
파일: UnoMain.cs 프로젝트: Vednix/Uno
 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!");
     }
 }
예제 #5
0
파일: Program.cs 프로젝트: P2A404/UNO
        static void Main(string[] args)
        {
            UnoGame game = new UnoGame(1);

            game.PrintGame();

            Console.Read();
        }
예제 #6
0
파일: UnoMain.cs 프로젝트: Vednix/Uno
 private void UnoCards(CommandArgs args)
 {
     if (UnoGame.state == "active" && UnoGame.isPlaying(args.Player.Index, args.Player.Name))
     {
         for (int i = 0; i < UnoGame.players.Count; i++)
         {
             if (UnoGame.players[i].tsplayer.Name == args.Player.Name)
             {
                 args.Player.SendInfoMessage("[Uno] Your current cards are {0}. The current card is {1}{2}.", string.Join(" ", UnoGame.players[i].hand.Select(p => p.ToOutput())), Deck.faceup.ToOutput(), (Deck.faceup.value == "wild" || Deck.faceup.value == "wdr4" ? " " + Deck.color : ""));
             }
         }
     }
 }
예제 #7
0
파일: UnoMain.cs 프로젝트: Vednix/Uno
        private void UnoPlay(CommandArgs args)
        {
            if (UnoGame.state == "active" && UnoGame.isPlaying(args.Player.Index, args.Player.Name) && UnoGame.isCurrentTurn(args.Player.Index, args.Player.Name))
            {
                if (args.Parameters.Count > 0 && args.Parameters.Count < 3)
                {
                    if (!Deck.IsValid(args.Parameters[0]))
                    {
                        args.Player.SendErrorMessage("[Uno] That is not a valid card.");
                        return;
                    }
                    if (!UnoGame.players[UnoGame.turnindex].hasCard(args.Parameters[0]))
                    {
                        args.Player.SendErrorMessage("[Uno] You do not have that card.");
                        return;
                    }
                    Card card = Deck.Parse(args.Parameters[0]);
                    if (card.color != Deck.color && card.value != Deck.faceup.value && card.value != "wild" && card.value != "wdr4")
                    {
                        args.Player.SendErrorMessage("[Uno] You cannot play that card!");
                        return;
                    }

                    UnoGame.playCard(args.Parameters[0], (args.Parameters.Count == 2 ? args.Parameters[1] : null));
                }
                else
                {
                    args.Player.SendErrorMessage("[Uno] Invalid Syntax: {0}play <card> [color]", TShock.Config.CommandSpecifier);
                    args.Player.SendErrorMessage("[Uno] Use {0}uno help <card> for help on how to play each card.", TShock.Config.CommandSpecifier);
                }
            }
            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
            {
                args.Player.SendErrorMessage("[Uno] An error occured.");
                TShock.Log.Error("An error with Uno occurred!");
            }
        }
예제 #8
0
파일: Player.cs 프로젝트: David176/SWT
 public Player(UnoGame unoGame, string name)
 {
     _unoGame = unoGame;
     Hand = new List<Card>();
     Name = name;
 }
예제 #9
0
파일: UnoMain.cs 프로젝트: Vednix/Uno
        private void UnoClass(CommandArgs args)
        {
            if (args.Parameters.Count > 0)
            {
                if (args.Parameters[0] == "help")
                {
                    UnoGame.displayHelp(args.Player, args.Parameters);
                    return;
                }
            }
            if (UnoGame.state == "inactive")
            {
                if (args.Parameters.Count == 1 && args.Parameters[0] == "start")
                {
                    UnoGame.StartVote(args.Player);
                    UnoGame.JoinGame(args.Player);
                }
                else
                {
                    if (args.Parameters.Count > 0 && (args.Parameters[0] == "join" || args.Parameters[0] == "quit"))
                    {
                        args.Player.SendErrorMessage("[Uno] No game running! Use {0}uno start to start a game of Uno!", TShock.Config.CommandSpecifier);
                    }
                    else if (args.Parameters.Count > 0 && args.Parameters[0] == "stop" && args.Player.Group.HasPermission("uno.mod"))
                    {
                        args.Player.SendErrorMessage("[Uno] No game running!");
                    }
                    else
                    {
                        args.Player.SendErrorMessage("[Uno] Invalid syntax! Use \"{0}uno start\" to start a game of Uno!", TShock.Config.CommandSpecifier);
                    }
                }
            }
            else if (UnoGame.state == "voting")
            {
                if (args.Parameters.Count == 1 && args.Parameters[0] == "join")
                {
                    if (!UnoGame.isPlaying(args.Player.Index, args.Player.Name))
                    {
                        UnoGame.JoinGame(args.Player);
                    }
                    else
                    {
                        args.Player.SendErrorMessage("[Uno] You have already joined this game of Uno!");
                    }
                }
                else if (args.Parameters.Count == 1 && args.Parameters[0] == "quit" && UnoGame.isPlaying(args.Player.Index, args.Player.Name))
                {
                    UnoGame.LeaveGame(args.Player.Index, args.Player.Name);
                }
                else
                {
                    if (args.Parameters.Count > 0 && args.Parameters[0] == "start")
                    {
                        args.Player.SendErrorMessage("[Uno] A game of Uno is already started! Use {0}uno join to join the game!", TShock.Config.CommandSpecifier);
                    }
                    else if (args.Parameters.Count > 0 && args.Parameters[0] == "stop" && args.Player.Group.HasPermission("uno.mod"))
                    {
                        UnoGame.toStartGame.Enabled = false;
                        UnoGame.stopGame(args.Player);
                    }
                    else
                    {
                        args.Player.SendErrorMessage("[Uno] Invalid syntax! Use \"{0}game join\" to join the game of Uno!", TShock.Config.CommandSpecifier);
                    }
                }
            }
            else if (UnoGame.state == "active")
            {
                if (args.Parameters.Count == 1 && args.Parameters[0] == "stop" && args.Player.Group.HasPermission("uno.mod"))
                {
                    UnoGame.stopGame(args.Player);
                }
                else if (args.Parameters.Count == 1 && args.Parameters[0] == "quit" && UnoGame.isPlaying(args.Player.Index, args.Player.Name))
                {
                    UnoGame.LeaveGame(args.Player.Index, args.Player.Name);
                }
                else if (args.Parameters.Count == 2 && args.Parameters[0] == "kick" && args.Player.Group.HasPermission("uno.mod"))
                {
                    List <TSPlayer> listplayers = TShock.Utils.FindPlayer(args.Parameters[1]);

                    if (listplayers.Count == 0)
                    {
                        args.Player.SendErrorMessage("No players matched.");
                    }
                    else if (listplayers.Count > 1)
                    {
                        TShock.Utils.SendMultipleMatchError(args.Player, listplayers.Select(p => p.Name));
                    }
                    else
                    {
                        TSPlayer kicked = listplayers[0];
                        UnoGame.LeaveGame(kicked.Index, kicked.Name);
                        UnoGame.broadcast(args.Player.Name + " has kicked " + kicked.Name + " from the game of Uno.");
                    }
                }
                else
                {
                    if (args.Parameters.Count > 0 && args.Parameters[0] == "start")
                    {
                        if (UnoGame.isPlaying(args.Player.Index, args.Player.Name))
                        {
                            args.Player.SendErrorMessage("[Uno] You are already playing a game of Uno!");
                        }
                        else
                        {
                            args.Player.SendErrorMessage("[Uno] A game of Uno is already in progress!");
                        }
                    }
                    else if (args.Parameters.Count > 0 && args.Parameters[0] == "join")
                    {
                        args.Player.SendErrorMessage("[Uno] You cannot join an ongoing game!");
                    }
                    else
                    {
                        args.Player.SendErrorMessage("[Uno] Invalid syntax!");
                    }
                }
            }
        }