Skip to content

Instantly share code, notes, and snippets.

@smkplus
Created April 10, 2020 09:10
Show Gist options
  • Save smkplus/38cb37f4d30608bf77a9f7d8543759a0 to your computer and use it in GitHub Desktop.
Save smkplus/38cb37f4d30608bf77a9f7d8543759a0 to your computer and use it in GitHub Desktop.
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