Пример #1
0
        public bool SecondaryAttack(bool isPlayer1, CharacterClass opponent) // returns true if killing blow
        {
            RedisManager redis  = new RedisManager();
            int          damage = 0;

            switch (ClassName)
            {
            case "Barbarian":
                if (redis.HasResource(isPlayer1))
                {
                    redis.ApplyEffect(isPlayer1, "Raging");
                    redis.DecrementResource(isPlayer1);
                    redis.AddToCombatLog(Character.Name + " goes into a rage, doing 2 extra damage on a successful hit!");
                }
                break;

            case "Bard":
                if (redis.HasResource(isPlayer1) && redis.HasAction())
                {
                    redis.DecrementResource(isPlayer1);
                    redis.AddToCombatLog(Character.Name + " used Hideous Laughter.");
                    if (!RollSpellSave((int)Stat.Cha, (int)Stat.Wis, opponent))
                    {
                        //redis.ApplyEffect(!isPlayer1, "Restrained");
                        redis.ApplyEffect(!isPlayer1, "Incapacitated");
                        redis.AddToCombatLog(opponent.Character.Name + " is incapacitated.");
                    }
                    redis.DecrementAction();
                }
                break;

            case "Cleric":
                if (redis.HasResource(isPlayer1))
                {
                    redis.DecrementResource(isPlayer1);
                    redis.HealDamage(isPlayer1, RollDamage(1, 4, (int)Stat.Wis, 3), this);
                }
                break;

            case "Druid":
                if (redis.HasResource(isPlayer1) && redis.HasAction())
                {
                    redis.DecrementResource(isPlayer1);
                    redis.AddToCombatLog(Character.Name + " used Entangle.");
                    if (!RollSpellSave((int)Stat.Wis, (int)Stat.Str, opponent))
                    {
                        redis.ApplyEffect(!isPlayer1, "Incapacitated");
                        redis.AddToCombatLog(opponent.Character.Name + " is incapacitated!");
                    }
                    else
                    {
                        redis.AddToCombatLog(opponent.Character.Name + " breaks through the vines, not being incapacitated!");
                    }
                    redis.DecrementAction();
                }
                break;

            case "Fighter":
                if (redis.HasResource(isPlayer1))
                {
                    redis.DecrementResource(isPlayer1);
                    redis.AddToCombatLog(Character.Name + " gathers their resolve, pushing past their injuries!");
                    redis.HealDamage(isPlayer1, RollDamage(1, 10, -1, 5), this);
                }
                break;

            case "Monk":
                if (redis.HasResource(isPlayer1))
                {
                    redis.AddToCombatLog(Character.Name + " focuses their Chi, striking with great speed!");
                    for (int i = 0; i < 2; i++)
                    {
                        if (RollAttack(opponent.ArmorClass))
                        {
                            damage = RollDamage(1, 4, (int)Stat.Dex, 0);     // 1d4 + DEX
                        }
                    }
                    redis.DecrementResource(isPlayer1);
                }
                break;

            case "Paladin":
                if (redis.HasResource(isPlayer1))
                {
                    redis.ApplyEffect(isPlayer1, "Smiting");
                    redis.DecrementResource(isPlayer1);
                    redis.AddToCombatLog(Character.Name + "'s weapon glows with radiant energy! (Smite)");
                }
                break;

            case "Ranger":
                if (redis.HasResource(isPlayer1))
                {
                    redis.ApplyEffect(isPlayer1, "Marking");
                    redis.DecrementResource(isPlayer1);
                    redis.AddToCombatLog(Character.Name + " applies a Hunter's Mark on the opponent! Their attacks deal extra damage.");
                }
                break;

            case "Rogue":
                if (RollAttack(opponent.ArmorClass))
                {
                    int sneakAttack;
                    if (redis.HasResource(isPlayer1))
                    {
                        sneakAttack = RollDie(6);
                        redis.AddToCombatLog(Character.Name + " has the advantage of stealth, dealing extra damage with this attack!");
                    }
                    else
                    {
                        sneakAttack = 0;
                    }
                    damage = RollDamage(1, 4, (int)Stat.Dex, sneakAttack);     // 1d4 + DEX + 1d6(Sneak Attack)
                    redis.DecrementResource(isPlayer1);
                }
                break;

            case "Sorcerer":
                if (redis.HasResource(isPlayer1))
                {
                    redis.AddToCombatLog(Character.Name + " conjures up a bolt of chaotic energy!");
                    if (RollAttack(opponent.ArmorClass))
                    {
                        damage = RollDamage(2, 8, -1, RollDie(6));     // 2d8 + 1d6
                    }
                    redis.DecrementResource(isPlayer1);
                }
                break;

            case "Warlock":
                if (redis.HasResource(isPlayer1))
                {
                    redis.ApplyEffect(isPlayer1, "Hexing");
                    redis.DecrementResource(isPlayer1);
                    redis.AddToCombatLog(Character.Name + " hexes the opponent! Their attacks deal extra damage.");
                }
                break;

            case "Wizard":
                if (redis.HasResource(isPlayer1))
                {
                    redis.AddToCombatLog(Character.Name + " fires three magic missiles guaranteed to hit!");
                    damage = RollDamage(3, 4, -1, 3);     // 3d4 + 3
                    redis.DecrementAction();
                    redis.DecrementResource(isPlayer1);
                }
                break;

            default:
                break;
            }

            bool over;

            if (damage != 0)
            {
                over = redis.ApplyDamage(isPlayer1, damage, Character.Name);
                if (over)
                {
                    //redis.MatchOver(); // Probably pass isPlayer
                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
        public bool PrimaryAttack(bool isPlayer1, CharacterClass opponent) // returns true if killing blow
        {
            RedisManager redis  = new RedisManager();
            int          damage = 0;

            switch (ClassName)
            {
            case "Barbarian":
                if (RollAttack(opponent.ArmorClass))
                {
                    int rage = 0;
                    if (redis.CheckIfEffectActive(isPlayer1, "Raging"))
                    {
                        rage = 2;
                    }
                    damage = RollDamage(1, 12, (int)Stat.Str, rage);     // 1d12 + STR + 2(Rage damage if active)
                }
                break;

            case "Bard":
                if (RollAttack(opponent.ArmorClass))
                {
                    damage = RollDamage(1, 8, (int)Stat.Dex, 0);     // 1d8 + DEX
                }
                break;

            case "Cleric":
                if (!RollSpellSave((int)Stat.Wis, (int)Stat.Dex, opponent))     // 1d8(DEX Save)
                {
                    damage = RollDie(8);
                }
                break;

            case "Druid":
                if (RollAttack(opponent.ArmorClass))
                {
                    damage = RollDamage(1, 8, (int)Stat.Wis, 0);     // 1d8 + WIS
                }
                break;

            case "Fighter":
                if (RollAttack(opponent.ArmorClass))
                {
                    damage = RollDamage(2, 6, (int)Stat.Str, 0);     // 2d6 + STR
                }
                break;

            case "Monk":
                if (RollAttack(opponent.ArmorClass))
                {
                    damage = RollDamage(1, 4, (int)Stat.Dex, 0);     // 1d4 + DEX
                }
                break;

            case "Paladin":
                if (RollAttack(opponent.ArmorClass))
                {
                    int smite = 0;
                    if (redis.CheckIfEffectActive(isPlayer1, "Smiting"))
                    {
                        smite = RollDie(8);
                        //redis.DecrementResource(isPlayer1);
                        redis.RemoveEffect(isPlayer1, "Smiting");
                    }
                    damage = RollDamage(1, 8, (int)Stat.Str, smite);     // 1d8 + STR
                }
                break;

            case "Ranger":
                if (RollAttack(opponent.ArmorClass))
                {
                    int mark = 0;
                    if (redis.CheckIfEffectActive(isPlayer1, "Marking"))
                    {
                        mark = RollDie(6);
                    }
                    damage = RollDamage(1, 8, (int)Stat.Dex, mark);     // 1d8 + DEX
                }
                break;

            case "Rogue":
                if (RollAttack(opponent.ArmorClass))
                {
                    damage = RollDamage(1, 4, (int)Stat.Dex, RollDie(6));     // 1d4 + DEX + 1d6(Sneak Attack)
                    redis.DecrementResource(isPlayer1);
                }
                break;

            case "Sorcerer":
                if (!RollSpellSave((int)Stat.Cha, (int)Stat.Con, opponent))     // 1d6(CON Save)
                {
                    damage = RollDie(6);
                }
                break;

            case "Warlock":
                if (RollAttack(opponent.ArmorClass))
                {
                    int hex = 0;
                    if (redis.CheckIfEffectActive(isPlayer1, "Hexing"))
                    {
                        hex = RollDie(6);
                    }
                    damage = RollDamage(1, 10, (int)Stat.Cha, hex);     // 1d10 + CHA
                }
                break;

            case "Wizard":
                if (RollAttack(opponent.ArmorClass))
                {
                    damage = RollDamage(1, 10, (int)Stat.Int, 0);     // 1d10 + INT
                }
                break;

            default:
                break;
            }

            redis.DecrementAction();

            bool over;

            if (damage != 0)
            {
                over = redis.ApplyDamage(isPlayer1, damage, Character.Name);
                if (over)
                {
                    //redis.MatchOver(); // Probably pass isPlayer
                    return(true);
                }
            }

            return(false);
        }