public void DisplayPursuits(User invoker) { var greeting = World.Strings.Merchant.FirstOrDefault(x => x.Key == "greeting"); var optionsCount = 0; var options = new MerchantOptions(); options.Options = new List <MerchantDialogOption>(); var merchant = this as Merchant; if (merchant?.Jobs.HasFlag(MerchantJob.Vend) ?? false) { optionsCount += 2; options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.BuyItemMenu, Text = "Buy" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.SellItemMenu, Text = "Sell" }); } if (merchant?.Jobs.HasFlag(MerchantJob.Bank) ?? false) { optionsCount += 4; options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.DepositGoldMenu, Text = "Deposit Gold" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.WithdrawGoldMenu, Text = "Withdraw Gold" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.DepositItemMenu, Text = "Deposit Item" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.WithdrawItemMenu, Text = "Withdraw Item" }); } if (merchant?.Jobs.HasFlag(MerchantJob.Repair) ?? false) { optionsCount += 2; options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.RepairItemMenu, Text = "Fix Item" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.RepairAllItems, Text = "Fix All Items" }); } if (merchant?.Jobs.HasFlag(MerchantJob.Skills) ?? false) { optionsCount += 2; options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.LearnSkillMenu, Text = "Learn Skill" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.ForgetSkillMenu, Text = "Forget Skill" }); } if (merchant?.Jobs.HasFlag(MerchantJob.Spells) ?? false) { optionsCount += 2; options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.LearnSpellMenu, Text = "Learn Secret" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.ForgetSpellMenu, Text = "Forget Secret" }); } if (merchant?.Jobs.HasFlag(MerchantJob.Post) ?? false) { if (invoker.HasParcels) { options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.ReceiveParcel, Text = "Receive Parcel" }); optionsCount++; } options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.SendParcelMenu, Text = "Send Parcel" }); optionsCount++; /* if user has item named "Letter" * menupacket.WriteString8("Send Letter"); * menupacket.WriteUInt16((ushort)MerchantMenuItem.SendLetterMenu); * pursuitCount++; * if user has incoming parcel * menupacket.WriteString8("Receive Parcel"); * menupacket.WriteUInt16((ushort)MerchantMenuItem.ReceiveParcel); * pursuitCount++; */ } foreach (var pursuit in Pursuits) { GameLog.DebugFormat("Pursuit {0}, id {1}", pursuit.Name, pursuit.Id); if (pursuit.MenuCheckExpression != string.Empty) { var ret = Script.ExecuteAndReturn(pursuit.MenuCheckExpression, invoker); // If the menu check expression returns anything other than true, we don't include the // pursuit on the main menu that is sent to the user if (!ret.CastToBool()) { GameLog.ScriptingDebug($"{pursuit.MenuCheckExpression} evaluated to {ret}"); continue; } } options.Options.Add(new MerchantDialogOption { Id = (ushort)pursuit.Id.Value, Text = pursuit.Name }); optionsCount++; } var packet = new ServerPacketStructures.MerchantResponse() { MerchantDialogType = MerchantDialogType.Options, MerchantDialogObjectType = MerchantDialogObjectType.Merchant, ObjectId = Id, Tile1 = (ushort)(0x4000 + Sprite), Color1 = 0, Tile2 = (ushort)(0x4000 + Sprite), Color2 = 0, PortraitType = 1, Name = Name, Text = greeting?.Value ?? string.Empty, Options = options }; invoker.Enqueue(packet.Packet()); }
public void DisplayPursuits(User invoker) { var greeting = World.Strings.Merchant.FirstOrDefault(x => x.Key == "greeting"); var optionsCount = 0; var options = new MerchantOptions(); options.Options = new List <MerchantDialogOption>(); var merchant = this as Merchant; if (merchant?.Jobs.HasFlag(MerchantJob.Vend) ?? false) { optionsCount += 2; options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.BuyItemMenu, Text = "Buy" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.SellItemMenu, Text = "Sell" }); } if (merchant?.Jobs.HasFlag(MerchantJob.Bank) ?? false) { optionsCount += 4; options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.DepositGoldMenu, Text = "Deposit Gold" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.WithdrawGoldMenu, Text = "Withdraw Gold" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.DepositItemMenu, Text = "Deposit Item" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.WithdrawItemMenu, Text = "Withdraw Item" }); } if (merchant?.Jobs.HasFlag(MerchantJob.Repair) ?? false) { optionsCount += 2; options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.RepairItemMenu, Text = "Fix Item" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.RepairAllItems, Text = "Fix All Items" }); } if (merchant?.Jobs.HasFlag(MerchantJob.Skills) ?? false) { optionsCount += 2; options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.LearnSkillMenu, Text = "Learn Skill" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.ForgetSkillMenu, Text = "Forget Skill" }); } if (merchant?.Jobs.HasFlag(MerchantJob.Spells) ?? false) { optionsCount += 2; options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.LearnSpellMenu, Text = "Learn Secret" }); options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.ForgetSpellMenu, Text = "Forget Secret" }); } if (merchant?.Jobs.HasFlag(MerchantJob.Post) ?? false) { options.Options.Add(new MerchantDialogOption { Id = (ushort)MerchantMenuItem.SendParcelMenu, Text = "Send Parcel" }); optionsCount++; /* if user has item named "Letter" * menupacket.WriteString8("Send Letter"); * menupacket.WriteUInt16((ushort)MerchantMenuItem.SendLetterMenu); * pursuitCount++; * if user has incoming parcel * menupacket.WriteString8("Receive Parcel"); * menupacket.WriteUInt16((ushort)MerchantMenuItem.ReceiveParcel); * pursuitCount++; */ } foreach (var pursuit in Pursuits) { Logger.DebugFormat("Pursuit {0}, id {1}", pursuit.Name, pursuit.Id); options.Options.Add(new MerchantDialogOption { Id = (ushort)pursuit.Id.Value, Text = pursuit.Name }); optionsCount++; } options.OptionsCount = (byte)optionsCount; var packet = new ServerPacketStructures.MerchantResponse() { MerchantDialogType = MerchantDialogType.Options, MerchantDialogObjectType = MerchantDialogObjectType.Merchant, ObjectId = Id, Tile1 = (ushort)(0x4000 + Sprite), Color1 = 0, Tile2 = (ushort)(0x4000 + Sprite), Color2 = 0, PortraitType = 0, Name = Name, Text = greeting?.Value ?? string.Empty, Options = options }; invoker.Enqueue(packet.Packet()); }