コード例 #1
0
ファイル: Character.cs プロジェクト: StiliyanM/Softuni
        public void GiveCharacterItem(Item item, Character character)
        {
            CheckIfAlive();
            character.CheckIfAlive();

            character.ReceiveItem(item);
        }
コード例 #2
0
ファイル: Cleric.cs プロジェクト: MertYumer/CSharp-OOP-Exams
        public void Heal(Character character)
        {
            this.CheckIfAlive();
            character.CheckIfAlive();

            if (this.Faction != character.Faction)
            {
                throw new InvalidOperationException("Cannot heal enemy character!");
            }

            character.IncreaseHealth(this.AbilityPoints);
        }
コード例 #3
0
ファイル: Warrior.cs プロジェクト: StiliyanM/Softuni
        public void Attack(Character character)
        {
            base.CheckIfAlive();

            character.CheckIfAlive();
            if (this.Name == character.Name)
            {
                throw new InvalidOperationException("Cannot attack self!");
            }

            if (this.Faction == character.Faction)
            {
                throw new ArgumentException($"Friendly fire! Both characters are from {this.Faction} faction!");
            }

            character.TakeDamage(this.AbilityPoints);
        }
コード例 #4
0
 public void UseItemOn(Item item, Character character)
 {
     CheckIfAlive();
     character.CheckIfAlive();
     item.AffectCharacter(character);
 }