Exemplo n.º 1
0
 public NhoodHandler(CityServerContext context, IRealestateDomain realestate, IDAFactory da, IDataService dataService, IKernel kernel, Neighborhoods nhoods)
 {
     Context          = context;
     GlobalRealestate = realestate;
     Realestate       = realestate.GetByShard(context.ShardId);
     DA          = da;
     DataService = dataService;
     Kernel      = kernel;
     Nhoods      = nhoods;
 }
Exemplo n.º 2
0
        public BulletinHandler(CityServerContext context, IDAFactory da, IDataService dataService, IKernel kernel, Neighborhoods nhoods)
        {
            Context     = context;
            DA          = da;
            DataService = dataService;
            Kernel      = kernel;
            Nhoods      = nhoods;

            POST_FREQ_LIMIT       = context.Config.Neighborhoods.Bulletin_Post_Frequency * 60 * 60 * 24;
            POST_FREQ_LIMIT_MAYOR = context.Config.Neighborhoods.Bulletin_Mayor_Frequency * 60 * 60 * 24;
            MOVE_LIMIT_PERIOD     = context.Config.Neighborhoods.Bulletin_Move_Penalty * 60 * 60 * 24;
        }
 public VoltronConnectionLifecycleHandler(ISessions sessions, IDataService dataService, IDAFactory da, CityServerContext context, LotServerPicker lotServers, CityLivenessEngine engine,
                                          EventSystem events, Neighborhoods neigh)
 {
     this.VoltronSessions = sessions.GetOrCreateGroup(Groups.VOLTRON);
     this.Sessions        = sessions;
     this.DataService     = dataService;
     this.DAFactory       = da;
     this.Context         = context;
     this.LotServers      = lotServers;
     this.Liveness        = engine;
     this.Events          = events;
     this.Neigh           = neigh;
 }
        /// <summary>
        /// Method which parses out all neighborhoods from the JSON data file.
        /// </summary>
        /// <returns>IEnumerable<string></returns>
        public static IEnumerable <string> FindAllNeighborhoods()
        {
            // Creates the deserialized object
            Neighborhoods neighborObj = Neighborhoods.DeserializeJSON();

            // Declare a list to store all neighborhoods from the deserialized object
            List <string> hoodList = new List <string>();

            // Iterates through the deserialized object, adding each neighborhood to hoodList
            for (int i = neighborObj.Features.Count - 1; i > 0; i--)
            {
                hoodList.Add(neighborObj.Features[i].Properties.Neighborhood);
            }

            return(hoodList);
        }
