コード例 #1
0
 public void MakeBattleMove(int moveSelection, DungeonCharacter opponent)
 {
     if (moveSelection == 1)
     {
         Attack(opponent);
     }
     else
     {
         Heal();
     }
 }
コード例 #2
0
        public void Attack(DungeonCharacter opponent)
        {
            Random rand      = new Random();
            bool   canAttack = rand.Next(101) <= Weapon.AccuracyPercent;

            if (canAttack)
            {
                Controller.Log(Weapon.GetMessage(this, opponent));
                int damage = Weapon.Strike();
                opponent.TakeDamage(damage);
            }
            else
            {
                Controller.Log($"{Name}'s attack on {opponent.Name} failed!");
            }

            Controller.Log("");
        }