Exemplo n.º 1
0
        private void AddPacket(DsoChatPacket packet)
        {
            foreach (DsoChatPacketMessage msg in packet.Messages)
            {
                switch (msg.Type)
                {
                case EDsoMsgTypes.ChatGlobal:
                    chatGlobal.AddMessage(msg);
                    HighlightTab(tabPageChatGlobal);
                    break;

                case EDsoMsgTypes.ChatHelp:
                    chatHelp.AddMessage(msg);
                    HighlightTab(tabPageChatHelp);
                    break;

                case EDsoMsgTypes.Trade:
                    // Build trade instance
                    // @EDIT: Trade now is a simple chat

                    /*
                     * DsoTrade trade = DsoTrade.Create(msg, (msg.MessageDetails != null ? msg.MessageDetails.Player : "<unknown?>"));
                     * if (trade != null) {
                     *      // Add to statistics
                     *      ItemStats.CountAverage(trade.OfferedItem, trade.DemandedItem, trade.Ratio);
                     *      // Add to trade list
                     *      listTrades.AddTrade(trade);
                     *      // highlight tab
                     *      HighlightTab(tabPageTrades);
                     *      // Refresh count
                     *      lblStatusTrades.Text = string.Format("Trades: {0}", listTrades.GetItemCount());
                     * }
                     */
                    break;
                }

                // Delete trades
                if ((msg.Type & EDsoMsgTypes.Clear) == EDsoMsgTypes.Clear)
                {
                    if ((msg.Type & EDsoMsgTypes.Trade) == EDsoMsgTypes.Trade)
                    {
                        DsoTrade trade = DsoTrade.Create(msg, (msg.MessageDetails != null ? msg.MessageDetails.Player : "<unknown?>"));
                        if (trade != null && listTrades.RemoveTrade(trade) == false)
                        {
                            //SetStatus("Failed to remove trade from player \"" + trade.Player + "\".");
                        }
                        else
                        {
                            // Refresh count
                            lblStatusTrades.Text = string.Format("Trades: {0}", listTrades.GetItemCount());
                        }
                    }
                }

                // Count captured packets
                mCapturedPackets++;
                lblStatusPackets.Text = string.Format("Packets: {0}", mCapturedPackets);
            }
        }
Exemplo n.º 2
0
		public static DsoTrade Create(string message, string player) {
			DsoTrade trade = null;
			try {
				trade = new DsoTrade(message, player);
			} catch {
				return null;
			}
			return trade;
		}
Exemplo n.º 3
0
        private void listTrades_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listTrades.SelectedIndex == -1)
            {
                return;
            }

            DsoTrade trade = (DsoTrade)listTrades.GetSelectedObject();

            SetStatus(string.Format("{0}x {1} => {2}x {3}", trade.OfferedItemAmount, trade.OfferedItemLocalized, trade.DemandedItemAmount, trade.DemandedItemLocalized));
        }
Exemplo n.º 4
0
        public static DsoTrade Create(string message, string player)
        {
            DsoTrade trade = null;

            try {
                trade = new DsoTrade(message, player);
            } catch {
                return(null);
            }
            return(trade);
        }
Exemplo n.º 5
0
        private void CleanupTimer_Tick(object sender, EventArgs e)
        {
            // Iterate all objects
            List <DsoTrade> trades = new List <DsoTrade>();

            foreach (var obj in listTrades.Objects)
            {
                DsoTrade trade = (DsoTrade)obj;
                // Kick
                if (trade != null && trade.IsExpired)
                {
                    trades.Add(trade);
                }
            }

            foreach (DsoTrade trade in trades)
            {
                listTrades.RemoveTrade(trade);
            }
            trades.Clear();
            trades = null;
        }