Пример #1
0
        public Profit GetProfit()
        {
            float ourAmount   = GoodsReceived.Sum(amount => amount.NumResources * GetPrice(amount.ResourceType)) + MoneyReceived;
            float theirAmount = GoodsSent.Sum(amount => amount.NumResources * GetPrice(amount.ResourceType)) + MoneySent;

            return(new Profit()
            {
                OurValue = ourAmount, TheirValue = theirAmount
            });
        }
Пример #2
0
        public void RecomputeTrade()
        {
            GoodsReceived.Clear();
            GoodsSent.Clear();

            foreach (GItem item in MyTrades.Items)
            {
                GoodsSent.Add(new ResourceAmount(item.ResourceType, item.CurrentAmount));
            }

            foreach (GItem item in TheirTrades.Items)
            {
                GoodsReceived.Add(new ResourceAmount(item.ResourceType, item.CurrentAmount));
            }

            TradeEvent trade =
                (new TradeEvent()
            {
                GoodsReceived = GoodsReceived,
                GoodsSent = GoodsSent,
                LikedThings = TheirGoods.LikedThings,
                HatedThings = TheirGoods.HatedThings,
                RareThings = TheirGoods.RareThings,
                CommonThings = TheirGoods.CommonThings,
                MoneyReceived = TheirTrades.MoneyEdit.CurrentMoney,
                MoneySent = MyTrades.MoneyEdit.CurrentMoney
            });

            float total = trade.GetProfit().TotalProfit;

            if (total >= 0)
            {
                BuyTotal.Text = "Their Profit: " + (total).ToString("C");

                if (trade.GetProfit().PercentProfit > 0.25f)
                {
                    BuyTotal.TextColor = Color.DarkGreen;
                }
                else
                {
                    BuyTotal.TextColor = Color.Black;
                }
            }
            else
            {
                BuyTotal.Text      = "Their Loss: " + (total).ToString("C");
                BuyTotal.TextColor = total < 0 ? Color.DarkRed : Color.Black;
            }

            BuyTotal.ToolTip = "They will need a profit of at least 25% to accept the trade. The current profit is " +
                               (int)(trade.GetProfit().PercentProfit * 100) + "%";
        }
Пример #3
0
 public bool IsLike()
 {
     return(GoodsSent.Any(amount => IsLiked(amount.ResourceType)));
 }