Ejemplo n.º 1
0
 public void OfferFulfillment(MarketUser user, double value, CurrencyTypes currency)
 {
     if (currency == Currency && value > 0 && IsInMargin(value))
     {
         Offers.Add(user, value);
     }
 }
Ejemplo n.º 2
0
 public void ListItem(MarketUser user, MarketItem item)
 {
     if (item.Valid && item.Type == ItemType)
     {
         ListedItems.Add(new KeyValuePair <MarketUser, MarketItem>(user, item));
         UpdatePriceLevel();
     }
 }
Ejemplo n.º 3
0
 public MarketOrder(Market inside, MarketUser user, MarketItem item, double desiredValue, double margin, CurrencyTypes desiredCurrency, int desiredOffers)
 {
     Market        = inside;
     NeededItem    = item;
     DesiredValue  = desiredValue;
     Margin        = margin;
     Currency      = desiredCurrency;
     DesiredOffers = desiredOffers;
     Offers        = new Dictionary <MarketUser, double>();
     User          = user;
 }
Ejemplo n.º 4
0
 public void PurchaseItem(MarketUser user, MarketItem item, double value, Market market)
 {
     if (MarketGoods.Contains(item))
     {
         if (user.Money.ChangeMoney(market.UsedCurrency, value * -1) == true)
         {
             MarketItem marketItem = MarketGoods.GetItem(item);
             marketItem.User = user;
             MarketGoods.Remove(marketItem);
             Money.ChangeMoney(market.UsedCurrency, value);
         }
     }
 }
Ejemplo n.º 5
0
        public bool ChangeUser(MarketUser newUser)
        {
            if (Valid)
            {
                if (newUser.WeightEnabled == false || (newUser.WeightEnabled && newUser.Weight + Weight <= newUser.MaxWeight))
                {
                    if (User.WeightEnabled)
                    {
                        User.Weight    -= Weight;
                        newUser.Weight += Weight;
                    }
                    User = newUser;
                    return(true);
                }

                return(false);
            }
            return(false);
        }
Ejemplo n.º 6
0
        public void AcceptOffer()
        {
            double     bestOffer = -1;
            MarketUser bestUser  = null;

            foreach (KeyValuePair <MarketUser, double> offer in Offers)
            {
                if (bestOffer >= 0 && offer.Value < bestOffer && offer.Key.MarketGoods.Contains(NeededItem) != false)
                {
                    bestUser  = offer.Key;
                    bestOffer = offer.Value;
                }
                else if (bestOffer == -1 && bestUser == null)
                {
                    bestUser  = offer.Key;
                    bestOffer = offer.Value;
                }
            }

            if (bestOffer != -1 && bestUser != null)
            {
                bestUser.PurchaseItem(User, bestUser.MarketGoods.GetItem(NeededItem), bestOffer, Market);
            }
        }