public void ApplyRune() { if (ItemToImprove == null || Rune == null) { return; } var rune = Rune; rune.Owner.Inventory.RemoveItem(rune.PlayerItem, 1); Crafter.MoveItem(rune.Guid, -1); foreach (var effect in rune.Effects.OfType <EffectInteger>()) { var existantEffect = GetEffectToImprove(effect); double criticalSuccess, neutralSuccess, criticalFailure; GetChances(existantEffect, effect, out criticalSuccess, out neutralSuccess, out criticalFailure); var rand = new CryptoRandom(); var randNumber = (int)(rand.NextDouble() * 100); if (randNumber <= criticalSuccess) { BoostEffect(effect); OnRuneApplied(CraftResultEnum.CRAFT_SUCCESS, MagicPoolStatus.UNMODIFIED); } else if (randNumber <= criticalSuccess + neutralSuccess) { BoostEffect(effect); int residual = DeBoostEffect(effect); OnRuneApplied(CraftResultEnum.CRAFT_SUCCESS, GetMagicPoolStatus(residual)); } else { int residual = DeBoostEffect(effect); OnRuneApplied(CraftResultEnum.CRAFT_FAILED, GetMagicPoolStatus(residual)); } } ItemToImprove.PlayerItem.Invalidate(); }