Ejemplo n.º 1
0
        private void Login_Click(object sender, EventArgs e)
        {
            if (Username.Text.Trim().Length < 3 || Password.Text.Trim().Length < 6)
            {
                MessageBox.Show("Provide all required inputs!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            bool show = true;

            Task.Run(async() =>
            {
                try
                {
                    client = new APBClient.APBClient(Username.Text, Password.Text, hw);
                    await client.Login();
                    Instance.Hide();
                }
                catch
                {
                    MessageBox.Show("Failed to login!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    show = false;
                }
            }).Wait();

            if (show)
            {
                MainScreen main = new MainScreen();
                main.Show();
            }
        }
Ejemplo n.º 2
0
        static async Task ScrapeForAccountCharacter(int accountIndex, int characterIndex, InfluxDb influxClient, WatcherConfig config, HardwareStore hw, ISocketFactory sf)
        {
            var defaultTimeout = new TimeSpan(0, 0, 30);
            var client         = new APBClient.APBClient(config.ApbAccounts[accountIndex]["username"], config.ApbAccounts[accountIndex]["password"], hw, sf);

            await TimeoutAfter(client.Login(), defaultTimeout);

            Console.WriteLine("Logged In!");
            List <CharacterInfo> characters = client.GetCharacters();

            Console.WriteLine("Got characters!");
            List <WorldInfo> worlds = await TimeoutAfter(client.GetWorlds(), defaultTimeout);

            Console.WriteLine("Received worlds!");
            CharacterInfo       chosenCharacter = characters[characterIndex];
            FinalWorldEnterData worldEnterData  = await TimeoutAfter(client.EnterWorld(chosenCharacter.SlotNumber), defaultTimeout);

            Console.WriteLine("Connected to world!");
            Dictionary <int, DistrictInfo> districts = client.GetDistricts();

            Console.WriteLine("Got districts");
            List <InstanceInfo> instances = await TimeoutAfter(client.GetInstances(), defaultTimeout);

            Console.WriteLine("Recieved instances");

            int totalCriminals = 0;
            int totalEnforcers = 0;

            foreach (var instance in instances)
            {
                string name = "UNKNOWN";
                try
                {
                    name = districts[instance.DistrictUid].Name;
                }
                catch (Exception e)
                {
                }

                Console.WriteLine(String.Format("DistrictUID={0}, SDD={1:X}, Instance={2}, Threat={3}, Crims={4}, Enfs={5}, Status={6}, World={7} ({8})", instance.DistrictUid, districts[instance.DistrictUid].DistrictInstanceTypeSdd, instance.InstanceNum, instance.Threat, instance.Criminals, instance.Enforcers, instance.DistrictStatus, chosenCharacter.WorldUID, name));

                totalCriminals += instance.Criminals;
                totalEnforcers += instance.Enforcers;

                var point = BuildPoint(instance, districts[instance.DistrictUid], chosenCharacter);
                var resp  = await influxClient.WriteAsync("apb", point);
            }

            var aggPoint = BuildAggregatePoint(chosenCharacter.WorldUID, instances.Count, totalEnforcers, totalCriminals);
            var resp2    = await influxClient.WriteAsync("apb", aggPoint);

            client.Disconnect();
        }
Ejemplo n.º 3
0
        static void Main2(/*USE THIS FOR UI DEV*/)
        {
            Console.Title = "egoAPB - External Game Observer for APB: Reloaded";
            string email = "mail", password = "******", character = "char";

            if (!Directory.Exists("PacketDumps"))
            {
                Directory.CreateDirectory("PacketDumps");
            }

            HardwareStore hw;

            using (TextReader reader = File.OpenText("hw.yml"))
                hw = new HardwareStore(reader);

            Task.Run(async() =>
            {
                try
                {
                    var client = new APBClient.APBClient(email, password, hw);
                    await client.Login();
                    Console.WriteLine("Connected to lobby server");

                    List <CharacterInfo> characters = client.GetCharacters();
                    Console.WriteLine($"Got {characters.Count} characters (threat: '{characters[0].Threat}')");
                    Console.WriteLine();

                    foreach (var ch in characters)
                    {
                        CharacterInfo.Detailed charinfo = await client.GetDetailedCharacterInfo(ch.SlotNumber);
                        ch.Details = charinfo;
                        Console.WriteLine($"Got details for character '{ch.CharacterName}'");
                        Console.WriteLine($"\t-> Faction: {ch.Faction.ToString()}\n\t-> Gender: {charinfo.Gender.ToString()}\n\t-> Money: {ch.Details.Money}$\n\t-> Jocker Tickets: {ch.Details.JokerTickets}\n\t-> Rank: {ch.Details.Rank}\n\t-> Clan: {ch.Details.Clan}");
                        Console.WriteLine();
                    }

                    List <WorldInfo> worlds = await client.GetWorlds();
                    Console.WriteLine($"Got {worlds.Count} worlds");
                    worlds.ForEach(world => { Console.WriteLine($"\t-> {world.Name}, {world.Region}, {world.Status.ToString()}"); });
                    Console.WriteLine();

                    //DONE TO THIS POINT
                    CharacterInfo ChosenCharacter  = characters.SingleOrDefault(c => c.CharacterName == character);
                    ChosenCharacter.WorldEnterData = await client.EnterWorld(ChosenCharacter.SlotNumber);
                    Console.WriteLine($"Connected to world server '{ChosenCharacter.WorldName}'");
                    Console.WriteLine();

                    try
                    {
                        ChosenCharacter.Clan      = client.GetClanInfo();
                        ChosenCharacter.Clan.MOTD = client.GetClanMOTD();
                        Console.WriteLine($"Got clan info for '{ChosenCharacter.Clan.Name}'");
                        string motd = ChosenCharacter.Clan.MOTD.Replace("\n", string.Empty).Replace("\r", string.Empty).Replace("\t", string.Empty);
                        Console.WriteLine($"\t-> Total members: {ChosenCharacter.Clan.Members}\n\t-> Message of the day: {motd}\n\t-> Leader ID: {ChosenCharacter.Clan.Leader}");
                        Console.WriteLine();

                        ChosenCharacter.Friends = client.GetFriendList();
                        ChosenCharacter.Ignores = client.GetIgnoreList();
                        Console.WriteLine($"Got friendlist with {ChosenCharacter.Friends.TotalFriends} friends and ignorelist with {ChosenCharacter.Ignores.TotalIgnores} ignores");

                        ChosenCharacter.ChallengesInfo = client.GetChallenges();
                        Console.WriteLine($"Got info for {ChosenCharacter.ChallengesInfo.TotalChallenges} challenges");
                    }
                    catch
                    {
                    }

                    ChosenCharacter.MailsInfo = client.GetMailInfo();
                    Console.WriteLine($"Got total of {ChosenCharacter.MailsInfo.Total} mails in inbox (unread: {ChosenCharacter.MailsInfo.Unread}, expired: {ChosenCharacter.MailsInfo.Expired})");

                    Dictionary <int, DistrictInfo> districts = client.GetDistricts();
                    Console.WriteLine($"Got {districts.Count} districts");
                    Console.WriteLine();

                    List <InstanceInfo> instances = await client.GetInstances();
                    Console.WriteLine($"Got {instances.Count} instances");

                    instances.ForEach(instance => { Console.WriteLine($"\t-> {districts[instance.DistrictUid].Name}-{instance.InstanceNum} ({instance.Enforcers} Enf, {instance.Criminals} Crim, Threat = {((ThreatType)instance.Threat).ToString()})"); });
                    Console.WriteLine();

                    var instanceToJoin          = (from instance in instances where instance.DistrictStatus == 0 && instance.Threat == (int)ChosenCharacter.Threat select instance).OrderBy(s => s.Criminals + s.Enforcers).First();
                    string inst                 = districts[instanceToJoin.DistrictUid].Name + "-" + instanceToJoin.InstanceNum;
                    DistrictEnterInfo enterInfo = await client.JoinInstance(instanceToJoin);
                    Console.WriteLine($"Joined {inst}");

                    Console.ReadKey();
                    client.Disconnect();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Console.ReadKey();
                }
            }).Wait();
        }
Ejemplo n.º 4
0
        static void DistrictTest()
        {
            WatcherConfig config;

            using (var configReader = File.OpenText("watcher_conf.yml"))
            {
                var deserializer = new Deserializer();
                config = deserializer.Deserialize <WatcherConfig>(configReader);
            }

            HardwareStore hw;

            using (TextReader reader = File.OpenText("hw.yml"))
            {
                hw = new HardwareStore(reader);
            }

            ISocketFactory sf = new ProxySocketFactory("127.0.0.1", 9150, null, null);

            Task.Run(async() =>
            {
                var client = new APBClient.APBClient(config.ApbAccounts[3]["username"], config.ApbAccounts[3]["password"], hw, sf);
                await client.Login();
                Console.WriteLine("Logged In!");
                List <CharacterInfo> characters = client.GetCharacters();
                Console.WriteLine("Got characters!");
                List <WorldInfo> worlds = await client.GetWorlds();
                Console.WriteLine("Received worlds!");
                CharacterInfo chosenCharacter      = characters[0];
                FinalWorldEnterData worldEnterData = await client.EnterWorld(chosenCharacter.SlotNumber);
                Console.WriteLine("Connected to world!");
                Dictionary <int, DistrictInfo> districts = client.GetDistricts();
                Console.WriteLine("Got districts");
                List <InstanceInfo> instances = await client.GetInstances();
                Console.WriteLine("Recieved instances");

                foreach (var instance in instances)
                {
                    string name = "UNKNOWN";
                    try
                    {
                        name = districts[instance.DistrictUid].Name;
                    }
                    catch (Exception e)
                    {
                    }

                    Console.WriteLine(
                        String.Format(
                            "DistrictUID={0}, SDD={1:X}, Instance={2}, Threat={3}, Crims={4}, Enfs={5}, Status={6}, World={7} ({8})",
                            instance.DistrictUid, districts[instance.DistrictUid].DistrictInstanceTypeSdd,
                            instance.InstanceNum, instance.Threat, instance.Criminals, instance.Enforcers,
                            instance.DistrictStatus, chosenCharacter.WorldUID, name));
                }

                var instanceToJoin = (from instance in instances
                                      where instance.DistrictStatus == 0 && instance.Threat == 1
                                      select instance).OrderBy(s => s.Criminals + s.Enforcers).First();

                Console.WriteLine(
                    String.Format(
                        "JOINING DistrictUID={0}, SDD={1:X}, Instance={2}, Threat={3}, Crims={4}, Enfs={5}, Status={6}, World={7}",
                        instanceToJoin.DistrictUid, districts[instanceToJoin.DistrictUid].DistrictInstanceTypeSdd,
                        instanceToJoin.InstanceNum, instanceToJoin.Threat, instanceToJoin.Criminals, instanceToJoin.Enforcers,
                        instanceToJoin.DistrictStatus, chosenCharacter.WorldUID));

                DistrictEnterInfo enterInfo = await client.JoinInstance(instanceToJoin);

                client.Disconnect();
            }).Wait();
        }