Пример #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!");
     }
 }
Пример #2
0
 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!");
     }
 }
Пример #3
0
        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!");
                    }
                }
            }
        }