public Inventory(Player player_) { Owner = player_; m_itemSlots = new ItemCount[10]; for (int i = 0; i < m_itemSlots.Length; ++i) { m_itemSlots[i] = new ItemCount(); } // default inventory m_itemSlots[0].Count = 1; m_itemSlots[0].Item = EItem.PickAxe; m_itemSlots[1].Count = 1; m_itemSlots[1].Item = EItem.Sword; m_itemSlots[2].Count = 1; m_itemSlots[2].Item = EItem.Copper_Axe; m_itemSlots[3].Count = 10; m_itemSlots[3].Item = EItem.Bomb; m_itemSlots[4].Count = 10; m_itemSlots[4].Item = EItem.Arrow; }
float timer; //제한 시간 타이머 private void Awake() { CitemCount = new ItemCount(); CPlayerInfo = new PlayerInfo(); min = 0; timer = 0; }
public MedEquipmentItem AddMedEquipmentItem(MedEquipmentType medEquipmentType, Room room) { medEquipmentType.Number += 1; medEquipmentType = MedEquipmentTypeRepository.GetInstance().Update(medEquipmentType); MedEquipmentItem mei = MedEquipmentItemRepository.GetInstance().Create(new MedEquipmentItem(medEquipmentType.GetId(), room.GetId(), medEquipmentType)); ItemCount temp = null; foreach (ItemCount ic in room.ItemCount) { if (mei.TypeId == ic.ItemId) { temp = ic; break; } } if (temp == null) { List <MedEquipmentItem> meiList = new List <MedEquipmentItem>(); meiList.Add(mei); ItemCount ic = ItemCountRepository.GetInstance().Create(new ItemCount(1, medEquipmentType.GetId(), meiList.ToArray())); room.ItemCount.Add(ic); RoomRepository.GetInstance().Update(room); } else { temp.Number += 1; ItemCountRepository.GetInstance().Update(temp); } return(mei); }
public async Task <ActionResult <ItemCount> > GetAuthorsCount() { ItemCount itemCount = new ItemCount(); itemCount.Count = _context.Authors.Count(); return(await Task.FromResult(itemCount)); }
public List <ItemCount> analyze(List <String> list) { list.Sort(); List <ItemCount> icList = new List <ItemCount>(); String prev = null; ItemCount counter = null; foreach (var s in list) { if (s.Equals(prev)) { // Same item. Just increment the count counter.increment(); } else { // Item changed. Add previous item count to icList if (counter != null) { icList.Add(counter); } counter = new ItemCount(s, 1); prev = s; } } // The last item has not yet been added to the list if (counter != null) { icList.Add(counter); } return(icList); }
public async Task <IActionResult> ApproveExport(string id, ExportRequest request) { if (id != request.Id) { return(NotFound()); } try { request = _context.ExportRequests.Include(r => r.StorageSpace).Include(r => r.Items).Single(r => r.Id == id); request.StorageSpace = _context.StorageSpaces.Single(sp => sp.Id == request.StorageSpaceId); var itemCounts = new List <ItemCount>(); bool requestValid = true; for (int i = 0; i < request.Items.Count; i++) { ItemCount itemCount = _context.ItemCounts.Include(ic => ic.Item).Single(ic => ic.Id == request.Items.ElementAt(i).Id); var numOfItemsOfThisType = _context.Items.Where(item => item.ItemDetails.UPC == itemCount.Item.UPC && item.StorageSpace.Id == request.StorageSpaceId).ToList().Count; //if (itemCount.Count > numOfItemsOfThisType) //{ // requestValid = false; // break; //} itemCounts.Add(itemCount); } //if (requestValid) //{ // _context.Requests.Remove(request); // await _context.SaveChangesAsync(); // return RedirectToAction(nameof(Index)); //} request.Processed = true; for (int i = 0; i < itemCounts.Count; i++) { ItemCount itemCount = itemCounts.ElementAt(i); var toRemove = _context.Items.Where(item => item.ItemDetails.UPC == itemCount.Item.UPC && item.StorageSpace.Id == request.StorageSpaceId).ToList(); for (int j = 0; j < itemCount.Count; j++) { _context.Items.Remove(toRemove.ElementAt(i)); } } _context.Entry(request).Property("Processed").IsModified = true; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RequestExists(request.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); }
public void UpdateGui() { itemCountText.text = ItemCount.ToString(); itemImage.sprite = ItemStored.inventorySprite; itemImage.color = ItemStored.color; itemImage.enabled = itemImage.sprite != null; }
public bool addItem(ItemCount it) { int index = checkItem(it.id); if (index != -1) { do { bool NotOverStack = content[index].updateCount(content[index].count + it.count); if (NotOverStack) { return(true); } index = content.FindIndex(index, x => x.id == it.id); } while(index != -1); } if (content.Count == MAX_ITEM_AMOUNT) { return(false); } content.Add(it); return(true); }
public async Task <IActionResult> ApproveImport(string id, ImportRequest request) { if (id != request.Id) { return(NotFound()); } try { request = _context.ImportRequests.Include(r => r.StorageSpace).Include(r => r.Items).Single(r => r.Id == id); request.StorageSpace = _context.StorageSpaces.Single(sp => sp.Id == request.StorageSpaceId); var itemCounts = new List <ItemCount>(); var capacity = 0.0; for (int i = 0; i < request.Items.Count; i++) { ItemCount itemCount = _context.ItemCounts.Include(ic => ic.Item).Single(ic => ic.Id == request.Items.ElementAt(i).Id); capacity += itemCount.Item.Volume; itemCounts.Add(itemCount); } bool requestValid = capacity > request.StorageSpace.Capacity * (1 - request.StorageSpace.UsedUp / 100.0); if (requestValid) { _context.Requests.Remove(request); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } request.Processed = true; for (int i = 0; i < itemCounts.Count; i++) { ItemCount itemCount = itemCounts.ElementAt(i); for (int j = 0; j < itemCount.Count; j++) { string itemID = itemCount.Item.UPC + "-" + DateTime.Now.Ticks + j; Item item = new Item { Id = itemID, ItemDetails = itemCount.Item, StorageSpace = request.StorageSpace }; _context.Items.Add(item); } } _context.Entry(request).Property("Processed").IsModified = true; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RequestExists(request.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); }
public override int GetHashCode() { int hash = 1; if (TotalCount != 0) { hash ^= TotalCount.GetHashCode(); } if (ItemCount != 0) { hash ^= ItemCount.GetHashCode(); } if (StartIndex != 0) { hash ^= StartIndex.GetHashCode(); } if (EndIndex != 0) { hash ^= EndIndex.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public Dictionary <string, ItemCount> analyzeDict(List <String> list) { list.Sort(); Dictionary <string, ItemCount> icList = new Dictionary <string, ItemCount>(); String prev = null; ItemCount counter = null; foreach (var s in list) { if (s.Equals(prev)) { // Same item. Just increment the count counter.increment(); } else { // Item changed. Add previous item count to icList if (counter != null) { icList.Add(s + "_" + counter.getCount().ToString(), counter); } counter = new ItemCount(s, 1); prev = s; } } // The last item has not yet been added to the list if (counter != null) { icList.Add(counter.getItem() + "_" + counter.getCount().ToString(), counter); } return(icList); }
public async Task <IActionResult> Submit(int?id) { if (id == null) { return(NotFound()); //Validate } //get inventory var inventory = await(from i in _context.InventoryLog.Include("InventoryAreaLogs.Inventory.Item") where i.InventorySummaryId == id select i).SingleOrDefaultAsync(); //Get Items var items = from i in _context.WildeRoverItem orderby i.Type, i.SubType, i.Name select i; var itemList = items.ToList(); //Create View Model InventorySummarySubmitViewModel model = new InventorySummarySubmitViewModel(); model.Summary = inventory; model.InventorySummaryId = inventory.InventorySummaryId; //Track new ItemCounts in Dictionary in addition to ViewModel to make tallying //inventory not O(n^3) var itemCountDict = new Dictionary <int, ItemCount>(); //Populate ViewModel Inventory foreach (var i in itemList) { //check Key for Type, if not add KeyValuePair if (!model.SubItems.ContainsKey(i.Type)) { model.SubItems.Add(i.Type, new List <ItemCount>()); } //Add itemCount to Value //Create ItemCount, set initial inventory count to 0 ItemCount temp = new ItemCount(); temp.Item = i; temp.Count = 0; model.SubItems[i.Type].Add(temp); //Add itemCountDict[i.WildeRoverItemId] = temp; } //Tally Inventory and update ItemCounts for View Model using Dictionary foreach (var areaLog in inventory.InventoryAreaLogs) { foreach (var ic in areaLog.Inventory) { itemCountDict[ic.WildeRoverItemId].Count += ic.Count; } } return(View(model)); }
public void Main(string argument, UpdateType updateSource) { // The main entry point of the script, invoked every time // one of the programmable block's Run actions are invoked, // or the script updates itself. The updateSource argument // describes where the update came from. Be aware that the // updateSource is a bitfield and might contain more than // one update type. // // The method itself is required, but the arguments above // can be removed if not needed. List <IMyCargoContainer> cargoContainers = new List <IMyCargoContainer>(); GridTerminalSystem.GetBlocksOfType(blocks: cargoContainers); List <MyInventoryItem> inventoryItems = new List <MyInventoryItem>(); foreach (IMyCargoContainer container in cargoContainers) { IMyInventory myInventory = container.GetInventory(); List <MyInventoryItem> items = new List <MyInventoryItem>(); myInventory.GetItems(items: items); foreach (MyInventoryItem item in items) { inventoryItems.Add(item: item); } } List <ItemCount> itemCounts = new List <ItemCount>(); foreach (MyInventoryItem item in inventoryItems) { if (itemCounts.All(x => x.Type != item.Type)) { ItemCount itemCount = new ItemCount(item.Type); itemCounts.Add(itemCount); itemCount.Amount += item.Amount; } else { ItemCount itemCount = itemCounts.FirstOrDefault(x => x.Type == item.Type); if (itemCount != null) { itemCount.Amount += item.Amount; } } } foreach (ItemCount count in itemCounts.OrderBy(x => x.Type).ToList()) { Echo("1"); Echo($"{count} : {count.Amount}"); } }
public bool Equals(DestinyInventoryBucketDefinition input) { if (input == null) { return(false); } return (( DisplayProperties == input.DisplayProperties || (DisplayProperties != null && DisplayProperties.Equals(input.DisplayProperties)) ) && ( Scope == input.Scope || (Scope != null && Scope.Equals(input.Scope)) ) && ( Category == input.Category || (Category != null && Category.Equals(input.Category)) ) && ( BucketOrder == input.BucketOrder || (BucketOrder.Equals(input.BucketOrder)) ) && ( ItemCount == input.ItemCount || (ItemCount.Equals(input.ItemCount)) ) && ( Location == input.Location || (Location != null && Location.Equals(input.Location)) ) && ( HasTransferDestination == input.HasTransferDestination || (HasTransferDestination != null && HasTransferDestination.Equals(input.HasTransferDestination)) ) && ( Enabled == input.Enabled || (Enabled != null && Enabled.Equals(input.Enabled)) ) && ( Fifo == input.Fifo || (Fifo != null && Fifo.Equals(input.Fifo)) ) && ( Hash == input.Hash || (Hash.Equals(input.Hash)) ) && ( Index == input.Index || (Index.Equals(input.Index)) ) && ( Redacted == input.Redacted || (Redacted != null && Redacted.Equals(input.Redacted)) )); }
void Start() { this.game = GameManager.GetMainGame(); this.controls = game.GetComponent <ControlsManager>(); this.inventory = game.GetComponent <GameInventory>(); this.render = this.GetComponent <ItemRender>(); this.itemCountManager = this.GetComponent <ItemCount>(); }
public void AddToInventory(ItemCount item) { CheckInventory(); if (!inventory.ContainsKey(item.item)) { inventory.Add(item.item, item.amount); return; } inventory[item.item] += item.amount; }
/// <summary> /// Called on collision. /// </summary> /// <param name="collision">Collision.</param> private void OnCollisionEnter(Collision collision) { ItemCount itemCount = collision.gameObject.GetComponent <ItemCount>(); if (itemCount != null) { itemCount.itemCount++; Destroy(gameObject); } }
protected override void Awake() { base.Awake(); ItemID = itemIDData[Random.Range(0, 3)]; itemSprite = GetComponent <UISprite>(); itemSprite.spriteName = ItemID; ItemCount = Random.Range(1, 5); itemCount = GetComponentInChildren <UILabel>(); itemCount.text = ItemCount.ToString(); }
private void UpdateText() { if (!GameManager.Instance) { return; } // Update all texts for now for (int i = 0; i < NumInventorySlots; ++i) { ItemCount ic = GameManager.Instance.MainPlayer.Inventory.GetSlotInformation(i); InventorySlotUI isu = m_inventorySlot[i]; if (ic.Count == 0) { isu.m_count.text = ""; } else { isu.m_count.text = ic.Count.ToString(); } isu.m_title.color = (i == m_selectSlotIndex) ? new Color(48 / 255f, 255 / 255f, 42 / 255f) : new Color(1f, 1f, 1f); // set what is owned by this inventory slot if (ic.Item == EItem.None) { isu.m_icon.sprite = null; isu.m_icon.color = new Color(1f, 1f, 1f, 0f); } else { if (isu.m_icon.sprite == null) { TileResourceDef tileResourceDef = TileMapping.GetTileResourceDef((ETile)ic.Item); Texture2D tex = tileResourceDef != null ? Resources.Load(tileResourceDef.Filename) as Texture2D : null; if (tex) { Sprite sprite = Sprite.Create(tex, tileResourceDef.Rect, Vector2.zero); isu.m_icon.sprite = sprite; isu.m_icon.color = ItemInstance.GetColorForItem(ic.Item); isu.m_icon.rectTransform.SetWidth(Mathf.Min(tileResourceDef.Rect.width, 32)); isu.m_icon.rectTransform.SetHeight(Mathf.Min(tileResourceDef.Rect.height, 32)); } } } } }
public override string ToString() { if (string.IsNullOrWhiteSpace(Name)) { return((ItemCount > 1 ? ItemCount.ToString() + " " : "") + ItemUniqueName.Split('/').Last()); } else { return((ItemCount > 1 ? ItemCount.ToString() + " " : "") + Name); } }
public bool removeItem(ItemCount req) { int index = checkItem(req); if (index == -1) { return(false); } return(content[index].updateCount(content[index].count - req.count)); }
public void AddItem(string message, TaskState state) { Info.Add(new Message(message, state)); //reset the counter so the ticks don't get too long if (ItemCount.Count > 20) { ItemCount.Clear(); } ItemCount.Add(message); InvokePropertyChanged("ItemCount"); }
private void FormSuperExport_Shown(object sender, EventArgs e) { listbox_ExportFiles.Items.Clear(); label_Count.Text = String.Format("{0} objects selected to be exported:", ItemCount.ToString()); if (SelectedItemNames != null) { foreach (String i in SelectedItemNames) { listbox_ExportFiles.Items.Add(i); } } }
public bool updateItem(ItemCount req) { int index = checkItem(req.id); if (index != -1) { return(content[index].updateCount(req.count)); } content.Add(req); return(true); }
public string DatasetBrief(string title) { string brief = ""; brief += Utils.CreateHeading(title); brief += Utils.PrintValueToString("# of users", UserCount.ToString("D")) + "\n"; brief += Utils.PrintValueToString("# of items", ItemCount.ToString("D")) + "\n"; brief += Utils.PrintValueToString("# of ratings", NonZerosCount.ToString("D")) + "\n"; brief += Utils.PrintValueToString("Density level", Density.ToString("P")) + "\n"; brief += Utils.PrintValueToString("Global mean", GetGlobalMean().ToString("0.00")); return(brief); }
//Create InventoryAreaLogs associated with new Inventory Summary private void CreateInventoryAreaLogs(InventorySummary summary) { var areas = from a in _context.InventoryAreas.Include("ItemSlots.WildeRoverItem") select a; foreach (var area in areas.ToList()) { //Create area inventory log InventoryAreaInventoryLog log = new InventoryAreaInventoryLog(); log.InventorySummary = summary; log.InventorySummaryId = summary.InventorySummaryId; log.InventoryArea = area; log.InventoryAreaid = area.InventoryAreaId; log.Date = DateTime.Now; //Add to context and retrieve Id _context.InventoryAreaLogs.Add(log); _context.SaveChanges(); log = _context.InventoryAreaLogs.Last(); //populate the Inventory var items = from i in area.ItemSlots orderby i.Slot ascending select i.WildeRoverItem; foreach (var item in items) { ItemCount temp = new ItemCount(); temp.InventoryAreaInventoryLog = log; temp.InventoryAreaInventoryLogId = log.InventoryAreaInventoryLogId; temp.Item = item; temp.WildeRoverItemId = item.WildeRoverItemId; _context.ItemCounts.Add(temp); //Add ItemCount to area log log.Inventory.Add(temp); } //Update log _context.InventoryAreaLogs.Update(log); //Add area inventory log to summary summary.InventoryAreaLogs.Add(log); } //Update summary _context.InventoryLog.Update(summary); //_context.SaveChanges(); }
public void GetBy_validItemCount_ReturnItemCounts() { //arrange var valid = new ItemCount(); valid.Sku = 612332; //act var result = sut.GetBy(valid); //assert iRepositoryFake.Received(1).GetBy(valid); }
public override int GetHashCode() { var hashCode = -596621668; hashCode = hashCode * -1521134295 + base.GetHashCode(); hashCode = hashCode * -1521134295 + IsEmpty.GetHashCode(); hashCode = hashCode * -1521134295 + BlockId.GetHashCode(); hashCode = hashCode * -1521134295 + ItemCount.GetHashCode(); hashCode = hashCode * -1521134295 + ItemDamage.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <NbtFile> .Default.GetHashCode(NBT); return(hashCode); }
public void GetBySku_ValidSku_ReturnItemCounts() { //arrange var valid = new ItemCount(); valid.Sku = 612332; //act var result = sut.GetBy(valid); //assert Assert.NotEmpty(result); }
public void GetBySku_InvalidSku_ReturnEmpty() { //arrange var invalid = new ItemCount(); invalid.Sku = 999999; //act var result = sut.GetBy(invalid); //assert Assert.Empty(result); }
public void Should_Call_CorrectPricer_With_Count() { var skus = "A"; var itemCounter = Mock.Create<IItemCounter>(); var aPricer = Mock.Create<IPricer>(); aPricer.Arrange(ap => ap.TotalPrice(1)).MustBeCalled(); var pricers = new List<IPricer> {aPricer}; var aItemCount = new ItemCount('a', 1); var counts = new List<ItemCount> { aItemCount }; itemCounter.Arrange(i => i.AddItems(skus)).Returns(counts); var checkout = new PriceCalculator(itemCounter, pricers); checkout.Calculate(skus); aPricer.Assert(); }
protected bool Equals(ItemCount other) { return Sku == other.Sku && Count == other.Count; }