예제 #1
0
        private void AddRows()
        {
            ISQLiteRow knightSpearmanStats = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 10, 10, 10, 10, 5f, 100, 10, 2, 150f, 10, 10, 150f, 50)); // -- 1
            ISQLiteRow knightFootmanStats  = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 10, 10, 10, 10, 5f, 100, 10, 2, 150f, 10, 10, 150f, 50)); // -- 2
            ISQLiteRow knightArcherStats   = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 10, 10, 10, 10, 5f, 100, 10, 2, 150f, 10, 10, 150f, 50)); // -- 3
            ISQLiteRow knightWorkerStats   = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 10, 10, 10, 10, 5f, 100, 10, 2, 150f, 10, 10, 150f, 50)); // -- 4

            ISQLiteRow vikingSpearmanStats = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 10, 10, 10, 10, 5f, 100, 10, 2, 150f, 10, 10, 150f, 50)); // -- 5
            ISQLiteRow vikingFootmanStats  = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 10, 10, 10, 10, 5f, 100, 10, 2, 150f, 10, 10, 150f, 50)); // -- 6
            ISQLiteRow vikingArcherStats   = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 10, 10, 10, 10, 5f, 100, 10, 2, 150f, 10, 10, 150f, 50)); // -- 7
            ISQLiteRow vikingWorkerStats   = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 10, 10, 10, 10, 5f, 100, 10, 2, 150f, 10, 10, 150f, 50)); // -- 8

            ISQLiteRow knightFaction  = FactionTable.Insert(new SQLiteFactionModel(FactionTable, EFaction.Knights.ToString()));                           // -- 1
            ISQLiteRow vikingsFaction = FactionTable.Insert(new SQLiteFactionModel(FactionTable, EFaction.Vikings.ToString()));                           // -- 2

            SQLiteUnitModel knightSpearmanUnit = new SQLiteUnitModel(UnitTable, knightFaction.Id, (int)EUnitType.Spearman, 0, knightSpearmanStats.Id, "Spearman");
            SQLiteUnitModel knightFootmanUnit  = new SQLiteUnitModel(UnitTable, knightFaction.Id, (int)EUnitType.Footman, 0, knightFootmanStats.Id, "Footman");
            SQLiteUnitModel knightArcherUnit   = new SQLiteUnitModel(UnitTable, knightFaction.Id, (int)EUnitType.Bowman, 0, knightArcherStats.Id, "Bowman");
            SQLiteUnitModel knightWorkerUnit   = new SQLiteUnitModel(UnitTable, knightFaction.Id, (int)EUnitType.Worker, 0, knightWorkerStats.Id, "Worker");

            SQLiteUnitModel vikingSpearmanUnit = new SQLiteUnitModel(UnitTable, vikingsFaction.Id, (int)EUnitType.Spearman, 0, vikingSpearmanStats.Id, "Spearman");
            SQLiteUnitModel vikingFootmanUnit  = new SQLiteUnitModel(UnitTable, vikingsFaction.Id, (int)EUnitType.Footman, 0, vikingFootmanStats.Id, "Footman");
            SQLiteUnitModel vikingArcherUnit   = new SQLiteUnitModel(UnitTable, vikingsFaction.Id, (int)EUnitType.Bowman, 0, vikingArcherStats.Id, "Bowman");
            SQLiteUnitModel vikingWorkerUnit   = new SQLiteUnitModel(UnitTable, vikingsFaction.Id, (int)EUnitType.Worker, 0, vikingWorkerStats.Id, "Worker");


            UnitTable.Insert(knightSpearmanUnit);                                                                                                               // -- 1
            UnitTable.Insert(knightFootmanUnit);                                                                                                                // -- 2
            UnitTable.Insert(knightArcherUnit);                                                                                                                 // -- 3
            UnitTable.Insert(knightWorkerUnit);                                                                                                                 // -- 4

            UnitTable.Insert(vikingSpearmanUnit);                                                                                                               // -- 5
            UnitTable.Insert(vikingFootmanUnit);                                                                                                                // -- 6
            UnitTable.Insert(vikingArcherUnit);                                                                                                                 // -- 7
            UnitTable.Insert(vikingWorkerUnit);                                                                                                                 // -- 8

            ISQLiteRow vikingArcheryRangeStats     = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 9
            ISQLiteRow vikingBarracksStats         = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 10
            ISQLiteRow vikingBlacksmithStats       = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 11
            ISQLiteRow vikingFieldStats            = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 12
            ISQLiteRow vikingGatheringStationStats = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 13
            ISQLiteRow vikingTowerStats            = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 250, 125, 50, 10, 5f, 400, 40, 2, 0f, 10, 10, 0f, 50)); // -- 14
            ISQLiteRow vikingTownHallStats         = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 15

            ISQLiteRow knightArcheryRangeStats     = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 9
            ISQLiteRow knightBarracksStats         = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 10
            ISQLiteRow knightBlacksmithStats       = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 11
            ISQLiteRow knightFieldStats            = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 12
            ISQLiteRow knightGatheringStationStats = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 13
            ISQLiteRow knightTowerStats            = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 250, 125, 50, 10, 5f, 400, 40, 2, 0f, 10, 10, 0f, 50)); // -- 14
            ISQLiteRow knightTownHallStats         = StatsTable.Insert(new SQLiteStatsModel(StatsTable, 500, 250, 100, 10, 5f, 800, 0, 2, 0f, 10, 10, 0f, 50)); // -- 15

            SQLiteBuildingModel vikingArcheryRangeBuilding     = new SQLiteBuildingModel(BuildingTable, vikingsFaction.Id, (int)EBuildingType.ArcheryRange, 0, vikingArcheryRangeStats.Id, "ArcheryRange");
            SQLiteBuildingModel vikingBarracksBuilding         = new SQLiteBuildingModel(BuildingTable, vikingsFaction.Id, (int)EBuildingType.Barracks, 0, vikingBarracksStats.Id, "Barracks");
            SQLiteBuildingModel vikingBlacksmithBuilding       = new SQLiteBuildingModel(BuildingTable, vikingsFaction.Id, (int)EBuildingType.Blacksmith, 0, vikingBlacksmithStats.Id, "Blacksmith");
            SQLiteBuildingModel vikingFieldBuilding            = new SQLiteBuildingModel(BuildingTable, vikingsFaction.Id, (int)EBuildingType.Field, 0, vikingFieldStats.Id, "Field");
            SQLiteBuildingModel vikingGatheringStationBuilding = new SQLiteBuildingModel(BuildingTable, vikingsFaction.Id, (int)EBuildingType.GatheringStation, 0, vikingGatheringStationStats.Id, "GatheringStation");
            SQLiteBuildingModel vikingTowerBuilding            = new SQLiteBuildingModel(BuildingTable, vikingsFaction.Id, (int)EBuildingType.Tower, 0, vikingTowerStats.Id, "Tower");
            SQLiteBuildingModel vikingTownHallBuilding         = new SQLiteBuildingModel(BuildingTable, vikingsFaction.Id, (int)EBuildingType.TownHall, 0, vikingTownHallStats.Id, "TownHall");

            SQLiteBuildingModel knightArcheryRangeBuilding     = new SQLiteBuildingModel(BuildingTable, knightFaction.Id, (int)EBuildingType.ArcheryRange, 0, knightArcheryRangeStats.Id, "ArcheryRange");
            SQLiteBuildingModel knightBarracksBuilding         = new SQLiteBuildingModel(BuildingTable, knightFaction.Id, (int)EBuildingType.Barracks, 0, knightBarracksStats.Id, "Barracks");
            SQLiteBuildingModel knightBlacksmithBuilding       = new SQLiteBuildingModel(BuildingTable, knightFaction.Id, (int)EBuildingType.Blacksmith, 0, knightBlacksmithStats.Id, "Blacksmith");
            SQLiteBuildingModel knightFieldBuilding            = new SQLiteBuildingModel(BuildingTable, knightFaction.Id, (int)EBuildingType.Field, 0, knightFieldStats.Id, "Field");
            SQLiteBuildingModel knightGatheringStationBuilding = new SQLiteBuildingModel(BuildingTable, knightFaction.Id, (int)EBuildingType.GatheringStation, 0, knightGatheringStationStats.Id, "GatheringStation");
            SQLiteBuildingModel knightTowerBuilding            = new SQLiteBuildingModel(BuildingTable, knightFaction.Id, (int)EBuildingType.Tower, 0, knightTowerStats.Id, "Tower");
            SQLiteBuildingModel knightTownHallBuilding         = new SQLiteBuildingModel(BuildingTable, knightFaction.Id, (int)EBuildingType.TownHall, 0, knightTownHallStats.Id, "TownHall");

            BuildingTable.Insert(vikingArcheryRangeBuilding);     // -- 1
            BuildingTable.Insert(vikingBarracksBuilding);         // -- 2
            BuildingTable.Insert(vikingBlacksmithBuilding);       // -- 3
            BuildingTable.Insert(vikingFieldBuilding);            // -- 4
            BuildingTable.Insert(vikingGatheringStationBuilding); // -- 5
            BuildingTable.Insert(vikingTowerBuilding);            // -- 6
            BuildingTable.Insert(vikingTownHallBuilding);         // -- 7

            BuildingTable.Insert(knightArcheryRangeBuilding);     // -- 8
            BuildingTable.Insert(knightBarracksBuilding);         // -- 9
            BuildingTable.Insert(knightBlacksmithBuilding);       // -- 10
            BuildingTable.Insert(knightFieldBuilding);            // -- 11
            BuildingTable.Insert(knightGatheringStationBuilding); // -- 12
            BuildingTable.Insert(knightTowerBuilding);            // -- 13
            BuildingTable.Insert(knightTownHallBuilding);         // -- 14
        }
