Пример #1
0
		public ShipTools(AccountModel account, string planetName)
		{
			this.account = account;
			var mainLayout = new StackLayout
			{
				BackgroundColor = Color.FromRgb (0, 0, 128),
				Children = {
					glyphinator
				}
			};

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

			glyphinator.Clicked += async (sender, e) =>
			{
				var systems = MapScripts.GetAllBodiesInRange30(account, 0, 0);
			};
			this.Appearing += async (sender, e) =>
			{
				planetID = (from b in account.Colonies
							where b.Value.Equals(planetName)
							select b.Key).First();
				LoadBuildingsAsync(account, planetID);
			};
		}
		public PlanetBuildings(AccountModel account, string planetName)
		{
			this.account = account;
			var mainLayout = new StackLayout
			{
				BackgroundColor = Color.FromRgb (0, 0, 128),
				Children = {
					buildingListView
				}
			};

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

			this.Appearing += (sender, e) =>
			{
				var planetID = (from b in account.Colonies
							   where b.Value.Equals(planetName)
							   select b.Key).First();
				LoadBuildingsAsync(planetID);
			};
			buildingList.Add(new BuildingData());
			buildingListView.ItemsSource = buildingList;
			buildingListView.ItemTemplate = new DataTemplate(typeof(BuildingViewCell));
			buildingListView.ItemTapped += (sender, e) =>
			{
				buildingListView.SelectedItem = null;
			};
			buildingListView.BackgroundColor = Color.FromRgb (0, 0, 128);
		}
 public static bool CaptchaStillValid(AccountModel account)
 {
     var captchaValidUntil = DateTime.Now.AddMinutes(-25);
     if (account.CaptchaLastRenewed > captchaValidUntil)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #4
0
		public BodyStatus(AccountModel account, Boolean typeStation)
		{
            #region controls Declaration

            #endregion
            //Adding something to the collection otherwise the listview doesn't like to display
            var b = new BodyStatusModel();
			b.Name = "loading bodies";
			bodyList.Add(b);

			bodies.ItemsSource = bodyList;
			bodies.ItemTemplate = new DataTemplate(typeof(ViewCells.PlanetStatusViewCell));
			bodies.BackgroundColor = Color.FromRgb (0, 0, 128);


			var mainLayout = new StackLayout
            {
				BackgroundColor = Color.FromRgb (0, 0, 128),
				Children = {
					bodies, 
                    notifyAllianceOfStations
				}
			};

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

			this.Appearing += async (sender, e) =>
			{
				await LoadPage(typeStation);
				
			};

            notifyAllianceOfStations.IsVisible = false;
            notifyAllianceOfStations.Clicked += async (sender, e) =>{
                var bodyString = "The following stations have warning indicators: ";
                foreach (var station in warningStations)
                    bodyString += station + ", \n";
                var json = Inbox.SendMessage(1, account.SessionID, "@ally", "Stations in trouble", bodyString);
                var server = new Data.Server();
                var response = await server.GetHttpResultStringAsyncAsString(account.Server, Inbox.url, json);
                var s = response;
            };
			bodies.ItemTapped += async (sender, e) =>
			{
				await Navigation.PushModalAsync(new BodyStatusDetail((bodies.SelectedItem as BodyStatusModel).response,
					(bodies.SelectedItem as BodyStatusModel).Name));
				bodies.SelectedItem = null;
			};
		}
		public SpeciesStats(AccountModel account)
		{
			this.response = response;
			var mainLayout = new StackLayout
			{
				BackgroundColor = Color.FromRgb (0, 0, 128),
				Children = {
					Name,
					Description,
					MinOrbit,
					MaxOrbit,	
					Manufacturing,					
					Deception,					
					Research,
					Management,
					Farming,
					Mining,
					Science,
					Environmental,
					Political,
					Trade,
					Growth
				}
			};

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

			this.Appearing += async (sender, e) => 
			{
				//AccountManager acntMgr = new AccountManager();
				//account = await acntMgr.GetActiveAccountAsync();
				Name.Text            = "Name: "           + response.result.status.empire.view_species_stats;
//				Description.Text     = "Description: "    + response.result.species.description;
//				MinOrbit.Text        = "Min Orbit: "      + response.result.species.min_orbit;
//				MaxOrbit.Text        = "Max Orbit: "      + response.result.species.max_orbit;
//				Manufacturing.Text   = "Manufacturing: "  + response.result.species.manufacturing_affinity;
//				Deception.Text       = "Deception: "      + response.result.species.deception_affinity;
//				Research.Text        = "Research: "       + response.result.species.research_affinity;
//				Management.Text      = "Management: "     + response.result.species.management_affinity;
//				Farming.Text         = "Farming: "        + response.result.species.farming_affinity;
//				Mining.Text          = "Mining: "         + response.result.species.mining_affinity;
//				Science.Text         = "Science: "        + response.result.species.science_affinity;
//				Environmental.Text   = "Environmental: "  + response.result.species.environmental_affinity;
//				Political.Text       = "Political: "      + response.result.species.political_affinity;
//				Trade.Text           = "Trade: "          + response.result.species.trade_affinity;
//				Growth.Text          = "Growth: "         + response.result.species.growth_affinity;
			};
		}
Пример #6
0
		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 StationsMain()
		{
			
			var mainLayout = new StackLayout
			{
				BackgroundColor = Color.FromRgb (0, 0, 128),
				Children = {
					pickerLabel,
					stationPicker,
					viewStation, 
                    parliamentBtn
				}
			};

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

			this.Appearing += async (sender, e) =>
			{
				AccountManagement.AccountManager accountMngr = new AccountManagement.AccountManager();
				activeAccount = await accountMngr.GetActiveAccountAsync();
				var stationNames = activeAccount.Stations.Values.ToList();
				stationNames.Sort();
				foreach (var s in stationNames)
				{
					stationPicker.Items.Add(s);
				}
			};
            viewStation.IsVisible = false;
            parliamentBtn.IsVisible = false;
			stationPicker.SelectedIndexChanged += (sender, e) =>
			{
				selectedStation = stationPicker.Items[stationPicker.SelectedIndex];
				ActivateButtons();
			};
            viewStation.Clicked += async (sender, e) =>
            {
                await Navigation.PushAsync(new StationBuildings(activeAccount, selectedStation));
            };
            parliamentBtn.Clicked += async (sender, e) =>
            {
                if(activeAccount.Stations.Count >0)
                    await Navigation.PushAsync(new Parliament(activeAccount, selectedStation));
            };
		}
Пример #8
0
 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;
 }
		public BuildingToolsView(AccountModel account, string planetName)
		{
			var mainLayout = new StackLayout
			{
				BackgroundColor = Color.FromRgb (0, 0, 128),
				Children = {
					planetNameLabel,
					avgbuildingLevel,
					buildingCount,
					damagedBuildings,
					bleeders,
					repairBuildings,
					fillWithSpacePorts,
					queueUpgrades,
					destroyBleeders
				}
			};

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

			this.Appearing += (sender, e) =>
			{
				planetID = (from b in account.Colonies
								where b.Value.Equals(planetName)
								select b.Key).First();
				LoadBuildingsAsync(planetID, account);
			};
			repairBuildings.Clicked += async (sender, e) =>
			{
				var json = Body.RepairList(1, account.SessionID, planetID, damagedBuildingIDs);
				var s = new LacunaExpress.Data.Server();
				var response = await s.GetHttpResultAsync(account.Server, Body.url, json);
				if (response.result != null)
				{
					damagedBuildingIDs = BuildingToolsScripts.GetDamagedBuildingIDs(response.result.buildings);
					damagedBuildings.Text = "Number of damaged buildings: " + damagedBuildingIDs.Count;
					damagedBuildings.TextColor = Color.White;
				}
			};
		}
