Esempio n. 1
0
        public TS_00TurnDetails[] GetTSTurnDetails(string turnId)
        {
            using (var dataContext = new AusterlitzDbContext())
            {
                var listRepository = new GenericRepository <TS_00TurnDetails>(dataContext);
                var tsItems        = listRepository.GetItems(x => x.TurnId == turnId);

                if (tsItems.Count() == 0)
                {
                    var newItems = new TS_00TurnDetails[1];

                    for (var itemCount = 1; itemCount <= newItems.Count(); itemCount++)
                    {
                        TS_00TurnDetails item = new TS_00TurnDetails()
                        {
                            TurnId = turnId
                        };
                        newItems[itemCount - 1] = item;
                    }

                    listRepository.InsertRange(newItems);
                    dataContext.SaveChanges();
                    tsItems = listRepository.GetItems(x => x.TurnId == turnId);
                }
                return(tsItems.ToArray());
            }
        }
Esempio n. 2
0
        public TS_02DemolishItems[] GetTSDemolishItems(string turnId)
        {
            using (var dataContext = new AusterlitzDbContext())
            {
                var listRepository = new GenericRepository <TS_02DemolishItems>(dataContext);
                var tsItems        = listRepository.GetItems(x => x.TurnId == turnId).OrderBy(y => y.OrderNo);

                if (tsItems.Count() == 0)
                {
                    var newItems = new TS_02DemolishItems[6];

                    for (var itemCount = 1; itemCount <= newItems.Count(); itemCount++)
                    {
                        TS_02DemolishItems item = new TS_02DemolishItems()
                        {
                            TurnId = turnId, OrderNo = itemCount
                        };
                        newItems[itemCount - 1] = item;
                    }

                    listRepository.InsertRange(newItems);
                    dataContext.SaveChanges();
                    tsItems = listRepository.GetItems(x => x.TurnId == turnId).OrderBy(y => y.OrderNo);
                }
                return(tsItems.ToArray());
            }
        }
