예제 #1
0
파일: dices.cs 프로젝트: 0xAvier/BushidoApp
        // Return the result of the roll of a bushido dice
        public static int BushidoDice()
        {
            // Get the value of a roll
            int res = Dices.D6();

            // Return 0 if the D6 is a 1
            return((res != 1) ? res : 0);
        }
예제 #2
0
파일: dices.cs 프로젝트: 0xAvier/BushidoApp
        static public bool TestDices()
        {
            bool functionnal = true;

            int  d2 = 0, d6 = 0, bushidoDice = 0;
            long max = 1000000;

            for (int i = 0; i < max; i++)
            {
                d2          += Dices.D2();
                d6          += Dices.D6();
                bushidoDice += Dices.BushidoDice();
            }

            double average;

            if (Test.verbose)
            {
                Output.Print("Test Dices.D2:   ");
            }
            average      = (double)d2 / max;
            functionnal &= Test.TestInterval(1.49, 1.51, average);

            if (Test.verbose)
            {
                Output.Print("Test Dices.D6:   ");
            }
            average      = (double)d6 / max;
            functionnal &= Test.TestInterval(3.49, 3.51, average);

            if (Test.verbose)
            {
                Output.Print("Test Dices.bushidoDice:   ");
            }
            average      = (double)bushidoDice / max;
            functionnal &= Test.TestInterval(3.33, 3.34, average);

            if (Test.verbose && functionnal)
            {
                Output.PrintLine("Test Dices:  ok.");
            }
            else if (Test.verbose)
            {
                Output.PrintLine("Test Dices:  not ok.");
            }

            return(functionnal);
        }
예제 #3
0
파일: Wound.cs 프로젝트: 0xAvier/BushidoApp
        static public int DamageRoll(Profile Attacker, Profile Defender)
        {
            int roll;

            // Get the roll
            if (Attacker.Treats.Strong.Has || Attacker.Treats.Assassin.Has)
            {
                int a = Dices.D6(), b = Dices.D6(), c = Dices.D6();
                roll = a + b + c - minOf3(a, b, c);
            }
            else if (Attacker.Treats.Weak.Has)
            {
                int a = Dices.D6(), b = Dices.D6(), c = Dices.D6();
                roll = a + b + c - maxOf3(Dices.D6(), Dices.D6(), Dices.D6());
            }
            else
            {
                roll = Dices.D6() + Dices.D6();
            }

            // Apply strengh
            roll += Attacker.Treats.Strengh.Value;

            // Apply armour & armour piercing
            bool sharpOrPiercing = Attacker.Treats.ArmourPiercing.Has;

            sharpOrPiercing |= Attacker.Treats.Sharp.Has;
            if (Defender.Treats.Armour.Has && !sharpOrPiercing)
            {
                roll -= Defender.Treats.Armour.Value;
            }

            // stay between 0 and 12
            roll = Math.Min(12, roll);
            roll = Math.Max(0, roll);

            return(roll);
        }