ALFAIRCBot.ALFAIRCBot.OnCommandStats C# (CSharp) Метод

OnCommandStats() приватный Метод

private OnCommandStats ( string Source, string Cmd ) : void
Source string
Cmd string
Результат void
        private void OnCommandStats(string Source, string Cmd)
        {
            // Check for command.
            if (Cmd == null || Cmd.Equals(""))
            {
                SendMessage(SendType.Message, Source, "No stat generation type specified. Defaulting to 4d6 drop lowest. Use \"!stats help\" to list other options.");
                Cmd = "4d6";
            }
            else if (Cmd.Equals("help"))
            {
                SendMessage(SendType.Message, Source, "\"!stats 3d6\" : Roll 3d6, take as-is.");
                SendMessage(SendType.Message, Source, "\"!stats 4d6\" : Roll 4d6, drop lowest dice.");
                return;
            }

            if (Cmd.Equals("4d6"))
            {
                // Results stored.
                int[] Results = new int[6];

                for (int r = 0; r < 6; r++)
                {
                    // Roll
                    int total = 0;
                    int lowest = 1024;
                    for (int i = 0; i < 4; i++)
                    {
                        int roll = (Rng.Next() % 6) + 1;
                        total += roll;

                        if (roll < lowest)
                        {
                            lowest = roll;
                        }
                    }
                    total -= lowest;

                    Results[r] = total;
                }

                // Print results.
                SendMessage(SendType.Message, Source, String.Format("Results: {0}; Point-Buy Value: {1}", string.Join(", ", Results), GetPointBuyValue(Results)));
            }
            else if (Cmd.Equals("3d6"))
            {
                // Results stored.
                int[] Results = new int[6];

                for (int r = 0; r < 6; r++)
                {
                    // Roll
                    int total = 0;
                    for (int i = 0; i < 3; i++)
                    {
                        int roll = (Rng.Next() % 6) + 1;
                        total += roll;
                    }

                    Results[r] = total;
                }

                // Print results.
                SendMessage(SendType.Message, Source, String.Format("Results: {0}; Point-Buy Value: {1}", string.Join(", ", Results), GetPointBuyValue(Results)));
            }
            else
            {
                // No valid command given.
                SendMessage(SendType.Message, Source, "Not a valid stat generation option. Use \"!stats help\" to list valid options.");
            }
        }