Exemplo n.º 5
0
        internal static GameActorPosition GetNearest(int x, int y, string type, IAtlas atlas)
        {
            Type t = GameActor.GetGameActorType(type);

            for (int i = 1; i < 20; i++)
            {
                IEnumerable <Vector2I> vonNeumannNeighborhood = Neighborhoods.VonNeumannNeighborhood(new Vector2I(x, y), i);

                foreach (var xy in vonNeumannNeighborhood)
                {
                    foreach (GameActorPosition gameActorPosition in atlas.ActorsAt((Vector2)xy))
                    {
                        if (gameActorPosition.Actor.GetType() == t)
                        {
                            return(gameActorPosition);
                        }
                    }
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Method to return a list containing all neighborhoods
        /// </summary>
        /// <returns>parsed out json object of neighborhoods</returns>
        public static List <Neighborhoods> ReadJson()
        {
            JObject propObject             = JObject.Parse(File.ReadAllText(@"../../../../../data.json"));
            var     newObject              = propObject["features"];
            List <Neighborhoods> listProps = new List <Neighborhoods>();

            foreach (var p in newObject)
            {
                Neighborhoods props = new Neighborhoods
                {
                    Zip          = (string)p["properties"]["zip"],
                    City         = (string)p["properties"]["city"],
                    State        = (string)p["properties"]["state"],
                    Address      = (string)p["properties"]["address"],
                    Borough      = (string)p["properties"]["borough"],
                    Neighborhood = (string)p["properties"]["neighborhood"],
                    County       = (string)p["properties"]["county"],
                };
                listProps.Add(props);
            }
            return(listProps);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            City dallas = new City();

            dallas.Name  = "Dallas";
            dallas.State = "TX";
            LatLng dallasCoords = new LatLng();

            dallasCoords.Lat     = 96.7970;
            dallasCoords.Lng     = 32.7767;
            dallas.Latlng        = dallasCoords;
            dallas.Neighborhoods = new List <Neighborhoods>();

            Neighborhoods deepEllum = new Neighborhoods();

            deepEllum.City        = dallas;
            deepEllum.Name        = "Deep Ellum";
            deepEllum.Restaurants = new List <Restaurants>();



            Neighborhoods upTown = new Neighborhoods();

            upTown.City        = dallas;
            upTown.Name        = "Uptown";
            upTown.Restaurants = new List <Restaurants>();

            dallas.Neighborhoods.Add(deepEllum);
            dallas.Neighborhoods.Add(upTown);

            Restaurants pecanLodge = new Restaurants();

            pecanLodge.Name       = "Pecan Lodge";
            pecanLodge.Type       = Category.American;
            pecanLodge.WebsiteUrl = "http://pecanlodge.com/";

            pecanLodge.Address = new Address();
            pecanLodge.Address.StreetAddress = "2702 Main St";
            pecanLodge.Address.City          = dallas;
            pecanLodge.Address.Zip           = 75226;
            pecanLodge.Address.Latlng        = new LatLng();
            pecanLodge.Address.Latlng.Lat    = 32.784065;
            pecanLodge.Address.Latlng.Lng    = -96.783745;


            Restaurants monkeyKing = new Restaurants();

            monkeyKing.Name       = "Monkey King";
            monkeyKing.Type       = Category.Chinese;
            monkeyKing.WebsiteUrl = "http://monkeykingnoodlecompany.com/";

            monkeyKing.Address = new Address();
            monkeyKing.Address.StreetAddress = "2933 Main St";
            monkeyKing.Address.City          = dallas;
            monkeyKing.Address.Zip           = 75226;
            monkeyKing.Address.Latlng        = new LatLng();
            monkeyKing.Address.Latlng.Lat    = 32.784065;
            monkeyKing.Address.Latlng.Lng    = -96.783745;

            deepEllum.Restaurants.Add(pecanLodge);
            deepEllum.Restaurants.Add(monkeyKing);



            //City dallas = new City();
            //dallas.Name = "Dallas";
            //dallas.State = "Texas";
            //dallas.Latlng.Lat = 96.7970;
            //dallas.Latlng.Lng = 32.7767;
            //dallas.Burroughs.Add(new Neighborhoods() {Name = "Bishop Arts District" });


            //dallas.Burroughs.Add(new Neighborhoods() {Name = "Deep Ellum" });

            //dallas.Restaurants.Add(new Restaurants() {Name = "Iron Cactus" });
            //dallas.Restaurants.Add(new Restaurants() { Name = "Five Sixty" });
            //dallas.Restaurants.Add(new Restaurants() { Name = "Meso Maya" });

            //dallas.Restaurants.Add(new Restaurants() { });

            //dallas.NeighboringCities.Add(new City { Name = "Plano"});
            //dallas.NeighboringCities.Add(new City { Name = "Irving" });
            //dallas.NeighboringCities.Add(new City { Name = "Duncanville" });
        }
 public static IEnumerable <Post> GetPost()
 {
     return(new[]
     {
         new Post
         {
             User = Users.Skip(0).FirstOrDefault(),
             AccomodationType = AccomodationType.None,
             AccomodationOption = AccomodationOptions.Without,
             ArePetsAllowed = true,
             Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer erat nisi, egestas sed consequat pulvinar, suscipit at ipsum. Praesent volutpat enim sit amet ex mattis semper. Curabitur blandit non sapien eu vestibulum. In tincidunt nunc dapibus ultricies sollicitudin. Morbi sit amet velit ex. Phasellus egestas eu purus a semper. Vivamus interdum ex vitae pharetra malesuada. Praesent ullamcorper porttitor libero id blandit. Donec neque nisl, dignissim in tellus ut, interdum vestibulum ex. Nulla vel tincidunt erat, ac scelerisque ex. Nam sit amet tristique velit, sit amet congue nulla. Mauris hendrerit ut orci nec viverra. Praesent dictum viverra est ut viverra. Vivamus finibus fermentum nisi, non aliquam neque mattis at.",
             IsSmokerAllowed = true,
             Neighborhoods = Neighborhoods.Where(n => n.City.Name == "Zagreb").ToList(),
             Likes = Users.ToList(),
             NumberOfRoommates = 2,
             PetOptions = PetOptions.Bird | PetOptions.SmallAnimal,
             PostDate = DateTimeOffset.Now.Subtract(new TimeSpan(1, 1, 1, 1)),
             Title = "Tražim cimera u Zagrebu",
             WantedGender = Gender.Any,
             CommentsCount = 3,
             LikesCount = 3,
             IsLiked = true
         },
         new Post
         {
             User = Users.Skip(1).FirstOrDefault(),
             AccomodationType = AccomodationType.House,
             AccomodationOption = AccomodationOptions.With,
             ArePetsAllowed = false,
             Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer erat nisi, egestas sed consequat pulvinar, suscipit at ipsum. Praesent volutpat enim sit amet ex mattis semper. Curabitur blandit non sapien eu vestibulum. In tincidunt nunc dapibus ultricies sollicitudin. Morbi sit amet velit ex. Phasellus egestas eu purus a semper. Vivamus interdum ex vitae pharetra malesuada. Praesent ullamcorper porttitor libero id blandit. Donec neque nisl, dignissim in tellus ut, interdum vestibulum ex. Nulla vel tincidunt erat, ac scelerisque ex. Nam sit amet tristique velit, sit amet congue nulla. Mauris hendrerit ut orci nec viverra. Praesent dictum viverra est ut viverra. Vivamus finibus fermentum nisi, non aliquam neque mattis at.",
             IsSmokerAllowed = false,
             Neighborhoods = Neighborhoods.Where(n => n.City.Name == "Split").ToList(),
             Likes = Users.ToList(),
             NumberOfRoommates = 3,
             PostDate = DateTimeOffset.Now.Subtract(new TimeSpan(2, 1, 1, 1)),
             Title = "Tražim cimera u Splitu",
             WantedGender = Gender.Female,
             PostPictures = GetPostPictures().ToList(),
             Price = 1500.00m,
             CommentsCount = 3,
             LikesCount = 3,
             IsLiked = true
         },
         new Post
         {
             User = Users.Skip(2).FirstOrDefault(),
             AccomodationType = AccomodationType.Apartment,
             AccomodationOption = AccomodationOptions.With,
             ArePetsAllowed = true,
             Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer erat nisi, egestas sed consequat pulvinar, suscipit at ipsum. Praesent volutpat enim sit amet ex mattis semper. Curabitur blandit non sapien eu vestibulum. In tincidunt nunc dapibus ultricies sollicitudin. Morbi sit amet velit ex. Phasellus egestas eu purus a semper. Vivamus interdum ex vitae pharetra malesuada. Praesent ullamcorper porttitor libero id blandit. Donec neque nisl, dignissim in tellus ut, interdum vestibulum ex. Nulla vel tincidunt erat, ac scelerisque ex. Nam sit amet tristique velit, sit amet congue nulla. Mauris hendrerit ut orci nec viverra. Praesent dictum viverra est ut viverra. Vivamus finibus fermentum nisi, non aliquam neque mattis at.",
             IsSmokerAllowed = true,
             Neighborhoods = Neighborhoods.Where(n => n.City.Name == "Osijek").ToList(),
             Likes = Users.ToList(),
             NumberOfRoommates = 2,
             PetOptions = PetOptions.Dog | PetOptions.Other,
             PostDate = DateTimeOffset.Now.Subtract(new TimeSpan(3, 1, 1, 1)),
             Title = "Tražim cimera u Osijeku",
             WantedGender = Gender.Any,
             PostPictures = GetPostPictures().ToList(),
             Price = 2000.00m,
             CommentsCount = 3,
             LikesCount = 3,
             IsLiked = true
         },
     }.OrderBy(p => p.PostDate));
 }
Exemplo n.º 9
0
 public IEnumerable <Vector2I> FreePositionsAround(Vector2I position, LayerType type = LayerType.All)
 {
     return(Neighborhoods.ChebyshevNeighborhood(position).Where(x => IsCoordinateFree(x, type)));
 }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            //setting the json file name to a variable
            string jsonFile = "data.json";
            string jsonData;

            //this way uses the variable we set!
            string path = Path.Combine(Environment.CurrentDirectory, @"..\", jsonFile);

            //This way uses the ABSOLUTE PATH, I can refactor this later to use one or the other to DRY it out
            using (StreamReader sr = File.OpenText(@"C:\Users\ZachAndChels\source\repos\Lab08-LINQ\data.json"))
            {
                jsonData = File.ReadAllText(path);
            }

            //This is the non-converted json
            var data = Neighborhoods.FromJson(jsonData);


            //this is the converted json, woo!
            var isThisThingOn = Neighborhoods.FromJson(jsonData);

            Console.WriteLine(isThisThingOn);
            Console.ReadLine();

            //this will grab everything from the json that isn't null!
            IEnumerable <Feature> allNeighborhoods = from raw in isThisThingOn.Features
                                                     where raw.Properties != null
                                                     select raw;


            //this foreach writes out all the hood names
            foreach (var raw in allNeighborhoods)
            {
                Console.WriteLine(raw.Properties.Neighborhood);
            }
            Console.ReadLine();

            //this LINQ query will get rid of anything that doesn't have a neighborhood name value, i.e. hoods.Properties.Neighborhood is an empty string
            //Can't use null for this, because technically an empty string isn't null
            IEnumerable <Feature> filterNoNameHoods = from hoods in allNeighborhoods
                                                      where hoods.Properties.Neighborhood != ""
                                                      select hoods;


            Console.WriteLine("---------BREAKLINE--------");
            //writing it out to make sure it works!
            foreach (var hoods in filterNoNameHoods)
            {
                Console.WriteLine(hoods.Properties.Neighborhood);
            }
            Console.ReadLine();

            // this lambda expression took a minute, make sure to read over the overloads and built in helper methods
            // so what's happening here is it's grouping everything by name, and then only grabbing the first instance of that name
            // then! we have a cleaned up list. I'm using the prefiltered no name LINQ call to build off of it.
            var noDupeHoods = filterNoNameHoods.GroupBy(hood => hood.Properties.Neighborhood).Select(firsthood => firsthood.First());

            Console.WriteLine("---------BREAKLINE-------");
            //writing again, to check it works as intended, we can move this stuff to TESTS soon
            foreach (var hoods in noDupeHoods)
            {
                Console.WriteLine(hoods.Properties.Neighborhood);
            }
            Console.ReadLine();

            // I tried for a half hour to do this with LINQ, and gave up when I realized it might be easier to do this with lambda.
            // So part one, we grab hoods where the name isn't equal to an empty string, then we group them by name, then we select the first!
            var endThis = allNeighborhoods.Where(x => x.Properties.Neighborhood != "").GroupBy(x => x.Properties.Neighborhood).Select(one => one.First());


            Console.WriteLine("---------------BREAKLINE---------------");

            // another test to implement
            foreach (var rah in endThis)
            {
                Console.WriteLine(rah.Properties.Neighborhood);
            }

            Console.ReadLine();
        }