Exemplo n.º 1
0
 public static void Attack(ICreature attacker, ICreature deffender, int answer)
 {
     //Chance of armor deflecting the attack
     //If armor doesnt stop the attack.
     if (RandomChance.Success(100 - deffender.Armor))
     {
         //Chance of dealing damage.
         int damageDealth = attacker.Attack(attacker.AttackChance[answer], attacker.AttackPower[answer]);
         //If any damage dealth
         if (damageDealth != 0)
         {
             deffender.HP -= damageDealth;
             //If defender is dead.
             if (deffender.HP > 0)
             {
                 Console.WriteLine($"{attacker.Name} dealth {damageDealth} damage. {deffender.Name} now has {deffender.HP}HP");
             }
             else
             {
                 Console.WriteLine("{1} dealth {0} damage.", damageDealth, attacker.Name);
             }
         }
         //No damage dealth.
         else
         {
             //Attack failed
             Console.WriteLine("{1} couldn't perform {0}.", attacker.AttackNames[answer], attacker.Name);
         }
     }
     else
     {
         //armor blocked
         Console.WriteLine("{0}'s armor stopped {1} attack.", deffender.Name, attacker.Name);
     }
 }
Exemplo n.º 2
0
        private int AttackPowerModifier(ICreature attacker)
        {
            Hit hit    = attacker.Attack();
            int damage = new int();

            if (hit.Type == PowerEnum.ForcePower)
            {
                damage = (int)(hit.Power * this.fightRules.ForceAttackCoefficient);
            }
            else if (hit.Type == PowerEnum.MentalPower)
            {
                damage = (int)(hit.Power * this.fightRules.MindAttackCoefficient);
            }

            return(damage);
        }
Exemplo n.º 3
0
        private void PlayTurn(IPlayer player, IPlayer opponent)
        {
            Console.WriteLine(constants.StartOfTurnOptions);

            while (true)
            {
                string input = Console.ReadLine();
                if (input == "8")
                {
                    break;
                }
                switch (input)
                {
                case "1":
                    Console.WriteLine(constants.AskToEnterCreatureName);
                    player.PrintCreaturesInHand();
                    ICreature creature = player.SelectACreature(Console.ReadLine());
                    if (creature.ManaCost > player.ManaCrystals)
                    {
                        Console.WriteLine(constants.NotEnoughManaCrystal);
                        break;
                    }
                    player.PlayCreature(creature);
                    break;

                case "2":
                    Console.WriteLine(constants.AskToEnterSpellName);
                    player.PrintSpellsInHand();
                    ISpell spell = player.SelectASpell(Console.ReadLine());
                    if (spell.ManaCost > player.ManaCrystals)
                    {
                        Console.WriteLine(constants.NotEnoughManaCrystal);
                        break;
                    }
                    player.ManaCrystals -= spell.ManaCost;
                    player.PlayerHand.Remove(spell);
                    Console.WriteLine(constants.MenuWhenCastingSpell);
                    switch (Console.ReadLine())
                    {
                    case "1":
                        spell.CastSpell(opponent);
                        break;

                    case "2":
                        CastSpellOnOpponentsCreature(player, opponent, spell);
                        break;
                    }
                    break;

                case "3":
                    if (opponent.BattleField.Count == 0)
                    {
                        Console.WriteLine(constants.EnemyDoesntHaveACreature);
                        PlayTurn(player, opponent);
                    }
                    else
                    {
                        Console.WriteLine(constants.AskToEnterCreatureName);
                        player.PrintCreaturesOnBattleField();
                        string    attackingCreature = Console.ReadLine().ToLower();
                        ICreature myCreature        = (ICreature)player.BattleField.FirstOrDefault(x => x.Name.ToLower() == attackingCreature);

                        Console.WriteLine(constants.EnterCreatureNameToBeAttacked);
                        opponent.PrintCreaturesOnBattleField();
                        string    defendingCreature = Console.ReadLine().ToLower();
                        ICreature oppoCreature      = (ICreature)opponent.BattleField.FirstOrDefault(x => x.Name.ToLower() == defendingCreature);
                        myCreature.Attack(oppoCreature);
                        if (oppoCreature.IsDead)
                        {
                            opponent.BattleField.Remove(oppoCreature);
                        }
                    }
                    break;

                case "4":
                    Console.WriteLine(constants.EnterCreatureName);
                    player.PrintCreaturesOnBattleField();
                    ICreature myCreature2 = (ICreature)player.BattleField.FirstOrDefault(x => x.Name.ToLower() == Console.ReadLine().ToLower());
                    myCreature2.Attack(opponent);
                    break;
                }
            }
        }
Exemplo n.º 4
0
        private int AttackPowerModifier(ICreature attacker)
        {
            Hit hit = attacker.Attack();
            int damage = new int();
            if (hit.Type == PowerEnum.ForcePower)
            {
                damage = (int)(hit.Power * this.fightRules.ForceAttackCoefficient);
            }
            else if (hit.Type == PowerEnum.MentalPower)
            {
                damage = (int)(hit.Power * this.fightRules.MindAttackCoefficient);
            }

            return damage;
        }