Пример #10
0
		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;
		}
Пример #11
0
		public AccountMain()
		{
			var mainLayout = new StackLayout
			{
				BackgroundColor = Color.FromRgb (0, 0, 128),

				Padding = new Thickness(6, 6, 6, 6),
				Children = {
					accountPicker,
					addAccount,
					deletAccount
				}
			};

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

			deletAccount.Clicked += (sender, e) =>
			{
				accountManager.ClearAccount();
			};
			accountPicker.SelectedIndexChanged += async (sender, e) =>
			{
				selectedAccount = accounts.AccountList.Where(x => x.DisplayName.Equals(accountPicker.Items[accountPicker.SelectedIndex])).First();
				var oldAccount = selectedAccount;
				selectedAccount.ActiveAccount = true;
				accountManager.ModifyAccountAsync(selectedAccount, oldAccount);
			};
			this.Appearing += (sender, e)  =>
			{
				LoadAccountsIntoPicker();
			};
			

			addAccount.Clicked += async (sender, e) =>
			{
				await Navigation.PushModalAsync(new LacunaExpress.Pages.AccountPages.Login());
			};
		}
Пример #12
0
        public Parliament(AccountModel account, string stationName)
        {
            stationNameLbl.Text = stationName;
			stationNameLbl.TextColor = Color.White;

            var options = OptionsLists.ParliamentLockDownProposals;
            parliamentOptions.ItemsSource = options;
            parliamentOptions.ItemTemplate = new DataTemplate(typeof(ParliamentProposalViewCell));
            parliamentOptions.ItemTapped += (sender, e) =>
            {
                //var s = (e as ParliamentProposalViewCell);
                //if (s.PropositionName.Text.Contains("Mining")){ }
                //else if (s.PropositionName.Text.Contains("Colonization")){ }
                //else if (s.PropositionName.Text.Contains("BHG")){ }
                //else if (s.PropositionName.Text.Contains("Excavator")){ }
                //else if (s.PropositionName.Text.Contains("Station")){ }
            };
			//parliamentOptions.BackgroundColor = Color.FromRgb (0, 0, 128);
			var mainLayout = new StackLayout
            {
				BackgroundColor = Color.FromRgb (0, 0, 128),
                Children = {
                    stationNameLbl,
                    parliamentOptions
                }
            };

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

            this.Appearing += (sender, e) =>
            {
                var planetID = (from b in account.Stations
                                where b.Value.Equals(stationName)
                                select b.Key).First();
                //LoadBuildingsAsync(planetID);
            };
        }
		public async void ModifyAccountAsync(AccountModel modifiedAccount, AccountModel originalAccount)
		{
			var accounts = await LoadAccountsAsync();
			if (accounts != null)
			{
				var index = accounts.AccountList.Find(x => x.DisplayName.Equals(originalAccount.DisplayName));
				accounts.AccountList.Remove(index);

				
				if (modifiedAccount.ActiveAccount)
				{

					var updatedList = MakeAllAccountsNotActive(accounts);
					accounts.AccountList.Clear();
					accounts.AccountList = updatedList.AccountList;
				}
				accounts.AccountList.Add(modifiedAccount);
			}
			
			await Storage.SaveTextAsync(AccountFile, Newtonsoft.Json.JsonConvert.SerializeObject(accounts));
		}
		public EmpireWideMain()
		{
			
			var mainLayout = new StackLayout
			{
				BackgroundColor = Color.FromRgb (0, 0, 128),
				Children = {
					planetStatusCheck,
					stationStatusCheck,
					speciesStats,
				}
			};

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

			planetStatusCheck.Clicked += async (sender, e) =>
			{
				await Navigation.PushAsync(new BodyStatus(account, false));
			};
			stationStatusCheck.Clicked += async (sender, e) =>
			{
				await Navigation.PushAsync(new BodyStatus(account, true));
			};
			speciesStats.Clicked += async (sender, e) =>
			{
				await Navigation.PushAsync(new SpeciesStats(account));
			};

			this.Appearing += async (sender, e) =>
			{
				AccountManager acntMgr = new AccountManager();
				account = await acntMgr.GetActiveAccountAsync();
			};
		}
