Created
April 29, 2022 18:09
-
-
Save eeevans/9406336af7d1221ac9f8eaa1fcabf334 to your computer and use it in GitHub Desktop.
This file contains 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
internal class Program | |
{ | |
public void Main() | |
{ | |
var rust = new Rust(); | |
var lumio = new Lumio(); | |
var roberto = new Roberto(); | |
rust.Attack(roberto); | |
} | |
} | |
public interface ITakeDamage | |
{ | |
void TakeDamage(int amount); | |
} | |
public interface ITakeHealing | |
{ | |
void TakeHealing(int amount); | |
} | |
public abstract class Character : ITakeDamage, ITakeHealing | |
{ | |
public int Damage { get; set; } | |
public int Health { get; set; } | |
public virtual void DoSpecial() { }; | |
public virtual void HealFriend(ITakeHealing friend) { }; | |
public virtual void Attack(ITakeDamage foe) { foe.TakeDamage(Damage) }; | |
public void TakeDamage(int amount) => Health -= amount; | |
public void TakeHealing(int amount) => Health += amount; | |
} | |
public abstract class Player : Character { }; | |
public abstract class Enemy : Character { }; | |
public class Rust : Player | |
{ | |
public Rust() | |
{ | |
Health = 50; | |
Damage = 2; | |
} | |
public override void HealFriend(ITakeHealing friend) | |
{ | |
friend.TakeHealing(10); | |
} | |
} | |
public class Lumio : Player | |
{ | |
public Lumio() | |
{ | |
Health = 28; | |
Damage = 5; | |
} | |
public override void DoSpecial() | |
{ | |
// show flash for powerup | |
Damage += 10; | |
} | |
} | |
public class Roberto : Enemy | |
{ | |
public Roberto() | |
{ | |
Health = 20; | |
Damage = 5; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment