public void Add_Datetime() { DateTime dt_1 = DateTime.Now; ItemCache<DateTime> ic_1 = new ItemCache<DateTime>(); ic_1.Key = "Add_Datetime"; ic_1.Value = dt_1; ic_1.Save(true); ItemCache<DateTime> ic_2 = ItemCache<DateTime>.GetItem("Add_Datetime"); Assert.AreEqual<DateTime>(dt_1, ic_2.Value); }
public void Add_String() { string obj_1 = Properties.Settings.Default.Value_Text_long; ItemCache<string> ic_1 = new ItemCache<string>(); ic_1.Key = "Add_String"; ic_1.Value = obj_1; ic_1.Save(true); ItemCache<string> ic_2 = ItemCache<string>.GetItem("Add_String"); Assert.AreEqual<string>(obj_1, ic_2.Value); }
static void Main(string[] args) { DateTime dt = DateTime.Now; Redis.Cache.ItemCache<DateTime> ic = new ItemCache<DateTime>("dt_1", dt); ic.Save(true); ItemCache<DateTime> dt_result = Redis.Cache.ItemCache<DateTime>.GetItem("dt_1"); System.Console.WriteLine((dt == dt_result.Value).ToString()); System.Console.WriteLine(DateTime.Now.ToUniversalTime()); System.Console.WriteLine(DateTime.UtcNow); }
public void Add_Datetime_TTLAbs() { DateTime dt_1 = DateTime.Now; ItemCache<DateTime> ic_1 = new ItemCache<DateTime>(); ic_1.Key = "Add_Datetime_TTLAbs"; ic_1.Value = dt_1; ic_1.AbsoluteExpiration = new TimeSpan(0, 0, 20); ic_1.Save(true); System.Threading.Thread.Sleep(5000); ItemCache<DateTime> ic_2 = ItemCache<DateTime>.GetItem("Add_Datetime_TTLAbs"); Assert.AreEqual<DateTime>(dt_1, ic_2.Value); System.Threading.Thread.Sleep(20000); ItemCache<DateTime> ic_3 = ItemCache<DateTime>.GetItem("Add_Datetime_TTLAbs"); Assert.AreEqual(ic_3, null); }
public void Add_Datetime_TTLAbsSli_Exist() { DateTime dt_1 = DateTime.Now; ItemCache<DateTime> ic_1 = new ItemCache<DateTime>(); ic_1.Key = "Add_Datetime_TTLAbsSli_Exist"; ic_1.Value = dt_1; ic_1.SlidingExpiration = new TimeSpan(0, 0, 10); ic_1.AbsoluteExpiration = new TimeSpan(0, 0, 25); ic_1.Save(true); System.Threading.Thread.Sleep(5000); Assert.AreEqual(true, ItemCache<DateTime>.ExistItem("Add_Datetime_TTLAbsSli_Exist")); }
private void DeleteCustomGemming(object sender, RoutedEventArgs e) { Character.CustomItemInstances.Remove(ItemInstance); ItemCache.OnItemsChanged(); }
public void ToggleAllOff() { ItemCache.ForEach(x => x.tgl.isOn = false); }
public void SetToPy() { string test = Properties.Settings.Default.Value_Text; Redis.Cache.ItemCache<string> t = new ItemCache<string>("k1", test); t.Save(false); }
public override List <NebulaObject> Filter(Func <NebulaObject, bool> filter) { return(ItemCache.Filter(filter)); }
public void BroadcastMessage(string message, object arg = null) { ItemCache.SendMessage(message, arg); }
internal void RefreshCache() { ItemCache.GetInstance().Clear(); ItemCache.GetInstance(); }
public override void RemoveObject(byte objectType, string objectId) { ItemCache.RemoveItem(objectType, objectId); }
private void OKButton_Click(object sender, RoutedEventArgs e) { if (CurrentItem != null) { CurrentItem.Name = NameText.Text; CurrentItem.SetName = SetNameText.Text; CurrentItem.IconPath = IconPathText.Text; CurrentItem.Unique = UniqueCheck.IsChecked.GetValueOrDefault(false); CurrentItem.ItemLevel = (int)IlvlNum.Value; CurrentItem.Id = (int)IdNum.Value; CurrentItem.MinDamage = (int)MinDamageNum.Value; CurrentItem.MaxDamage = (int)MaxDamageNum.Value; CurrentItem.Speed = (float)SpeedNum.Value; CurrentItem.Stats = clonedStats; CurrentItem.Type = (ItemType)TypeCombo.SelectedIndex; CurrentItem.Slot = (ItemSlot)SlotCombo.SelectedIndex; CurrentItem.Quality = (ItemQuality)QualityCombo.SelectedIndex; CurrentItem.DamageType = (ItemDamageType)DamageTypeComboBox.SelectedIndex; CurrentItem.Cost = float.Parse(CostText.Text); if (Gem1Combo.SelectedIndex == 1) { CurrentItem.SocketColor1 = ItemSlot.Meta; } else if (Gem1Combo.SelectedIndex == 2) { CurrentItem.SocketColor1 = ItemSlot.Red; } else if (Gem1Combo.SelectedIndex == 3) { CurrentItem.SocketColor1 = ItemSlot.Yellow; } else if (Gem1Combo.SelectedIndex == 4) { CurrentItem.SocketColor1 = ItemSlot.Blue; } else { CurrentItem.SocketColor1 = ItemSlot.None; } if (Gem2Combo.SelectedIndex == 1) { CurrentItem.SocketColor2 = ItemSlot.Meta; } else if (Gem2Combo.SelectedIndex == 2) { CurrentItem.SocketColor2 = ItemSlot.Red; } else if (Gem2Combo.SelectedIndex == 3) { CurrentItem.SocketColor2 = ItemSlot.Yellow; } else if (Gem2Combo.SelectedIndex == 4) { CurrentItem.SocketColor2 = ItemSlot.Blue; } else { CurrentItem.SocketColor2 = ItemSlot.None; } if (Gem3Combo.SelectedIndex == 1) { CurrentItem.SocketColor3 = ItemSlot.Meta; } else if (Gem3Combo.SelectedIndex == 2) { CurrentItem.SocketColor3 = ItemSlot.Red; } else if (Gem3Combo.SelectedIndex == 3) { CurrentItem.SocketColor3 = ItemSlot.Yellow; } else if (Gem3Combo.SelectedIndex == 4) { CurrentItem.SocketColor3 = ItemSlot.Blue; } else { CurrentItem.SocketColor3 = ItemSlot.None; } foreach (PropertyInfo info in Stats.PropertyInfoCache) { if (Extensions.DisplayName(info).Equals(BonusStat.SelectedItem)) { PropertyInfo oldStat = BonusStat.Tag as PropertyInfo; object[] param = new object[1] { 0 }; oldStat.GetSetMethod().Invoke(CurrentItem.SocketBonus, param); param = new object[1] { float.Parse(BonusAmount.Text) }; info.GetSetMethod().Invoke(CurrentItem.SocketBonus, param); BonusStat.Tag = info; break; } } string req = null; foreach (KeyValuePair <string, CheckBox> kvp in ClassCheckBoxes) { if (kvp.Value.IsChecked.GetValueOrDefault(false)) { if (req == null) { req = kvp.Key; } else { req += "|" + kvp.Key; } } } CurrentItem.RequiredClasses = req; ItemCache.OnItemsChanged(); } this.DialogResult = true; }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { ItemCache.DeleteItem(CurrentItem); this.DialogResult = true; }
private void MainForm_Load(object sender, EventArgs e) { personCity = new Dictionary<int, City>(); IList<City> allcity = new List<City>(); cache = new ItemCache<Certificate>(); using (RepositoryBase repository = new RepositoryBase()) { try { var city = repository.GetCity(); int i = 0; foreach (City c in city) { comboBoxEdit1.Properties.Items.Add(c.Name); personCity.Add(i, c); i++; } var certificate = repository.GetCertificates(); foreach (Certificate c in certificate) { cache.Add(listBoxControl1.Items.Add(c.Name), c.Id, c); } } catch (Exception) { repository.RollbackTransaction(); } } listBoxControl1.SelectedIndex = -1; }
static ItemManager() { ItemMap = FileManager.GetItems(); }
private void OKButton_Click(object sender, RoutedEventArgs e) { ItemCache.OnItemsChanged(); this.DialogResult = true; }
void SetItem(ProjectBudgetLineLocal rec) { var item = (InvItem)ItemCache.Get(rec._Item); if (item == null) { return; } if (item._CostPrice != 0d) { if (rec._Qty == 0) { rec.Qty = 1d; } rec.CostPrice = item._CostPrice; } if (item._SalesPrice1 != 0d) { if (rec._Qty == 0) { rec.Qty = 1d; } rec.SalesPrice = item._SalesPrice1; } if (item._Dim1 != null) { rec.Dimension1 = item._Dim1; } if (item._Dim2 != null) { rec.Dimension2 = item._Dim2; } if (item._Dim3 != null) { rec.Dimension3 = item._Dim3; } if (item._Dim4 != null) { rec.Dimension4 = item._Dim4; } if (item._Dim5 != null) { rec.Dimension5 = item._Dim5; } if (item._PrCategory != null) { rec.PrCategory = item._PrCategory; } if (item._PayrollCategory != null) { rec.PayrollCategory = item._PayrollCategory; PayrollCat(rec, false); } if (item._Unit != 0 && rec._Unit != item._Unit) { rec._Unit = item._Unit; rec.NotifyPropertyChanged("Unit"); } globalEvents.NotifyRefreshViewer(NameOfControl, item); }
public List <Item> GetAllItems() { return(ItemCache.GetInstance().Items); }
public bool Contains(byte type, string id) { return(ItemCache.Contains(type, id)); }
//public Item InsertItem(Item item) //{ // item.Unit = (new UnitManager()).SyncUnit(item.Unit); // DBFunctions.GetInstance().OpenConnection(); // OleDbCommand command = DBFunctions.GetInstance().GetCommand("Insert Into Items " + // "(ItemName, RetailRate, ItemUnit, WholesaleRate, TaxRate, LastUpdatedTime) " + // "Values(?,?,?,?,?,Now())"); // command.Parameters.AddWithValue("ItemName", item.Name); // command.Parameters.AddWithValue("RetailRate", item.Rate); // command.Parameters.AddWithValue("ItemUnit", item.Unit.ID); // return null;//id //} public Item GetItemByID(int id) { return(ItemCache.GetInstance().GetItemById(id)); }
public override bool AddObject(NebulaObject obj) { return(ItemCache.AddItem(obj as Item)); }
public Search(ItemCache oItemCache) : this(oItemCache, false) { }
public void Tick(float deltaTime) { try { //if (zone.Id == "H1") { // log.InfoFormat("world = {0} tick", zone.Id); //} playerCountOnStartFrame = playerCount; ItemCache.Tick(deltaTime); asteroidManager.Update(deltaTime); npcManager.Update(deltaTime); nebulaObjectManager.Update(deltaTime); if (mSaveWorldTimer.Update(deltaTime)) { try { application.DatabaseManager.SetWorld(this); } catch (Exception exc) { log.InfoFormat("catched exception when saving worlds"); log.InfoFormat(exc.Message); log.InfoFormat(exc.StackTrace); } } //restore saved objects if (!mStateRestored) { if (mWorldState != null) { mStateRestored = true; mWorldState.RestoreObjectsFromSave(this); } } if (underAttack) { if (mUnderAttackTimer > 0f) { mUnderAttackTimer -= deltaTime; if (mUnderAttackTimer <= 0f) { SetUnderAttack(false); } } mUnderAttackDuration += deltaTime; if (mUnderAttackDuration >= MAX_UNDER_ATTACK_INTERVAL) { if (!invulnerable) { invulnerable = true; mInvulnerableTimer = INVULENRABLE_INTERVAL; BroadcastMessage("OnInvulnerableChanged"); return; } mUnderAttackDuration = 0f; } } if (invulnerable) { mInvulnerableTimer -= deltaTime; if (mInvulnerableTimer <= 0f) { invulnerable = false; BroadcastMessage("OnInvulnerableChanged"); } } //update event manager m_EventManager.Update(deltaTime); } catch (Exception exception) { log.ErrorFormat("exception in world: {0}", zone.Id); log.ErrorFormat(exception.Message); log.ErrorFormat(exception.StackTrace); } }
public Search(ItemCache oItemCache, bool bBypassItems) { this.oItemCache = oItemCache; this.bBypassItems = bBypassItems; Reset(); }
public void ClearResources() { ItemCache.DeleteItems(); }
private void OnFrame(object sender, EventArgs e) { if (State == ValueDumpState.Idle) { return; } var marketWindow = DirectEve.Windows.OfType <DirectMarketWindow>().FirstOrDefault(); var hangar = DirectEve.GetItemHangar(); var sellWindow = DirectEve.Windows.OfType <DirectMarketActionWindow>().FirstOrDefault(w => w.IsSellAction); var reprorcessingWindow = DirectEve.Windows.OfType <DirectReprocessingWindow>().FirstOrDefault(); switch (State) { case ValueDumpState.CheckMineralPrices: _currentMineral = InvTypesById.Values.FirstOrDefault(i => i.Id != 27029 && i.GroupId == 18 && i.LastUpdate < DateTime.Now.AddHours(-4)); if (_currentMineral == null) { if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > 5) { State = ValueDumpState.SaveMineralPrices; if (marketWindow != null) { marketWindow.Close(); } } } else { State = ValueDumpState.GetMineralPrice; } break; case ValueDumpState.GetMineralPrice: if (marketWindow == null) { if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > 5) { DirectEve.ExecuteCommand(DirectCmd.OpenMarket); _lastExecute = DateTime.Now; } return; } if (marketWindow.DetailTypeId != _currentMineral.Id) { if (DateTime.Now.Subtract(_lastExecute).TotalSeconds < 5) { return; } Log("Loading orders for " + _currentMineral.Name); marketWindow.LoadTypeId(_currentMineral.Id); _lastExecute = DateTime.Now; return; } if (!marketWindow.BuyOrders.Any(o => o.StationId == DirectEve.Session.StationId)) { _currentMineral.LastUpdate = DateTime.Now; Log("No orders found for " + _currentMineral.Name); State = ValueDumpState.CheckMineralPrices; } // Take top 5 orders, average the buy price and consider that median-buy (it's not really median buy but its what we want) _currentMineral.MedianBuy = marketWindow.BuyOrders.Where(o => o.StationId == DirectEve.Session.StationId).OrderByDescending(o => o.Price).Take(5).Average(o => o.Price); _currentMineral.LastUpdate = DateTime.Now; State = ValueDumpState.CheckMineralPrices; Log("Average price for " + _currentMineral.Name + " is " + _currentMineral.MedianBuy.Value.ToString("#,##0.00")); break; case ValueDumpState.SaveMineralPrices: Log("Saving InvItems.xml"); var xdoc = new XDocument(new XElement("invtypes")); foreach (var type in InvTypesById.Values.OrderBy(i => i.Id)) { xdoc.Root.Add(type.Save()); } xdoc.Save(InvTypesPath); State = ValueDumpState.Idle; break; case ValueDumpState.GetItems: if (hangar.Window == null) { // No, command it to open if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > 5) { Log("Opening hangar"); DirectEve.ExecuteCommand(DirectCmd.OpenHangarFloor); _lastExecute = DateTime.Now; } return; } if (!hangar.IsReady) { return; } Log("Loading hangar items"); // Clear out the old Items.Clear(); var hangarItems = hangar.Items; if (hangarItems != null) { Items.AddRange(hangarItems.Where(i => i.ItemId > 0 && i.MarketGroupId > 0 && i.Quantity > 0).Select(i => new ItemCache(i, RefineCheckBox.Checked))); } State = ValueDumpState.UpdatePrices; break; case ValueDumpState.UpdatePrices: foreach (var item in Items) { InvType invType; if (!InvTypesById.TryGetValue(item.TypeId, out invType)) { Log("Unknown TypeId " + item.TypeId + " for " + item.Name); continue; } item.InvType = invType; foreach (var material in item.RefineOutput) { if (!InvTypesById.TryGetValue(material.TypeId, out invType)) { Log("Unknown TypeId " + material.TypeId + " for " + material.Name); continue; } material.InvType = invType; } } State = ValueDumpState.Idle; if (cbxSell.Checked) { // Copy the items to sell list ItemsToSell.Clear(); ItemsToRefine.Clear(); if (cbxUndersell.Checked) { ItemsToSell.AddRange(Items.Where(i => i.InvType != null)); } else { ItemsToSell.AddRange(Items.Where(i => i.InvType != null && i.InvType.MedianBuy.HasValue)); } State = ValueDumpState.NextItem; } break; case ValueDumpState.NextItem: if (ItemsToSell.Count == 0) { if (ItemsToRefine.Count != 0) { State = ValueDumpState.RefineItems; } else { State = ValueDumpState.Idle; } break; } Log(ItemsToSell.Count + " items left to sell"); _currentItem = ItemsToSell[0]; ItemsToSell.RemoveAt(0); // Dont sell containers if (_currentItem.GroupId == 448) { Log("Skipping " + _currentItem.Name); break; } State = ValueDumpState.StartQuickSell; break; case ValueDumpState.StartQuickSell: if (DateTime.Now.Subtract(_lastExecute).TotalSeconds < 1) { break; } _lastExecute = DateTime.Now; var directItem = hangar.Items.FirstOrDefault(i => i.ItemId == _currentItem.Id); if (directItem == null) { Log("Item " + _currentItem.Name + " no longer exists in the hanger"); break; } // Update Quantity _currentItem.QuantitySold = _currentItem.Quantity - directItem.Quantity; Log("Starting QuickSell for " + _currentItem.Name); if (!directItem.QuickSell()) { _lastExecute = DateTime.Now.AddSeconds(-5); Log("QuickSell failed for " + _currentItem.Name + ", retrying in 5 seconds"); break; } State = ValueDumpState.WaitForSellWindow; break; case ValueDumpState.WaitForSellWindow: if (sellWindow == null || !sellWindow.IsReady || sellWindow.Item.ItemId != _currentItem.Id) { break; } // Mark as new execution _lastExecute = DateTime.Now; Log("Inspecting sell order for " + _currentItem.Name); State = ValueDumpState.InspectOrder; break; case ValueDumpState.InspectOrder: // Let the order window stay open for 2 seconds if (DateTime.Now.Subtract(_lastExecute).TotalSeconds < 2) { break; } if (!sellWindow.OrderId.HasValue || !sellWindow.Price.HasValue || !sellWindow.RemainingVolume.HasValue) { Log("No order available for " + _currentItem.Name); sellWindow.Cancel(); State = ValueDumpState.WaitingToFinishQuickSell; break; } var price = sellWindow.Price.Value; var quantity = (int)Math.Min(_currentItem.Quantity - _currentItem.QuantitySold, sellWindow.RemainingVolume.Value); var totalPrice = quantity * price; string otherPrices = " "; if (_currentItem.InvType.MedianBuy.HasValue) { otherPrices += "[Median buy price: " + (_currentItem.InvType.MedianBuy.Value * quantity).ToString("#,##0.00") + "]"; } else { otherPrices += "[No median buy price]"; } if (RefineCheckBox.Checked) { var portions = quantity / _currentItem.PortionSize; var refinePrice = _currentItem.RefineOutput.Any() ? _currentItem.RefineOutput.Sum(m => m.Quantity * m.InvType.MedianBuy ?? 0) * portions : 0; refinePrice *= (double)RefineEfficiencyInput.Value / 100; otherPrices += "[Refine price: " + refinePrice.ToString("#,##0.00") + "]"; if (refinePrice > totalPrice) { Log("Refining gives a better price for item " + _currentItem.Name + " [Refine price: " + refinePrice.ToString("#,##0.00") + "][Sell price: " + totalPrice.ToString("#,##0.00") + "]"); // Add it to the refine list ItemsToRefine.Add(_currentItem); sellWindow.Cancel(); State = ValueDumpState.WaitingToFinishQuickSell; break; } } if (!cbxUndersell.Checked) { if (!_currentItem.InvType.MedianBuy.HasValue) { Log("No historical price available for " + _currentItem.Name); sellWindow.Cancel(); State = ValueDumpState.WaitingToFinishQuickSell; break; } var perc = price / _currentItem.InvType.MedianBuy.Value; var total = _currentItem.InvType.MedianBuy.Value * _currentItem.Quantity; // If percentage < 85% and total price > 1m isk then skip this item (we don't undersell) if (perc < 0.85 && total > 1000000) { Log("Not underselling item " + _currentItem.Name + " [Median buy price: " + _currentItem.InvType.MedianBuy.Value.ToString("#,##0.00") + "][Sell price: " + price.ToString("#,##0.00") + "][" + perc.ToString("0%") + "]"); sellWindow.Cancel(); State = ValueDumpState.WaitingToFinishQuickSell; break; } } // Update quantity sold _currentItem.QuantitySold += quantity; // Update station price if (!_currentItem.StationBuy.HasValue) { _currentItem.StationBuy = price; } _currentItem.StationBuy = (_currentItem.StationBuy + price) / 2; Log("Selling " + quantity + " of " + _currentItem.Name + " [Sell price: " + (price * quantity).ToString("#,##0.00") + "]" + otherPrices); sellWindow.Accept(); // Requeue to check again if (_currentItem.QuantitySold < _currentItem.Quantity) { ItemsToSell.Add(_currentItem); } _lastExecute = DateTime.Now; State = ValueDumpState.WaitingToFinishQuickSell; break; case ValueDumpState.WaitingToFinishQuickSell: if (sellWindow == null || !sellWindow.IsReady || sellWindow.Item.ItemId != _currentItem.Id) { var modal = DirectEve.Windows.FirstOrDefault(w => w.IsModal); if (modal != null) { modal.Close(); } State = ValueDumpState.NextItem; break; } break; case ValueDumpState.RefineItems: if (reprorcessingWindow == null) { if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > 5) { var refineItems = hangar.Items.Where(i => ItemsToRefine.Any(r => r.Id == i.ItemId)); DirectEve.ReprocessStationItems(refineItems); _lastExecute = DateTime.Now; } return; } if (reprorcessingWindow.NeedsQuote) { if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > 5) { reprorcessingWindow.GetQuotes(); _lastExecute = DateTime.Now; } return; } // Wait till we have a quote if (reprorcessingWindow.Quotes.Count == 0) { _lastExecute = DateTime.Now; return; } // Wait another 5 seconds to view the quote and then reprocess the stuff if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > 5) { // TODO: We should wait for the items to appear in our hangar and then sell them... reprorcessingWindow.Reprocess(); State = ValueDumpState.Idle; } break; } }
private void OnFrame(object sender, EventArgs e) { if (State == ValueDumpState.Idle) { return; } var hangar = DirectEve.GetItemHangar(); var sellWindow = DirectEve.Windows.OfType <DirectMarketActionWindow>().FirstOrDefault(w => w.IsSellAction); switch (State) { case ValueDumpState.GetItems: if (hangar.Window == null) { // No, command it to open if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > 5) { Log("Opening hangar"); DirectEve.ExecuteCommand(DirectCmd.OpenHangarFloor); _lastExecute = DateTime.Now; } return; } if (!hangar.IsReady) { return; } Log("Loading hangar items"); // Clear out the old Items.Clear(); var hangarItems = hangar.Items; if (hangarItems != null) { Items.AddRange(hangarItems.Where(i => i.ItemId > 0 && i.MarketGroupId > 0 && i.Quantity > 0).Select(i => new ItemCache(i))); } State = ValueDumpState.UpdatePrices; break; case ValueDumpState.UpdatePrices: foreach (var item in Items) { InvType invType; if (!InvTypesById.TryGetValue(item.TypeId, out invType)) { Log("Unknown TypeId " + _currentItem.TypeId + " for " + _currentItem.Name); continue; } item.InvType = invType; } State = ValueDumpState.Idle; if (cbxSell.Checked) { // Copy the items to sell list ItemsToSell.Clear(); if (cbxUndersell.Checked) { ItemsToSell.AddRange(Items.Where(i => i.InvType != null)); } else { ItemsToSell.AddRange(Items.Where(i => i.InvType != null && i.InvType.MedianBuy.HasValue)); } State = ValueDumpState.NextItem; } break; case ValueDumpState.NextItem: if (ItemsToSell.Count == 0) { State = ValueDumpState.Idle; break; } Log(ItemsToSell.Count + " items left to sell"); _currentItem = ItemsToSell[0]; ItemsToSell.RemoveAt(0); // Dont sell containers if (_currentItem.GroupId == 448 || _currentItem.GroupId == 649) { Log("Skipping " + _currentItem.Name); break; } State = ValueDumpState.StartQuickSell; break; case ValueDumpState.StartQuickSell: if (DateTime.Now.Subtract(_lastExecute).TotalSeconds < 1) { break; } _lastExecute = DateTime.Now; var directItem = hangar.Items.FirstOrDefault(i => i.ItemId == _currentItem.Id); if (directItem == null) { Log("Item " + _currentItem.Name + " no longer exists in the hanger"); break; } // Update Quantity _currentItem.QuantitySold = _currentItem.Quantity - directItem.Quantity; Log("Starting QuickSell for " + _currentItem.Name); if (!directItem.QuickSell()) { _lastExecute = DateTime.Now.AddSeconds(-5); Log("QuickSell failed for " + _currentItem.Name + ", retrying in 5 seconds"); break; } State = ValueDumpState.WaitForSellWindow; break; case ValueDumpState.WaitForSellWindow: if (sellWindow == null || !sellWindow.IsReady || sellWindow.Item.ItemId != _currentItem.Id) { break; } // Mark as new execution _lastExecute = DateTime.Now; Log("Inspecting sell order for " + _currentItem.Name); State = ValueDumpState.InspectOrder; break; case ValueDumpState.InspectOrder: // Let the order window stay open for 2 seconds if (DateTime.Now.Subtract(_lastExecute).TotalSeconds < 2) { break; } if (!sellWindow.OrderId.HasValue || !sellWindow.Price.HasValue || !sellWindow.RemainingVolume.HasValue) { Log("No order available for " + _currentItem.Name); sellWindow.Cancel(); State = ValueDumpState.WaitingToFinishQuickSell; break; } var price = sellWindow.Price.Value; if (!cbxUndersell.Checked) { if (!_currentItem.InvType.MedianBuy.HasValue) { Log("No historical price available for " + _currentItem.Name); sellWindow.Cancel(); State = ValueDumpState.WaitingToFinishQuickSell; break; } var perc = price / _currentItem.InvType.MedianBuy.Value; var total = _currentItem.InvType.MedianBuy.Value * _currentItem.Quantity; // If percentage < 85% and total price > 1m isk then skip this item (we don't undersell) if (perc < 0.85 && total > 1000000) { Log("Not underselling item " + _currentItem.Name + " [" + _currentItem.InvType.MedianBuy.Value.ToString("#,##0.00") + "][" + price.ToString("#,##0.00") + "][" + perc.ToString("0%") + "]"); sellWindow.Cancel(); State = ValueDumpState.WaitingToFinishQuickSell; break; } } var quantity = (int)Math.Min(_currentItem.Quantity - _currentItem.QuantitySold, sellWindow.RemainingVolume.Value); // Update quantity sold _currentItem.QuantitySold += quantity; // Update station price if (!_currentItem.StationBuy.HasValue) { _currentItem.StationBuy = price; } _currentItem.StationBuy = (_currentItem.StationBuy + price) / 2; Log("Selling " + quantity + " of " + _currentItem.Name + " for " + (price * quantity).ToString("#,##0.00")); sellWindow.Accept(); // Requeue to check again if (_currentItem.QuantitySold < _currentItem.Quantity) { ItemsToSell.Add(_currentItem); } _lastExecute = DateTime.Now; State = ValueDumpState.WaitingToFinishQuickSell; break; case ValueDumpState.WaitingToFinishQuickSell: if (sellWindow == null || !sellWindow.IsReady || sellWindow.Item.ItemId != _currentItem.Id) { var modal = DirectEve.Windows.FirstOrDefault(w => w.IsModal); if (modal != null) { modal.Close(); } State = ValueDumpState.NextItem; break; } break; } }
/// <summary> /// Creates a basket for a consumer with a given type /// </summary> /// <param name="customer"> /// The customer. /// </param> /// <param name="itemCacheType"> /// The item Cache Type. /// </param> /// <param name="versionKey"> /// The version Key. /// </param> /// <returns> /// The <see cref="IItemCache"/>. /// </returns> public IItemCache GetItemCacheWithKey(ICustomerBase customer, ItemCacheType itemCacheType, Guid versionKey) { Mandate.ParameterCondition(Guid.Empty != versionKey, "versionKey"); // determine if the consumer already has a item cache of this type, if so return it. var itemCache = GetItemCacheByCustomer(customer, itemCacheType); if (itemCache != null) return itemCache; itemCache = new ItemCache(customer.EntityKey, itemCacheType) { VersionKey = versionKey }; if (Creating.IsRaisedEventCancelled(new Events.NewEventArgs<IItemCache>(itemCache), this)) { // registry.WasCancelled = true; return itemCache; } itemCache.EntityKey = customer.EntityKey; using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateItemCacheRepository(uow)) { repository.AddOrUpdate(itemCache); uow.Commit(); } } Created.RaiseEvent(new Events.NewEventArgs<IItemCache>(itemCache), this); return itemCache; }
public void ProcessState() { XDocument invIgnore = XDocument.Load(Settings.Instance.Path + "\\InvIgnore.xml"); //items to ignore DirectMarketWindow marketWindow = Cache.Instance.DirectEve.Windows.OfType<DirectMarketWindow>().FirstOrDefault(); DirectMarketActionWindow sellWindow = Cache.Instance.DirectEve.Windows.OfType<DirectMarketActionWindow>().FirstOrDefault(w => w.IsSellAction); DirectReprocessingWindow reprorcessingWindow = Cache.Instance.DirectEve.Windows.OfType<DirectReprocessingWindow>().FirstOrDefault(); switch (_States.CurrentValueDumpState) { case ValueDumpState.Idle: case ValueDumpState.Done: break; case ValueDumpState.Begin: if (_form.RefineCheckBox.Checked && _form.cbxSell.Checked) { _form.cbxSell.Checked = false; _valueProcess = true; _States.CurrentValueDumpState = ValueDumpState.GetItems; } else if (_form.RefineCheckBox.Checked && _valueProcess) { _form.RefineCheckBox.Checked = false; _form.cbxSell.Checked = true; _valueProcess = false; _States.CurrentValueDumpState = ValueDumpState.GetItems; } else _States.CurrentValueDumpState = ValueDumpState.GetItems; break; case ValueDumpState.CheckMineralPrices: _currentMineral = _form.InvTypesById.Values.FirstOrDefault(i => i.Id != 27029 && i.GroupId == 18 && i.LastUpdate < DateTime.Now.AddHours(-4)); if (_currentMineral == null) { if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > Time.Instance.Marketlookupdelay_seconds) { _States.CurrentValueDumpState = ValueDumpState.SaveMineralPrices; if (marketWindow != null) marketWindow.Close(); } } else _States.CurrentValueDumpState = ValueDumpState.GetMineralPrice; break; case ValueDumpState.GetMineralPrice: if (marketWindow == null) { if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > Time.Instance.Marketlookupdelay_seconds) { Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.OpenMarket); _lastExecute = DateTime.Now; } return; } if (marketWindow.DetailTypeId != _currentMineral.Id) { if (DateTime.Now.Subtract(_lastExecute).TotalSeconds < Time.Instance.Marketlookupdelay_seconds) return; Logging.Log("ValueDump", "Loading orders for " + _currentMineral.Name, Logging.White); marketWindow.LoadTypeId(_currentMineral.Id); _lastExecute = DateTime.Now; return; } if (marketWindow.BuyOrders.All(o => o.StationId != Cache.Instance.DirectEve.Session.StationId)) { _currentMineral.LastUpdate = DateTime.Now; Logging.Log("ValueDump", "No orders found for " + _currentMineral.Name, Logging.White); _States.CurrentValueDumpState = ValueDumpState.CheckMineralPrices; } // Take top 5 orders, average the buy price and consider that median-buy (it's not really median buy but its what we want) _currentMineral.MedianBuy = marketWindow.BuyOrders.Where(o => o.StationId == Cache.Instance.DirectEve.Session.StationId).OrderByDescending(o => o.Price).Take(5).Average(o => o.Price); _currentMineral.LastUpdate = DateTime.Now; _States.CurrentValueDumpState = ValueDumpState.CheckMineralPrices; Logging.Log("ValueDump", "Average price for " + _currentMineral.Name + " is " + _currentMineral.MedianBuy.Value.ToString("#,##0.00"), Logging.White); break; case ValueDumpState.SaveMineralPrices: Logging.Log("ValueDump", "Saving InvTypes.xml", Logging.White); XDocument xdoc = new XDocument(new XElement("invtypes")); foreach (InvType type in _form.InvTypesById.Values.OrderBy(i => i.Id)) if (xdoc.Root != null) xdoc.Root.Add(type.Save()); try { xdoc.Save(InvTypesPath); } catch (Exception ex) { Logging.Log("ValueDump", "Unable to save [" + InvTypesPath + "], is it a file permissions issue? Is the file open and locked? exception was [ " + ex.Message + "]", Logging.Orange); } _States.CurrentValueDumpState = ValueDumpState.Idle; break; case ValueDumpState.GetItems: if (!Cache.Instance.OpenItemsHangar("Valuedump")) return; Logging.Log("ValueDump", "Loading hangar items", Logging.White); // Clear out the old _form.Items.Clear(); List<DirectItem> hangarItems = Cache.Instance.ItemHangar.Items; if (hangarItems != null) _form.Items.AddRange(hangarItems.Where(i => i.ItemId > 0 && i.MarketGroupId > 0 && i.Quantity > 0).Select(i => new ItemCache(i, _form.RefineCheckBox.Checked))); _States.CurrentValueDumpState = ValueDumpState.UpdatePrices; break; case ValueDumpState.UpdatePrices: _form.ItemsToSell.Clear(); _form.ItemsToRefine.Clear(); _form.ItemsToSellUnsorted.Clear(); if (_form.cbxSell.Checked) { _form.ItemsToSellUnsorted.AddRange(_form.cbxUndersell.Checked ? _form.Items.Where(i => i.InvType != null) : _form.Items.Where( i => i.InvType != null && i.InvType.MinSell.HasValue)); _form.ItemsToSell = _form.ItemsToSellUnsorted.OrderBy(i => i.Name).ToList(); _States.CurrentValueDumpState = ValueDumpState.NextItem; } else if (_form.RefineCheckBox.Checked) { _form.ItemsToSellUnsorted.AddRange(_form.Items.Where(i => i.InvType != null && i.InvType.MaxBuy.HasValue)); _form.ItemsToSell = _form.ItemsToSellUnsorted.OrderBy(i => i.Name).ToList(); _States.CurrentValueDumpState = ValueDumpState.NextItem; } else _States.CurrentValueDumpState = ValueDumpState.Done; break; case ValueDumpState.NextItem: if (_form.ItemsToSell.Count == 0) { _States.CurrentValueDumpState = _form.ItemsToRefine.Count != 0 ? ValueDumpState.RefineItems : ValueDumpState.Done; break; } bool block = false; if (!_form.RefineCheckBox.Checked) Logging.Log("ValueDump", _form.ItemsToSell.Count + " items left to sell", Logging.White); _currentItem = _form.ItemsToSell[0]; _form.ItemsToSell.RemoveAt(0); // Do not sell containers if (_currentItem.GroupID == 448 || _currentItem.GroupID == 649) { Logging.Log("ValueDump", "Skipping " + _currentItem.Name, Logging.White); break; } // Do not sell items in invignore.xml if (invIgnore.Root != null) if (invIgnore.Root.Elements("invtype").Any(element => _currentItem.TypeId == (int)element.Attribute("id"))) { Logging.Log("ValueDump", "Skipping (block list) " + _currentItem.Name, Logging.White); block = true; } if (block) break; _States.CurrentValueDumpState = ValueDumpState.StartQuickSell; break; case ValueDumpState.StartQuickSell: if ((DateTime.Now.Subtract(_lastExecute).TotalSeconds < Cache.Instance.RandomNumber(1,3)) && _form.cbxSell.Checked) break; _lastExecute = DateTime.Now; DirectItem directItem = Cache.Instance.ItemHangar.Items.FirstOrDefault(i => i.ItemId == _currentItem.Id); if (directItem == null) { Logging.Log("ValueDump", "Item " + _currentItem.Name + " no longer exists in the hanger", Logging.White); break; } // Update Quantity _currentItem.QuantitySold = _currentItem.Quantity - directItem.Quantity; if (_form.cbxSell.Checked) { Logging.Log("ValueDump", "Starting QuickSell for " + _currentItem.Name, Logging.White); if (!directItem.QuickSell()) { _lastExecute = DateTime.Now.AddSeconds(-5); Logging.Log("ValueDump", "QuickSell failed for " + _currentItem.Name + ", retrying in 5 seconds", Logging.White); break; } _States.CurrentValueDumpState = ValueDumpState.WaitForSellWindow; } else { _States.CurrentValueDumpState = ValueDumpState.InspectRefinery; } break; case ValueDumpState.WaitForSellWindow: if (sellWindow == null || !sellWindow.IsReady || sellWindow.Item.ItemId != _currentItem.Id) break; // Mark as new execution _lastExecute = DateTime.Now; Logging.Log("ValueDump", "Inspecting sell order for " + _currentItem.Name, Logging.White); _States.CurrentValueDumpState = ValueDumpState.InspectOrder; break; case ValueDumpState.InspectOrder: // Let the order window stay open for random number if (DateTime.Now.Subtract(_lastExecute).TotalSeconds < Cache.Instance.RandomNumber(1, 3)) break; if (sellWindow != null && (!sellWindow.OrderId.HasValue || !sellWindow.Price.HasValue || !sellWindow.RemainingVolume.HasValue)) { Logging.Log("ValueDump", "No order available for " + _currentItem.Name, Logging.White); sellWindow.Cancel(); _States.CurrentValueDumpState = ValueDumpState.WaitingToFinishQuickSell; break; } if (sellWindow != null) { double price = sellWindow.Price.Value; int quantity = (int)Math.Min(_currentItem.Quantity - _currentItem.QuantitySold, sellWindow.RemainingVolume.Value); double totalPrice = quantity * price; const string otherPrices = " "; if (!_form.cbxUndersell.Checked) { if (_currentItem.InvType.MinSell != null) { double perc = _currentItem.InvType.MinSell.Value / price; double total = _currentItem.InvType.MinSell.Value * _currentItem.Quantity; // If percentage >= 130% and total price >= 1m isk then skip this item (we don't undersell) if (perc >= 1.4 && ((total - totalPrice) >= 2000000)) { Logging.Log("ValueDump", "Not underselling item " + _currentItem.Name + " [Min sell price: " + _currentItem.InvType.MinSell.Value.ToString("#,##0.00") + "][Sell price: " + price.ToString("#,##0.00") + "][" + perc.ToString("0%") + "]", Logging.White); sellWindow.Cancel(); _States.CurrentValueDumpState = ValueDumpState.WaitingToFinishQuickSell; break; } } } // Update quantity sold _currentItem.QuantitySold += quantity; // Update station price if (!_currentItem.StationBuy.HasValue) _currentItem.StationBuy = price; _currentItem.StationBuy = (_currentItem.StationBuy + price) / 2; Logging.Log("ValueDump", "Selling " + quantity + " of " + _currentItem.Name + " [Sell price: " + (price * quantity).ToString("#,##0.00") + "]" + otherPrices, Logging.White); } if (sellWindow != null) sellWindow.Accept(); // Re-queue to check again if (_currentItem.QuantitySold < _currentItem.Quantity) _form.ItemsToSell.Add(_currentItem); _lastExecute = DateTime.Now; _States.CurrentValueDumpState = ValueDumpState.WaitingToFinishQuickSell; break; case ValueDumpState.InspectRefinery: if (_currentItem.InvType.MaxBuy != null) { double priceR = _currentItem.InvType.MaxBuy.Value; int quantityR = _currentItem.Quantity; double totalPriceR = quantityR * priceR; int portions = quantityR / _currentItem.PortionSize; double refinePrice = _currentItem.RefineOutput.Any() ? _currentItem.RefineOutput.Sum(m => m.Quantity * m.InvType.MaxBuy ?? 0) * portions : 0; refinePrice *= (double)_form.RefineEfficiencyInput.Value / 100; if (refinePrice > totalPriceR || totalPriceR <= 1500000 || _currentItem.TypeId == 30497) { Logging.Log("ValueDump", "Refining gives a better price for item " + _currentItem.Name + " [Refine price: " + refinePrice.ToString("#,##0.00") + "][Sell price: " + totalPriceR.ToString("#,##0.00") + "]", Logging.White); // Add it to the refine list _form.ItemsToRefine.Add(_currentItem); } } /*else { Logging.Log("Selling gives a better price for item " + _currentItem.Name + " [Refine price: " + refinePrice.ToString("#,##0.00") + "][Sell price: " + totalPrice_r.ToString("#,##0.00") + "]"); }*/ _lastExecute = DateTime.Now; _States.CurrentValueDumpState = ValueDumpState.NextItem; break; case ValueDumpState.WaitingToFinishQuickSell: if (sellWindow == null || !sellWindow.IsReady || sellWindow.Item.ItemId != _currentItem.Id) { DirectWindow modal = Cache.Instance.DirectEve.Windows.FirstOrDefault(w => w.IsModal); if (modal != null) modal.Close(); _States.CurrentValueDumpState = ValueDumpState.NextItem; break; } break; case ValueDumpState.RefineItems: if (reprorcessingWindow == null) { if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > Cache.Instance.RandomNumber(1, 3)) { IEnumerable<DirectItem> refineItems = Cache.Instance.ItemHangar.Items.Where(i => _form.ItemsToRefine.Any(r => r.Id == i.ItemId)); Cache.Instance.DirectEve.ReprocessStationItems(refineItems); _lastExecute = DateTime.Now; } return; } if (reprorcessingWindow.NeedsQuote) { if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > Cache.Instance.RandomNumber(1, 3)) { reprorcessingWindow.GetQuotes(); _lastExecute = DateTime.Now; } return; } // Wait till we have a quote if (reprorcessingWindow.Quotes.Count == 0) { _lastExecute = DateTime.Now; return; } // Wait another 5 seconds to view the quote and then reprocess the stuff if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > 5) { // TODO: We should wait for the items to appear in our hangar and then sell them... reprorcessingWindow.Reprocess(); _lastExecute = DateTime.Now; Logging.Log("Valuedump", "Waiting 17 second", Logging.White); _States.CurrentValueDumpState = ValueDumpState.WaitingToBack; } break; case ValueDumpState.WaitingToBack: if (DateTime.Now.Subtract(_lastExecute).TotalSeconds > 17 && _valueProcess) { _States.CurrentValueDumpState = _valueProcess ? ValueDumpState.Begin : ValueDumpState.Done; } break; } }
public ItemProvider(ItemCache itemCache, WowheadClient wowheadClient) { _itemCache = itemCache; _wowheadClient = wowheadClient; }
private void OKButton_Click(object sender, RoutedEventArgs e) { if (CurrentItem != null) { CurrentItem.Name = NameText.Text; CurrentItem.SetName = SetNameText.Text; CurrentItem.IconPath = IconPathText.Text; CurrentItem.Unique = UniqueCheck.IsChecked.GetValueOrDefault(false); CurrentItem.ItemLevel = (int)IlvlNum.Value; CurrentItem.Id = (int)IdNum.Value; CurrentItem.MinDamage = (int)MinDamageNum.Value; CurrentItem.MaxDamage = (int)MaxDamageNum.Value; CurrentItem.Speed = (float)SpeedNum.Value; CurrentItem.Stats = clonedStats; CurrentItem.Type = (ItemType)TypeCombo.SelectedIndex; CurrentItem.Slot = (ItemSlot)SlotCombo.SelectedIndex; CurrentItem.Bind = (BindsOn)BindCombo.SelectedIndex; CurrentItem.Quality = (ItemQuality)QualityCombo.SelectedIndex; CurrentItem.DamageType = (ItemDamageType)DamageTypeComboBox.SelectedIndex; CurrentItem.Cost = (float)CostText.Value; if (Gem1Combo.SelectedIndex == 1) { CurrentItem.SocketColor1 = ItemSlot.Meta; } else if (Gem1Combo.SelectedIndex == 2) { CurrentItem.SocketColor1 = ItemSlot.Red; } else if (Gem1Combo.SelectedIndex == 3) { CurrentItem.SocketColor1 = ItemSlot.Yellow; } else if (Gem1Combo.SelectedIndex == 4) { CurrentItem.SocketColor1 = ItemSlot.Blue; } else if (Gem1Combo.SelectedIndex == 5) { CurrentItem.SocketColor1 = ItemSlot.Cogwheel; } else if (Gem1Combo.SelectedIndex == 6) { CurrentItem.SocketColor1 = ItemSlot.Hydraulic; } else if (Gem1Combo.SelectedIndex == 7) { CurrentItem.SocketColor1 = ItemSlot.Prismatic; } else { CurrentItem.SocketColor1 = ItemSlot.None; } if (Gem2Combo.SelectedIndex == 1) { CurrentItem.SocketColor2 = ItemSlot.Meta; } else if (Gem2Combo.SelectedIndex == 2) { CurrentItem.SocketColor2 = ItemSlot.Red; } else if (Gem2Combo.SelectedIndex == 3) { CurrentItem.SocketColor2 = ItemSlot.Yellow; } else if (Gem2Combo.SelectedIndex == 4) { CurrentItem.SocketColor2 = ItemSlot.Blue; } else if (Gem2Combo.SelectedIndex == 5) { CurrentItem.SocketColor2 = ItemSlot.Cogwheel; } else if (Gem2Combo.SelectedIndex == 6) { CurrentItem.SocketColor2 = ItemSlot.Hydraulic; } else if (Gem2Combo.SelectedIndex == 7) { CurrentItem.SocketColor2 = ItemSlot.Prismatic; } else { CurrentItem.SocketColor2 = ItemSlot.None; } if (Gem3Combo.SelectedIndex == 1) { CurrentItem.SocketColor3 = ItemSlot.Meta; } else if (Gem3Combo.SelectedIndex == 2) { CurrentItem.SocketColor3 = ItemSlot.Red; } else if (Gem3Combo.SelectedIndex == 3) { CurrentItem.SocketColor3 = ItemSlot.Yellow; } else if (Gem3Combo.SelectedIndex == 4) { CurrentItem.SocketColor3 = ItemSlot.Blue; } else if (Gem3Combo.SelectedIndex == 5) { CurrentItem.SocketColor3 = ItemSlot.Cogwheel; } else if (Gem3Combo.SelectedIndex == 6) { CurrentItem.SocketColor3 = ItemSlot.Hydraulic; } else if (Gem3Combo.SelectedIndex == 7) { CurrentItem.SocketColor3 = ItemSlot.Prismatic; } else { CurrentItem.SocketColor3 = ItemSlot.None; } if (SourcesChanged /* && tempSources != null*/) { CurrentItem.LocationInfo = tempSources; } if (CB_Faction.SelectedIndex == 0) { currentItem.Faction = ItemFaction.Neutral; } else if (CB_Faction.SelectedIndex == 1) { currentItem.Faction = ItemFaction.Alliance; } else if (CB_Faction.SelectedIndex == 2) { currentItem.Faction = ItemFaction.Horde; } else { currentItem.Faction = ItemFaction.Neutral; } foreach (PropertyInfo info in Stats.PropertyInfoCache) { if (Extensions.DisplayName(info).Equals(BonusStat.SelectedItem)) { PropertyInfo oldStat = BonusStat.Tag as PropertyInfo; object[] param = new object[1] { 0 }; oldStat.GetSetMethod().Invoke(CurrentItem.SocketBonus, param); param = new object[1] { float.Parse(BonusAmount.Text) }; info.GetSetMethod().Invoke(CurrentItem.SocketBonus, param); BonusStat.Tag = info; break; } } string req = null; foreach (KeyValuePair <string, CheckBox> kvp in ClassCheckBoxes) { if (kvp.Value.IsChecked.GetValueOrDefault(false)) { if (req == null) { req = kvp.Key; } else { req += "|" + kvp.Key; } } } CurrentItem.RequiredClasses = req; CurrentItem.InvalidateCachedData(); ItemCache.OnItemsChanged(); } LoadScreen.SaveFiles(); this.DialogResult = true; }
public Item GetItem(Func <Item, bool> filter) { return(ItemCache.GetItem(filter)); }
public ConcurrentDictionary <string, Item> GetItems(Func <Item, bool> filter) { return(ItemCache.GetItems(filter)); }
void Access() { /* *从文件中读入等级技能数据 */ string fileName = saveFileNamePrefix + "_Player_" + heroName + saveFileNameSuffix; StreamReader sr = new StreamReader(fileName); string sLine = ""; int lineNo = 1; while ((sLine = sr.ReadLine()) != null) { sLine.Trim(); if (sLine[0] == '#') { continue; } switch (lineNo) { case 1: { string[] splitArray = sLine.Split(new char[2] { '_', ';' }, StringSplitOptions.RemoveEmptyEntries); level = int.Parse(splitArray[0]); eltraHP = float.Parse(splitArray[1]); eltraSpeed = float.Parse(splitArray[2]); eltraAttack = float.Parse(splitArray[3]); skillPoint = int.Parse(splitArray[4]); exp = float.Parse(splitArray[5]); golds = int.Parse(splitArray[6]); break; } case 2: { string[] splitArray = sLine.Split(new char[2] { '_', ';' }, StringSplitOptions.RemoveEmptyEntries); skill1.level = int.Parse(splitArray[0]); skill2.level = int.Parse(splitArray[1]); skill3.level = int.Parse(splitArray[2]); skill4.level = int.Parse(splitArray[3]); skill5.level = int.Parse(splitArray[4]); skill6.level = int.Parse(splitArray[5]); skill7.level = int.Parse(splitArray[6]); skill8.level = int.Parse(splitArray[7]); skill9.level = int.Parse(splitArray[8]); break; } default: break; } lineNo++; } sr.Close(); /* *从文件中读入背包物品信息 */ if (!im.CacheDone) { im.BuildCache(); } fileName = saveFileNamePrefix + "_Stash_" + heroName + saveFileNameSuffix; sr = new StreamReader(fileName); sLine = ""; int columnNo = 0; while ((sLine = sr.ReadLine()) != null) { sLine.Trim(); if (sLine [0] == '#') { continue; } string[] splitArray = sLine.Split(new char[2] { '_', ';' }, StringSplitOptions.RemoveEmptyEntries); Item item = new Item(); item.itemID = int.Parse(splitArray[0]); item.itemNumber = int.Parse(splitArray[1]); ItemCache ic = new ItemCache(); ic = im.FindInCache(item.itemID); string attributes = ic.Attributes; string[] splitArray2 = attributes.Split(new char[2] { '_', ';' }, StringSplitOptions.RemoveEmptyEntries); if (int.Parse(splitArray2[1]) == 0) { item.canUse = false; } else { item.canUse = true; } if (int.Parse(splitArray[2]) == 1) { if (columnNo <= 5) { column[columnNo] = item; columnNo++; } else { stash.Add(item); } } else { stash.Add(item); } } sr.Close(); }
public ConcurrentDictionary <string, Item> GetItems(ItemType type, Func <Item, bool> filter) { return(ItemCache.GetItemsConcurrent((byte)type, filter)); }
public Index(ItemCache itemCache, StringsCache stringsCache, string formulasFilename = "formulas.gst") : this(formulasFilename) { _itemCache = itemCache; _stringsCache = stringsCache; }