Пример #15
0
        public MapMain()
        {
            Resources = Styles.Styles.StyleDictionary;
            Button cacheStarMapBtn = new Button
            {
                Text = "Cache Map",
                Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.RegularButton.ToString()]
                //TextColor = Color.White,
                //BorderWidth = 2,
                //BorderColor = Color.White,
                //BackgroundColor = Color.Blue,
                //FontAttributes = FontAttributes.Bold
            };
			var mainLayout = new StackLayout
            {
				BackgroundColor = Color.FromRgb (0, 0, 128),
                Children = {
                    cacheStarMapBtn
                }
            };

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

            this.Appearing += async (sender, e) =>
            {
                AccountManagement.AccountManager accountMngr = new AccountManagement.AccountManager();
                activeAccount = await accountMngr.GetActiveAccountAsync();
            };
            cacheStarMapBtn.Clicked += async (sender, e) =>
            {
                var s = await MapScripts.GetAllStarsInRange300(activeAccount, 0, 0);
                Data.FileStorage.SaveStarsAsync(s);
            };
        }
Пример #16
0
		async void LoadBuildingsAsync(AccountModel account, string bodyID)
		{
			var json = Body.GetBuildings(1, account.SessionID, bodyID);
			var s = new LacunaExpress.Data.Server();
			var response = await s.GetHttpResultAsync(account.Server, Body.url, json);
			if (response.result != null)
			{
				shipyardsList = (from b in response.result.buildings
						where b.Value.url.Equals(Shipyard.URL)
						select new ShipyardsModel
						{
							buildingID = b.Key,
							efficiency = b.Value.efficiency,
							level = b.Value.efficiency
						}).ToList();
				spaceportID = (from b in response.result.buildings
							   where b.Value.Equals(Spaceport.URL) && b.Value.efficiency.Equals("100")
							   select b.Key).First();
				archminID = (from b in response.result.buildings
							   where b.Value.Equals(Archaeology.URL) && b.Value.efficiency.Equals("100")
							   select b.Key).First();
			}
		}
