void HandleTradeItemsCommand(string msg, TradeSession trade) { trade.SendChatMessage("Not implemented yet!"); return; var sb = new StringBuilder(); sb.AppendLine("Items:"); foreach (var item in trade.ItemsToReceive) { sb.AppendLine(string.Format("{0} | {1}", item.id, item.details.name)); } trade.SendChatMessage(sb.ToString()); }
void HandleTradeHelpCommand(string msg, TradeSession trade) { OutputCommandsHelp<TradeCommand>("Trade", (s) => trade.SendChatMessage(s)); }
void HandleTradeRemoveCommand(string msg, TradeSession trade) { string[] args = msg.Split(' '); if (args.Length < 2) { trade.SendChatMessage("Invalid arguments."); return; } var pattern = string.Format(".*{0}.*", msg.Substring(msg.IndexOf(" ")).Trim()); if (string.IsNullOrWhiteSpace(pattern)) return; UpdateBackpack(); var assets = GetAssetsMatchingPattern(pattern); foreach (var asset in assets) { var item = GetItemFromDefIndex(asset.DefIndex); Logger.WriteLine("Removing from trade: {0}", item.Name); trade.RemoveItem(asset.Id); } }
void HandleTradeTextCommand(TradeSession trade, TradeEvent @event) { SendChatDelegate sendDelegate = (sender, entry, text) => { trade.SendChatMessage(text); }; TradeCommand cmd; if (!HandleCommandCommon( @event.message, @event.sender, sendDelegate, out cmd)) return; var messageMap = new Dictionary<TradeCommand, Action<string, TradeSession>> { { TradeCommand.Help, HandleTradeHelpCommand }, { TradeCommand.Ready, HandleTradeReadyCommand }, { TradeCommand.Add, HandleTradeAddCommand }, { TradeCommand.Remove, HandleTradeRemoveCommand }, { TradeCommand.Confirm, HandleTradeConfirmCommand }, { TradeCommand.Items, HandleTradeItemsCommand }, { TradeCommand.Cancel, HandleTradeCancelCommand }, }; Action<string, TradeSession> func; if (!messageMap.TryGetValue(cmd, out func)) { Logger.WriteLine("Unhandled trade command: {0}", cmd); return; } func(@event.message, trade); }