private void УлучшитьToolStripMenuItem_Click(object sender, EventArgs e) { var item = GetSelectedItem(); if (item == null) return; if (item is ICanBeEnchanted itemToEnchant) { _itemToEnchant = itemToEnchant; UpdateItemToEnchantSlot(_itemToEnchant); if (_scrollOfEnchant != null && !InventoryController.CanBeEnchantedWith(_itemToEnchant, _scrollOfEnchant)) { _scrollOfEnchant = null; SetPictureBox(ScrollOfEnchantSlot, null); } } else if (item is ScrollOfEnchant scrollOfEnchant) { if (_itemToEnchant == null || InventoryController.CanBeEnchantedWith(_itemToEnchant, scrollOfEnchant)) { _scrollOfEnchant = scrollOfEnchant; SetPictureBox(ScrollOfEnchantSlot, scrollOfEnchant); } } if (_itemToEnchant != null && _scrollOfEnchant != null) { EnchantChanceLabel.Text = InventoryController.GetItemEnchantChance(_itemToEnchant, _scrollOfEnchant) .ToPercentString(2); EnchantButton.Text = $"Улучшить на +{_itemToEnchant.EnchantmentLevel + 1}"; } else { EnchantChanceLabel.Text = ""; EnchantButton.Text = ""; } }