Пример #17
0
		async void LoadAccountsIntoPicker()
		{
			AccountManagement.AccountManager accountManger = new AccountManagement.AccountManager();
			accounts = await accountManager.LoadAccountsAsync();
			selectedAccount = await accountManager.GetActiveAccountAsync();
			if (accounts != null)
			{
				foreach (var a in accounts.AccountList)
					accountPicker.Items.Add(a.DisplayName);
			}
			else
			{
				await Navigation.PushModalAsync(new LacunaExpress.Pages.AccountPages.Login());
			}
		}
Пример #18
0
        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);
                }
            }
        }
Пример #19
0
		public async static void ExecutePrisonersOnPlanet(AccountModel account, string SecurityMinstryID, List<Prisoner> prisonerList)
		{
			List<ThrottledServerRequest> requests = new List<ThrottledServerRequest>();
			foreach (var prisoner in prisonerList)
			{
				var json = Security.ExecutePrisoner(account.SessionID, SecurityMinstryID, prisoner.id);
				requests.Add(new ThrottledServerRequest(account.Server, Security.URL, json));
			}
			if (requests.Count > 0)
			{
				var server = new Data.Server();
				server.ThrottledServer(requests);
			}
		}
Пример #20
0
		public async static  Task<List<Prisoner>> GetPrisoners(AccountModel account, string SecurityMinstryID)
		{
			var server = new Data.Server();
			var json = Security.ViewPrisoners(account.SessionID, SecurityMinstryID, "");
			var response = await server.GetHttpResultAsync(account.Server, Security.URL, json);
			if (response != null)
			{
				return response.result.prisoners;
			}
			else
				return new List<Prisoner>();
		}
Пример #21
0
 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);
     }
 }
