public ScrollUseResult UseScroll(SessionToken sessionToken, Guid characterId, ScrollType scrollType) { var session = gameData.GetSession(sessionToken.SessionId); if (session == null) { return(ScrollUseResult.Error); } var character = gameData.GetCharacter(characterId); //if (session.UserId != character.UserIdLock) // return ScrollUseResult.Error; var inventory = inventoryProvider.Get(characterId); var scrolls = inventory.GetUnequippedItems(DataModels.ItemCategory.Scroll); DataModels.UserBankItem bankItemScroll = null; var scroll = scrolls.FirstOrDefault(x => IsScrollOfType(x, scrollType)); if (scroll.IsNull()) { var bankItems = gameData.GetUserBankItems(character.UserId); bankItemScroll = bankItems.FirstOrDefault(x => IsScrollOfType(x, scrollType)); if (bankItemScroll == null) { return(ScrollUseResult.InsufficientScrolls); } } var result = ScrollUseResult.Error; var isExpScroll = scrollType == ScrollType.Experience;//scroll.Item.Name.Contains("exp", StringComparison.OrdinalIgnoreCase); if (isExpScroll) { if (!serverManager.CanIncreaseGlobalExpMultiplier()) { return(ScrollUseResult.Error); } var user = gameData.GetUser(character.UserId); if (serverManager.IncreaseGlobalExpMultiplier(user)) { if (bankItemScroll != null) { // Remove Scroll from Stash gameData.RemoveFromStash(bankItemScroll, 1); } else { inventory.RemoveItem(scroll, 1); } return(ScrollUseResult.Success); } } else { if (bankItemScroll != null) { // Remove Scroll from Stash if (gameData.RemoveFromStash(bankItemScroll, 1)) { return(ScrollUseResult.Success); } } else { if (inventory.RemoveItem(scroll, 1)) { return(ScrollUseResult.Success); } } } return(ScrollUseResult.Error); }