コード例 #1
0
ファイル: Combat.cs プロジェクト: Marcotte173/Upstairs
    private static void Attack(Gladiator a, Gladiator b)
    {
        int attackRoll = Return.RandomInt(0, 101);

        //A crits
        if (attackRoll < 6)
        {
            if (momentum < 0)
            {
                b.TakeDamage(a, momentum, 1);
            }
            else
            {
                b.TakeDamage(a, Math.Abs(momentum), 1);
            }
            momentum -= 3;
        }
        //B Crits
        else if (attackRoll > 95)
        {
            if (momentum > 0)
            {
                a.TakeDamage(b, momentum, 1);
            }
            else
            {
                a.TakeDamage(b, -momentum, 1);
            }
            momentum += 3;
        }
        //Up for grabs!
        else
        {
            //Modify based on offence
            attackRoll -= a.Offence;
            attackRoll += b.Offence;
            //If less than 50, a wins, but b's defence can mitigate
            if (attackRoll < 50)
            {
                attackRoll = (attackRoll + b.Defence / 2 > 50) ? 50 : attackRoll + b.Defence / 2;
            }
            //If not, b wins, but a's defence can mitigate
            else
            {
                attackRoll = (attackRoll - a.Defence / 2 < 50) ? 50 : attackRoll - a.Defence / 2;
            }

            if (attackRoll < 45 && attackRoll >= 25)
            {
                if (momentum < 0)
                {
                    b.TakeDamage(a, momentum, 3);
                }
                else
                {
                    b.TakeDamage(a, Math.Abs(momentum), 3);
                }
                momentum -= 1;
            }
            else if (attackRoll < 25 && attackRoll >= 11)
            {
                if (momentum < 0)
                {
                    b.TakeDamage(a, momentum, 2);
                }
                else
                {
                    b.TakeDamage(a, Math.Abs(momentum), 2);
                }
                momentum -= 2;
            }
            else if (attackRoll < 11)
            {
                if (momentum < 0)
                {
                    b.TakeDamage(a, momentum, 1);
                }
                else
                {
                    b.TakeDamage(a, Math.Abs(momentum), 1);
                }
                momentum -= 3;
            }
            else if (attackRoll > 55 && attackRoll <= 75)
            {
                if (momentum > 0)
                {
                    a.TakeDamage(b, momentum, 3);
                }
                else
                {
                    a.TakeDamage(b, -momentum, 3);
                }
                momentum += 1;
            }
            else if (attackRoll > 75 && attackRoll <= 90)
            {
                if (momentum > 0)
                {
                    a.TakeDamage(b, momentum, 2);
                }
                else
                {
                    a.TakeDamage(b, -momentum, 2);
                }
                momentum += 2;
            }
            else if (attackRoll > 90)
            {
                if (momentum > 0)
                {
                    a.TakeDamage(b, momentum, 1);
                }
                else
                {
                    a.TakeDamage(b, -momentum, 1);
                }
                momentum += 3;
            }
            else
            {
                int r = Return.RandomInt(0, 3);
                if (a.Owner.player || b.Owner.player)
                {
                    string x = (r == 0) ? "The two gladiators circle each other, neither gaining an advantage" : (r == 1) ? $"{a.name} makes a feint, but {b.name} doesn't fall for it" : $"{b.name} makes a feint, but {a.name} doesn't fall for it";
                    Write.Line(0, 24, x);
                }
            }
        }
    }