Пример #22
0
        async void LoadBuildingsAsync(AccountModel account, string bodyID)
        {
            var json = Body.GetBuildings(1, account.SessionID, bodyID);
            var s = new LacunaExpress.Data.Server();
            var response = await s.GetHttpResultAsync(account.Server, Body.url, json);
            if (response.result != null)
            {
                


                foreach (var bd in response.result.buildings.OrderBy(x => x.Value.name))
                {
                    //var imageUri = new Uri(("https://raw.githubusercontent.com/plainblack/Lacuna-Assets/master/planet_side/100/"+bd.Value.image+".png"));
                    var imageUri = "LacunaExpress.Images.100." + bd.Value.image + ".png";
                    int index = 11 * (5 - Convert.ToInt16(bd.Value.y)) + Convert.ToInt16(bd.Value.x) + 5;
                    buildingImages[index].Source = ImageSource.FromResource("LacunaExpress.Images.SizeTwo." + bd.Value.image + ".png");
                    buildingImages[index].imageString = "LacunaExpress.Images.SizeTwo." + bd.Value.image + ".png";
                    //buildingImages[index].x = bd.Value.x;
                   // buildingImages[index].y = bd.Value.y;
                    buildingImages[index].name = bd.Value.name;
                    buildingImages[index].level = bd.Value.level;
                    buildingImages[index].id = bd.Key;
                    //var imgIndex = (from bi in buildingImages
                    //                    where bi.PLOTNUMBER == index
                    //                    select bi).First();
                    //    imgIndex.buildingImage.Source = ImageSource.FromResource("LacunaExpress.Images.SizeTwo." + bd.Value.image + ".png");

                    //var x = Convert.ToInt16(bd.Value.x) + 5;
                   // var y = (Convert.ToInt16(bd.Value.y) + -6) * -1;
                    //var img = new Image();
                    //img.Source = ImageSource.FromResource("LacunaExpress.Images.SizeTwo." + bd.Value.image + ".png");
                    //grid.Children.Add(img, x, y);
                    //BuildingArrangements.Add(new BuildingArrangementModel
                    //{
                    //    BuildingID = bd.Key,
                    //    BuildingName = bd.Value.name,
                    //    BuildingLevel = bd.Value.name,
                    //    BuildingImageString = imageUri,
                    //    X = bd.Value.x,
                    //    Y = bd.Value.y,
                    //    GridLeft = x,
                    //    GridTop = y
                    //});
                }

            }
        }
Пример #23
0
        public PlanetMap(AccountModel account, string planetName)
        {
            OuterBuilding.Children.Add(tempBuildingImage);
            OuterBuilding.Children.Add(InnerBuilding);
            InnerBuilding.Children.Add(tempPlanetBuildingName);
            InnerBuilding.Children.Add(tempPlanetBuildingLevel);
            OuterBuilding.Children.Add(submitArrangement);

            planetlbl.Text = planetName;
            ScrollView scrollMap = new ScrollView
            {
                HorizontalOptions = LayoutOptions.Fill,
                Orientation = ScrollOrientation.Horizontal,

                Content = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children = {
                                     grid
                                },                    
                }
            };
            int left = 0;
            int top = 1;
            int xcounter = -5;
            int ycounter = 5;
            for (int i = 0; i <= 120; i++)
            {
                var b = new BuildingImage { PLOTNUMBER = i, x = Convert.ToString(xcounter), y = Convert.ToString(ycounter), Source = ImageSource.FromResource("LacunaExpress.Images.Demolish.png") };
                xcounter++;
                if(xcounter > 5)
                {
                    xcounter = -5;
                    ycounter--;
                }
                //b.buildingImage.Source = ImageSource.FromResource("LacunaExpress.Images.Demolish.png");
                b.GestureRecognizers.Add((new TapGestureRecognizer
                {
                    Command = new Command(o =>
                    {
                        
                        var index = b.PLOTNUMBER;
                        if(index != 60) //that's the center building of the map and it's not allowed to move
                        {
                            if (selectedBuilding.name.Length > 0)
                            {
                                tempHolding.id = selectedBuilding.id;
                                tempHolding.imageString = selectedBuilding.imageString;
                                tempHolding.level = selectedBuilding.level;
                                tempHolding.name = selectedBuilding.name;

                                selectedBuilding.id = "";
                                selectedBuilding.imageString = "";
                                selectedBuilding.level = "";
                                selectedBuilding.name = "";

                                tempPlanetBuildingName.Text = "No Building Selected";
                                tempPlanetBuildingLevel.Text = "0";
                                tempBuildingImage.Source = null;
                                tempBuildingImage.Source = ImageSource.FromResource("LacunaExpress.Images.Demolish.png");
                            }
                            if (buildingImages[index].name.Length > 0)
                            {
                                selectedBuilding.id = buildingImages[index].id;
                                selectedBuilding.imageString = buildingImages[index].imageString;
                                selectedBuilding.level = buildingImages[index].level;
                                selectedBuilding.name = buildingImages[index].name;

                                buildingImages[index].Source = null;
                                buildingImages[index].Source = ImageSource.FromResource("LacunaExpress.Images.Demolish.png");
                                buildingImages[index].name = "";
                                buildingImages[index].level = "";
                                buildingImages[index].imageString = "";
                                buildingImages[index].id = "";

                                tempPlanetBuildingName.Text = selectedBuilding.name;
                                tempPlanetBuildingLevel.Text = selectedBuilding.level;
                                tempBuildingImage.Source = ImageSource.FromResource(selectedBuilding.imageString);
                            }

                            if (tempHolding.name.Length > 0)
                            {
                                buildingImages[index].level = tempHolding.level;
                                buildingImages[index].name = tempHolding.name;
                                buildingImages[index].id = tempHolding.id;
                                buildingImages[index].imageString = tempHolding.imageString;
                                buildingImages[index].Source = ImageSource.FromResource(tempHolding.imageString);

                                tempHolding.id = "";
                                tempHolding.imageString = "";
                                tempHolding.level = "";
                                tempHolding.x = "";
                                tempHolding.y = "";
                                tempHolding.name = "";
                            }
                        }
                        //SwapBuildings(b.PLOTNUMBER);
                        

                    })
                }));
                buildingImages.Add(b);
                grid.Children.Add(b, left, top);
                left++;
                
                if (left == 11)
                {
                    left = 0;
                    top++;
                }
            }

			var mainLayout = new StackLayout
            {
                Children = {
                    planetlbl,
                    scrollMap,
                    OuterBuilding
                }

            };

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

            this.Appearing += (sender, e) =>
            {

                planetID = (from b in account.Colonies
                            where b.Value.Equals(planetName)
                            select b.Key).First();
                LoadBuildingsAsync(account, planetID);
            };
            submitArrangement.Clicked += async (sender, e) =>
            {
                List<BuildingArrangement> movedBuildings = new List<BuildingArrangement>();
                foreach(var b in buildingImages)
                {
                    if(b.name.Length > 0)
                    {
                        movedBuildings.Add(new BuildingArrangement(b.x, b.y, b.id));
                        
                    }
                }
                string json = Body.RearrangeBuildings(1, account.SessionID, planetID, movedBuildings);
                var server = new Data.Server();
                string response = await server.GetHttpResultStringAsyncAsString(account.Server, Body.url, json);
                string s = response;
            };

        }