예제 #2
0
        public static XotlTable GenerateFromFiles()
        {
            string currentDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
            string tablesFolder     = Path.Combine(currentDirectory, "XotlTables");

            string[] filePaths = Directory.GetFiles(tablesFolder, "*.csv");

            XotlTable generatedTable = new XotlTable();

            foreach (string path in filePaths)
            {
                FactionTable factionTable = new FactionTable();
                string       factionName  = null;

                using (var reader = new StreamReader(path))
                {
                    if (reader != null)
                    {
                        var firstLine   = reader.ReadLine();
                        var firstValues = firstLine.Split(',');

                        factionName = firstValues[0];

                        while (!reader.EndOfStream)
                        {
                            var line   = reader.ReadLine();
                            var values = line.Split(',');

                            if (values[0].StartsWith("Collection:"))
                            {
                                factionTable.Collection.Add(values[0].TrimStart('C', 'o', 'l', 'e', 'c', 't', 'i', 'o', 'n', ':'), ReadWeightLine(values));
                            }
                            else if (values[0].StartsWith("Salvage:"))
                            {
                                factionTable.Salvage.Add(values[0].TrimStart('S', 'a', 'l', 'v', 'a', 'g', 'e', ':'), ReadWeightLine(values));
                            }
                            else if (values[0].Contains("Dates"))
                            {
                                for (int element = 1; element < values.Length; element += 2)
                                {
                                    factionTable.Dates.Add(DateTime.Parse(values[element]));
                                }
                            }
                            else if (values[0].Contains("Lights"))
                            {
                                while (!reader.EndOfStream &&
                                       !values[0].Contains("Mediums"))
                                {
                                    line   = reader.ReadLine();
                                    values = line.Split(',');
                                    if (values[0] != "" &&
                                        !values[0].Contains("Mediums"))
                                    {
                                        factionTable.Mechs.Lights.Add(values[0], ReadWeightLine(values));
                                    }
                                }
                                while (!reader.EndOfStream &&
                                       !values[0].Contains("Heavies"))
                                {
                                    line   = reader.ReadLine();
                                    values = line.Split(',');
                                    if (values[0] != "" &&
                                        !values[0].Contains("Heavies"))
                                    {
                                        factionTable.Mechs.Mediums.Add(values[0], ReadWeightLine(values));
                                    }
                                }
                                while (!reader.EndOfStream &&
                                       !values[0].Contains("Assaults"))
                                {
                                    line   = reader.ReadLine();
                                    values = line.Split(',');
                                    if (values[0] != "" &&
                                        !values[0].Contains("Assaults"))
                                    {
                                        factionTable.Mechs.Heavies.Add(values[0], ReadWeightLine(values));
                                    }
                                }
                                while (!reader.EndOfStream)
                                {
                                    line   = reader.ReadLine();
                                    values = line.Split(',');
                                    if (values[0] != "")
                                    {
                                        factionTable.Mechs.Assaults.Add(values[0], ReadWeightLine(values));
                                    }
                                }
                            }
                        }
                    }
                }

                if (factionName != null)
                {
                    generatedTable.Factions.Add(factionName, factionTable);
                }
            }

            return(generatedTable);
        }