public void Enhance(IEnhancable enhancable, IEnumerable <Item> particles, int desiredEnhancement) { if (desiredEnhancement <= enhancable.Enhancement) { return; } int cost = GetCost(enhancable, desiredEnhancement); if (particles.Where(o => o.ItemId == EmpoweredParticle.Id).Count() != cost) { throw new InsufficientEmpoweredParticlesException(); } enhancable.Enhancement = desiredEnhancement; if (enhancable.GetType() == typeof(Equipment)) { equipmentGenerator.AdjustStats((Equipment)enhancable); } }
public void Enhance(IEnhancable enhancable, IEnumerable <Item> particles) { if (particles.Where(o => o.ItemId == EmpoweredParticle.Id).Count() != ParticlesCost) { throw new InsufficientEmpoweredParticlesException(); } var success = enhancementProbability.IsSuccess(enhancable); if (success) { enhancable.Enhancement += 1; } else { enhancable.Enhancement = 0; } if (enhancable.GetType() == typeof(Equipment)) { equipmentGenerator.AdjustStats((Equipment)enhancable); } }