Пример #24
0
        public static async Task<List<Stars>> GetAllStarsInRange300(AccountModel account, int x, int y)
        {
            int max, min;
            max = 1500;
            min = -1500;

            int startX, endX, startY, endY, maxRangePerRequest;
            maxRangePerRequest = 30;


            //setting initial x range values
            startX = x - 150;
            startX = CheckMaxMinAt1500(startX);
            endX = x + 150;
            endX = CheckMaxMinAt1500(endX);

            //setting initial y range values
            startY = y + 150;
            startY = CheckMaxMinAt1500(startY);
            endY = y - 150;
            endY = CheckMaxMinAt1500(endY);


            int xStart30 = startX;
            int yStart30 = startY;
            int xEnd30 = startX + 30;
            int yEnd30 = startY - 30;
            bool keepgoing = true;
            List<ThrottledServerRequest> requests = new List<ThrottledServerRequest>();
            do
            {
                if (xEnd30 > endX)
                    xEnd30 = endX;
                var json = Map.GetStars(account.SessionID, xStart30.ToString(), yStart30.ToString(), xEnd30.ToString(),  yEnd30.ToString());
                var request = new ThrottledServerRequest(account.Server, Map.URL, json);
                requests.Add(request);

                //increasing counter but being warry of map edges
                
                if (xEnd30 >= endX)
                {
                    xEnd30 = endX;
                    xStart30 = startX;
                    xEnd30 = xStart30 + 30;
                    yStart30 = yEnd30;
                    yEnd30 -= 30;
                    if (yEnd30 < endY)
                        yEnd30 = endY;
                }
                else
                {
                    xStart30 = xEnd30;
                    xEnd30 += 30;
                }

                if (xEnd30 == endX && yEnd30 == endY)
                    keepgoing = false;
                               
            } while (keepgoing);
            var responses = await LacunaExpress.Data.Server.ThrottledServerReturns(requests);

            List<Stars> stars = new List<Stars>();
            foreach(var response in responses)
            {
                if(response.result != null)
                {
                    foreach (var star in response.result.stars)
                        stars.Add(star);
                }
            }

            if (stars.Count > 0)
                return stars.Distinct().ToList();
            else
                return null;
        }
		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;

		}
		async void LoadBuildingsAsync(string bodyID, AccountModel account)
		{
			var json = Body.GetBuildings(1, account.SessionID, bodyID);
			var s = new LacunaExpress.Data.Server();
			var response = await s.GetHttpResultAsync(account.Server, Body.url, json);
			if (response.result != null)
			{
				damagedBuildingIDs = BuildingToolsScripts.GetDamagedBuildingIDs(response.result.buildings);
				damagedBuildings.Text = "Number of damaged buildings: " + damagedBuildingIDs.Count;
				avgbuildingLevel.Text = "Average Level: " + BuildingToolsScripts.GetAvgBuildingLevel(response.result.buildings);
				avgbuildingLevel.TextColor = Color.White;
				buildingCount.Text = "Number of Buildings: " + response.result.buildings.Count;
				buildingCount.TextColor = Color.White;
			}
		}
