static void Main(string[] args) { var input = new Input(); input.RequestInput(); var bldgProgram = new BldgProgram(input); var house = new House(input, bldgProgram); house.RunThrowAndStick(); house.RunPushPull(); foreach (Room r in house) { WriteLine(r.ToString()); } foreach (System.Tuple <Room, Room> pair in house.Adjacencies) { WriteLine(pair.ToString()); } //house.Draw(); ReadKey(); }
// Constructor, of the House, no irony whatsoever public House(Input input, BldgProgram bldgProgram) { mainList = new List <Room>(); Adjacencies = new List <Tuple <Room, Room> >(); Streetside = input.StreetSides; MainStreet = input.MainStreet; var privatePool = bldgProgram.PrivatePool / (GridSize * GridSize); var publicPool = bldgProgram.PublicPool / (GridSize * GridSize); var bedroomCount = bldgProgram.BedroomCount; var kitchenPool = bldgProgram.KitchenPool / (GridSize * GridSize); if (input.MainStreet == CardinalDirections.East || input.MainStreet == CardinalDirections.West) { Boundary = new Rectangle(input.PlotDepth / GridSize, input.PlotWidth / GridSize); } else { Boundary = new Rectangle(input.PlotWidth / GridSize, input.PlotDepth / GridSize); } var main = AddRoom <LivingRoom>("Main", 12 / GridSize, 16 / GridSize); privatePool -= main.Area; Room livingRoom; if (privatePool > (24 / GridSize) * (12 / GridSize)) { livingRoom = AddRoom <LivingRoom>(null, 24 / GridSize, 12 / GridSize); privatePool -= livingRoom.Area; PairRooms(main, livingRoom); } else { main.ExtendLength(privatePool); livingRoom = main; } BedroomCtor(input, bldgProgram, bedroomCount, livingRoom); var desiredRooms = input.Rooms; Room diningRoom; if (desiredRooms.HasFlag(InputRooms.DiningRoom)) // Sketch { var diningRoomSize = input.Total <= 8 ? 16 : Floor((input.Total - 8d) / 4) * 4 + 16; // 12 * 16 for 8 people !! more for each extra 4 ppl add 4 ft. diningRoom = AddRoom <DiningRoom>("Dining", 12 / GridSize, diningRoomSize / (12 * GridSize)); publicPool -= diningRoom.Area; PairRooms(diningRoom, livingRoom); } else { livingRoom.ExtendLength(3); diningRoom = livingRoom; } KitchenCtor(input.Total, bldgProgram.Kitchenette, livingRoom, diningRoom, desiredRooms); #region Desired Rooms // Ideally the code would cycle through those by the priority made by the client. or CRITERIA // Check how many flags are satisfied. If the flags are more than a certain percentage: // create a corridor/or private rooms hub, and connect the extra rooms to it. // alternatively, if livingRoom has more than a certain number of connection, // it is extended per extra connection. // // TODO TODO TODO // // if(publicPool > 0 && desiredRooms.HasFlag(InputRooms.Reception)) // { // int receptionHallArea = Function(input.Total); // What would that be? // var reception = AddRoom<Reception>(12 / GridSize, receptionHallArea / (12 * GridSize)); // PairRooms(main, reception); // publicPool -= reception.Area; // if(publicPool > receptionHallArea) // { // // new Reception Room for te other gender .. maybe? // } // else // { // reception.ExtendLength(publicPool); // // There should be an entrypoint variable where I assign to the street in the end. // } // } // if(privatePool > 0 && desiredRooms.HasFlag(InputRooms.Library)) // { // } // Go through rooms in desiredRooms. Check if privatePool has enough space. // Library // Office // GameRoom // w/e #endregion }
void BedroomCtor(Input input, BldgProgram bldgProgram, int bedroomCount, Room livingRoom) { if (input.Grandparents > 0) { // Technically this should be a suite var gparentsbedroom = AddRoom <Bedroom>("Grandparents", 12 / GridSize, 20 / GridSize); bedroomCount--; PairRooms(gparentsbedroom, livingRoom); } Room bedroomHub; if (bedroomCount > 1) { bedroomHub = AddRoom <Corridor>("Bedroom Corridor", 4 / GridSize, ((bedroomCount * 6) + 6) / GridSize); PairRooms(bedroomHub, livingRoom); } else { bedroomHub = livingRoom; } if (input.Grandparents > 2) { // Technically this should be a suite var gparentsbedroom = AddRoom <Bedroom>("Grandparents 2", 12 / GridSize, 20 / GridSize); bedroomCount--; PairRooms(gparentsbedroom, bedroomHub); } if (input.Parents > 0) { var parentsBedroom = AddRoom <Bedroom>("Parents", 12 / GridSize, 20 / GridSize); bedroomCount--; PairRooms(parentsBedroom, bedroomHub); } foreach (int residentFactor in bldgProgram.NumberOfKidsInTheOlderKidsBedroom) { if (residentFactor != 0) { if (residentFactor <= 2) // Odd rooms. { var bedroom = AddRoom <Bedroom>("Older Kids", 16 / GridSize, 12 / GridSize); bedroomCount--; PairRooms(bedroom, bedroomHub); } else { var bedroom = AddRoom <Bedroom>("Older Kids", ((4 * (residentFactor - 1)) + 12) / GridSize, 12 / GridSize); bedroomCount--; PairRooms(bedroom, bedroomHub); } } } for (int i = 0; i < bedroomCount; i++) { var bedroom = AddRoom <Bedroom>(((4 * input.KidsPerBedroom) + 8) / GridSize, 12 / GridSize); PairRooms(bedroom, bedroomHub); } }