public async Task<AccountModel> GetActiveAccountAsync() { if (Storage.Exists(AccountFile)) { var accounts = await LoadAccountsAsync(); if (accounts != null) { foreach (var a in accounts.AccountList) { //a.ActiveAccount = true; if (a.ActiveAccount) { if (a.SessionRenewed < DateTime.Now.AddHours(-2)) { var oldAccount = a; string json = Empire.Login(1, a.EmpireName, a.Password); var s = new Server(); var response = await s.GetHttpResultAsync(a.Server, Empire.url, json); s = null; a.SessionID = response.result.session_id; a.SessionRenewed = DateTime.Now; ModifyAccountAsync(a, oldAccount); } return a; } } } else return null; } return null; }
public ReadMessage(string sessionID, string server, Messages message) { Date.Text = message.date; From.Text = message.from; To.Text = message.to; Subject.Text = message.subject; Message.Text = message.body; Message.BackgroundColor = Color.FromRgb(0, 0, 128); var mainLayout = new StackLayout { Children = { Date, From, To, Subject, new ScrollView { Content = Message, VerticalOptions = LayoutOptions.FillAndExpand, }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { Reply, Archive, Forward, Delete }, VerticalOptions = LayoutOptions.End, BackgroundColor = Color.FromRgb(0,0, 128), } } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness(0, 20, 0, 0); } Reply.Clicked += async(sender, e) => { //await Navigation.PopAsync(); await Navigation.PushAsync(new ComposeReply(sessionID, server, message, "Re: ")); }; Archive.Clicked += async(sender, e) => { var json = Inbox.ArchiveMessages(1, sessionID, message.id); var s = new LacunaExpress.Data.Server(); var response = await s.GetHttpResultAsync(server, Inbox.url, json); await Navigation.PopAsync(); }; Forward.Clicked += async(sender, e) => { //await Navigation.PopAsync(); await Navigation.PushAsync(new ComposeReply(sessionID, server, message, "Fw: ")); }; Delete.Clicked += async(sender, e) => { var json = Inbox.TrashMessages(1, sessionID, message.id); var s = new LacunaExpress.Data.Server(); var response = await s.GetHttpResultAsync(server, Inbox.url, json); await Navigation.PopAsync(); }; }
public ReadMessage(string sessionID, string server, Messages message) { Date.Text = message.date; From.Text = message.from; To.Text = message.to; Subject.Text = message.subject; Message.Text = message.body; Message.BackgroundColor = Color.FromRgb (0, 0, 128); var mainLayout = new StackLayout { Children = { Date, From, To, Subject, new ScrollView{ Content = Message, VerticalOptions = LayoutOptions.FillAndExpand, }, new StackLayout{ Orientation = StackOrientation.Horizontal, Children = {Reply, Archive, Forward, Delete}, VerticalOptions = LayoutOptions.End, BackgroundColor = Color.FromRgb (0, 0, 128), } } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness (0, 20, 0, 0); } Reply.Clicked += async (sender, e) =>{ //await Navigation.PopAsync(); await Navigation.PushAsync(new ComposeReply(sessionID, server, message, "Re: ")); }; Archive.Clicked += async (sender, e) => { var json = Inbox.ArchiveMessages(1, sessionID, message.id); var s = new LacunaExpress.Data.Server(); var response = await s.GetHttpResultAsync(server, Inbox.url, json); await Navigation.PopAsync(); }; Forward.Clicked += async (sender, e) => { //await Navigation.PopAsync(); await Navigation.PushAsync(new ComposeReply(sessionID, server, message, "Fw: ")); }; Delete.Clicked += async (sender, e) => { var json = Inbox.TrashMessages(1, sessionID, message.id); var s = new LacunaExpress.Data.Server(); var response = await s.GetHttpResultAsync(server, Inbox.url, json); await Navigation.PopAsync(); }; }
public static async void BatchAssignSpies(AccountModel account, List<Spies> spies, string assignment, string intelMinID) { List<ThrottledServerRequest> requests = new List<ThrottledServerRequest>(); foreach (var spy in spies) { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, assignment); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); } if (requests.Count > 0) { var server = new LacunaExpress.Data.Server(); server.ThrottledServer(requests); } }
public static async void BatchAssignSpies(AccountModel account, List <Spies> spies, string assignment, string intelMinID) { List <ThrottledServerRequest> requests = new List <ThrottledServerRequest>(); foreach (var spy in spies) { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, assignment); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); } if (requests.Count > 0) { var server = new LacunaExpress.Data.Server(); server.ThrottledServer(requests); } }
public async static void MakeSpiesIdle(AccountModel account, string intelMinID, List <LacunaExpanseAPIWrapper.ResponseModels.Spies> spies) { List <ThrottledServerRequest> requests = new List <ThrottledServerRequest>(); foreach (var spy in spies) { if (spy.assignment != "Idle") { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Idle"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); } } if (requests.Count > 0) { var server = new LacunaExpress.Data.Server(); server.ThrottledServer(requests); } }
public static async Task<List<Stars>> GetAllBodiesInRange30(AccountModel account, int x, int y) { int x1, x2, y1, y2; x1 = x - 15; x2 = x + 15; y1 = y - 15; y2 = y + 15; //Map map = new Map(); var json = Map.GetStars(account.SessionID, Convert.ToString(x1), Convert.ToString(y1), Convert.ToString(x2), Convert.ToString(y2)); var server = new LacunaExpress.Data.Server(); var reply = await server.GetHttpResultAsync(account.Server, Map.URL, json); if (reply.result != null) { return reply.result.stars; } else return null; }
async Task<bool> LoadMessagesAsync(string category) { var acntMgr = new AccountManagement.AccountManager(); account = await acntMgr.GetActiveAccountAsync(); if (account == null) { await Navigation.PushAsync(new Login()); return false; } else { messageList.Clear(); string json; switch (category) { case "All": json = Inbox.ViewInbox(account.SessionID); break; case "Sent": json = Inbox.ViewSent(account.SessionID); break; case "Trashed": json = Inbox.ViewTrash(account.SessionID); break; case "Archived": json = Inbox.ViewArchive(account.SessionID); break; default: json = Inbox.ViewInbox(account.SessionID, category); break; } try { var s = new Server(); var response = await s.GetHttpResultAsync(account.Server, Inbox.url, json); foreach (var m in response.result.messages) messageList.Add(new MessageData(m.from, m.subject, m.body_preview, m.id.ToString())); } catch (Exception e) { var f = e.Message; } } return true; }
public static async Task <List <Stars> > GetAllBodiesInRange30(AccountModel account, int x, int y) { int x1, x2, y1, y2; x1 = x - 15; x2 = x + 15; y1 = y - 15; y2 = y + 15; //Map map = new Map(); var json = Map.GetStars(account.SessionID, Convert.ToString(x1), Convert.ToString(y1), Convert.ToString(x2), Convert.ToString(y2)); var server = new LacunaExpress.Data.Server(); var reply = await server.GetHttpResultAsync(account.Server, Map.URL, json); if (reply.result != null) { return(reply.result.stars); } else { return(null); } }
async void LoadBuildingsAsync(string bodyID) { var json = Body.GetBuildings(1, account.SessionID, bodyID); var s = new Server(); var response = await s.GetHttpResultAsync(account.Server, Body.url, json); if (response.result != null) { buildingList.Clear(); foreach(var bd in response.result.buildings.OrderBy( x => x.Value.name)) { var b = new BuildingData(); b.BuildingName = bd.Value.name; b.BuildingLevel = bd.Value.level; b.Efficiency = bd.Value.efficiency; b.BuildingID = bd.Key; b.ImageName = bd.Value.image; b.url = "https://raw.githubusercontent.com/plainblack/Lacuna-Assets/master/planet_side/100/" + bd.Value.image + ".png"; b.BuildingURL = bd.Value.url; buildingList.Add(b); } } }
async Task<bool> LoadPage(Boolean typeStation){ AccountManager accountMan = new AccountManager(); account = await accountMan.GetActiveAccountAsync(); var originalAccount = account; if (typeStation) { bodyList.Clear(); foreach(var s in account.Stations.Keys) { var json = LacunaExpanseAPIWrapper.Body.GetBuildings(1, account.SessionID, s); var server = new LacunaExpress.Data.Server(); var response = await server.GetHttpResultAsync(account.Server, LacunaExpanseAPIWrapper.Body.url, json); if (response.result != null) { BodyStatusModel bdy = new BodyStatusModel(); bdy.response = response; bdy.Name = response.result.status.body.name; bdy.Star = response.result.status.body.star_name; bdy.Zone = response.result.status.body.zone; bdy.X = response.result.status.body.x; bdy.Y = response.result.status.body.y; if (!Scripts.StatusCheckers.StationOk(response)) { bdy.Status = "Warning"; notifyAllianceOfStations.IsVisible = true; warningStations.Add(bdy.Name +"{ Planet "+bdy.Name+" "+ response.result.status.body.id+" }"); } bodyList.Add(bdy); if (response.result.buildings != null) { foreach(var b in response.result.buildings) { if (account.Parliaments == null) account.Parliaments = new List<BuildingCache>(); if(b.Value.url.Contains(Parliament.URL)) account.Parliaments.Add(new BuildingCache { planetID = b.Value.name, buildingID = b.Key, level = Convert.ToInt16(b.Value.level) }); } //var parliament = (from p in response.result.buildings // where p.Value.url.Contains(Parliament.URL) // select new { id = p.Key, level = p.Value.level, }).First(); //account.Parliaments.Add(new BuildingCache { planetID = bdy.Name, buildingID = parliament.id, level = Convert.ToInt16(parliament.level) }); } } } if(account.Parliaments.Count >0) accountMan.ModifyAccountAsync(account, originalAccount); } else { bodyList.Clear(); foreach (var c in account.Colonies.Keys) { var json = LacunaExpanseAPIWrapper.Body.GetBuildings(1, account.SessionID, c); var s = new LacunaExpress.Data.Server(); var response = await s.GetHttpResultAsync(account.Server, LacunaExpanseAPIWrapper.Body.url, json); if (response.result != null) { BodyStatusModel bdy = new BodyStatusModel(); bdy.response = response; bdy.Name = response.result.status.body.name; bdy.Star = response.result.status.body.star_name; bdy.Zone = response.result.status.body.zone; bdy.X = response.result.status.body.x; bdy.Y = response.result.status.body.y; if (!Scripts.StatusCheckers.PlanetOk(response)) bdy.Status = "Warning"; bodyList.Add(bdy); } //BodyStatus bodyresult = response.result.Bodies; //(BodyStatus)bodyresult = } } return true; }
private async void LoadSpyInfo(string bodyID) { IsBusy = true; var json = LacunaExpanseAPIWrapper.Body.GetBuildings(1, account.SessionID, bodyID); var s = new LacunaExpress.Data.Server(); var response = await s.GetHttpResultAsync(account.Server, LacunaExpanseAPIWrapper.Body.url, json); if (response.result != null) { var building = response.result.buildings.Where(x => x.Value.name.Contains("Security")).First(); var secMinID = response.result.buildings.FirstOrDefault(x => x.Value.name.Contains("Security")).Key; intelMinID = response.result.buildings.FirstOrDefault(x => x.Value.name.Contains("Intelligence")).Key; intelMinistry = response.result.buildings.FirstOrDefault(x => x.Value.name.Contains("Intelligence")).Value; intelTrain = response.result.buildings.FirstOrDefault(x => x.Value.name.Contains("Intel Training")).Value; mayhemTrain = response.result.buildings.FirstOrDefault(x => x.Value.name.Contains("Mayhem Training")).Value; theftTrain = response.result.buildings.FirstOrDefault(x => x.Value.name.Contains("Theft Training")).Value; politicalTrain = response.result.buildings.FirstOrDefault(x => x.Value.name.Contains("Politics Training")).Value; if (secMinID.Length > 0 || !secMinID.Contains("Uknown ident")) { json = Security.ViewForeignSpies(account.SessionID, secMinID, "1"); s = new LacunaExpress.Data.Server(); response = await s.GetHttpResultAsync(account.Server, Security.URL, json); if (response.result != null) { foreignSpies.Text = "Foreign Spies Detected: " + response.result.spy_count; } json = Security.ViewPrisoners(account.SessionID, secMinID, "1"); s = new LacunaExpress.Data.Server(); response = await s.GetHttpResultAsync(account.Server, Security.URL, json); if (response.result != null) { prisoners.Text = "Prisoners: " + response.result.prisoners.Count; prisonersList = response.result.prisoners; } } if (intelMinID.Length > 0 || !secMinID.Contains("Uknown ident")) { json = Intelligence.ViewAllSpies(account.SessionID, intelMinID); s = new LacunaExpress.Data.Server(); response = await s.GetHttpResultAsync(account.Server, Intelligence.URL, json); if (response.result != null) { planetSpies = response.result.spies; totalSpies.Text = "Total Spies: " + response.result.spies.Count; totalSpies.TextColor = Color.White; spiesOnCounter.Text = "Counter Espionage: " + (from counterCount in response.result.spies where counterCount.assignment.Equals("Counter Espionage") select counterCount).Count().ToString(); spiesOnCounter.TextColor = Color.White; spiesOnIntelTraining.Text = "Intelligence Training: " + (from counterCount in response.result.spies where counterCount.assignment.Equals("Intel Training") select counterCount).Count().ToString(); spiesOnIntelTraining.TextColor = Color.White; spiesOnMayhemTraining.Text = "Mayhem Training: " + (from counterCount in response.result.spies where counterCount.assignment.Equals("Mayhem Training") select counterCount).Count().ToString(); spiesOnMayhemTraining.TextColor = Color.White; spiesOnTheftTraining.Text = "Theft Training: " + (from counterCount in response.result.spies where counterCount.assignment.Equals("Theft Training") select counterCount).Count().ToString(); spiesOnTheftTraining.TextColor = Color.White; spiesOnPoliticsTraining.Text = "Politics Training: " + (from counterCount in response.result.spies where counterCount.assignment.Equals("Politics Training") select counterCount).Count().ToString(); spiesOnPoliticsTraining.TextColor = Color.White; spiesIdle.Text = "Idle: " + (from counterCount in response.result.spies where counterCount.assignment.Equals("Idle") select counterCount).Count().ToString(); spiesOnPropaganda.TextColor = Color.White; spiesOnPropaganda.Text = "Propaganda: " + (from counterCount in response.result.spies where counterCount.assignment.Equals("Political Propaganda") select counterCount).Count().ToString(); } } } IsBusy = false; }
public static void TrainSpies(List<LacunaExpanseAPIWrapper.ResponseModels.Spies> spies, AccountModel account, string intelMinID, Building intelMin, Building intelTrain, Building mayhemTrain, Building theftTrain, Building politicalTrain, string planetID, int numToTrain) { if (intelMin.efficiency == "100") { List<ThrottledServerRequest> requests = new List<ThrottledServerRequest>(); int intelCounter = (from counterCount in spies where counterCount.assignment.Equals("Intel Training") select counterCount).Count(); int politicalCounter = (from counterCount in spies where counterCount.assignment.Equals("Politics Training") select counterCount).Count(); int theftCounter = (from counterCount in spies where counterCount.assignment.Equals("Theft Training") select counterCount).Count(); int mayhemCounter = (from counterCount in spies where counterCount.assignment.Equals("Mayhem Training") select counterCount).Count(); int counterEsp = (from counterCount in spies where counterCount.assignment.Equals("Counter Espionage") select counterCount).Count(); int politicalProp = (from counterCount in spies where counterCount.assignment.Equals("Political Propaganda") select counterCount).Count(); var idleSpies = from s in spies where s.assignment.Contains("Idle") select s; //350 + $view->{building}{level} * 75 foreach (var spy in idleSpies) { if (Convert.ToInt64(spy.intel) < 350 + (Convert.ToInt64(intelTrain.level) * 75) && intelTrain.efficiency == "100" && intelCounter < numToTrain) { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Intel Training"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); intelCounter++; } else if (Convert.ToInt64(spy.mayhem) < 350 + (Convert.ToInt64(mayhemTrain.level) * 75) && mayhemTrain.efficiency == "100" && mayhemCounter < numToTrain) { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Mayhem Training"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); mayhemCounter++; } else if (Convert.ToInt64(spy.politics) < 350 + (Convert.ToInt64(politicalTrain.level) * 75) && politicalTrain.efficiency == "100" && politicalCounter < numToTrain) { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Politics Training"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); politicalCounter++; } else if (Convert.ToInt64(spy.theft) < 350 + (Convert.ToInt64(theftTrain.level) * 75) && theftTrain.efficiency == "100" && theftCounter < numToTrain) { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Theft Training"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); theftCounter++; } else if (counterEsp < numToTrain) {//Political Propaganda var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Counter Espionage"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); counterEsp++; } else if (politicalProp < numToTrain && Convert.ToInt16(spy.mission_count.defensive) < 100) {//Political Propaganda var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Political Propaganda"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); politicalProp++; } //var json = Security.ExecutePrisoner(account.SessionID, secMinID, prisoner.id); //requests.Add(new ThrottledServerRequest(account.Server, Security.URL, json)); } if (requests.Count > 0) { var server = new LacunaExpress.Data.Server(); server.ThrottledServer(requests); } } }
public async static void MakeSpiesIdle(AccountModel account, string intelMinID, List<LacunaExpanseAPIWrapper.ResponseModels.Spies> spies) { List<ThrottledServerRequest> requests = new List<ThrottledServerRequest>(); foreach (var spy in spies) { if (spy.assignment != "Idle") { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Idle"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); } } if (requests.Count > 0) { var server = new LacunaExpress.Data.Server(); server.ThrottledServer(requests); } }
async Task <bool> LoadPage(Boolean typeStation) { AccountManager accountMan = new AccountManager(); account = await accountMan.GetActiveAccountAsync(); var originalAccount = account; if (typeStation) { bodyList.Clear(); foreach (var s in account.Stations.Keys) { var json = LacunaExpanseAPIWrapper.Body.GetBuildings(1, account.SessionID, s); var server = new LacunaExpress.Data.Server(); var response = await server.GetHttpResultAsync(account.Server, LacunaExpanseAPIWrapper.Body.url, json); if (response.result != null) { BodyStatusModel bdy = new BodyStatusModel(); bdy.response = response; bdy.Name = response.result.status.body.name; bdy.Star = response.result.status.body.star_name; bdy.Zone = response.result.status.body.zone; bdy.X = response.result.status.body.x; bdy.Y = response.result.status.body.y; if (!Scripts.StatusCheckers.StationOk(response)) { bdy.Status = "Warning"; notifyAllianceOfStations.IsVisible = true; warningStations.Add(bdy.Name + "{ Planet " + bdy.Name + " " + response.result.status.body.id + " }"); } bodyList.Add(bdy); if (response.result.buildings != null) { foreach (var b in response.result.buildings) { if (account.Parliaments == null) { account.Parliaments = new List <BuildingCache>(); } if (b.Value.url.Contains(Parliament.URL)) { account.Parliaments.Add(new BuildingCache { planetID = b.Value.name, buildingID = b.Key, level = Convert.ToInt16(b.Value.level) }); } } //var parliament = (from p in response.result.buildings // where p.Value.url.Contains(Parliament.URL) // select new { id = p.Key, level = p.Value.level, }).First(); //account.Parliaments.Add(new BuildingCache { planetID = bdy.Name, buildingID = parliament.id, level = Convert.ToInt16(parliament.level) }); } } } if (account.Parliaments.Count > 0) { accountMan.ModifyAccountAsync(account, originalAccount); } } else { bodyList.Clear(); foreach (var c in account.Colonies.Keys) { var json = LacunaExpanseAPIWrapper.Body.GetBuildings(1, account.SessionID, c); var s = new LacunaExpress.Data.Server(); var response = await s.GetHttpResultAsync(account.Server, LacunaExpanseAPIWrapper.Body.url, json); if (response.result != null) { BodyStatusModel bdy = new BodyStatusModel(); bdy.response = response; bdy.Name = response.result.status.body.name; bdy.Star = response.result.status.body.star_name; bdy.Zone = response.result.status.body.zone; bdy.X = response.result.status.body.x; bdy.Y = response.result.status.body.y; if (!Scripts.StatusCheckers.PlanetOk(response)) { bdy.Status = "Warning"; } bodyList.Add(bdy); } //BodyStatus bodyresult = response.result.Bodies; //(BodyStatus)bodyresult = } } return(true); }
public static void TrainSpies(List <LacunaExpanseAPIWrapper.ResponseModels.Spies> spies, AccountModel account, string intelMinID, Building intelMin, Building intelTrain, Building mayhemTrain, Building theftTrain, Building politicalTrain, string planetID, int numToTrain) { if (intelMin.efficiency == "100") { List <ThrottledServerRequest> requests = new List <ThrottledServerRequest>(); int intelCounter = (from counterCount in spies where counterCount.assignment.Equals("Intel Training") select counterCount).Count(); int politicalCounter = (from counterCount in spies where counterCount.assignment.Equals("Politics Training") select counterCount).Count(); int theftCounter = (from counterCount in spies where counterCount.assignment.Equals("Theft Training") select counterCount).Count(); int mayhemCounter = (from counterCount in spies where counterCount.assignment.Equals("Mayhem Training") select counterCount).Count(); int counterEsp = (from counterCount in spies where counterCount.assignment.Equals("Counter Espionage") select counterCount).Count(); int politicalProp = (from counterCount in spies where counterCount.assignment.Equals("Political Propaganda") select counterCount).Count(); var idleSpies = from s in spies where s.assignment.Contains("Idle") select s; //350 + $view->{building}{level} * 75 foreach (var spy in idleSpies) { if (Convert.ToInt64(spy.intel) < 350 + (Convert.ToInt64(intelTrain.level) * 75) && intelTrain.efficiency == "100" && intelCounter < numToTrain) { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Intel Training"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); intelCounter++; } else if (Convert.ToInt64(spy.mayhem) < 350 + (Convert.ToInt64(mayhemTrain.level) * 75) && mayhemTrain.efficiency == "100" && mayhemCounter < numToTrain) { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Mayhem Training"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); mayhemCounter++; } else if (Convert.ToInt64(spy.politics) < 350 + (Convert.ToInt64(politicalTrain.level) * 75) && politicalTrain.efficiency == "100" && politicalCounter < numToTrain) { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Politics Training"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); politicalCounter++; } else if (Convert.ToInt64(spy.theft) < 350 + (Convert.ToInt64(theftTrain.level) * 75) && theftTrain.efficiency == "100" && theftCounter < numToTrain) { var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Theft Training"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); theftCounter++; } else if (counterEsp < numToTrain) {//Political Propaganda var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Counter Espionage"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); counterEsp++; } else if (politicalProp < numToTrain && Convert.ToInt16(spy.mission_count.defensive) < 100) {//Political Propaganda var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Political Propaganda"); requests.Add(new ThrottledServerRequest(account.Server, Intelligence.URL, json)); politicalProp++; } //var json = Security.ExecutePrisoner(account.SessionID, secMinID, prisoner.id); //requests.Add(new ThrottledServerRequest(account.Server, Security.URL, json)); } if (requests.Count > 0) { var server = new LacunaExpress.Data.Server(); server.ThrottledServer(requests); } } }
public MessageList() { messageCategories = new Picker { Title = "Message Categories", VerticalOptions = LayoutOptions.CenterAndExpand }; foreach (var s in messageCategoryList) { messageCategories.Items.Add(s); } messageList.Add(new MessageData("Messages Loading", "Messages Loading", "Messages Loading", "Messages Loading")); messages.HasUnevenRows = true; messages.IsVisible = true; messages.SeparatorColor = Color.Red; messages.BackgroundColor = Color.FromRgb (0, 0, 128); var mainLayout = new StackLayout { BackgroundColor = Color.FromRgb (0, 0, 128), Children = { messages, messageCategories, compose //new Label { Text = "" } } }; Content = mainLayout; if (Device.OS == TargetPlatform.iOS) { mainLayout.Padding = new Thickness (0, 20, 0, 0); } this.Appearing += async (sender, e) =>{ await LoadMessagesAsync("All"); }; messages.ItemTemplate = new DataTemplate(typeof(MenuItem)); if (messageList.Count > 0) { messages.ItemsSource = messageList; } messages.ItemSelected += async (sender, e) => { var json = Inbox.ReadMessage(account.SessionID, (e.SelectedItem as MessageData).MessageID); var s = new Server(); var response = await s.GetHttpResultAsync(account.Server, Inbox.url, json); if(response.result != null) await Navigation.PushAsync(new ReadMessage(account.SessionID, account.Server, response.result.message)); }; messageCategories.SelectedIndexChanged += async (sender, e) => { await LoadMessagesAsync(messageCategories.Items[messageCategories.SelectedIndex]); }; compose.Clicked += async (sender, e) => { await Navigation.PushAsync(new ComposeReply(account.SessionID, account.Server)); }; }
public async Task<bool> CreateAndAddAccountAsync(string username, string password, string server, bool setAsActive) { string json = Empire.Login(1, username, password); var s = new Server(); var response = await s.GetHttpResultAsync(server, Empire.url, json); if (response.result != null) { var account = new AccountModel(username, password, server, response.result.session_id, setAsActive); account.SessionRenewed = DateTime.Now; account.ActiveAccount = setAsActive; account.Colonies = response.result.status.empire.colonies; account.Stations = response.result.status.empire.stations; account.AllBodies = response.result.status.empire.planets; account.Capital = response.result.status.empire.colonies[response.result.status.empire.home_planet_id]; account.Colonies.OrderBy(x => x.Value); account.Stations.OrderBy(x => x.Value); account.AllBodies.OrderBy(x => x.Value); var accounts = await LoadAccountsAsync(); if (accounts != null) { var accountCollection = new AccountCollection(); if (setAsActive) { accountCollection = MakeAllAccountsNotActive(accounts); } accountCollection.AccountList.Add(account); await Storage.SaveTextAsync(AccountFile, Newtonsoft.Json.JsonConvert.SerializeObject(accountCollection)); return true; } else { var accountCollection = new AccountCollection(); account.ActiveAccount = true; accountCollection.AccountList.Add(account); await Storage.SaveTextAsync(AccountFile, Newtonsoft.Json.JsonConvert.SerializeObject(accountCollection)); return true; } } else return false; }
public BuildingViewCell() { layout.Children.Add(buildingImage); layout.Children.Add(planetName); layout.Children.Add(buildingLevel); layout.Children.Add(efficiency); layout.Children.Add(buildingID); layout.Children.Add(buildingimg); layout.Children.Add(repair); layout.Children.Add(upgrade); layout.Children.Add(downgrade); layout.Children.Add(buildingUrl); buildingID.SetBinding(Label.TextProperty, "BuildingID"); planetName.SetBinding(Label.TextProperty, "BuildingName"); buildingLevel.SetBinding(Label.TextProperty, "BuildingLevel"); efficiency.SetBinding(Label.TextProperty, "Efficiency"); buildingimg.SetBinding(Label.TextProperty, "ImageName"); buildingImage.SetBinding(Image.SourceProperty, new Binding("url")); buildingUrl.SetBinding(Label.TextProperty, "BuildingURL"); if (Convert.ToInt16(buildingLevel.Text) < 30) { up.IsVisible = false; up.IsEnabled = false; } //var uri = new Uri(("https://github.com/plainblack/Lacuna-Assets/tree/master/planet_side/50/" + buildingimg.Text + ".png")); //buildingImage.Source = ImageSource.FromUri(uri); buildingimg.IsVisible = false; buildingUrl.IsVisible = false; View = layout; upgrade.GestureRecognizers.Add((new TapGestureRecognizer { Command = new Command(async o => { AccountManager acntMgr = new AccountManager(); var account = await acntMgr.GetActiveAccountAsync(); var json = Buildings.Upgrade(account.SessionID, buildingID.Text); var server = new Server(); var response = await server.GetHttpResultAsync(account.Server, buildingUrl.Text, json); }) })); repair.GestureRecognizers.Add((new TapGestureRecognizer { Command = new Command(async o => { AccountManager acntMgr = new AccountManager(); var account = await acntMgr.GetActiveAccountAsync(); var json = Buildings.Repair(account.SessionID, buildingID.Text); var server = new Server(); var response = await server.GetHttpResultAsync(account.Server, buildingUrl.Text, json); }) })); downgrade.GestureRecognizers.Add((new TapGestureRecognizer { Command = new Command(async o => { AccountManager acntMgr = new AccountManager(); var account = await acntMgr.GetActiveAccountAsync(); var json = Buildings.Downgrade(account.SessionID, buildingID.Text); var server = new Server(); var response = await server.GetHttpResultAsync(account.Server, buildingUrl.Text, json); }) })); up.Clicked += async (sender, e) => { AccountManager acntMgr = new AccountManager(); var account = await acntMgr.GetActiveAccountAsync(); var json = Buildings.Upgrade(account.SessionID, buildingID.Text); var server = new Server(); var response = server.GetHttpResultAsync(account.Server, buildingUrl.Text, buildingID.Text); }; }