private void OnAuctionItemTargeted(Mobile from, object targeted) { var item = targeted as Item; if (item == null || item is BaseContainer) { from.SendMessage("Only items can be auctioned."); m_auctionStatus = AuctionStatus.Ready; return; } if (!from.Backpack.Items.Contains(item)) { from.SendMessage("The item must be in your backpack to auction."); m_auctionStatus = AuctionStatus.Ready; return; } this.AddItem(item); this.m_ItemOwner = from; //start a timer to timeout if they dont fill in price if (m_StartPrice == -1) { from.CloseGump(typeof(AuctionPriceGump)); from.SendGump(new AuctionPriceGump(from, item, StartAuction)); } else { StartAuction(item, m_StartPrice); } }
private void OnAuction(CommandEventArgs e) { var pm = e.Mobile as MythikPlayerMobile; if (m_auctionStatus != AuctionStatus.Ready) { pm.SendMessage("An Auction is already in progress, please wait for it to finish"); return; } m_StartPrice = -1; pm.SendMessage("Select an Item to Auction"); pm.BeginTarget(1, false, Server.Targeting.TargetFlags.None, OnAuctionItemTargeted); pm.Target = new AuctionTarget(OnAuctionItemTargeted); m_auctionStatus = AuctionStatus.Starting; if (e.Arguments.Length > 0) { int price = -1; int.TryParse(e.Arguments[0], out price); if (price > -1 && price < 20000000) { m_StartPrice = price; } } }
private async Task <ActionResult <Auction> > ChangeAuctionStatus(int id, AuctionStatus status) { var auction = await _context.Auction .Where(x => x.ID == id) .FirstOrDefaultAsync(); if (auction == null) { return(NotFound()); } auction.Status = status; _context.Entry(auction).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuctionExists(id)) { return(NotFound()); } else { throw; } } return(auction); }
public Auction(string car, IEvaluationModalities evaluationMod) { Car = car; _bid = new List <Bid>(); Status = AuctionStatus.AuctionBeforePreaching; _evaluationMod = evaluationMod; }
private IEnumerable <Auction> ValidateAuctionStatus(IEnumerable <Auction> actions) { foreach (var action in actions) { AuctionStatus OldStatus = action.AuctionStatus; if ((action.AuctionStatus == AuctionStatus.Open || action.AuctionStatus == AuctionStatus.PickWinnerWating) && action.PickWinnerDate < DateTime.Now) { action.AuctionStatus = AuctionStatus.CloseWating; } else if (action.AuctionStatus == AuctionStatus.Open && action.CloseDate < DateTime.Now) { action.AuctionStatus = AuctionStatus.PickWinnerWating; } if (OldStatus != action.AuctionStatus) { this.Update(action); this._uow.Commit(); } } return(actions); }
public void EndsPreaching() { if (Status != AuctionStatus.AuctionInProgress) { throw new System.InvalidOperationException("It is not possible to finish the trading session without it having started."); } Winner = _evaluationMod.Measure(this); Status = AuctionStatus.AuctionFinished; }
public AuctionViewModel(Auction auction) { Product = new ProductViewModel(auction.Product); Bid = auction.Bid == null ? null : new BidViewModel { Id = auction.Bid.Id, UserId = auction.Bid.UserId, Price = auction.Bid.Price }; Status = auction.Status; }
public void Close(DateTime closeAt) { var winner = _bids.OrderByDescending(b => b.Amount).FirstOrDefault(); _status = AuctionStatus.Closed; RaiseEvent<AuctionClosed>(e => { e.AuctionId = Id; e.ClosedAt = closeAt; if (winner != null) e.WinningBid = winner.BidId; }); }
private string setAuctionStatusForArtist(AuctionStatus acs) { string name = ""; switch (acs) { case AuctionStatus.Open: name = "פתוח"; break; case AuctionStatus.close: name = "סגור"; break; } return(name); }
private void StartAuction(Item item, int price) { //-1 price cancel it. if (price == -1) { m_ItemOwner.SendAsciiMessage("You failed to set a valid price and your auction was cancelled."); EndAuction(false); return; } m_Item = item; Broadcast("Auction Starting!"); Broadcast(item.Amount + " " + item.Name + " Price: " + price); m_CurrentBid = price; this.m_timer = new AuctionTimer(this); m_timer.Start(); m_auctionStatus = AuctionStatus.Ongoing; }
private void EndAuction(bool sendbroadcast = true) { m_auctionStatus = AuctionStatus.Finishing; if (sendbroadcast) { Broadcast("Auction Ended"); } if (m_CurrentBidder == null) { m_ItemOwner.PlaceInBackpack(m_Item); } else { m_CurrentBidder.PlaceInBackpack(m_Item); m_ItemOwner.PlaceInBackpack(new BankCheck((int)(m_CurrentBid * TAX))); } m_ItemOwner = null; m_CurrentBid = -1; m_CurrentBid = -1; m_CurrentBidder = null; m_auctionStatus = AuctionStatus.Ready; }
private void ParseResponse(ResponseContainer response) { AuctionStatus status = response.GetParsedSingle <AuctionStatus>(false); switch (status?.MinutesRemaining ?? 10) { case 0: ExecutionInterval = status.NextIn.Add(TimeSpan.FromMinutes(1)); break; case 5: ExecutionInterval = TimeSpan.FromMinutes(1); break; default: ExecutionInterval = TimeSpan.FromMinutes(2); break; } if (status != null) { Auction = status; } Restart(); }
void Apply(AuctionRegistered @event) { Id = @event.AuctionId; _status = AuctionStatus.Running; _bids = new List<BidInfo>(); }
private async Task <ActionResult <IEnumerable <Auction> > > GetAuctionByStatus(AuctionStatus status) { return(await _context.Auction .Include(a => a.Images) .Where(x => x.Status == status) .ToListAsync()); }
protected override CommandQueueElement RunInternal() { var resp = Client.IssueRequest(Client.RequestBuilder.GetOverviewPage(PlanetId)); var info = resp.GetParsedSingle <OgamePageInfo>(); var planetList = resp.GetParsed <PlanetListItem>(); var postParams = planetList.Cartesian(new[] { "metal", "crystal", "deuterium" }, (pi, res) => string.Format(BidFormat, pi.Id, res)).ToDictionary(k => k, v => "0"); // bidding key string key = string.Format(BidFormat, PlanetId, BidResource.ToString().ToLower()); postParams["ajax"] = "1"; postParams["bid[honor]"] = "0"; int bidCount = 1, checkCount = 0; double multiplier = 1; switch (BidResource) { case ResourceType.Metal: multiplier = 1.0; break; case ResourceType.Crystal: multiplier = 1.5; break; case ResourceType.Deuterium: multiplier = 3.0; break; } AuctionStatus status = null; AuctionBidResponse last = null; do { resp = Client.IssueRequest(Client.RequestBuilder.GetAuctioneer()); status = resp.GetParsedSingle <AuctionStatus>(); checkCount++; if (status.HighestBidderId != info.PlayerId && status.MinutesRemaining != 0) { int bidValue = status.Shortfall; if (status.Shortfall < 3000) { bidValue *= 2; } else if (status.Shortfall < 100000) { bidValue = (int)(bidValue * 1.2); } else if (status.Shortfall > 200000) { Logger.Instance.Log(LogLevel.Error, $"Too high bid amount: {bidValue}, bid on your own or rerun!"); return(null); } bidValue += 1; int bid = (int)(Math.Ceiling(bidValue / multiplier)); postParams["token"] = status.Token; postParams[key] = bid.ToString(); var req = Client.BuildPost(new Uri("/game/index.php?page=auctioneer", UriKind.Relative), postParams); resp = Client.IssueRequest(req); last = resp.GetParsedSingle <AuctionBidResponse>(false); Logger.Instance.Log(LogLevel.Info, $"Bid {bidCount++}/{checkCount} was for {status.OwnBid + bidValue}: {last?.Message}"); } int delay = 0; if (status.MinutesRemaining > 5) { delay = 30000; } Thread.Sleep(delay); } while (status.MinutesRemaining != 0); Logger.Instance.Log(status.HighestBidderId == info.PlayerId ? LogLevel.Success : LogLevel.Warning, $"Auction for {status.Item} won by {status.HighestBidderName} at {status.CurrentBid}"); return(null); }
public List<Auction> GetMyAuctionsWithStatus(string userEmail, AuctionStatus status) { var owner = db.Users.Where(e => e.Email == userEmail).FirstOrDefault(); if (owner == null) throw new FaultException("User not found!"); return TranslateListEntityAuctionProduct(db.AutionProducts.Include("Bids").Include("AuctionComments").Include("Category").Include("Owner").Where(e => e.AutionStatus == status).ToList()); }
private void AddAuctionsToCategory(AuctioneerDbContext context, int categoryId, int auctionCount, AuctionStatus status = AuctionStatus.Active) { for(int i = 0; i < auctionCount; ++i) { var auction = new TestAuction { CategoryId = categoryId, EndDate = (status != AuctionStatus.Expired) ? DateTime.Now.Add(TimeSpan.FromDays(1)) : DateTime.Now.Subtract(TimeSpan.FromDays(1)), BuyoutPrice = new Money(10, new TestCurrency()) }; if(status == AuctionStatus.Sold) { auction.Offers.Add(new TestBuyOffer { Amount = 10 } ); } context.Auctions.Add(auction); } }
public int GetAuctionsCountByStatus(AuctionStatus status) { return(dbSet.Where(auct => auct.AuctionStatus == status).Count()); }
public override IEnumerable <DataObject> ProcessInternal(ClientBase client, ResponseContainer container) { var doc = container.ResponseHtml.Value.DocumentNode; var leftContent = doc.SelectSingleNode(".//div[@class='left_content']"); var rightContent = doc.SelectSingleNode(".//div[@class='right_content']"); if (leftContent == null) { yield break; } AuctionStatus status = new AuctionStatus(); var auctionInfo = leftContent.SelectSingleNode("./p[@class='auction_info']"); var remaining = auctionInfo.SelectSingleNode("./span")?.InnerText ?? string.Empty; Match match = timeParser.Match(remaining); if (match.Success) { var time = int.Parse(match.Groups[1].Value); if (match.Groups[2].Value == "m") { status.MinutesRemaining = time; } else { status.NextIn = TimeSpan.FromSeconds(time); } } var bid = leftContent.SelectSingleNode("./div[contains(@class, 'currentSum')]"); status.CurrentBid = int.Parse(bid.InnerText, NumberStyles.AllowThousands | NumberStyles.Integer, client.ServerCulture); var count = leftContent.SelectSingleNode("./div[contains(@class, 'numberOfBids')]"); status.BidCount = int.Parse(count.InnerText, NumberStyles.Integer); var bidder = leftContent.SelectSingleNode("./a[contains(@class, 'currentPlayer')]"); status.HighestBidderName = bidder.InnerText.Trim(); status.HighestBidderId = int.Parse(bidder.Attributes["data-player-id"]?.Value ?? "0"); var item = leftContent.SelectSingleNode(".//a[contains(@class, 'detail_button')]"); string reference = item.Attributes["ref"].Value; IEnumerable <ShopItem> all = ShopItem.All(); status.Item = all.Where(si => si.Reference == reference).FirstOrDefault(); var ownBid = rightContent.SelectSingleNode(".//td[contains(@class, 'js_alreadyBidden')]"); status.OwnBid = int.Parse(ownBid.InnerText, NumberStyles.AllowThousands | NumberStyles.Integer, client.ServerCulture); var minBid = rightContent.SelectSingleNode(".//td[contains(@class, 'js_price')]"); status.MinimumBid = int.Parse(minBid.InnerText, NumberStyles.AllowThousands | NumberStyles.Integer, client.ServerCulture); HtmlNodeCollection scriptBlocks = doc.SelectNodes("//script[@type='text/javascript' and not(@src)]"); if (scriptBlocks != null) { foreach (HtmlNode block in scriptBlocks) { Match tokenMatch = TokenRegex.Match(block.InnerText); if (tokenMatch.Success) { status.Token = tokenMatch.Groups[1].Value; break; } } } yield return(status); }
public void Do() => AuctionStatus.Do();
public void Update() { AuctionStatus status = _subject.State; _subject.Detach(this); }
public void StartsPreaching() { Status = AuctionStatus.AuctionInProgress; }
void Apply(AuctionClosed @event) { _status = AuctionStatus.Closed; }
public List<Auction> GetAutionsByStatus(AuctionStatus status) { return TranslateListEntityAuctionProduct(db.AutionProducts.Include("Bids").Include("AuctionComments").Include("Category").Include("Owner").Where(e =>e.AutionStatus == status).ToList()); }