Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using PlayerIOClient;
- using System.Threading;
- namespace EESpender
- {
- class Program
- {
- static void Main(string[] args)
- {
- System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;
- Log(LogLevel.Notice, "Accounts: " + args.Count() / 2);
- for (int AccountID = 0; args.Count() > AccountID; AccountID += 2)
- {
- Spend(new Profile() { Email = args[AccountID], Password = args[AccountID + 1] });
- }
- }
- public static void Spend(Profile profile)
- {
- Client client;
- Connection lobby;
- client = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", profile.Email, profile.Password, null);
- lobby = client.Multiplayer.CreateJoinRoom(client.ConnectUserId, $"Lobby{client.BigDB.Load("config", "config")["version"]}", true, null, null);
- var messages = new List<Message>();
- var required = new List<Message>() { Message.Create("getMySimplePlayerObject"), Message.Create("getLobbyProperties"), Message.Create("getShop") };
- lobby.OnMessage += delegate (object sender, Message e)
- {
- messages.Add(e);
- switch (e.Type)
- {
- case "connectioncomplete":
- foreach (var m in required)
- { lobby.Send(m); Thread.Sleep(512); }
- break;
- case "getShop":
- profile.CurrentShop = new Shop(e);
- profile.CurrentShop.PriorityItems = profile.CurrentShop.ShopItems.Where(x => x.OwnedAmount == 0).Where(x => x.Price >= 0)
- .OrderByDescending(x => x.Price).Reverse().OrderByDescending(x => x.EnergySpent).OrderByDescending(x => x.IsNew).ToList();
- if (profile.CurrentShop.PriorityItems.Count() < 1)
- profile.CurrentShop.PriorityItems = profile.CurrentShop.ShopItems.Where(x => x.Price >= 0).OrderByDescending(x => x.EnergySpent).ToList();
- var priorityItem = profile.CurrentShop.PriorityItems[0];
- if (profile.CurrentShop.CurrentEnergy >= priorityItem.EnergyPerClick)
- {
- Log(LogLevel.Notice, string.Format("Spending {0} energy on {1}",
- priorityItem.EnergyPerClick * (Math.Floor((double)profile.CurrentShop.CurrentEnergy / priorityItem.EnergyPerClick)),
- priorityItem.SafeName));
- lobby.Send("useAllEnergy", profile.CurrentShop.PriorityItems[0].Name);
- }
- break;
- case "getLobbyProperties":
- profile.FirstDailyLogin = (bool)e[0];
- profile.LoginStreak = (int)e[1];
- if (profile.FirstDailyLogin && profile.LoginStreak >= 0)
- {
- for (uint i = 2; i < e.Count; i += 2)
- {
- var x = e[i];
- var y = e[i + 1];
- var nextReward = Reward.LoginReward(DateTime.Now, profile.LoginStreak + 1, true);
- Log(LogLevel.Notice, $"Login streak! You've gained {y} {x}! Next reward is {nextReward}...");
- }
- }
- break;
- case "useEnergy":
- case "useAllEnergy":
- lobby.Send("getShop");
- break;
- case "getMySimplePlayerObject":
- profile.Username = (string)e[0];
- break;
- default:
- break;
- }
- };
- var watch = new System.Diagnostics.Stopwatch();
- watch.Start();
- while (watch.Elapsed < TimeSpan.FromSeconds(10))
- {
- try
- {
- if (!required.Select(x => x.Type).All(messages.Select(x => x.Type).Contains))
- {
- Thread.Sleep(512);
- continue;
- }
- Log(LogLevel.Notice, string.Format("({0}) {1} | {2} | {3} ({4})",
- DateTime.Now, profile.Username, $"{profile.CurrentShop.CurrentEnergy}/{profile.CurrentShop.MaximumEnergy}",
- profile.CurrentShop.PriorityItems[0].SafeName,
- $"{profile.CurrentShop.PriorityItems[0].EnergySpent}/{profile.CurrentShop.PriorityItems[0].Price}"));
- GC.Collect();
- Thread.Sleep(TimeSpan.FromSeconds(150 * 50) /* 50 energy w/ 2.5 minutes = 1 energy*/);
- Spend(profile);
- }
- catch (Exception ex)
- {
- Log(LogLevel.Error, $"Uh oh. {ex.Message} { (string.Format(", ", messages.Select(d => d.Type))) }");
- Thread.Sleep(512);
- }
- }
- if (lobby.Connected)
- try { lobby.Disconnect(); } catch { }
- Log(LogLevel.Error, "Something went wrong. Reconnecting...");
- Thread.Sleep(1000);
- Spend(profile);
- }
- enum LogLevel { Notice, Warning, Error }
- static void Log(LogLevel l, string message)
- {
- Console.WriteLine($"<EESpender> [{l.ToString().ToUpper()}] {message}");
- }
- }
- class Shop
- {
- public int MaximumEnergy { get; set; }
- public int CurrentEnergy { get; set; }
- public List<ShopItem> ShopItems { get; set; }
- public List<ShopItem> PriorityItems { get; set; }
- public Shop(Message e)
- {
- MaximumEnergy = (int)e[3];
- CurrentEnergy = (int)e[1];
- ShopItems = new List<ShopItem>();
- for (uint i = 5; i < e.Count; i += 25)
- {
- var name = (string)e[i];
- var price = (int)e[i + 2];
- var amount = (int)e[i + 3];
- var spent = (int)e[i + 4];
- var gems = (int)e[i + 5];
- var owned = (int)e[i + 6];
- var safename = (string)e[i + 8];
- var isnew = (bool)e[i + 17];
- ShopItem item = new ShopItem()
- {
- Name = name,
- Price = price,
- EnergyPerClick = amount,
- OwnedAmount = owned,
- PriceGems = gems,
- SafeName = safename,
- EnergySpent = spent,
- IsNew = isnew
- };
- ShopItems.Add(item);
- }
- }
- public class ShopItem
- {
- public string Name { get; set; }
- public int Price { get; set; }
- public int EnergyPerClick { get; set; }
- public int OwnedAmount { get; set; }
- public int PriceGems { get; set; }
- public int EnergySpent { get; set; }
- public string SafeName { get; set; }
- public bool IsNew { get; set; }
- }
- }
- class Profile
- {
- public string Email { get; set; }
- public string Password { get; set; }
- public string Username { get; set; }
- public int LoginStreak { get; set; }
- public bool FirstDailyLogin { get; set; }
- public Shop CurrentShop { get; set; }
- }
- static class Reward
- {
- public static string LoginReward(DateTime dt, int streak, bool forceRewards = false)
- {
- var totalDays = ((DateTime.UtcNow.AddHours((-TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours)).Date) - dt).TotalDays;
- var firstDailyLogin = totalDays >= 1.0;
- var canGetRewards = totalDays < 2.0;
- if (forceRewards || (firstDailyLogin && canGetRewards))
- return (streak == 0) ? "10 energy" : ((streak % 7 + 1) < 8) ? 25 * (streak % 7 + 1) + " energy" :
- 0 + ((streak % 28 + 1 != 14) ? ((streak % 28 + 1 != 28) ? 1u : 3u) : 2u) + " gems";
- return "nothing";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement