コード例 #1
0
ファイル: Dice.cs プロジェクト: Terallis/SWLOR_NWN
        private void DoDiceRoll(NWPlayer user, int sides, int number)
        {
            int value;

            if (number < 1)
            {
                number = 1;
            }
            else if (number > 10)
            {
                number = 10;
            }

            switch (sides)
            {
            case 2:
                value = RandomService.D2(number);
                break;

            case 4:
                value = RandomService.D4(number);
                break;

            case 6:
                value = RandomService.D6(number);
                break;

            case 8:
                value = RandomService.D8(number);
                break;

            case 10:
                value = RandomService.D10(number);
                break;

            case 20:
                value = RandomService.D20(number);
                break;

            case 100:
                value = RandomService.D100(number);
                break;

            default:
                value = 0;
                break;
            }

            string dieRoll = number + "d" + sides;
            string message = ColorTokenService.SkillCheck("Dice Roll: ") + dieRoll + ": " + value;

            user.SpeakString(message);
        }