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;
            }
        }
        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;
            }
        }
        private void BuildPage()
        {
            StackLayout buttonHolder = new StackLayout
            {
                Orientation     = StackOrientation.Horizontal,
                Children        = { send, cancel },
                VerticalOptions = LayoutOptions.End,
                BackgroundColor = Color.Black
            };
            var mainLayout = new StackLayout
            {
                BackgroundColor = Color.FromRgb(0, 0, 128),
                Children        =
                {
                    to,
                    subject,
                    new ScrollView {
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        Content         = body
                    },
                    buttonHolder
                }
            };

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

            send.Clicked += async(sender, e) =>
            {
                string json     = Inbox.SendMessage(1, session, to.Text, subject.Text, body.Text);
                var    s        = new LacunaExpress.Data.Server();
                var    response = await s.GetHttpResultAsync(server, Inbox.url, json);

                var x = response;
                if (response.result != null)
                {
                    await Navigation.PopAsync();
                }
            };
            cancel.Clicked += async(sender, e) =>
            {
                await Navigation.PopAsync();
            };
        }
        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;
                }
            };
        }
		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;
				}
			};
		}
Example #6
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
                    //});
                }
            }
        }
		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();
			}
		}
Example #8
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();
            }
        }
        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);
                }
            };
        }
		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;
			}
		}
		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);
				}
			};			
		}
		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;
			}
		}
        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
                    //});
                }

            }
        }
        public SendSpies(AccountModel account, string intelMinID, string bodyID)
        {
            spies.ItemsSource  = SpyList;
            spies.ItemTemplate = new DataTemplate(typeof(SpySelectionViewCell));

            shipSelector.ItemsSource  = ShipSelectionList;
            shipSelector.ItemTemplate = new DataTemplate(typeof(ShipsForSpiesViewCell));

            Content = new StackLayout
            {
                Children =
                {
                    toBodyID, getShips, sendSpies, spies
                }
            };

            this.Appearing += async(sender, e) =>
            {
                var json     = LacunaExpanseAPIWrapper.Body.GetBuildings(1, account.SessionID, bodyID);
                var server   = new LacunaExpress.Data.Server();
                var response = await server.GetHttpResultAsync(account.Server, LacunaExpanseAPIWrapper.Body.url, json);

                if (response.result != null)
                {
                    spaceportID = (from s in response.result.buildings
                                   where s.Value.url.Contains("paceport") && Convert.ToInt64(s.Value.efficiency) == 100
                                   select s.Key).First();
                }
                ;
                json     = LacunaExpanseAPIWrapper.Intelligence.ViewAllSpies(account.SessionID, intelMinID);
                response = await server.GetHttpResultAsync(account.Server, LacunaExpanseAPIWrapper.Intelligence.URL, json);

                if (response.result != null)
                {
                    foreach (var s in response.result.spies)
                    {
                        var spy = new SpyViewCellModel
                        {
                            SpyName   = s.name,
                            SpyLevel  = s.level,
                            SpyID     = s.id,
                            Intel     = s.intel,
                            Mayhem    = s.mayhem,
                            Political = s.politics,
                            Theft     = s.theft,
                        };
                        SpyList.Add(spy);
                    }
                }
            };
            getShips.Clicked += async(sender, e) =>
            {
                var json     = LacunaExpanseAPIWrapper.Spaceport.PrepareSendSpies(account.SessionID, bodyID, toBodyID.Text);
                var server   = new Data.Server();
                var response = await server.GetHttpResultAsync(account.Server, LacunaExpanseAPIWrapper.Spaceport.URL, json);

                if (response.result != null)
                {
                    foreach (var s in response.result.spies)
                    {
                        var spy = new SpyViewCellModel
                        {
                            SpyName   = s.name,
                            SpyLevel  = s.level,
                            SpyID     = s.id,
                            Intel     = s.intel,
                            Mayhem    = s.mayhem,
                            Political = s.politics,
                            Theft     = s.theft,
                        };
                        SpyList.Add(spy);
                    }
                    //var ships = from s in response.result.ships
                    //			select s.type.
                }
            };
            sendSpies.Clicked += async(sender, e) =>
            {
                //var json = LacunaExpanseAPIWrapper.Spaceport.SendSpies(account.SessionID, bodyID, toBodyID.Text, shipID, spyIDs);
            };
        }
        public BodyStatusDetail(Response response, string pName)
        {
            this.response = response;
            var mainLayout = new StackLayout
            {
                BackgroundColor = Color.FromRgb(0, 0, 128),
                Children        =
                {
                    planetName,
                    planetLocation,
                    enemyIncoming,
                    damagedBuildings,
                    fissures,
                    bleeders,
                    food,
                    water,
                    ore,
                    energy,
                    happiness,
                    waste,
                    repairBuildings,
                    destroyBleeders,
                    fillFissure
                }
            };

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

            repairBuildings.Clicked += async(sender, e) =>
            {
                var damagedIDs = LacunaExpress.Scripts.BuildingToolsScripts.GetDamagedBuildingIDs(response.result.buildings);

                if (account != null)
                {
                    //foreach(var p in account.AllBodies)
                    //{
                    //	if (p.Value.Equals(planetName.Text))
                    //	{
                    //		planetID = p.Key;
                    //		break;
                    //	}
                    //}

                    //planetID = account.AllBodies.Where(x => x.Value.Equals(planetName)).First().Key;
                    var json   = LacunaExpanseAPIWrapper.Body.RepairList(1, account.SessionID, planetID, damagedIDs);
                    var server = new LacunaExpress.Data.Server();
                    var r      = await server.GetHttpResultAsync(account.Server, LacunaExpanseAPIWrapper.Body.url, json);

                    var xyz = r;
                }
            };

            this.Appearing += async(sender, e) =>
            {
                AccountManager acntMgr = new AccountManager();
                account = await acntMgr.GetActiveAccountAsync();

                planetName.Text = pName;
                planetID        = (from i in account.AllBodies
                                   where i.Value.Equals(planetName.Text)
                                   select i.Key).First();
                //planetLocation.Text = response.result.status.body.name;
                //planetID = response.result.status.body.id
                food.Text      = "Food: " + response.result.status.body.food_stored + "/" + response.result.status.body.food_hour;
                water.Text     = "Water: " + response.result.status.body.water_stored + "/" + response.result.status.body.water_hour;
                ore.Text       = "Ore: " + response.result.status.body.ore_stored + "/" + response.result.status.body.ore_hour;
                energy.Text    = "Energy: " + response.result.status.body.energy_stored + "/" + response.result.status.body.energy_hour;
                happiness.Text = "Happiness: " + response.result.status.body.happiness + "/" + response.result.status.body.happiness_hour;
                waste.Text     = "Waste: " + response.result.status.body.waste_stored + "/" + response.result.status.body.waste_hour;

                enemyIncoming.Text = "Enemy Incoming: " + response.result.status.body.incoming_enemy_ships;

                int bleederCount          = 0;
                int fissureCount          = 0;
                int damagedBuildingsCount = 0;
                foreach (var b in response.result.buildings)
                {
                    if (Convert.ToInt64(b.Value.efficiency) < 100)
                    {
                        damagedBuildingsCount++;
                        repairBuildings.IsVisible = true;
                    }
                    if (b.Value.name.Contains("eeder"))
                    {
                        bleederCount++;
                    }
                    if (b.Value.name.Contains("issure"))
                    {
                        fissureCount++;
                    }
                }
                damagedBuildings.Text = "Damaged Buildings: " + damagedBuildingsCount;
                fissures.Text         = "Fissures: " + fissureCount;
                bleeders.Text         = "Bleeders: " + bleederCount;
            };
        }
		public BodyStatusDetail(Response response, string pName)
		{
			this.response = response;
			var mainLayout = new StackLayout
			{
				BackgroundColor = Color.FromRgb (0, 0, 128),
				Children = {
					planetName,
					planetLocation,
					enemyIncoming,
					damagedBuildings,	
					fissures,					
					bleeders,					
					food,
					water,
					ore,
					energy,
					happiness,
					waste,
					repairBuildings,
					destroyBleeders,
					fillFissure
				}
			};

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

            repairBuildings.Clicked += async (sender, e) =>
            {
                var damagedIDs = LacunaExpress.Scripts.BuildingToolsScripts.GetDamagedBuildingIDs(response.result.buildings);
                
                if(account != null)
                {
					//foreach(var p in account.AllBodies)
					//{
					//	if (p.Value.Equals(planetName.Text))
					//	{
					//		planetID = p.Key;
					//		break;
					//	}
					//}
					
                    //planetID = account.AllBodies.Where(x => x.Value.Equals(planetName)).First().Key;
                    var json = LacunaExpanseAPIWrapper.Body.RepairList(1, account.SessionID, planetID, damagedIDs);
                    var server = new LacunaExpress.Data.Server();
                    var r = await server.GetHttpResultAsync(account.Server, LacunaExpanseAPIWrapper.Body.url, json);
                    var xyz = r;
                }
               
            };

            this.Appearing += async (sender, e) => 
            {
                AccountManager acntMgr = new AccountManager();
                account = await acntMgr.GetActiveAccountAsync();
                planetName.Text = pName;
				planetID = (from i in account.AllBodies
							where i.Value.Equals(planetName.Text)
							select i.Key).First();
                //planetLocation.Text = response.result.status.body.name;
                //planetID = response.result.status.body.id
                food.Text      = "Food: " + response.result.status.body.food_stored + "/" + response.result.status.body.food_hour;
                water.Text     = "Water: " + response.result.status.body.water_stored + "/" + response.result.status.body.water_hour;
                ore.Text       = "Ore: " + response.result.status.body.ore_stored + "/" + response.result.status.body.ore_hour;
                energy.Text    = "Energy: " + response.result.status.body.energy_stored + "/" + response.result.status.body.energy_hour;
                happiness.Text = "Happiness: " + response.result.status.body.happiness + "/" + response.result.status.body.happiness_hour;
                waste.Text     = "Waste: " + response.result.status.body.waste_stored + "/" + response.result.status.body.waste_hour;

                enemyIncoming.Text = "Enemy Incoming: " + response.result.status.body.incoming_enemy_ships;

                int bleederCount = 0;
                int fissureCount = 0;
                int damagedBuildingsCount = 0;
                foreach (var b in response.result.buildings)
                {
                    if (Convert.ToInt64(b.Value.efficiency) < 100)
                    {
                        damagedBuildingsCount++;
                        repairBuildings.IsVisible = true;
                    }
                    if (b.Value.name.Contains("eeder"))
                        bleederCount++;
                    if (b.Value.name.Contains("issure"))
                        fissureCount++;
                }
                damagedBuildings.Text = "Damaged Buildings: " + damagedBuildingsCount;
                fissures.Text = "Fissures: " + fissureCount;
                bleeders.Text = "Bleeders: " + bleederCount;
            };
		}