Пример #27
0
		public CaptchaPage(AccountModel account)
		{
            Resources = Styles.Styles.StyleDictionary;
			BoxView topSpacer = new BoxView
			{
				BackgroundColor = Color.Transparent,
				VerticalOptions = LayoutOptions.StartAndExpand,
			};
            Entry answerEntry = new Entry
            {
                Placeholder = "Answer",
				Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.EntryStyle.ToString()],				
				VerticalOptions = LayoutOptions.CenterAndExpand,
			};
            Button answerButton = new Button
            {
                Text = "Answer",
				Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.RegularButton.ToString()],
				VerticalOptions = LayoutOptions.EndAndExpand,
            };
			var mainLayout = new StackLayout
			{
				Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.MainLayout.ToString()],
				Children = {
					topSpacer,
					captchaImage,
					answerEntry,
					answerButton
				}
			};

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

			answerButton.Clicked += async (sender, e) =>{
				if (answerEntry.Text.Length > 0)
				{
					answerButton.IsEnabled = false;
					var s = new LacunaExpress.Data.Server();
					var json = Captcha.Solve(account.SessionID, guid, answerEntry.Text);
					var response = await s.GetHttpResultStringAsyncAsString(account.Server, Captcha.url, json);
					if (response != null)
					{
						var r = Newtonsoft.Json.JsonConvert.DeserializeObject<CaptchaResponse>(response);
						if(r.result==1){
							var oldacnt = account;
							account.CaptchaLastRenewed = DateTime.Now;
							AccountManager accountMan = new AccountManager();
							accountMan.ModifyAccountAsync(account, oldacnt);
							await Navigation.PopModalAsync();
						}
						else
						{
							answerButton.IsEnabled = true;
							GetCaptcha(account);
							answerEntry.Text = "";
						}
					}
					else
					{
						answerButton.IsEnabled = true;
						GetCaptcha(account);
						answerEntry.Text = "";
					}
				}
			};
			this.Appearing += async (sender, e) =>
			{
				var captchaValidUntil = DateTime.Now.AddMinutes(-25);
				if (account.CaptchaLastRenewed > captchaValidUntil) 
				{
					await Navigation.PopModalAsync();
				}else
				{
					GetCaptcha(account);
				}
			};			
		}
Пример #28
0
		async void GetCaptcha(AccountModel account)
		{
			var s = new LacunaExpress.Data.Server();
			var json = Captcha.Fetch(account.SessionID);
			var response = await s.GetHttpResultAsync(account.Server, Captcha.url, json);
			if (response.result != null)
			{
				guid = response.result.guid;
				captchaImage.Source = response.result.url;
			}
		}
		//public void ChangeActiveAccount() { }
		public async void DeleteAccountAsync(AccountModel account)
		{
			var accounts = await LoadAccountsAsync();
			if (accounts != null)
			{
				accounts.AccountList.Remove(account);
				await Storage.SaveTextAsync(AccountFile, Newtonsoft.Json.JsonConvert.SerializeObject(accounts));
			}
		}
