Created
April 10, 2020 09:10
-
-
Save smkplus/38cb37f4d30608bf77a9f7d8543759a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| public abstract class Character | |
| { | |
| public int Armor { get; set; } | |
| public int Life { get; set; } | |
| public abstract void Attack(); | |
| public abstract void TakeDamage(int damage); | |
| } | |
| public class Warrior : Character | |
| { | |
| public int Armor { get; set; } | |
| public int Life { get; set; } | |
| public override void Attack() | |
| { | |
| // Attack to closest enemy | |
| } | |
| public override void TakeDamage(int damage) | |
| { | |
| Life -= Math.Max(0, damage - Armor); | |
| } | |
| } | |
| public class Mage : Character | |
| { | |
| public int MagicProtection { get; set; } | |
| public override void Attack() | |
| { | |
| // Throw a Fire to target | |
| } | |
| public void Hex() | |
| { | |
| // Convert target to sheep | |
| } | |
| public override void TakeDamage(int damage) | |
| { | |
| Life -= Math.Max(0, damage - Armor - MagicProtection); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment