public void SellItem(SellItem rpc) { for (int i = 0; i < rpc.amount; i++) { money += itemStacks[rpc.index].Pop().price; } }
//Create Get public async Task <IActionResult> PostItem(int inventoryId) { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); var inventory = await _db.InventoryDb.Include(g => g.GameItemVP).FirstOrDefaultAsync(i => i.Id == inventoryId); SellItem sellItem = new SellItem() { SellerId = claim.Value, Days = 3, Price = 100, SellerName = claimsIdentity.Name, DateTimeEnd = DateTime.Now, GameItemVP = inventory.GameItemVP, GameItemId = inventory.GameItemVP.Id, TimeRemained = new TimeSpan(0, 0, 0, 0, 0), InventoryId = inventory.Id, CountOfItemsToSell = 0 }; sellItem.GameItemVP.Count = inventory.Count; return(View(sellItem)); }
public async Task <IActionResult> PutSellItem(int id, SellItem sellItem) { if (id != sellItem.Id) { return(BadRequest()); } _context.Entry(sellItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SellItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ResponseCommissionList(ServerPacket pck) : base(pck) { this.Position += 12; int count = ReadInt(); this.Position += 2; this.Items = new List<SellItem>(count); for (int i = 0; i < count; i++) { var item = new SellItem(); this.Items.Add(item); this.Position += 6; item.Price = ReadLong(); this.Position += 3 * 4; item.SellerName = ReadString(); this.Position += 4; item.ItemID = ReadInt(); item.Count = ReadInt(); this.Position += 10; item.Enchant = ReadInt(); this.Position += 4; this.Position += 2; this.Position += 5 * 4; this.Position += 2; } }
private bool RunNextSellAction() { int orderCap = Cache.Instance.OrderCap; int maxSellOrders = (int)((decimal)orderCap * 0.66m); if (_mySellOrders.Count + _newSellOrders <= maxSellOrders && _myBuyOrders.Count + _mySellOrders.Count + _newSellOrders < orderCap) { SellItem sellItem = null; if (_sellActions.Count > 0) { sellItem = _sellActions.Dequeue(); } if (sellItem != null) { Logging.Log("Automation:RunNextSellItem", "Popping next sell script to run", Logging.White); RunAction(sellItem); return(true); } else { Logging.Log("Automation:RunNextSellItem", "No more sell scripts left, going to create buy orders state", Logging.White); } } else { Logging.Log("Automation:RunNextSellItem", "Hit max number of sell orders allowed, going to create buy orders state", Logging.White); } _sellActions.Clear(); return(false); }
public void SellItemsInHanger() { List <DirectItem> sellItemList = new List <DirectItem>(); itemHangerGrid.Invoke((MethodInvoker) delegate { foreach (DataGridViewRow row in itemHangerGrid.Rows) { try { if (Convert.ToBoolean(row.Cells["ItemHanger_Select"].Value) == true) { long itemId = (long)row.Cells["ItemHanger_ItemId"].Value; DirectItem item = Cache.Instance.ItemHanger.Items.FirstOrDefault(i => i.ItemId == itemId); if (item != null) { Logging.Log("OmniEveUI:SellItemsInHanger", "Adding item to list of items to be sold ItemId - " + itemId, Logging.Debug); SellItem sellItem = new SellItem(item, true); sellItem.OnSellItemFinished += OnSellItemFinished; _omniEve.AddAction(sellItem); } } } catch (Exception ex) { Logging.Log("OmniEveUI:SellItemsInHanger", "Exception [" + ex + "]", Logging.Debug); } } }); }
public unsafe bool HandlePacket(ENetPeer *peer, byte[] data, Game game) { var sell = new SellItem(data); var client = game.getPeerInfo(peer); var i = game.getPeerInfo(peer).getChampion().getInventory().getItemSlot(sell.slotId); if (i == null) { return(false); } float sellPrice = i.getTemplate().getTotalPrice() * i.getTemplate().getSellBackModifier(); client.getChampion().getStats().setGold(client.getChampion().getStats().getGold() + sellPrice); if (i.getTemplate().getMaxStack() > 1) { i.decrementStacks(); PacketNotifier.notifyRemoveItem(client.getChampion(), sell.slotId, i.getStacks()); if (i.getStacks() == 0) { client.getChampion().getInventory().removeItem(sell.slotId); } } else { PacketNotifier.notifyRemoveItem(client.getChampion(), sell.slotId, 0); client.getChampion().getInventory().removeItem(sell.slotId); } return(true); }
public async Task <IActionResult> PostItem(SellItem sItem) { if (ModelState.IsValid) { if ((sItem.CountOfItemsToSell > sItem.GameItemVP.Count) || (sItem.CountOfItemsToSell < 1)) { return(View(sItem)); } var itemFromInventory = await _db.InventoryDb.FindAsync(sItem.InventoryId); sItem.DateTimeEnd = DateTime.Now.AddDays(sItem.Days);//czy nie doda dat w przypadku invalid model - datEnd = dateNow na koncu? sItem.GameItemVP = await _db.GameItemsDb.Include(c => c.CategoryVP).Include(c => c.SubCategoryVP).Include(c => c.ItemQualityVP) .Include(c => c.ForWhichClassItemVP).FirstOrDefaultAsync(s => s.Id == itemFromInventory.GameItemId); int balance = itemFromInventory.Count - sItem.CountOfItemsToSell; sItem.GameItemVP.Count = sItem.CountOfItemsToSell; _db.SellItemDb.Add(sItem); if (balance == 0) { _db.InventoryDb.Remove(itemFromInventory); } else { itemFromInventory.Count -= sItem.CountOfItemsToSell; // itemFromInventory.Count = balance; } await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //sItem.DateTimeEnd = DateTime.Now; return(View(sItem)); }
public bool HandlePacket(Peer peer, byte[] data) { var sell = new SellItem(data); var client = _playerManager.GetPeerInfo(peer); var i = _playerManager.GetPeerInfo(peer).Champion.getInventory().GetItem(sell.slotId); if (i == null) { return(false); } float sellPrice = i.ItemType.TotalPrice * i.ItemType.SellBackModifier; client.Champion.GetStats().Gold += sellPrice; if (i.ItemType.MaxStack > 1) { i.DecrementStackSize(); _game.PacketNotifier.NotifyRemoveItem(client.Champion, sell.slotId, i.StackSize); if (i.StackSize == 0) { client.Champion.getInventory().RemoveItem(sell.slotId); } } else { _game.PacketNotifier.NotifyRemoveItem(client.Champion, sell.slotId, 0); client.Champion.getInventory().RemoveItem(sell.slotId); } client.Champion.GetStats().RemoveModifier(i.ItemType); return(true); }
public async Task <ActionResult <SellItem> > PostSellItem(SellItem sellItem) { _context.SellItems.Add(sellItem); await _context.SaveChangesAsync(); //return CreatedAtAction("GetSellItem", new { id = sellItem.Id }, sellItem); return(CreatedAtAction(nameof(GetSellItem), new { id = sellItem.Id }, sellItem)); }
public ActionResult DeleteConfirmed(long id) { SellItem sellItem = db.SellItems.Find(id); db.SellItems.Remove(sellItem); db.SaveChanges(); return(RedirectToAction("Index")); }
private void BtnAddToList_Click(object sender, EventArgs e) { int sellected = cmbSellProducts.SelectedIndex; if (txtQuantityBuying.Value > 0 && sellected >= 0 && sellected <= cmbSellProducts.Items.Count && txtQuantityBuying.Value <= products[sellected].InStock) { int saleAddWithIndex = -1; for (int x = 0; x < sellItems.Count; x++) { if (sellItems[x].Product.Id == products[sellected].Id) { //MessageBox.Show("Record Found"); saleAddWithIndex = x; break; } } if (saleAddWithIndex == -1) { SellItem sell = new SellItem(SellItemNumber, products[sellected].Name, products[sellected].Price, Convert.ToInt32(txtQuantityBuying.Value), products[sellected].Price * Convert.ToInt32(txtQuantityBuying.Value), products[sellected]); //SellItem sell2 = new SellItem(1, "Ernest", 5.6, 5); SellItemNumber++; sellItems.Add(sell); } else { sellItems[saleAddWithIndex].QUANTITY = sellItems[saleAddWithIndex].QUANTITY + Convert.ToInt32(txtQuantityBuying.Value); sellItems[saleAddWithIndex].SUB_TOTAL = products[sellected].Price * sellItems[saleAddWithIndex].QUANTITY; //MessageBox.Show("It has been added Already at Index " + saleAddWithIndex); } BindingSource binding = new BindingSource(); binding.DataSource = typeof(SellItem); foreach (SellItem item in sellItems) { binding.Add(item); } //soldItemsGridView.AutoGenerateColumns = true; soldItemsGridView.ReadOnly = true; soldItemsGridView.DataSource = binding; cmbSellProducts.Text = ""; lbShowSellItemInStock.Text = ""; lbShowSellItemPrice.Text = ""; txtQuantityBuying.Value = 0; updateGrandTotal(); btnSaveAndPrint.Enabled = true; } }
public static async Task AddSell(SellItem sellItem, ProductItem product, DatabaseContext _context) { product.SalesList.Add(new SellItem { Quantity = sellItem.Quantity, TotalCost = sellItem.TotalCost, Paid = sellItem.Paid, ContainerReturned = sellItem.ContainerReturned }); product.StockAmount -= sellItem.Quantity; await _context.SaveChangesAsync(); }
public ActionResult Edit([Bind(Include = "SellItemId,Quantity,UnitPrice,ProductId,SellId")] SellItem sellItem) { if (ModelState.IsValid) { db.Entry(sellItem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(db.Products .Where(o => o.Deleted == false), "ProductId", "Name", sellItem.ProductId); ViewBag.SellId = new SelectList(db.Sells, "SellId", "SellNumver", sellItem.SellId); return(View(sellItem)); }
// GET: SellItems/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SellItem sellItem = db.SellItems.Find(id); if (sellItem == null) { return(HttpNotFound()); } return(View(sellItem)); }
public static async Task <bool> DeleteSell(SellItem sellItem, DatabaseContext _context) { try { sellItem.Product.StockAmount += sellItem.Quantity; _context.SellItems.Remove(sellItem); await _context.SaveChangesAsync(); return(true); } catch (Exception) { return(false); } }
// GET: SellItems/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SellItem sellItem = db.SellItems.Find(id); if (sellItem == null) { return(HttpNotFound()); } ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Name", sellItem.ProductId); ViewBag.SellId = new SelectList(db.Sells, "SellId", "SellNumver", sellItem.SellId); return(View(sellItem)); }
public static async Task UpdateSell(SellUpdate updateSell, SellItem sellItem, DatabaseContext _context) { if (updateSell.Quantity != -1) { sellItem.Quantity = updateSell.Quantity; } if (updateSell.TotalCost != -1) { sellItem.TotalCost = updateSell.TotalCost; } sellItem.ContainerReturned = updateSell.ContainerReturned; _context.Entry(sellItem).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public ActionResult Create([Bind(Include = "SellItemId,Quantity,UnitPrice,ProductId,SellId")] SellItem sellItem) { if (ModelState.IsValid) { db.SellItems.Add(sellItem); var sell = db.Sells.Find(sellItem.SellId); sell.TotalPrice += sellItem.Quantity * sellItem.UnitPrice; db.Entry(sell).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Edit", "Sells", new { id = sellItem.SellId })); } //ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Name", sellItem.ProductId); //ViewBag.SellId = new SelectList(db.Sells, "SellId", "SellNumver", sellItem.SellId); return(RedirectToAction("Edit", "Sells", new { id = sellItem.SellId })); }
public ActionResult Sell() { try { CartDAO cdao = new CartDAO(); IList <Cart> cart = cdao.GetUserCart(int.Parse(Session["Id"].ToString())); if (Session["Id"] != null && cart.Count() != 0) { SellDAO dao = new SellDAO(); Sell s = new Sell(); s.UserId = int.Parse(Session["Id"].ToString()); s.Date = DateTime.Now; s.TotalPrice = cdao.GetSubtotal(s.UserId); dao.Add(s); foreach (var c in cart) { SellItemDAO sidao = new SellItemDAO(); SellItem si = new SellItem(); si.ApplicationId = c.ApplicationId; si.PriceItem = c.Price; si.SellId = s.Id; sidao.Add(si); cdao.Remove(c); //Removing from Wishlist WishlistDAO wdao = new WishlistDAO(); IList <Wishlist> wishs = wdao.GetUserList(int.Parse(Session["Id"].ToString())); foreach (var w in wishs) { if (w.ApplicationId == c.ApplicationId) { wdao.Remove(w); } } } return(RedirectToAction("Library", "User")); } else { return(RedirectToAction("../Home/Index")); } } catch { return(RedirectToAction("../Home/Index")); } }
private void RunCreateSellOrders() { if (_itemsInHanger == null) { ChangeState(State.CreateBuyOrders); } _sellActions.Clear(); _newSellOrders = 0; Logging.Log("Automation:RunCreateSellOrders", "CreateSellOrders State - Begin", Logging.Debug); List <DirectItem> sellItemList = new List <DirectItem>(); foreach (DirectItem item in _itemsInHanger) { if (item == null) { continue; } int typeId = item.TypeId; DirectOrder order = _mySellOrders.FirstOrDefault(o => o.TypeId == typeId); if (order == null) { SellItem sellItem = new SellItem(item, true); sellItem.OnSellItemFinished += OnSellItemFinished; sellItem.OnSellItemFinished += SellItemFinished; _sellActions.Enqueue(sellItem); } } if (RunNextSellAction() == true) { ChangeState(State.Processing); } else { ChangeState(State.CreateBuyOrders); } }
public bool HandlePacket(Peer peer, byte[] data, Game game) { var sell = new SellItem(data); var client = game.GetPeerInfo(peer); var i = game.GetPeerInfo(peer).GetChampion().getInventory().GetItem(sell.slotId); if (i == null) { return(false); } float sellPrice = i.ItemType.TotalPrice * i.ItemType.TotalPrice; client.GetChampion().GetStats().Gold += sellPrice; if (i.ItemType.MaxStack > 1) { i.DecrementStackSize(); game.PacketNotifier.notifyRemoveItem(client.GetChampion(), sell.slotId, i.StackSize); if (i.StackSize == 0) { client.GetChampion().getInventory().RemoveItem(sell.slotId); } } else { game.PacketNotifier.notifyRemoveItem(client.GetChampion(), sell.slotId, 0); client.GetChampion().getInventory().RemoveItem(sell.slotId); } client.GetChampion().GetStats().RemoveBuff(i.ItemType); return(true); }
/// <summary> /// 界面显示时调用 /// </summary> protected override void OnShow(INotification notification) { if (panelType == PanelType.Info || panelType == PanelType.Sell || panelType == PanelType.Use) { m_Panel.CloseBtn.transform.localPosition = new Vector3(323, 244, 0); m_Panel.itemInfo.gameObject.SetActive(true); itemIcon = m_Panel.transform.FindChild("itemInfo/itemIcon").GetComponent <UITexture>(); itemcolor = m_Panel.transform.FindChild("itemInfo/itemcolor").GetComponent <UISprite>(); itemName = m_Panel.transform.FindChild("itemInfo/itemName").GetComponent <UILabel>(); ShowItemInfo showItemInfo = (notification.Body as List <object>)[0] as ShowItemInfo; itemID = (notification.Body as List <object>)[1] as string; string uuid = (notification.Body as List <object>)[2] as string; item = ItemManager.GetItemInfo(itemID); EquipItemInfo equip = EquipConfig.GetEquipDataByUUID(uuid); if (equip != null) { itemcolor.spriteName = UtilTools.StringBuilder("color", equip.star); } else { itemcolor.spriteName = UtilTools.StringBuilder("color", item.color); } itemName.text = TextManager.GetItemString(item.itemID); LoadSprite.LoaderItem(itemIcon, itemID, false); if (panelType == PanelType.Info) { m_Panel.SellOne.gameObject.SetActive(false); m_Panel.Info.gameObject.SetActive(true); sellBtn = m_Panel.transform.FindChild("itemInfo/Info/sellBtn").GetComponent <UIButton>(); useItemBtn = m_Panel.transform.FindChild("itemInfo/Info/useItemBtn").GetComponent <UIButton>(); itemDesc = m_Panel.transform.FindChild("itemInfo/Info/itemDesc").GetComponent <UILabel>(); itemPrice = m_Panel.transform.FindChild("itemInfo/Info/itemPrice").GetComponent <UILabel>(); itemNum = m_Panel.transform.FindChild("itemInfo/Info/itemNum").GetComponent <UILabel>(); UIEventListener.Get(sellBtn.gameObject).onClick = OnClick; UIEventListener.Get(useItemBtn.gameObject).onClick = OnClick; if (item == null) { return; } itemDesc.text = TextManager.GetPropsString("description_" + item.itemID); itemPrice.text = item.itemPrice.ToString(); itemNum.text = ItemManager.GetBagItemCount(itemID.ToString()).ToString(); sellItem = showItemInfo.sellItem; useItem = showItemInfo.useItem; if (sellItem == null && useItem == null) { sellBtn.gameObject.SetActive(false); useItemBtn.gameObject.SetActive(false); } else { sellBtn.gameObject.SetActive(true); useItemBtn.gameObject.SetActive(true); sellItem = showItemInfo.sellItem; useItem = showItemInfo.useItem; } } else if (panelType == PanelType.Sell) { m_Panel.Info.gameObject.SetActive(false); m_Panel.SellOne.gameObject.SetActive(true); minBtn = m_Panel.transform.FindChild("itemInfo/SellOne/minBtn").GetComponent <UIButton>(); maxBtn = m_Panel.transform.FindChild("itemInfo/SellOne/maxBtn").GetComponent <UIButton>(); addBtn = m_Panel.transform.FindChild("itemInfo/SellOne/addBtn").GetComponent <UIButton>(); subtractBtn = m_Panel.transform.FindChild("itemInfo/SellOne/subtractBtn").GetComponent <UIButton>(); cancelOneSellBtn = m_Panel.transform.FindChild("itemInfo/SellOne/cancelOneSellBtn").GetComponent <UIButton>(); okOneSellBtn = m_Panel.transform.FindChild("itemInfo/SellOne/okOneSellBtn").GetComponent <UIButton>(); haveNum = m_Panel.transform.FindChild("itemInfo/SellOne/haveNum").GetComponent <UILabel>(); changeNum = m_Panel.transform.FindChild("itemInfo/SellOne/changeNum").GetComponent <UILabel>(); sellPrcie = m_Panel.transform.FindChild("itemInfo/SellOne/sellPrcie").GetComponent <UILabel>(); UIEventListener.Get(cancelOneSellBtn.gameObject).onClick = OnClick; LongClickEvent.Get(subtractBtn.gameObject).onPress = OnPress; LongClickEvent.Get(subtractBtn.gameObject).duration = 3; LongClickEvent.Get(addBtn.gameObject).onPress = OnPress; LongClickEvent.Get(addBtn.gameObject).duration = 3; UIEventListener.Get(minBtn.gameObject).onClick = OnClick; UIEventListener.Get(maxBtn.gameObject).onClick = OnClick; UIEventListener.Get(okOneSellBtn.gameObject).onClick = OnClick; subtractBtn.gameObject.SetActive(info.amount > 1); addBtn.gameObject.SetActive(info.amount > 1); maxBtn.gameObject.SetActive(info.amount > 1); minBtn.gameObject.SetActive(info.amount > 1); changeNum.gameObject.SetActive(info.amount > 1); changeNum.text = "1"; sellPrcie.text = item.itemPrice.ToString(); haveNum.text = info.amount.ToString(); SellOne = showItemInfo.sellOne; } else if (panelType == PanelType.Use) { sellBtn = m_Panel.transform.FindChild("itemInfo/Info/sellBtn").GetComponent <UIButton>(); useItemBtn = m_Panel.transform.FindChild("itemInfo/Info/useItemBtn").GetComponent <UIButton>(); itemDesc = m_Panel.transform.FindChild("itemInfo/Info/itemDesc").GetComponent <UILabel>(); itemPrice = m_Panel.transform.FindChild("itemInfo/Info/itemPrice").GetComponent <UILabel>(); itemNum = m_Panel.transform.FindChild("itemInfo/Info/itemNum").GetComponent <UILabel>(); sellBtn.gameObject.SetActive(false); useItemBtn.gameObject.SetActive(false); m_Panel.Info.gameObject.SetActive(true); m_Panel.use.gameObject.SetActive(true); if (item == null) { return; } itemDesc.text = TextManager.GetPropsString("description_" + item.itemID); itemPrice.text = item.itemPrice.ToString(); itemNum.text = info.amount.ToString(); okuse = m_Panel.transform.FindChild("itemInfo/use/okuse").GetComponent <UIButton>(); cancelUse = m_Panel.transform.FindChild("itemInfo/use/cancelUse").GetComponent <UIButton>(); UIEventListener.Get(okuse.gameObject).onClick = OnClick; UIEventListener.Get(cancelUse.gameObject).onClick = OnClick; UseOne = showItemInfo.useOne; } } else if (panelType == PanelType.Reward) { rewardIndex = 0; m_Panel.Mask.GetComponent <BoxCollider>().enabled = false; UIEventListener.Get(m_Panel.Mask.gameObject).onClick = OnClick; m_Panel.CloseBtn.gameObject.SetActive(false); GameObject cell = m_Panel.RewardItem.gameObject; PoolManager.CreatePrefabPools(PoolManager.PoolKey.Prefab_RewardItem, cell, false); m_Panel.getReward.gameObject.SetActive(true); rewardList = notification.Body as List <object>; TimerManager.Destroy("rewardIndex"); TimerManager.AddTimer("rewardIndex", 0.02f, CreateRewardItem); //getRewardBtn = m_Panel.transform.FindChild("getReward/getRewardBtn").GetComponent<UIButton>(); //UIEventListener.Get(getRewardBtn.gameObject).onClick = OnClick; } else if (panelType == PanelType.ChooseFriend) { if (FriendMediator.friendList.Count < 1) { GUIManager.SetPromptInfo(TextManager.GetUIString("UI2048"), null); ClosePanel(null); return; } m_Panel.CloseBtn.transform.localPosition = new Vector3(374, 229, 0); m_Panel.chooseFriend.gameObject.SetActive(true); FriendGrid = UtilTools.GetChild <UIGrid>(m_Panel.transform, "chooseFriend/ScrollView/FriendGrid"); FriendGrid.enabled = true; FriendGrid.BindCustomCallBack(UpdateFriendGrid); FriendGrid.StartCustom(); } else if (panelType == PanelType.UpMentality) { m_Panel.CloseBtn.transform.localPosition = new Vector3(316, 277, 0); UPMentality = UtilTools.GetChilds <UIToggle>(m_Panel.transform, "ballerUpMentality/group"); mentalityDesc = UtilTools.GetChilds <UILabel>(m_Panel.transform, "ballerUpMentality/group"); UPMentalityBtn = m_Panel.transform.FindChild("ballerUpMentality/UPMentalityBtn").GetComponent <UISprite>(); UIEventListener.Get(UPMentalityBtn.gameObject).onClick = OnClick; m_Panel.ballerUpMentality.gameObject.SetActive(true); } else if (panelType == PanelType.SwitchInherit) { m_Panel.CloseBtn.transform.localPosition = new Vector3(378, 243, 0); m_Panel.switchballer.gameObject.SetActive(true); List <object> list = notification.Body as List <object>; ChooseGrid = UtilTools.GetChild <UIGrid>(m_Panel.transform, "switchballer/ScrollView/ChooseGrid"); ChooseGrid.enabled = true; ChooseGrid.BindCustomCallBack(UpdateInheriter); ChooseGrid.StartCustom(); ChooseGrid.AddCustomDataList(list); } }
public static void DoShopping(int x, int y, Shop shop, BuyItem buyMethod, SellItem sellMethod) { #region Draw list of items ActionPanel.ClearArea(); var exitFlag = false; var current = 0; if (shop.DescriptionItems != null) foreach (var item in shop.DescriptionItems) { var caption = item.Split('\t')[0]; var text = item.Split('\t')[1]; shop.Add(new ShopItem(caption, 0, true, text, true)); } if (shop.HasQuit) { shop.Add(new ShopItem(ActionPanel.Common_Quit, 0, true, null, true)); } while (!shop[current].IsActive) current++; var oldPosition = current; var goodsX = x + 3; var goodsY = y + 2; var lastIndex = shop.Count - 1; var isBBC = shop.Type == ShopType.BBC; ZFrame.DrawFrame(x, y, new ZFrame.Options{ Caption = shop.Name, Width = shop.Header.Length+6, Height = lastIndex+4, FrameType = FrameType.Double}); ZOutput.Print(goodsX, y+1, shop.Header, Color.Cyan, Color.Black); for (var i = 0; i < shop.Count; i++) PrintItem(goodsX, goodsY + i, shop, shop[i], isBBC); ZOutput.Print(x + (shop.Header.Length+6-shop.Footer.Length)/2, goodsY+shop.Count+1, shop.Footer, Color.Red, Color.Black); #endregion while (!exitFlag) { var item = shop[current]; PrintItem(goodsX, goodsY + current, shop, item, isBBC, true); var key = ZInput.ReadKey(); switch (key) { case ConsoleKey.UpArrow : do { current = (current > 0) ? current - 1 : lastIndex; } while (!shop[current].IsActive); break; case ConsoleKey.DownArrow: do { current = (current < lastIndex) ? current + 1 : 0; } while (!shop[current].IsActive); break; case ConsoleKey.Enter : case ConsoleKey.PageUp : case ConsoleKey.RightArrow: case ConsoleKey.Add: case ConsoleKey.Insert: #region Buy Item if (item.Name == ActionPanel.Common_Quit) { exitFlag = true; break; } if (item.ItemObject is string) { EventLog.Print(item.ItemObject as string); break; } if (shop.Type != ShopType.BBC) { if (Player.Credits >= item.Price) { exitFlag = buyMethod(item) ? shop.ExitAfter : exitFlag; } else { EventLog.Print("Planet_NoMoneyToBuy"); } } else { buyMethod(item); } PlayerStats.Draw_PlayerStats(); break; #endregion case ConsoleKey.PageDown: case ConsoleKey.LeftArrow: case ConsoleKey.Subtract: case ConsoleKey.Delete: #region Sell Item if (item.Name == ActionPanel.Common_Quit) { exitFlag = true; break; } if (item.ItemObject is string) { EventLog.Print(item.ItemObject as string); break; } var result = (sellMethod != null) ? sellMethod(item) : buyMethod(item); exitFlag = result && shop.ExitAfter; PlayerStats.Draw_PlayerStats(); break; #endregion case ConsoleKey.Escape: case ConsoleKey.Backspace: exitFlag = true; break; case ConsoleKey.F1 : HelpInfo.Show(); break; case ConsoleKey.F5 : PlayerInfo.Show(); break; case ConsoleKey.F6 : GalaxyInfo.Show(); break; case ConsoleKey.F10 : ZFrontier.Quit_Game(); break; } while (!shop[current].IsActive) current = (current < lastIndex) ? current + 1 : 0; if (current != oldPosition) { PrintItem(goodsX, goodsY + oldPosition, shop, shop[oldPosition], isBBC); oldPosition = current; } } ActionPanel.ClearArea(); }
public override int GetHashCode() { return(Qty.GetHashCode() ^ SellItem.GetHashCode()); }
void HandleSellItem(SellItem packet) { if (packet.ItemGUID.IsEmpty()) { return; } var pl = GetPlayer(); Creature creature = pl.GetNPCIfCanInteractWith(packet.VendorGUID, NPCFlags.Vendor, NPCFlags2.None); if (creature == null) { Log.outDebug(LogFilter.Network, "WORLD: HandleSellItemOpcode - {0} not found or you can not interact with him.", packet.VendorGUID.ToString()); pl.SendSellError(SellResult.CantFindVendor, null, packet.ItemGUID); return; } if (creature.GetCreatureTemplate().FlagsExtra.HasFlag(CreatureFlagsExtra.NoSellVendor)) { _player.SendSellError(SellResult.CantSellToThisMerchant, creature, packet.ItemGUID); return; } // remove fake death if (pl.HasUnitState(UnitState.Died)) { pl.RemoveAurasByType(AuraType.FeignDeath); } Item pItem = pl.GetItemByGuid(packet.ItemGUID); if (pItem != null) { // prevent sell not owner item if (pl.GetGUID() != pItem.GetOwnerGUID()) { pl.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID); return; } // prevent sell non empty bag by drag-and-drop at vendor's item list if (pItem.IsNotEmptyBag()) { pl.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID); return; } // prevent sell currently looted item if (pl.GetLootGUID() == pItem.GetGUID()) { pl.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID); return; } // prevent selling item for sellprice when the item is still refundable // this probably happens when right clicking a refundable item, the client sends both // CMSG_SELL_ITEM and CMSG_REFUND_ITEM (unverified) if (pItem.IsRefundable()) { return; // Therefore, no feedback to client } // special case at auto sell (sell all) if (packet.Amount == 0) { packet.Amount = pItem.GetCount(); } else { // prevent sell more items that exist in stack (possible only not from client) if (packet.Amount > pItem.GetCount()) { pl.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID); return; } } ItemTemplate pProto = pItem.GetTemplate(); if (pProto != null) { if (pProto.GetSellPrice() > 0) { ulong money = pProto.GetSellPrice() * packet.Amount; if (!_player.ModifyMoney((long)money)) // ensure player doesn't exceed gold limit { _player.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID); return; } _player.UpdateCriteria(CriteriaType.MoneyEarnedFromSales, money); _player.UpdateCriteria(CriteriaType.SellItemsToVendors, 1); if (packet.Amount < pItem.GetCount()) // need split items { Item pNewItem = pItem.CloneItem(packet.Amount, pl); if (pNewItem == null) { Log.outError(LogFilter.Network, "WORLD: HandleSellItemOpcode - could not create clone of item {0}; count = {1}", pItem.GetEntry(), packet.Amount); pl.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID); return; } pItem.SetCount(pItem.GetCount() - packet.Amount); pl.ItemRemovedQuestCheck(pItem.GetEntry(), packet.Amount); if (pl.IsInWorld) { pItem.SendUpdateToPlayer(pl); } pItem.SetState(ItemUpdateState.Changed, pl); pl.AddItemToBuyBackSlot(pNewItem); if (pl.IsInWorld) { pNewItem.SendUpdateToPlayer(pl); } } else { pl.RemoveItem(pItem.GetBagSlot(), pItem.GetSlot(), true); pl.ItemRemovedQuestCheck(pItem.GetEntry(), pItem.GetCount()); Item.RemoveItemFromUpdateQueueOf(pItem, pl); pl.AddItemToBuyBackSlot(pItem); } } else { pl.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID); } return; } } pl.SendSellError(SellResult.CantSellItem, creature, packet.ItemGUID); return; }
void LoadItemManager(SellItem sellItem) { ItemAmountManager itemManager; Item item = (Item)XmlManager.LoadInstanceAsXml(sellItem.itemId, typeof(Item)); itemManager = new ItemAmountManager(item, sellItem.amount); if (itemManager == null) Debug.LogError("[Shop] No shop at file " + sellItem.itemId); listSellItem.Add(itemManager); }
public async Task <ActionResult <SellItem> > PostSellItem([FromBody] SellItem sellItem, [FromQuery] long productID) { try { if (productID <= 0) { throw new Exception("One or more validation errors occurred"); } var productExists = await DbAccessClass.ProductIDExists(productID, _context); if (!productExists) { throw new Exception("Product not found"); } var product = await DbAccessClass.GetProduct(productID, _context); var availableStock = product.StockAmount - sellItem.Quantity; if (product.StockAmount == 0) { throw new Exception("Product out of stock"); } if (availableStock < 0) { throw new Exception("Not enough quantity available"); } var verifyPrice = product.SellPrice * sellItem.Quantity; var verifyWithDiscount = DbAccessClass.CalculateSubtotal(verifyPrice, product.Discount); if (sellItem.ContainerReturned && verifyWithDiscount != sellItem.TotalCost) { throw new Exception("Price does not match subtotal"); } else if (!sellItem.ContainerReturned && verifyPrice != sellItem.TotalCost) { throw new Exception("Price does not match subtotal"); } if (sellItem.Paid < 0) { throw new Exception("Payment is required"); } var change = sellItem.Paid - sellItem.TotalCost; if (change < 0) { throw new Exception("Not enough payment"); } await DbAccessClass.AddSell(sellItem, product, _context); return(CreatedAtAction("GetSell", new { id = sellItem.SellID }, Ok(change))); } catch (Exception ex) { return(ex.Message switch { "Product not found" => NotFound(new JsonResult(ex.Message)), "Product out of stock" => StatusCode(417, new JsonResult(ex.Message)), "Not enough quantity available" => StatusCode(417, new JsonResult(ex.Message)), "Price does not match subtotal" => StatusCode(409, new JsonResult(ex.Message)), "Payment is required" => StatusCode(402, new JsonResult(ex.Message)), "Not enough payment" => StatusCode(406, new JsonResult(ex.Message)), "One or more validation errors occurred" => UnprocessableEntity(new JsonResult(ex.Message)), _ => BadRequest(new JsonResult(ex.Message)), });
public override string ToString() { return($"Sell Item: {SellItem.ToString()} Qty: {Qty.ToString()}"); }
public override string ToString() { return($"Cell Id: {CellId} Sell Item: {SellItem.ToString()} Qty: {SellItemQty}"); }
public SellItemRequest ReadSellItemRequest(byte[] data) { var rq = new SellItem(data); return(new SellItemRequest(rq.NetId, rq.SlotId)); }
public void SellItem(SellItem rpc) { for (int i = 0; i < rpc.amount; i++) money += itemStacks[rpc.index].Pop().price; }
public override int GetHashCode() { return(CellId.GetHashCode() * SellItem.GetHashCode() * SellItemQty.GetHashCode()); }
public static void GetInstanceData(this GameParameter.ItemInstanceTypes instanceType, int index, GameObject gameObject, out ItemParam itemParam, out int itemNum) { switch (instanceType) { case GameParameter.ItemInstanceTypes.Any: ItemData dataOfClass1 = DataSource.FindDataOfClass <ItemData>(gameObject, (ItemData)null); if (dataOfClass1 != null) { itemParam = dataOfClass1.Param; itemNum = dataOfClass1.Num; return; } itemParam = DataSource.FindDataOfClass <ItemParam>(gameObject, (ItemParam)null); itemNum = 0; return; case GameParameter.ItemInstanceTypes.Inventory: PlayerData player = MonoSingleton <GameManager> .Instance.Player; if (0 <= index && index < player.Inventory.Length && player.Inventory[index] != null) { itemParam = player.Inventory[index].Param; itemNum = player.Inventory[index].Num; return; } break; case GameParameter.ItemInstanceTypes.QuestReward: if (Object.op_Inequality((Object)SceneBattle.Instance, (Object)null)) { QuestParam questParam = MonoSingleton <GameManager> .Instance.FindQuest(SceneBattle.Instance.Battle.QuestID) ?? DataSource.FindDataOfClass <QuestParam>(gameObject, (QuestParam)null); if (questParam != null && 0 <= index && (questParam.bonusObjective != null && index < questParam.bonusObjective.Length)) { itemParam = MonoSingleton <GameManager> .Instance.GetItemParam(questParam.bonusObjective[index].item); itemNum = questParam.bonusObjective[index].itemNum; return; } break; } break; case GameParameter.ItemInstanceTypes.Equipment: EquipData dataOfClass2 = DataSource.FindDataOfClass <EquipData>(gameObject, (EquipData)null); if (dataOfClass2 != null) { itemParam = dataOfClass2.ItemParam; itemNum = 0; return; } break; case GameParameter.ItemInstanceTypes.EnhanceMaterial: EnhanceMaterial dataOfClass3 = DataSource.FindDataOfClass <EnhanceMaterial>(gameObject, (EnhanceMaterial)null); if (dataOfClass3 != null && dataOfClass3.item != null) { itemParam = dataOfClass3.item.Param; itemNum = dataOfClass3.item.Num; return; } break; case GameParameter.ItemInstanceTypes.EnhanceEquipData: EnhanceEquipData dataOfClass4 = DataSource.FindDataOfClass <EnhanceEquipData>(gameObject, (EnhanceEquipData)null); if (dataOfClass4 != null && dataOfClass4.equip != null) { itemParam = dataOfClass4.equip.ItemParam; itemNum = 0; return; } break; case GameParameter.ItemInstanceTypes.SellItem: SellItem dataOfClass5 = DataSource.FindDataOfClass <SellItem>(gameObject, (SellItem)null); if (dataOfClass5 != null && dataOfClass5.item != null) { itemParam = dataOfClass5.item.Param; itemNum = dataOfClass5.num; return; } break; } itemParam = (ItemParam)null; itemNum = 0; }