CardsAgainstIRC3.Game.States.Base.DeckWeightCommand C# (CSharp) Method

DeckWeightCommand() private method

private DeckWeightCommand ( CommandContext context, IEnumerable arguments ) : void
context CommandContext
arguments IEnumerable
return void
        public void DeckWeightCommand(CommandContext context, IEnumerable<string> arguments)
        {
            if (arguments.Count() > 2 || arguments.Count() == 0)
            {
                SendInContext(context, "Usage: !deck.weight deck [weight]");
                return;
            }

            int deck;
            if (!int.TryParse(arguments.First(), out deck) || deck < 0 || deck >= Manager.CardSets.Count)
            {
                SendInContext(context, "Out of range!");
                return;
            }

            if (arguments.Count() == 1)
            {
                var deckinfo = Manager.CardSets[deck];
                SendInContext(context, "Weight of {0} is {1}", deckinfo.Item1.Description, deckinfo.Item2);
            }
            else
            {
                int weight;
                if (!int.TryParse(arguments.ElementAt(1), out weight) || weight < 1)
                {
                    SendInContext(context, "Weight is out of range!");
                    return;
                }

                var deckinfo = Manager.CardSets[deck];
                Manager.CardSets[deck] = new Tuple<IDeckType, int>(deckinfo.Item1, weight);
            }
        }