Esempio n. 3
0
 public TS_11BuildBaggageTrain[] PostTSBuildBaggageTrain(TS_11BuildBaggageTrain[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_11BuildBaggageTrain>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 4
0
 public TS_23ChangeStateRelationships[] PostTSChangeStateRelationships(TS_23ChangeStateRelationships[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_23ChangeStateRelationships>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 5
0
 public TS_21HandOverTerritory[] PostTSHandOverTerritory(TS_21HandOverTerritory[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_21HandOverTerritory>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 6
0
 public TS_15CoastalDefence[] PostTSCoastalDefence(TS_15CoastalDefence[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_15CoastalDefence>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 7
0
 public TS_19TradeAndLoading2[] PostTSTradeAndLoading2(TS_19TradeAndLoading2[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_19TradeAndLoading2>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 8
0
 public TS_13BuildProductionSites[] PostTSBuildProductionSites(TS_13BuildProductionSites[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_13BuildProductionSites>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 9
0
 public TS_18Movement[] PostTSMovement(TS_18Movement[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_18Movement>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 10
0
 public TS_14FormFederations[] PostTSFormFederations(TS_14FormFederations[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_14FormFederations>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 11
0
        private void loadTurnReport(string filePath)
        {
            AusterlitzDbContext _auDB = new AusterlitzDbContext();

            var lineList     = loadTurnFile(filePath);
            var lineLocation = 0;

            lineLocation = loadPoliticalMap(lineList, lineLocation, _auDB);
        }
Esempio n. 12
0
 public TS_12IncreasePopulationDensity[] PostTSIncreasePopulationDensity(TS_12IncreasePopulationDensity[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_12IncreasePopulationDensity>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 13
0
 public TS_09RepairShips_BaggageTrains[] PostTSRepairShips_BaggageTrains(TS_09RepairShips_BaggageTrains[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_09RepairShips_BaggageTrains>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 14
0
 public TS_06IncreaseBrigadeXP[] PostTSIncreaseBrigadeXP(TS_06IncreaseBrigadeXP[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_06IncreaseBrigadeXP>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 15
0
 public TS_04SetUpAdditionalBrigades[] PostTSSetUpAdditionalBrigades(TS_04SetUpAdditionalBrigades[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_04SetUpAdditionalBrigades>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 16
0
 public TS_02DemolishItems[] PostTSDemolishItems(TS_02DemolishItems[] tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new TurnSheetRepository <TS_02DemolishItems>(dataContext);
         var result         = listRepository.SaveRange(tsPostedRecords);
         return(result.ToArray());
     }
 }
Esempio n. 17
0
        public TS_00TurnDetails[] GetAllTSTurnDetails()
        {
            using (var dataContext = new AusterlitzDbContext())
            {
                var listRepository = new GenericRepository <TS_00TurnDetails>(dataContext);
                var tsItems        = listRepository.Get().ToArray();

                return(tsItems);
            }
        }
Esempio n. 18
0
 public TS_00TurnDetails PostTSTurnDetails(TS_00TurnDetails tsPostedRecords)
 {
     using (var dataContext = new AusterlitzDbContext())
     {
         var listRepository = new GenericRepository <TS_00TurnDetails>(dataContext);
         listRepository.Insert(tsPostedRecords);
         var result = listRepository.GetItems(x => x.TurnId == tsPostedRecords.TurnId);
         dataContext.SaveChanges();
         return(result.ToArray()[0]);
     }
 }
Esempio n. 19
0
        public REF_Terrain[] GetRefTerrain()
        {
            using (var dataContext = new AusterlitzDbContext())
            {
                var listRepository = new GenericRepository <REF_Terrain>(dataContext);

                IEnumerable <REF_Terrain> rtnList = listRepository
                                                    .Get();

                return(rtnList.ToArray());
            }
        }
Esempio n. 20
0
        public REF_States[] GetRefStates()
        {
            using (var dataContext = new AusterlitzDbContext())
            {
                var listRepository = new GenericRepository <REF_States>(dataContext);

                IEnumerable <REF_States> rtnList = listRepository
                                                   .Get()
                                                   .OrderBy(y => y.State);

                return(rtnList.ToArray());
            }
        }
Esempio n. 21
0
        public REF_ArmyList[] GetArmyList(string state = "E")
        {
            using (var dataContext = new AusterlitzDbContext())
            {
                var listRepository = new GenericRepository <REF_ArmyList>(dataContext);

                IEnumerable <REF_ArmyList> armyList = listRepository
                                                      .GetItems(x => x.State == state)
                                                      .OrderBy(y => y.ItemNo);

                return(armyList.ToArray());
            }
        }
Esempio n. 22
0
 public TurnSheetRepository(AusterlitzDbContext austerlitzDbContext)
 {
     this._austerlitzDbContext = austerlitzDbContext;
     this.dbSet = austerlitzDbContext.Set <T>();
 }
Esempio n. 23
0
 public GenericRepository(AusterlitzDbContext austerlitzDbContext)
 {
     this.dbSet = austerlitzDbContext.Set <T>();
 }
Esempio n. 24
0
        private int loadPoliticalMap(ArrayList lineList, int lineLocation, AusterlitzDbContext auDB)
        {
            bool locationFound      = false;
            int  xStart             = 0;
            var  coordinatesOnALine = new REF_PoliticalMapCoordinates[40];
            var  y = 0;

            var mapBoundaryEurope1   = "    1  2  3  4  5  6  7  8  9";
            var mapBoundaryEurope2   = "   41 42 43 44 45 46 47 48 49 50";
            var mapBoundaryCarribean = "    1  2  3  4  5  6";
            var mapBoundaryIndies    = "   51 52 53 54 55";
            var mapBoundaryText      = mapBoundaryEurope1;

            // delete all the existing coordinate ... in future, dont do this as should only load once...
            var existingCoordinates = auDB.REF_PoliticalMapCoordinates;

            auDB.REF_PoliticalMapCoordinates.RemoveRange(existingCoordinates);

            for (; lineLocation < lineList.Count; lineLocation++)
            {
                var lineToProcess = lineList[lineLocation].ToString();

                if (lineToProcess.IndexOf(mapBoundaryText) != -1)
                {
                    if (locationFound)
                    {
                        locationFound = false;
                        if (mapBoundaryText == mapBoundaryEurope1)
                        {
                            mapBoundaryText = mapBoundaryEurope2;
                        }
                        else if (mapBoundaryText == mapBoundaryEurope2)
                        {
                            mapBoundaryText = mapBoundaryCarribean;
                        }
                        else if (mapBoundaryText == mapBoundaryCarribean)
                        {
                            mapBoundaryText = mapBoundaryIndies;
                        }
                        else if (mapBoundaryText == mapBoundaryIndies)
                        {
                            break; // finished!
                        }
                    }
                    else
                    {
                        locationFound = true;
                        lineLocation  = lineLocation + 1; //skip two lines and switch on brigadeCapture
                        lineToProcess = lineList[lineLocation].ToString();

                        if (mapBoundaryText == mapBoundaryEurope1)
                        {
                            xStart = 1;
                            y      = 1;
                        }
                        else if (mapBoundaryText == mapBoundaryEurope2)
                        {
                            xStart = 41;
                            y      = 1;
                        }
                        else if (mapBoundaryText == mapBoundaryCarribean)
                        {
                            xStart = 1;
                            y      = 70;
                        }
                        else if (mapBoundaryText == mapBoundaryIndies)
                        {
                            xStart = 51;
                            y      = 70;
                        }
                    }
                }

                if (locationFound)
                {
                    if (lineToProcess.IndexOf(mapBoundaryText) != -1)
                    {
                        break;
                    }

                    for (var x = xStart; x < xStart + 40; x++)
                    {
                        var    newCoordinate = new REF_PoliticalMapCoordinates();
                        string coordinate    = lineToProcess.Substring(3 + (x - xStart) * 3, 3);

                        newCoordinate.X                = x;
                        newCoordinate.Y                = y;
                        newCoordinate.Owner            = coordinate.Substring(0, 1);
                        newCoordinate.Terrain          = coordinate.Substring(1, 1);
                        newCoordinate.Bonus            = coordinate.Substring(2, 1);
                        coordinatesOnALine[x - xStart] = newCoordinate;
                    }

                    auDB.REF_PoliticalMapCoordinates.AddRange(coordinatesOnALine);
                    auDB.SaveChanges();
                    y++;
                }
            }

            return(lineLocation);
        }
Esempio n. 25
0
        public TurnReport getTRFullTurnDetails(string turnId)
        {
            using (var dataContext = new AusterlitzDbContext())
            {
                var turnReport = new TurnReport();

                var turnCommanders = new GenericRepository <TR_Commanders>(dataContext);
                turnReport.Commanders = turnCommanders.GetItems(x => x.TurnId == turnId).ToArray();

                var turnBrigades = new GenericRepository <TR_Brigades>(dataContext);
                turnReport.Brigades = turnBrigades.GetItems(x => x.TurnId == turnId).ToArray();

                var turnWarships = new GenericRepository <TR_Warships>(dataContext);
                turnReport.Warships = turnWarships.GetItems(x => x.TurnId == turnId).ToArray();

                var turnMerchantShips = new GenericRepository <TR_MerchantShips>(dataContext);
                turnReport.MerchantShips = turnMerchantShips.GetItems(x => x.TurnId == turnId).ToArray();

                var turnBaggageTrains = new GenericRepository <TR_BaggageTrains>(dataContext);
                turnReport.BaggageTrains = turnBaggageTrains.GetItems(x => x.TurnId == turnId).ToArray();

                var turnSpies = new GenericRepository <TR_Spies>(dataContext);
                turnReport.Spies = turnSpies.GetItems(x => x.TurnId == turnId).ToArray();

                var turnStateRelationships = new GenericRepository <TR_StateRelationships>(dataContext);
                turnReport.StateRelationships = turnStateRelationships.GetItems(x => x.TurnId == turnId).ToArray();

                var turnWarehouses = new GenericRepository <TR_Warehouses>(dataContext);
                turnReport.Warehouses = turnWarehouses.GetItems(x => x.TurnId == turnId).ToArray();

                var turnBarracks = new GenericRepository <TR_Barracks>(dataContext);
                turnReport.Barracks = turnBarracks.GetItems(x => x.TurnId == turnId).ToArray();

                var turnTradingPortsAndCities = new GenericRepository <TR_TradingPortsAndCities>(dataContext);
                turnReport.TradingPortsAndCities = turnTradingPortsAndCities.GetItems(x => x.TurnId == turnId).ToArray();

                List <MovementItems> movementItems = turnReport.Commanders.Select(x => new MovementItems()
                {
                    ItemNo = x.ItemNo, ItemType = ItemType.Commander, MP = x.MP, X = x.X, Y = x.Y
                }).ToList();
                var dummy = 0;

                movementItems.AddRange(turnReport.Brigades.Select(x =>
                                                                  new MovementItems()
                {
                    ItemNo = x.ItemNo, ItemType = ItemType.Brigade, MP = x.MP
                    , X    = Int32.TryParse(x.X_OrState, out dummy) ? int.Parse(x.X_OrState) : 0
                    , Y    = Int32.TryParse(x.Y_OrFleet, out dummy) ? int.Parse(x.Y_OrFleet) : 0
                }).ToList());

                // can add more union stuff here if necessary, not sure it makes much difference

                movementItems.AddRange(turnReport.Warships.Select(x => new MovementItems()
                {
                    ItemNo = x.ItemNo, ItemType = ItemType.Warship, MP = x.MP, X = x.X, Y = x.Y
                }).ToList());
                movementItems.AddRange(turnReport.MerchantShips.Select(x => new MovementItems()
                {
                    ItemNo = x.ItemNo, ItemType = ItemType.MerchantShip, MP = x.MP, X = x.X, Y = x.Y
                }).ToList());
                movementItems.AddRange(turnReport.BaggageTrains.Select(x => new MovementItems()
                {
                    ItemNo = x.ItemNo, ItemType = ItemType.BaggageTrain, MP = x.MP, X = x.X, Y = x.Y
                }).ToList());
                movementItems.AddRange(turnReport.Spies.Select(x => new MovementItems()
                {
                    ItemNo = x.ItemNo, ItemType = ItemType.Spy, MP = 75, X = x.X, Y = x.Y
                }).ToList());

                turnReport.MovementItemList = movementItems.ToArray();
                turnReport.MapCoordinates   = GetMapCoordinates(turnId);

                return(turnReport);
            }
        }
Esempio n. 26
0
        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);
            }
        }