public DisplayCoordinate[][] GetMapCoordinates(string turnId) { var displayMapArray = new DisplayCoordinate[100][]; using (var dataContext = new AusterlitzDbContext()) { var turnMap = new GenericRepository<TR_MapCoordinates>(dataContext); var regionalMap = new GenericRepository<REF_PoliticalMapCoordinates>(dataContext); var turnCoordinateList = turnMap.GetItems(x => x.TurnId == turnId); var regionalCoordinateList = regionalMap.Get(); var rulesCatalogApiController = new RulesCatalogApiController(); var refProductionSites = rulesCatalogApiController.GetRefProductionSites(); for (var y = 0; y <= 99; y++) { displayMapArray[y] = new DisplayCoordinate[91]; for (var x = 0; x <= 90; x++) { var turnCoord = turnCoordinateList.SingleOrDefault(a => a.X == x && a.Y == y); var regionalCoord = regionalCoordinateList.SingleOrDefault(a => a.X == x && a.Y == y); if (turnCoord != null && regionalCoord != null) { displayMapArray[turnCoord.Y][turnCoord.X] = new DisplayCoordinate() { X = x, Y = y, TurnId = turnId, Population = turnCoord.Population, ProductionSite = turnCoord.ProductionSite.Replace(".",""), State = turnCoord.State, Bonus = regionalCoord.Bonus, Owner = regionalCoord.Owner, Terrain = regionalCoord.Terrain, }; //displayMapArray[turnCoord.Y][turnCoord.X].allowableProdSites = calcAllowableProdSites(displayMapArray[turnCoord.Y][turnCoord.X], refProductionSites, state); } else { displayMapArray[y][x] = new DisplayCoordinate() { X = x, Y = y, TurnId = turnId, Population = ".", ProductionSite = " ", State = " ", Bonus = " ", Owner = " ", Terrain = " " }; } if (x == 0) displayMapArray[y][x].Population = x.ToString(); else if (y == 0) displayMapArray[y][x].Population = y.ToString(); } } return displayMapArray; } }
public DisplayCoordinate[][] GetMapCoordinates(string turnId) { var displayMapArray = new DisplayCoordinate[100][]; using (var dataContext = new AusterlitzDbContext()) { var turnMap = new GenericRepository <TR_MapCoordinates>(dataContext); var regionalMap = new GenericRepository <REF_PoliticalMapCoordinates>(dataContext); var turnCoordinateList = turnMap.GetItems(x => x.TurnId == turnId); var regionalCoordinateList = regionalMap.Get(); var rulesCatalogApiController = new RulesCatalogApiController(); var refProductionSites = rulesCatalogApiController.GetRefProductionSites(); for (var y = 0; y <= 99; y++) { displayMapArray[y] = new DisplayCoordinate[91]; for (var x = 0; x <= 90; x++) { var turnCoord = turnCoordinateList.SingleOrDefault(a => a.X == x && a.Y == y); var regionalCoord = regionalCoordinateList.SingleOrDefault(a => a.X == x && a.Y == y); if (turnCoord != null && regionalCoord != null) { displayMapArray[turnCoord.Y][turnCoord.X] = new DisplayCoordinate() { X = x, Y = y, TurnId = turnId, Population = turnCoord.Population, ProductionSite = turnCoord.ProductionSite.Replace(".", ""), State = turnCoord.State, Bonus = regionalCoord.Bonus, Owner = regionalCoord.Owner, Terrain = regionalCoord.Terrain, }; //displayMapArray[turnCoord.Y][turnCoord.X].allowableProdSites = calcAllowableProdSites(displayMapArray[turnCoord.Y][turnCoord.X], refProductionSites, state); } else { displayMapArray[y][x] = new DisplayCoordinate() { X = x, Y = y, TurnId = turnId, Population = ".", ProductionSite = " ", State = " ", Bonus = " ", Owner = " ", Terrain = " " }; } if (x == 0) { displayMapArray[y][x].Population = x.ToString(); } else if (y == 0) { displayMapArray[y][x].Population = y.ToString(); } } } return(displayMapArray); } }