Esempio n. 1
0
        private static void Main(string[] args)
        {
            var db = new All(JsonDb.Load(), JsonNames.LoadNames());

            albionParser = new AlbionParser();

            albionParser.AddEventHandler<PlayerCounts>(p =>
            {
                Console.WriteLine($"Players: {p.Blue} / {p.Red}");
            });

            albionParser.AddOperationHandler<ConsloeCommand>(p =>
            {
                Console.WriteLine($"LocId: {p.LocId} {p.Town}");
            });

//            albionParser.AddOperationHandler<AuctionBuyOffer>(p =>
//            {
//                if (p.Items.Length==0) return;
//                var items = p.Items.GroupBy(x=>x.ItemTypeId).ToArray();
//                foreach (var item in items)
//                {
//                    var max = item.Max(x => x.UnitPriceSilver) / 10000;
//
//                    var ph = db.GetItem(item.Key).PriceHolder;
//
//                    ph.UpdateBye(max, items.Length == 1);
//                }
//            });
//
//            albionParser.AddOperationHandler<AuctionGetRequests>(p =>
//            {
//                if (p.Items.Length == 0) return;
//                var items = p.Items.GroupBy(x => x.ItemTypeId).ToArray();
//                foreach (var item in items)
//                {
//                    var min = item.Min(x => x.UnitPriceSilver) / 10000;
//
//                    var ph = db.GetItem(item.Key).PriceHolder;
//
//                    ph.UpdateSell(min, items.Length == 1);
//                }
//            });

            Console.WriteLine("Start");

            albionParser.Start();

            Console.Read();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            albionParser = new AlbionParser();
            albionParser.AddRequestHandler <MoveOperation>(OperationCodes.Move, (operation) =>
            {
                Console.WriteLine($"Move request");
            });
            albionParser.AddEventHandler <MoveEvent>(EventCodes.Move, (operation) =>
            {
                Console.WriteLine($"Id: {operation.Id} x: {operation.Position.X} y: {operation.Position.Y}");
            });
            albionParser.AddEventHandler <NewCharacterEvent>(EventCodes.NewCharacter, (operation) =>
            {
                Console.WriteLine($"New ch Id: {operation.Id}");
            });

            Console.WriteLine("Start");

            var devices = LivePacketDevice.AllLocalMachine;

            foreach (var device in devices)
            {
                new Thread(() =>
                {
                    Console.WriteLine($"Open... {device.Description}");

                    using (PacketCommunicator communicator = device.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000))
                    {
                        communicator.ReceivePackets(0, PacketHandler);
                    }
                })
                .Start();
            }

            Console.Read();
        }