Пример #30
0
		public SpiesMain(AccountModel account, string selectedPlanet)
		{
            buttonScroll.Content = buttonHolder;
            buttonHolder.Children.Add(trainSpiesBtn);
            buttonHolder.Children.Add(runSweepsBtn);
            buttonHolder.Children.Add(viewSpiesBtn);
            buttonHolder.Children.Add(executePrisonersBtn);
            buttonHolder.Children.Add(removeSpiesFromPolicalPropaganda);
            buttonHolder.Children.Add(sendSpies);
            this.account = account;
			var mainLayout = new StackLayout
			{
				//BackgroundColor = Color.FromRgb (0, 0, 128),
				Style = (Style)Styles.Styles.StyleDictionary[Styles.Styles.StyleName.MainLayout.ToString()],
                Children = {
					planetNameLabel,
					totalSpies,
					spiesOnCounter,
					spiesOnIntelTraining,
					spiesOnPoliticsTraining,
					spiesOnMayhemTraining,
					spiesOnTheftTraining,
					spiesOnPropaganda,
					spiesIdle,
					foreignSpies,
					prisoners,
                    buttonScroll

				}

			};

			Content = mainLayout;
			if (Device.OS == TargetPlatform.iOS)
			{
				mainLayout.Padding = new Thickness (0, 20, 0, 0);
			}

			this.Appearing += async (sender, e) =>
			{
                if (!AccountManager.CaptchaStillValid(account))
                {
                    await Navigation.PushModalAsync(new CaptchaPage.CaptchaPage(account));
                }
				planetName = selectedPlanet;			
				planetID = (from b in account.Colonies
								where b.Value.Equals(selectedPlanet)
								select b.Key).First();
				planetNameLabel.Text = selectedPlanet + " " + planetID;
				planetNameLabel.TextColor = Color.White;
				LoadSpyInfo(planetID);
			};
			sendSpies.Clicked += async (sender, e) =>
			{
				await Navigation.PushAsync(new SendSpies(account, intelMinID, planetID));
			};
            removeSpiesFromPolicalPropaganda.Clicked += async (sender, e) =>
            {
                List<LacunaExpanseAPIWrapper.ResponseModels.Spies> spiesOnPoliticalProp = await SpyScripts.FilterSpiesByAssignment(planetSpies, "Political Propaganda");
                SpyScripts.BatchAssignSpies(account, spiesOnPoliticalProp, "Idle", intelMinID);
                if (spiesOnPoliticalProp.Count > 30)
                    await DisplayAlert("Notice", "This may take a couple of minutes to complete", "OK");
            };
			executePrisonersBtn.Clicked += async (sender, e) =>
			{
				var prisoners = await SpyScripts.GetPrisoners(account, secMinID);
				SpyScripts.ExecutePrisonersOnPlanet(account, secMinID, prisoners);
			};
			trainSpiesBtn.Clicked += (sender, e) =>
			{
				if (intelMinID != null)
				{
					SpyScripts.TrainSpies(planetSpies, account, intelMinID, intelMinistry, intelTrain, mayhemTrain, theftTrain, politicalTrain, selectedPlanet, 6);
				}
			};
			runSweepsBtn.Clicked += async (sender, e) =>
			{
                await DisplayAlert("Performance", "This script will run a series of up to 6 sweeps using idle spies", "Ok");
				
				if (intelMinID != null)
				{
					var idleSpies = SpyScripts.GetIdleSpiesFromList(planetSpies);
					var orderedIdleSpies = idleSpies.OrderByDescending(x => x.level);
					var spiesToUse = new List<LacunaExpanseAPIWrapper.ResponseModels.Spies>();
					int i = 0;
					foreach (var spy in orderedIdleSpies)
					{
						spiesToUse.Add(spy);
						i++;
						if (i == 6)
							break;
					}
					foreach (var spy in spiesToUse)
					{
						var server = new Data.Server();
						var json = Intelligence.AssignSpy(account.SessionID, intelMinID, spy.id, "Security Sweep");
						var response = await server.GetHttpResultStringAsyncAsString(account.Server, Intelligence.URL, json);
						if (response != null)
						{

						}
					}
					
				}
			};

		}