public override bool OnDragDrop(Mobile from, Item dropped) { if (dropped is SkillMasteryScroll) { SkillMasteryScroll skillMasteryScroll = dropped as SkillMasteryScroll; SkillMasteryScrollLibraryEntry entry = GetLibraryEntry(skillMasteryScroll.Skill); if (entry != null) { skillMasteryScroll.Delete(); entry.Count++; from.SendMessage("You add a skill mastery scroll to the library."); from.SendSound(addItemSound); } return(true); } else { return(false); } }
public void EjectScroll(Mobile from, SkillName skillName, bool ejectAll) { if (from == null) { return; } SkillMasteryScrollLibraryEntry entry = GetLibraryEntry(skillName); if (entry == null) { return; } if (entry.Count == 0) { from.SendMessage("You do not have any copies of that skill mastery scroll currently stored within this library."); return; } if (from.Backpack == null) { return; } if (from.Backpack.TotalItems >= from.Backpack.MaxItems) { from.SendMessage("Your backpack is at maximum capacity. Please remove some items and try again."); return; } if (ejectAll) { int spaceAvailable = from.Backpack.MaxItems - from.Backpack.TotalItems; int retrievalAmount = 0; bool partialRetrieval = false; if (spaceAvailable >= entry.Count) { retrievalAmount = entry.Count; } else { partialRetrieval = true; retrievalAmount = spaceAvailable; } for (int a = 0; a < retrievalAmount; a++) { SkillMasteryScroll skillMasteryScroll = new SkillMasteryScroll(entry.skillName); from.Backpack.DropItem(skillMasteryScroll); } entry.Count -= retrievalAmount; from.SendSound(addItemSound); if (entry.Count == 1) { from.SendMessage("You retrieve a skill mastery scroll from the library."); } else if (partialRetrieval) { from.SendMessage("You retrieve several skill mastery scrolls from the library but require more backpack space in order to retrieve the remaining scrolls."); } else { from.SendMessage("You retrieve several skill mastery scrolls from the library."); } } else { SkillMasteryScroll skillMasteryScroll = new SkillMasteryScroll(entry.skillName); entry.Count--; from.Backpack.DropItem(skillMasteryScroll); from.SendSound(addItemSound); from.SendMessage("You retrieve a skill mastery scroll from the library."); } }
public void AddAllScrollsInPack(Mobile from) { if (from == null) { return; } if (from.Backpack == null) { return; } List <SkillMasteryScroll> m_SkillMasteryScrolls = from.Backpack.FindItemsByType <SkillMasteryScroll>(); int totalCount = 0; Queue m_Queue = new Queue(); foreach (SkillMasteryScroll skillMasteryScroll in m_SkillMasteryScrolls) { m_Queue.Enqueue(skillMasteryScroll); } while (m_Queue.Count > 0) { SkillMasteryScroll skillMasteryScroll = (SkillMasteryScroll)m_Queue.Dequeue(); if (skillMasteryScroll == null) { continue; } if (skillMasteryScroll.Deleted) { continue; } SkillMasteryScrollLibraryEntry entry = GetLibraryEntry(skillMasteryScroll.Skill); if (entry == null) { continue; } entry.Count++; totalCount++; skillMasteryScroll.Delete(); } if (totalCount > 1) { from.SendMessage("You add " + totalCount.ToString() + " skill mastery scrolls to the library."); from.SendSound(addItemSound); } else if (totalCount == 1) { from.SendMessage("You add a skill mastery scroll to the library."); from.SendSound(addItemSound); } else { from.SendMessage("You do not have any skill mastery scrolls in your backpack."); } }