Skip to content

Instantly share code, notes, and snippets.

@chuwilliamson
Created March 16, 2016 17:45
Show Gist options
  • Select an option

  • Save chuwilliamson/3b26cb29cd573e3dc3ef to your computer and use it in GitHub Desktop.

Select an option

Save chuwilliamson/3b26cb29cd573e3dc3ef to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
public interface IDamager
{
/// <summary>
/// OUTGOING DAMAGE
/// </summary>
/// <returns>return how much damage was SENT</returns>
float Damage { get; }
}
public interface IDamageable //do damage and take damage
{
/// <summary>
/// INCOMING DAMAGE
/// </summary>
/// Perform damage on an object, it is the implementing class's responsibility to perform the
/// damage mitigation
void TakeDamage(int amount);
}
public interface Iitem
{
int doItem(IStat s);
}
public interface IStat
{
int hp { get; set; }
int resource { get; set; }
}
public class Rogue : IStat
{
Rogue()
{
inventory.Add(potion1);
inventory.Add(potion2);
}
public int hp
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public int resource
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public List<Iitem> inventory;
HealthPotion potion1 = new HealthPotion(1);
HealthPotion potion2 = new HealthPotion(25);
EnergyPotion thistleTea = new EnergyPotion(25);
}
public class EnergyPotion : Iitem
{
EnergyPotion(int val)
{
value = val;
}
int value;
public int doItem(IStat s)
{
return s.resource + value;
}
}
public class HealthPotion : Iitem
{
int value;
public HealthPotion(int healthAmount)
{
value = healthAmount;
}
public int doItem(IStat stat)
{
return stat.hp + value;
}
}
public class Game
{
}
@chuwilliamson
Copy link
Copy Markdown
Author

example usage of interfaces for guy goudeau

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment