/// <summary> /// Warrior drinks a portion /// </summary> /// <param name="portion">The portion<see cref="PortionTypes"/></param> public void Drink(PortionTypes portion) { switch (CharacterType) { case CharacterTypes.Elf: switch (portion) { case PortionTypes.Wine: Health -= 20; break; case PortionTypes.Poison: Health += 40; break; } break; case CharacterTypes.Ogre: switch (portion) { case PortionTypes.Wine: Health += 40; break; case PortionTypes.Poison: Health -= 20; break; } break; } }
public ActionResult <Warrior> Drink(string id, PortionTypes portion) { var warrior = WarriorCollection.Warriors.FirstOrDefault(w => w.Id == id); if (warrior == null) { return(NotFound()); } warrior.Drink(portion); return(Ok(warrior)); }