Пример #1
0
        public static List<AvgSpeedReportItem> GetReportData()
        {
            string query =
@"WITH RankedLink AS (
		SELECT ROW_NUMBER() OVER (ORDER BY Link, SegEndC) [Number], *
		FROM dbo.Olaine_LINK_EVAL),
	MiddleLink AS (
		SELECT AVG(Number) [MiddleLink]
		FROM RankedLink
		GROUP BY Link),
	AvgSpeed AS (
		SELECT AVG(v__0_) [speed], Link
		FROM dbo.Olaine_LINK_EVAL
		GROUP BY Link)

SELECT RankedLink.Link, 0 [Lane], (SegStX + SegEndX)/2 [center.x], (SegStY + SegEndY)/2 [center.y], AvgSpeed.speed
FROM RankedLink
	JOIN MiddleLink ON RankedLink.Number=MiddleLink.MiddleLink
	JOIN AvgSpeed ON RankedLink.Link=AvgSpeed.Link";

            var list = new List<AvgSpeedReportItem>();

            try
            {
                var sb = new OleDbConnectionStringBuilder(vissim.Instance.Evaluation.Wrap().GetConnectionString());
                if (sb.ContainsKey("Password"))
                {
                    using (var conn = new OleDbConnection(sb.ConnectionString))
                    {
                        conn.Open();
                        try
                        {
                            using (var reader = new OleDbCommand(query, conn).ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    list.Add(new AvgSpeedReportItem()
                                    {
                                        Link = reader.GetInt32(0),
                                        Lane = reader.GetInt32(1),
                                        Center = new Point(reader.GetDouble(2), reader.GetDouble(3)),
                                        AvgSpeed = reader.GetDouble(4)
                                    });
                                }
                            }
                        }
                        finally
                        {
                            conn.Close();
                        }
                    }
                }
            }
            catch { }

            return list;
        }
Пример #2
0
        public void ImportDataFromExcelEquity()
        {

            string excelFilePath = "C:/Users/ahksysuser06/Desktop/EDISData/International_Equity_Daily_Closing_Price_20131211.xlsx";
            // make sure your sheet name is correct, here sheet name is sheet1, so you can change the sheet name if have    different 
            string excelQuery = "select SecId,Name,Symbol from [Sheet1$]";
            try
            {
                string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFilePath +
                ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;'";
                OleDbConnection oleConn = new OleDbConnection(excelConnectionString);
                oleConn.Open();
                OleDbDataReader oleReader = new OleDbCommand(excelQuery, oleConn).ExecuteReader();
                //while (oleReader.Read())
                //{
                //    Domain.Portfolio.AggregateRoots.Asset.Equity equity = new AustralianEquity(edisRepo)
                //    {
                //        Name = oleReader.GetString(1),
                //        Sector = oleReader.GetString(0),
                //        Ticker = oleReader.GetString(2),
                //        EquityType = EquityTypes.AustralianEquity,
                //    };

                //    edisRepo.InsertEquityData(equity);
                //}
                while (oleReader.Read())
                {
                    Domain.Portfolio.AggregateRoots.Asset.Equity equity = new InternationalEquity(edisRepo)
                    {
                        Name = oleReader.GetString(1),
                        Sector = oleReader.GetString(0),
                        Ticker = oleReader.GetString(2),
                        EquityType = EquityTypes.InternationalEquity,
                    };

                    edisRepo.InsertEquityData(equity);
                }
                oleReader.Close();
                oleConn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #3
0
 public List<string> LoadIdealTendencyKind(OleDbConnection connection, GameScenario scen)
 {
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From IdealTendencyKind", connection).ExecuteReader();
     while (reader.Read())
     {
         IdealTendencyKind t = new IdealTendencyKind();
         t.Scenario = scen;
         t.ID = (short)reader["ID"];
         t.Name = reader["Name"].ToString();
         t.Offset = (short)reader["Offset"];
         this.AllIdealTendencyKinds.Add(t);
     }
     connection.Close();
     return new List<string>();
 }
Пример #4
0
        public bool LoadFromDatabase(string connectionString)
        {
            int num;
            Animation animation;
            OleDbConnection connection = new OleDbConnection(connectionString);
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From TerrainDetail", connection).ExecuteReader();
            while (reader.Read())
            {
                TerrainDetail terrainDetail = new TerrainDetail();
                terrainDetail.ID = (short)reader["ID"];
                terrainDetail.Name = reader["Name"].ToString();
                terrainDetail.GraphicLayer = (int)reader["GraphicLayer"];
                terrainDetail.ViewThrough = (bool)reader["ViewThrough"];
                terrainDetail.RoutewayBuildFundCost = (int)reader["RoutewayBuildFundCost"];
                terrainDetail.RoutewayActiveFundCost = (int)reader["RoutewayActiveFundCost"];
                terrainDetail.RoutewayBuildWorkCost = (int)reader["RoutewayBuildWorkCost"];
                terrainDetail.RoutewayConsumptionRate = (float)reader["RoutewayConsumptionRate"];
                terrainDetail.FoodDeposit = (int)reader["FoodDeposit"];
                terrainDetail.FoodRegainDays = (int)reader["FoodRegainDays"];
                terrainDetail.FoodSpringRate = (float)reader["FoodSpringRate"];
                terrainDetail.FoodSummerRate = (float)reader["FoodSummerRate"];
                terrainDetail.FoodAutumnRate = (float)reader["FoodAutumnRate"];
                terrainDetail.FoodWinterRate = (float)reader["FoodWinterRate"];
                terrainDetail.FireDamageRate = (float)reader["FireDamageRate"];
                this.AllTerrainDetails.AddTerrainDetail(terrainDetail);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Color", connection).ExecuteReader();
            while (reader.Read())
            {
                Color item = new Color();
                item.PackedValue = uint.Parse(reader["Code"].ToString());
                this.AllColors.Add(item);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From IdealTendencyKind", connection).ExecuteReader();
            while (reader.Read())
            {
                IdealTendencyKind t = new IdealTendencyKind();
                t.ID = (short)reader["ID"];
                t.Name = reader["Name"].ToString();
                t.Offset = (short)reader["Offset"];
                this.AllIdealTendencyKinds.Add(t);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From CharacterKind", connection).ExecuteReader();
            while (reader.Read())
            {
                CharacterKind kind2 = new CharacterKind();
                kind2.ID = (short)reader["ID"];
                kind2.Name = reader["Name"].ToString();
                kind2.IntelligenceRate = (float)reader["IntelligenceRate"];
                kind2.ChallengeChance = (short)reader["ChallengeChance"];
                kind2.ControversyChance = (short)reader["ControversyChance"];
                this.AllCharacterKinds.Add(kind2);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From ArchitectureKind", connection).ExecuteReader();
            while (reader.Read())
            {
                ArchitectureKind architectureKind = new ArchitectureKind();
                architectureKind.ID = (short)reader["ID"];
                architectureKind.Name = reader["Name"].ToString();
                architectureKind.AgricultureBase = (short)reader["AgricultureBase"];
                architectureKind.AgricultureUnit = (short)reader["AgricultureUnit"];
                architectureKind.CommerceBase = (short)reader["CommerceBase"];
                architectureKind.CommerceUnit = (short)reader["CommerceUnit"];
                architectureKind.TechnologyBase = (short)reader["TechnologyBase"];
                architectureKind.TechnologyUnit = (short)reader["TechnologyUnit"];
                architectureKind.DominationBase = (short)reader["DominationBase"];
                architectureKind.DominationUnit = (short)reader["DominationUnit"];
                architectureKind.MoraleBase = (short)reader["MoraleBase"];
                architectureKind.MoraleUnit = (short)reader["MoraleUnit"];
                architectureKind.EnduranceBase = (short)reader["EnduranceBase"];
                architectureKind.EnduranceUnit = (short)reader["EnduranceUnit"];
                architectureKind.PopulationBase = (int)reader["PopulationBase"];
                architectureKind.PopulationUnit = (int)reader["PopulationUnit"];
                architectureKind.PopulationBoundary = (int)reader["PopulationBoundary"];
                architectureKind.ViewDistance = (short)reader["ViewDistance"];
                architectureKind.ViewDistanceIncrementDivisor = (short)reader["VDIncrementDivisor"];
                architectureKind.HasObliqueView = (bool)reader["HasObliqueView"];
                architectureKind.HasLongView = (bool)reader["HasLongView"];
                architectureKind.HasPopulation = (bool)reader["HasPopulation"];
                architectureKind.HasAgriculture = (bool)reader["HasAgriculture"];
                architectureKind.HasCommerce = (bool)reader["HasCommerce"];
                architectureKind.HasTechnology = (bool)reader["HasTechnology"];
                architectureKind.HasDomination = (bool)reader["HasDomination"];
                architectureKind.HasMorale = (bool)reader["HasMorale"];
                architectureKind.HasEndurance = (bool)reader["HasEndurance"];
                architectureKind.HasHarbor = (bool)reader["HasHarbor"];
                architectureKind.FacilityPositionUnit = (short)reader["FacilityPositionUnit"];
                architectureKind.FundMaxUnit = (int)reader["FundMaxUnit"];
                architectureKind.FoodMaxUnit = (int)reader["FoodMaxUnit"];
                try
                {
                    architectureKind.CountToMerit = (bool)reader["CountToMerit"];
                }
                catch (Exception)
                {
                    architectureKind.CountToMerit = architectureKind.ID == 1 ? true : false;
                }
                this.AllArchitectureKinds.AddArchitectureKind(architectureKind);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From SectionAIDetail", connection).ExecuteReader();
            while (reader.Read())
            {
                SectionAIDetail sectionAIDetail = new SectionAIDetail();
                sectionAIDetail.ID = (short)reader["ID"];
                sectionAIDetail.Name = reader["Name"].ToString();
                sectionAIDetail.Description = reader["Description"].ToString();
                sectionAIDetail.OrientationKind = (SectionOrientationKind)((short)reader["OrientationKind"]);
                sectionAIDetail.AutoRun = (bool)reader["AutoRun"];
                sectionAIDetail.ValueAgriculture = (bool)reader["ValueAgriculture"];
                sectionAIDetail.ValueCommerce = (bool)reader["ValueCommerce"];
                sectionAIDetail.ValueTechnology = (bool)reader["ValueTechnology"];
                sectionAIDetail.ValueDomination = (bool)reader["ValueDomination"];
                sectionAIDetail.ValueMorale = (bool)reader["ValueMorale"];
                sectionAIDetail.ValueEndurance = (bool)reader["ValueEndurance"];
                sectionAIDetail.ValueTraining = (bool)reader["ValueTraining"];
                sectionAIDetail.ValueRecruitment = (bool)reader["ValueRecruitment"];
                sectionAIDetail.ValueNewMilitary = (bool)reader["ValueNewMilitary"];
                sectionAIDetail.ValueOffensiveCampaign = (bool)reader["ValueOffensiveCampaign"];
                sectionAIDetail.AllowInvestigateTactics = (bool)reader["AllowInvestigateTactics"];
                sectionAIDetail.AllowOffensiveTactics = (bool)reader["AllowOffensiveTactics"];
                sectionAIDetail.AllowPersonTactics = (bool)reader["AllowPersonTactics"];
                sectionAIDetail.AllowOffensiveCampaign = (bool)reader["AllowOffensiveCampaign"];
                sectionAIDetail.AllowFundTransfer = (bool)reader["AllowFundTransfer"];
                sectionAIDetail.AllowFoodTransfer = (bool)reader["AllowFoodTransfer"];
                sectionAIDetail.AllowMilitaryTransfer = (bool)reader["AllowMilitaryTransfer"];
                try
                {
                    sectionAIDetail.AllowFacilityRemoval = (bool)reader["AllowFacilityRemoval"];
                }
                catch
                {
                    sectionAIDetail.AllowFacilityRemoval = true;
                }
                this.AllSectionAIDetails.AddSectionAIDetail(sectionAIDetail);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From InfluenceKind", connection).ExecuteReader();
            while (reader.Read())
            {
                num = (short)reader["ID"];
                InfluenceKind ik = InfluenceKindFactory.CreateInfluenceKindByID(num);
                if (ik != null)
                {
                    ik.ID = num;
                    ik.Type = (InfluenceType)((short)reader["Type"]);
                    ik.Name = reader["Name"].ToString();
                    try
                    {
                        ik.Combat = (bool)reader["Combat"];
                    }
                    catch
                    {
                        ik.Combat = true;
                    }
                    this.AllInfluenceKinds.AddInfluenceKind(ik);
                }
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Influence", connection).ExecuteReader();
            while (reader.Read())
            {
                Influence influence = new Influence();
                influence.ID = (short)reader["ID"];
                influence.Name = reader["Name"].ToString();
                influence.Description = reader["Description"].ToString();
                influence.Parameter = reader["Parameter"].ToString();
                influence.Parameter2 = reader["Parameter2"].ToString();
                influence.Kind = this.AllInfluenceKinds.GetInfluenceKind((short)reader["Kind"]);
                if (influence.Kind != null)
                {
                    this.AllInfluences.AddInfluence(influence);
                }
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From ConditionKind", connection).ExecuteReader();
            while (reader.Read())
            {
                num = (short)reader["ID"];
                ConditionKind ck = ConditionKindFactory.CreateConditionKindByID(num);
                if (ck != null)
                {
                    ck.ID = num;
                    ck.Name = reader["Name"].ToString();
                    this.AllConditionKinds.AddConditionKind(ck);
                }
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Condition", connection).ExecuteReader();
            while (reader.Read())
            {
                Condition condition = new Condition();
                condition.ID = (short)reader["ID"];
                condition.Name = reader["Name"].ToString();
                condition.Parameter = reader["Parameter"].ToString();
                condition.Parameter2 = reader["Parameter2"].ToString();
                condition.Kind = this.AllConditionKinds.GetConditionKind((short)reader["Kind"]);
                this.AllConditions.AddCondition(condition);
            }
            connection.Close();

            ///

            connection.Open();
            reader = new OleDbCommand("Select * From TroopEventEffectKind", connection).ExecuteReader();
            while (reader.Read())
            {
                num = (short)reader["ID"];
                EventEffectKind e = EventEffectKindFactory.CreateEventEffectKindByID(num);
                if (e != null)
                {
                    e.ID = num;
                    e.Name = reader["Name"].ToString();
                    this.AllTroopEventEffectKinds.AddEventEffectKind(e);
                }
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From TroopEventEffect", connection).ExecuteReader();
            while (reader.Read())
            {
                GameObjects.TroopDetail.EventEffect.EventEffect effect = new GameObjects.TroopDetail.EventEffect.EventEffect();
                effect.ID = (short)reader["ID"];
                effect.Name = reader["Name"].ToString();
                effect.Parameter = reader["Parameter"].ToString();
                effect.Kind = this.AllTroopEventEffectKinds.GetEventEffectKind((short)reader["Kind"]);
                this.AllTroopEventEffects.AddEventEffect(effect);
            }
            connection.Close();

            //////////////////////////////////////////////////////////

            connection.Open();
            reader = new OleDbCommand("Select * From EventEffectKind", connection).ExecuteReader();
            while (reader.Read())
            {
                num = (short)reader["ID"];
                GameObjects.ArchitectureDetail.EventEffect.EventEffectKind e = GameObjects.ArchitectureDetail.EventEffect.EventEffectKindFactory.CreateEventEffectKindByID(num);
                if (e != null)
                {
                    e.ID = num;
                    e.Name = reader["Name"].ToString();
                    this.AllEventEffectKinds.AddEventEffectKind(e);
                }
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From EventEffect", connection).ExecuteReader();
            while (reader.Read())
            {
                GameObjects.ArchitectureDetail.EventEffect.EventEffect effect = new GameObjects.ArchitectureDetail.EventEffect.EventEffect();
                effect.ID = (short)reader["ID"];
                effect.Name = reader["Name"].ToString();
                effect.Parameter = reader["Parameter"].ToString();
                effect.Parameter2 = reader["Parameter2"].ToString();
                effect.Kind = this.AllEventEffectKinds.GetEventEffectKind((short)reader["Kind"]);
                this.AllEventEffects.AddEventEffect(effect);
            }
            connection.Close();

            //////

            connection.Open();
            reader = new OleDbCommand("Select * From FacilityKind", connection).ExecuteReader();
            while (reader.Read())
            {
                FacilityKind facilityKind = new FacilityKind();
                facilityKind.ID = (short)reader["ID"];
                facilityKind.Name = reader["Name"].ToString();
                try
                {
                    facilityKind.AILevel = (float)reader["AILevel"];
                }
                catch
                {
                    facilityKind.AILevel = 1;
                }
                facilityKind.PositionOccupied = (int)reader["PositionOccupied"];
                facilityKind.TechnologyNeeded = (int)reader["TechnologyNeeded"];
                facilityKind.FundCost = (int)reader["FundCost"];
                facilityKind.PointCost = (int)reader["PointCost"];
                facilityKind.MaintenanceCost = (int)reader["MaintenanceCost"];
                facilityKind.Days = (short)reader["Days"];
                facilityKind.Endurance = (int)reader["Endurance"];
                facilityKind.UniqueInArchitecture = (bool)reader["UniqueInArchitecture"];
                facilityKind.UniqueInFaction = (bool)reader["UniqueInFaction"];
                facilityKind.PopulationRelated = (bool)reader["PopulationRelated"];
                facilityKind.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                facilityKind.rongna = (short)reader["rongna"];
                facilityKind.bukechaichu = (bool)reader["bukechaichu"];
                facilityKind.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString());
                this.AllFacilityKinds.AddFacilityKind(facilityKind);
            }
            connection.Close();

            ///////////////////////////////////////////////////////////////////////
            connection.Open();
            reader = new OleDbCommand("Select * From DisasterKind", connection).ExecuteReader();
            while (reader.Read())
            {
                zainanzhongleilei zainanzhonglei = new zainanzhongleilei();

                zainanzhonglei.ID = (short)reader["ID"];
                zainanzhonglei.Name = reader["名称"].ToString();
                zainanzhonglei.shijianxiaxian = (short)reader["时间下限"];
                zainanzhonglei.shijianshangxian = (short)reader["时间上限"];

                zainanzhonglei.renkoushanghai = (short)reader["人口伤害"];
                zainanzhonglei.tongzhishanghai = (short)reader["统治伤害"];
                zainanzhonglei.naijiushanghai = (short)reader["耐久伤害"];
                zainanzhonglei.nongyeshanghai = (short)reader["农业伤害"];
                zainanzhonglei.shangyeshanghai = (short)reader["商业伤害"];
                zainanzhonglei.jishushanghai = (short)reader["技术伤害"];
                zainanzhonglei.minxinshanghai = (short)reader["民心伤害"];

                this.suoyouzainanzhonglei.Addzainanzhonglei(zainanzhonglei);
            }

            connection.Close();

            ///////////////////////////////////////////////////////////////////////

            ///////////////////////////////////////////////////////////////////////
            connection.Open();
            reader = new OleDbCommand("Select * From guanjuezhonglei", connection).ExecuteReader();
            while (reader.Read())
            {
                guanjuezhongleilei guanjuedezhonglei = new guanjuezhongleilei();

                guanjuedezhonglei.ID = (short)reader["ID"];
                guanjuedezhonglei.Name = reader["名称"].ToString();
                guanjuedezhonglei.shengwangshangxian = (int)reader["声望上限"];
                guanjuedezhonglei.xuyaogongxiandu = (int)reader["需要贡献度"];

                guanjuedezhonglei.xuyaochengchi = (short)reader["需要城池"];

                this.suoyouguanjuezhonglei.Addguanjuedezhonglei(guanjuedezhonglei);
            }

            connection.Close();

            ///////////////////////////////////////////////////////////////////////

            connection.Open();
            reader = new OleDbCommand("Select * From Technique", connection).ExecuteReader();
            while (reader.Read())
            {
                Technique technique = new Technique();
                technique.ID = (short)reader["ID"];
                technique.Kind = (short)reader["Kind"];
                technique.DisplayRow = (short)reader["DisplayRow"];
                technique.DisplayCol = (short)reader["DisplayCol"];
                technique.Name = reader["Name"].ToString();
                technique.Description = reader["Description"].ToString();
                technique.PreID = (short)reader["PreID"];
                technique.PostID = (short)reader["PostID"];
                technique.Reputation = (int)reader["Reputation"];
                technique.FundCost = (int)reader["FundCost"];
                technique.PointCost = (int)reader["PointCost"];
                technique.Days = (short)reader["Days"];
                technique.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                this.AllTechniques.AddTechnique(technique);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Skill", connection).ExecuteReader();
            while (reader.Read())
            {
                Skill skill = new Skill();
                skill.ID = (short)reader["ID"];
                skill.DisplayRow = (short)reader["DisplayRow"];
                skill.DisplayCol = (short)reader["DisplayCol"];
                skill.Kind = (short)reader["Kind"];
                skill.Level = (short)reader["Level"];
                skill.Combat = (bool)reader["Combat"];
                skill.Name = reader["Name"].ToString();
                skill.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                skill.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString());
                this.AllSkills.AddSkill(skill);
            }
            connection.Close();

            int titleKindShift = 0;
            connection.Open();
            try
            {
                reader = new OleDbCommand("Select * From TitleKind", connection).ExecuteReader();
                while (reader.Read())
                {
                    TitleKind tk = new TitleKind();
                    tk.ID = (short)reader["ID"];
                    tk.Name = reader["KName"].ToString();
                    tk.Combat = (bool)reader["Combat"];
                    tk.StudyDay = (short)reader["StudyDay"];
                    tk.SuccessRate = (short)reader["SuccessRate"];
                    this.AllTitleKinds.AddTitleKind(tk);
                }
            }
            catch
            {
                TitleKind tk = new TitleKind();
                tk.ID = 1;
                tk.Name = "个人称号";
                tk.Combat = false;
                tk.StudyDay = 90;
                this.AllTitleKinds.AddTitleKind(tk);
                tk = new TitleKind();
                tk.ID = 2;
                tk.Name = "战斗称号";
                tk.Combat = true;
                tk.StudyDay = 90;
                this.AllTitleKinds.AddTitleKind(tk);
                titleKindShift = 1;
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Title", connection).ExecuteReader();
            while (reader.Read())
            {
                Title title = new Title();
                title.ID = (short)reader["ID"];
                title.Kind = this.AllTitleKinds.GetTitleKind((short)reader["Kind"] + titleKindShift);
                title.Level = (short)reader["Level"];
                title.Combat = (bool)reader["Combat"];
                title.Name = reader["Name"].ToString();
                title.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                title.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString());
                this.AllTitles.AddTitle(title);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From MilitaryKind", connection).ExecuteReader();
            while (reader.Read())
            {
                MilitaryKind militaryKind = new MilitaryKind();
                militaryKind.ID = (short)reader["ID"];
                militaryKind.Type = (MilitaryType)((short)reader["Type"]);
                militaryKind.Name = reader["Name"].ToString();
                militaryKind.Description = reader["Description"].ToString();
                militaryKind.Merit = (short)reader["Merit"];
                militaryKind.Speed = (short)reader["Speed"];
                militaryKind.TitleInfluence = (short)reader["TitleInfluence"];
                militaryKind.CreateCost = (int)reader["CreateCost"];
                militaryKind.CreateTechnology = (int)reader["CreateTechnology"];
                militaryKind.IsShell = (bool)reader["IsShell"];
                militaryKind.CreateBesideWater = (bool)reader["CreateBesideWater"];
                militaryKind.Offence = (short)reader["Offence"];
                militaryKind.Defence = (short)reader["Defence"];
                militaryKind.OffenceRadius = (short)reader["OffenceRadius"];
                militaryKind.CounterOffence = (bool)reader["CounterOffence"];
                militaryKind.BeCountered = (bool)reader["BeCountered"];
                militaryKind.ObliqueOffence = (bool)reader["ObliqueOffence"];
                militaryKind.ArrowOffence = (bool)reader["ArrowOffence"];
                militaryKind.AirOffence = (bool)reader["AirOffence"];
                militaryKind.ContactOffence = (bool)reader["ContactOffence"];
                militaryKind.OffenceOnlyBeforeMove = (bool)reader["OffenceOnlyBeforeMove"];
                militaryKind.ArchitectureDamageRate = (float)reader["ArchitectureDamageRate"];
                militaryKind.ArchitectureCounterDamageRate = (float)reader["ArchitectureCounterDamageRate"];
                militaryKind.StratagemRadius = (short)reader["StratagemRadius"];
                militaryKind.ObliqueStratagem = (bool)reader["ObliqueStratagem"];
                militaryKind.ViewRadius = (short)reader["ViewRadius"];
                militaryKind.ObliqueView = (bool)reader["ObliqueView"];
                militaryKind.Movability = (short)reader["Movability"];
                militaryKind.OneAdaptabilityKind = (short)reader["OneAdaptabilityKind"];
                militaryKind.PlainAdaptability = (short)reader["PlainAdaptability"];
                militaryKind.GrasslandAdaptability = (short)reader["GrasslandAdaptability"];
                militaryKind.ForrestAdaptability = (short)reader["ForrestAdaptability"];
                militaryKind.MarshAdaptability = (short)reader["MarshAdaptability"];
                militaryKind.MountainAdaptability = (short)reader["MountainAdaptability"];
                militaryKind.WaterAdaptability = (short)reader["WaterAdaptability"];
                militaryKind.RidgeAdaptability = (short)reader["RidgeAdaptability"];
                militaryKind.WastelandAdaptability = (short)reader["WastelandAdaptability"];
                militaryKind.DesertAdaptability = (short)reader["DesertAdaptability"];
                militaryKind.CliffAdaptability = (short)reader["CliffAdaptability"];
                militaryKind.PlainRate = (float)reader["PlainRate"];
                militaryKind.GrasslandRate = (float)reader["GrasslandRate"];
                militaryKind.ForrestRate = (float)reader["ForrestRate"];
                militaryKind.MarshRate = (float)reader["MarshRate"];
                militaryKind.MountainRate = (float)reader["MountainRate"];
                militaryKind.WaterRate = (float)reader["WaterRate"];
                militaryKind.RidgeRate = (float)reader["RidgeRate"];
                militaryKind.WastelandRate = (float)reader["WastelandRate"];
                militaryKind.DesertRate = (float)reader["DesertRate"];
                militaryKind.CliffRate = (float)reader["CliffRate"];
                militaryKind.InjuryChance = (short)reader["InjuryRate"];
                try
                {
                    militaryKind.FireDamageRate = (float)reader["FireDamageRate"];
                    militaryKind.RecruitLimit = (int)reader["RecruitLimit"];
                }
                catch
                {
                    try
                    {
                        militaryKind.FireDamageRate = (bool)reader["AfraidOfFire"] ? 3.0f : 1.0f;
                        militaryKind.RecruitLimit = (bool)reader["Unique"] ? 1 : 1000;
                    }
                    catch
                    {
                        militaryKind.FireDamageRate = 1.0f;
                        militaryKind.RecruitLimit = 10000;
                    }
                }
                militaryKind.FoodPerSoldier = (short)reader["FoodPerSoldier"];
                militaryKind.RationDays = (int)reader["RationDays"];
                militaryKind.PointsPerSoldier = (int)reader["PointsPerSoldier"];
                militaryKind.MinScale = (int)reader["MinScale"];
                militaryKind.MaxScale = (int)reader["MaxScale"];
                militaryKind.OffencePerScale = (short)reader["OffencePerScale"];
                militaryKind.DefencePerScale = (short)reader["DefencePerScale"];
                militaryKind.CanLevelUp = (bool)reader["CanLevelUp"];
                militaryKind.LevelUpKindID = (short)reader["LevelUpKindID"];
                militaryKind.LevelUpExperience = (int)reader["LevelUpExperience"];
                militaryKind.OffencePer100Experience = (short)reader["OffencePer100Experience"];
                militaryKind.DefencePer100Experience = (short)reader["DefencePer100Experience"];
                militaryKind.AttackDefaultKind = (TroopAttackDefaultKind)((short)reader["AttackDefaultKind"]);
                militaryKind.AttackTargetKind = (TroopAttackTargetKind)((short)reader["AttackTargetKind"]);
                militaryKind.CastDefaultKind = (TroopCastDefaultKind)((short)reader["CastDefaultKind"]);
                militaryKind.CastTargetKind = (TroopCastTargetKind)((short)reader["CastTargetKind"]);
                militaryKind.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                militaryKind.zijinshangxian = (int)reader["zijinshangxian"];
                this.AllMilitaryKinds.AddMilitaryKind(militaryKind);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From MilitaryKind", connection).ExecuteReader();
            while (reader.Read())
            {
                MilitaryKind current = this.AllMilitaryKinds.GetMilitaryKindList().GetGameObject((short)reader["ID"]) as MilitaryKind;
                current.successor = new MilitaryKindTable();
                current.successor.LoadFromString(this.AllMilitaryKinds, reader["Successor"].ToString());
            }
            connection.Close();

            connection.Open();
            reader = new OleDbCommand("Select * From InformationKind", connection).ExecuteReader();
            while (reader.Read())
            {
                InformationKind kind9 = new InformationKind();
                kind9.ID = (short)reader["ID"];
                kind9.Level = (InformationLevel)((short)reader["iLevel"]);
                kind9.Oblique = (bool)reader["Oblique"];
                kind9.Radius = (short)reader["Radius"];
                kind9.CostFund = (int)reader["CostFund"];
                this.AllInformationKinds.Add(kind9);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From AttackDefaultKind", connection).ExecuteReader();
            while (reader.Read())
            {
                AttackDefaultKind kind10 = new AttackDefaultKind();
                kind10.ID = (short)reader["ID"];
                kind10.Name = reader["Name"].ToString();
                this.AllAttackDefaultKinds.Add(kind10);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From AttackTargetKind", connection).ExecuteReader();
            while (reader.Read())
            {
                AttackTargetKind kind11 = new AttackTargetKind();
                kind11.ID = (short)reader["ID"];
                kind11.Name = reader["Name"].ToString();
                this.AllAttackTargetKinds.Add(kind11);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From CombatMethod", connection).ExecuteReader();
            while (reader.Read())
            {
                CombatMethod combatMethod = new CombatMethod();
                combatMethod.ID = (short)reader["ID"];
                combatMethod.Name = reader["Name"].ToString();
                combatMethod.Description = reader["Description"].ToString();
                combatMethod.Combativity = (short)reader["Combativity"];
                combatMethod.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                combatMethod.AttackDefault = this.AllAttackDefaultKinds.GetGameObject((short)reader["AttackDefault"]) as AttackDefaultKind;
                combatMethod.AttackTarget = this.AllAttackTargetKinds.GetGameObject((short)reader["AttackTarget"]) as AttackTargetKind;
                combatMethod.ArchitectureTarget = (bool)reader["ArchitectureTarget"];
                combatMethod.CastConditions.LoadFromString(this.AllConditions, reader["CastConditions"].ToString());
                combatMethod.ViewingHostile = (bool)reader["ViewingHostile"];
                combatMethod.AnimationKind = (TileAnimationKind)((short)reader["AnimationKind"]);
                this.AllCombatMethods.AddCombatMethod(combatMethod);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Stunt", connection).ExecuteReader();
            while (reader.Read())
            {
                Stunt stunt = new Stunt();
                stunt.ID = (short)reader["ID"];
                stunt.Name = reader["Name"].ToString();
                stunt.Combativity = (short)reader["Combativity"];
                stunt.Period = (short)reader["Period"];
                stunt.Animation = (short)reader["Animation"];
                stunt.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                stunt.CastConditions.LoadFromString(this.AllConditions, reader["CastConditions"].ToString());
                stunt.LearnConditions.LoadFromString(this.AllConditions, reader["LearnConditions"].ToString());
                stunt.AIConditions.LoadFromString(this.AllConditions, reader["AIConditions"].ToString());
                this.AllStunts.AddStunt(stunt);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From CastDefaultKind", connection).ExecuteReader();
            while (reader.Read())
            {
                CastDefaultKind kind12 = new CastDefaultKind();
                kind12.ID = (short)reader["ID"];
                kind12.Name = reader["Name"].ToString();
                this.AllCastDefaultKinds.Add(kind12);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From CastTargetKind", connection).ExecuteReader();
            while (reader.Read())
            {
                CastTargetKind kind13 = new CastTargetKind();
                kind13.ID = (short)reader["ID"];
                kind13.Name = reader["Name"].ToString();
                this.AllCastTargetKinds.Add(kind13);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Stratagem", connection).ExecuteReader();
            while (reader.Read())
            {
                Stratagem stratagem = new Stratagem();
                stratagem.ID = (short)reader["ID"];
                stratagem.Name = reader["Name"].ToString();
                stratagem.Description = reader["Description"].ToString();
                stratagem.Combativity = (short)reader["Combativity"];
                stratagem.Chance = (short)reader["Chance"];
                stratagem.TechniquePoint = (int)reader["TechniquePoint"];
                stratagem.Friendly = (bool)reader["Friendly"];
                stratagem.Self = (bool)reader["Self"];
                stratagem.AnimationKind = (TileAnimationKind)((short)reader["AnimationKind"]);
                stratagem.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                stratagem.CastDefault = this.AllCastDefaultKinds.GetGameObject((short)reader["CastDefault"]) as CastDefaultKind;
                stratagem.CastTarget = this.AllCastTargetKinds.GetGameObject((short)reader["CastTarget"]) as CastTargetKind;
                stratagem.ArchitectureTarget = (bool)reader["ArchitectureTarget"];
                stratagem.RequireInfluenceToUse = (bool)reader["RequireInfluneceToUse"];
                this.AllStratagems.AddStratagem(stratagem);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From TroopAnimation", connection).ExecuteReader();
            while (reader.Read())
            {
                animation = new Animation();
                animation.ID = (short)reader["ID"];
                animation.Name = reader["Name"].ToString();
                animation.FrameCount = (short)reader["FrameCount"];
                animation.StayCount = (short)reader["StayCount"];
                this.AllTroopAnimations.AddAnimation(animation);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From TileAnimation", connection).ExecuteReader();
            while (reader.Read())
            {
                animation = new Animation();
                animation.ID = (short)reader["ID"];
                animation.Name = reader["Name"].ToString();
                animation.FrameCount = (short)reader["FrameCount"];
                animation.StayCount = (short)reader["StayCount"];
                animation.Back = (bool)reader["Back"];
                this.AllTileAnimations.AddAnimation(animation);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From Biography", connection).ExecuteReader();
            while (reader.Read())
            {
                Biography biography = new Biography();
                biography.ID = (short)reader["ID"];
                biography.Brief = reader["Brief"].ToString();
                biography.Romance = reader["Romance"].ToString();
                biography.History = reader["History"].ToString();
                biography.FactionColor = (short)reader["FactionColor"];
                biography.MilitaryKinds.LoadFromString(this.AllMilitaryKinds, reader["MilitaryKinds"].ToString());
                this.AllBiographies.AddBiography(biography);
            }
            connection.Close();

            connection.Open();
            try
            {
                reader = new OleDbCommand("Select * From TextMessageMap", connection).ExecuteReader();
                while (reader.Read())
                {
                    int pid = (short)reader["Person"];
                    TextMessageKind kind = (TextMessageKind) (short) reader["Kind"];
                    List<string> messages = new List<string>();
                    StaticMethods.LoadFromString(messages, reader["Messages"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, kind, messages);
                }
            }
            catch
            {
                reader = new OleDbCommand("Select * From TextMessage", connection).ExecuteReader();
                while (reader.Read())
                {
                    int pid = (short)reader["ID"];

                    List<string> messages = new List<string>();
                    StaticMethods.LoadFromString(messages, reader["CriticalStrike"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Critical, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["CriticalStrikeOnArchitecture"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.CriticalArchitecture, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["ReceiveCriticalStrike"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.BeCritical, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["Surround"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Surround, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["Rout"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Rout, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["DualInitiativeWin"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.DualActiveWin, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["DualPassiveWin"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.DualPassiveWin, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["ControversyInitiativeWin"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ControversyActiveWin, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["ControversyPassiveWin"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ControversyPassiveWin, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["Chaos"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Chaos, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["DeepChaos"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.DeepChaos, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["CastDeepChaos"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.CastDeepChaos, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["RecoverFromChaos"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.RecoverChaos, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["TrappedByStratagem"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.TrappedByStratagem, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["HelpedByStratagem"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.HelpedByStratagem, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["ResistHarmfulStratagem"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ResistHarmfulStratagem, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["ResistHelpfulStratagem"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.ResistHelpfulStratagem, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["AntiAttack"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.AntiAttack, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["BreakWall"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.BreakWall, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["OutburstAngry"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Angry, messages);

                    messages.Clear();
                    StaticMethods.LoadFromString(messages, reader["OutburstQuiet"].ToString());
                    this.AllTextMessages.AddTextMessages(pid, TextMessageKind.Calm, messages);
                }
            }
            connection.Close();

            connection.Open();
            try
            {
                reader = new OleDbCommand("Select * From BiographyAdjectives", connection).ExecuteReader();
                while (reader.Read())
                {
                    int t;
                    BiographyAdjectives b = new BiographyAdjectives();
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Strength"].ToString(), out t);
                    b.Strength = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Command"].ToString(), out t);
                    b.Command = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Intelligence"].ToString(), out t);
                    b.Intelligence = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Politics"].ToString(), out t);
                    b.Politics = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Glamour"].ToString(), out t);
                    b.Glamour = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Braveness"].ToString(), out t);
                    b.Braveness = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Calmness"].ToString(), out t);
                    b.Calmness = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["PersonalLoyalty"].ToString(), out t);
                    b.PersonalLoyalty = t;
                    b.ID = (short)reader["ID"];
                    int.TryParse(reader["Ambition"].ToString(), out t);
                    b.Ambition = t;
                    b.Male = (bool)reader["Male"];
                    b.Female = (bool)reader["Female"];
                    StaticMethods.LoadFromString(b.Text, reader["BioText"].ToString());
                    StaticMethods.LoadFromString(b.SuffixText, reader["SuffixText"].ToString());
                    this.AllBiographyAdjectives.Add(b);
                }
            }
            catch
            {
            }
            connection.Close();

            return true;
        }
Пример #5
0
 public List<string> LoadTroopAnimation(OleDbConnection connection, GameScenario scen)
 {
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From TroopAnimation", connection).ExecuteReader();
     while (reader.Read())
     {
         Animation animation = new Animation();
         animation.Scenario = scen;
         animation.ID = (short)reader["ID"];
         animation.Name = reader["Name"].ToString();
         animation.FrameCount = (short)reader["FrameCount"];
         animation.StayCount = (short)reader["StayCount"];
         this.AllTroopAnimations.AddAnimation(animation);
     }
     connection.Close();
     return new List<string>();
 }
Пример #6
0
        public List<string> LoadPersonGeneratorTypes(OleDbConnection connection, GameScenario scen)
        {
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From PersonGeneratorType", connection).ExecuteReader();
            bool hasZero = false;
            while (reader.Read())
            {
                PersonGeneratorType type = new PersonGeneratorType();
                type.ID = (int)reader["ID"];
                if (type.ID == 0)
                {
                    hasZero = true;
                }
                type.Name = reader["TypeName"].ToString();
                type.generationChance = (int)reader["GenerationChance"];
                type.commandLo = (int)reader["CommandLo"];
                type.commandHi = (int)reader["CommandHi"];
                type.strengthLo = (int)reader["StrengthLo"];
                type.strengthHi = (int)reader["StrengthHi"];
                type.intelligenceLo = (int)reader["IntelligenceLo"];
                type.intelligenceHi = (int)reader["IntelligenceHi"];
                type.politicsLo = (int)reader["PoliticsLo"];
                type.politicsHi = (int)reader["PoliticsHi"];
                type.glamourLo = (int)reader["GlamourLo"];
                type.glamourHi = (int)reader["GlamourHi"];
                type.braveLo = (int)reader["BraveLo"];
                type.braveHi = (int)reader["BraveHi"];
                type.calmnessLo = (int)reader["CalmnessLo"];
                type.calmnessHi = (int)reader["CalmnessHi"];
                type.personalLoyaltyLo = (int)reader["PersonalLoyaltyLo"];
                type.personalLoyaltyHi = (int)reader["PersonalLoyaltyHi"];
                type.ambitionLo = (int)reader["AmbitionLo"];
                type.ambitionHi = (int)reader["AmbitionHi"];
                type.titleChance = (int)reader["TitleChance"];
                type.affectedByRateParameter = (bool)reader["AffectedByRateParameter"];
                this.AllPersonGeneratorTypes.Add(type);
            }
            connection.Close();

            // for backward compatibility
            if (!hasZero)
            {
                foreach (PersonGeneratorType type in this.AllPersonGeneratorTypes)
                {
                    type.ID--;
                }
            }

            return new List<string>();
        }
Пример #7
0
 public object DLookup(string sqlQuery)
 {
     object data = null;
     bool connectedP = isConnectedDo;
     try
     {
         if (dbType == DatabaseType.MSSQL)
         {
             getQueryDbChanger(sqlQuery, SqlTypes.SELECT);
             SqlDataReader Dr = new SqlCommand(sqlQuery, MSSQLConn).ExecuteReader();
             if (Dr.Read())
             {
                 data = Dr[0];
             }
             Dr.Close();
         }
         else if (dbType == DatabaseType.MYSQL)
         {
             MySqlDataReader Dr = new MySqlCommand(sqlQuery, MySQLConn).ExecuteReader();
             if (Dr.Read())
             {
                 data = Dr[0];
             }
             Dr.Close();
         }
         else if (dbType == DatabaseType.MSACCESS2003 | dbType == DatabaseType.MSACCESS2007)
         {
             OleDbDataReader Dr = new OleDbCommand(sqlQuery, MSDBSQLConn).ExecuteReader();
             if (Dr.Read())
             {
                 data = Dr[0];
             }
             Dr.Close();
         }
     }
     catch (Exception eee)
     {
         OnError(eee);
         data = eee.Message;
     }
     finally
     {
         if (!connectedP)
             closeConnection();
     }
     return data;
 }
Пример #8
0
 public List<string> LoadInformationKind(OleDbConnection connection, GameScenario scen)
 {
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From InformationKind", connection).ExecuteReader();
     while (reader.Read())
     {
         InformationKind kind9 = new InformationKind();
         kind9.Scenario = scen;
         kind9.ID = (short)reader["ID"];
         kind9.Level = (InformationLevel)((short)reader["iLevel"]);
         kind9.Oblique = (bool)reader["Oblique"];
         kind9.Radius = (short)reader["Radius"];
         kind9.CostFund = (int)reader["CostFund"];
         this.AllInformationKinds.Add(kind9);
     }
     connection.Close();
     return new List<string>();
 }
Пример #9
0
        public List<string> LoadOfficeKind(OleDbConnection connection, GameScenario scen)
        {
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From guanjuezhonglei", connection).ExecuteReader();
            while (reader.Read())
            {
                guanjuezhongleilei guanjuedezhonglei = new guanjuezhongleilei();

                guanjuedezhonglei.Scenario = scen;
                guanjuedezhonglei.ID = (short)reader["ID"];
                guanjuedezhonglei.Name = reader["名称"].ToString();
                guanjuedezhonglei.shengwangshangxian = (int)reader["声望上限"];
                guanjuedezhonglei.xuyaogongxiandu = (int)reader["需要贡献度"];

                guanjuedezhonglei.xuyaochengchi = (short)reader["需要城池"];
                guanjuedezhonglei.ShowDialog = (bool)reader["ShowDialog"];

                this.suoyouguanjuezhonglei.Addguanjuedezhonglei(guanjuedezhonglei);
            }

            connection.Close();

            return new List<string>();
        }
Пример #10
0
        public List<string> LoadColor(OleDbConnection connection, GameScenario scen)
        {
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From Color", connection).ExecuteReader();
            while (reader.Read())
            {
                Color item = new Color();
                item.PackedValue = uint.Parse(reader["Code"].ToString());
                this.AllColors.Add(item);
            }
            connection.Close();

            return new List<string>();
        }
Пример #11
0
 public List<string> LoadCombatMethodKind(OleDbConnection connection, GameScenario scen)
 {
     List<string> errorMsg = new List<string>();
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From CombatMethod", connection).ExecuteReader();
     while (reader.Read())
     {
         CombatMethod combatMethod = new CombatMethod();
         combatMethod.Scenario = scen;
         combatMethod.ID = (short)reader["ID"];
         combatMethod.Name = reader["Name"].ToString();
         combatMethod.Description = reader["Description"].ToString();
         combatMethod.Combativity = (short)reader["Combativity"];
         List<string> e = combatMethod.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
         combatMethod.AttackDefault = this.AllAttackDefaultKinds.GetGameObject((short)reader["AttackDefault"]) as AttackDefaultKind;
         combatMethod.AttackTarget = this.AllAttackTargetKinds.GetGameObject((short)reader["AttackTarget"]) as AttackTargetKind;
         combatMethod.ArchitectureTarget = (bool)reader["ArchitectureTarget"];
         e.AddRange(combatMethod.CastConditions.LoadFromString(this.AllConditions, reader["CastConditions"].ToString()));
         if (e.Count > 0)
         {
             errorMsg.Add("战法ID" + combatMethod.ID);
             errorMsg.AddRange(e);
         }
         combatMethod.ViewingHostile = (bool)reader["ViewingHostile"];
         combatMethod.AnimationKind = (TileAnimationKind)((short)reader["AnimationKind"]);
         this.AllCombatMethods.AddCombatMethod(combatMethod);
     }
     connection.Close();
     return errorMsg;
 }
Пример #12
0
 public List<string> LoadCastTargetKind(OleDbConnection connection, GameScenario scen)
 {
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From CastTargetKind", connection).ExecuteReader();
     while (reader.Read())
     {
         CastTargetKind kind13 = new CastTargetKind();
         kind13.Scenario = scen;
         kind13.ID = (short)reader["ID"];
         kind13.Name = reader["Name"].ToString();
         this.AllCastTargetKinds.Add(kind13);
     }
     connection.Close();
     return new List<string>();
 }
Пример #13
0
 public List<string> LoadCharacterKind(OleDbConnection connection, GameScenario scen)
 {
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From CharacterKind", connection).ExecuteReader();
     while (reader.Read())
     {
         CharacterKind kind2 = new CharacterKind();
         kind2.Scenario = scen;
         kind2.ID = (short)reader["ID"];
         kind2.Name = reader["Name"].ToString();
         kind2.IntelligenceRate = (float)reader["IntelligenceRate"];
         kind2.ChallengeChance = (short)reader["ChallengeChance"];
         kind2.ControversyChance = (short)reader["ControversyChance"];
         kind2.GenerationChance[0] = (int)reader["General"];
         kind2.GenerationChance[1] = (int)reader["Brave"];
         kind2.GenerationChance[2] = (int)reader["Advisor"];
         kind2.GenerationChance[3] = (int)reader["Politician"];
         kind2.GenerationChance[4] = (int)reader["IntelGeneral"];
         kind2.GenerationChance[5] = (int)reader["Emperor"];
         kind2.GenerationChance[6] = (int)reader["AllRounder"];
         kind2.GenerationChance[7] = (int)reader["Normal"];
         kind2.GenerationChance[8] = (int)reader["Cheap"];
         try
         {
             kind2.GenerationChance[9] = (int)reader["Normal2"];
         }
         catch
         {
             kind2.GenerationChance[9] = kind2.GenerationChance[7];
         }
         this.AllCharacterKinds.Add(kind2);
     }
     connection.Close();
     return new List<string>();
 }
Пример #14
0
        public List<string> LoadBiographyAdjectives(OleDbConnection connection, GameScenario scen)
        {
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From BiographyAdjectives", connection).ExecuteReader();
            while (reader.Read())
            {
                int t;
                BiographyAdjectives b = new BiographyAdjectives();
                b.Scenario = scen;
                b.ID = (short)reader["ID"];
                int.TryParse(reader["Strength"].ToString(), out t);
                b.Strength = t;
                b.ID = (short)reader["ID"];
                int.TryParse(reader["Command"].ToString(), out t);
                b.Command = t;
                b.ID = (short)reader["ID"];
                int.TryParse(reader["Intelligence"].ToString(), out t);
                b.Intelligence = t;
                b.ID = (short)reader["ID"];
                int.TryParse(reader["Politics"].ToString(), out t);
                b.Politics = t;
                b.ID = (short)reader["ID"];
                int.TryParse(reader["Glamour"].ToString(), out t);
                b.Glamour = t;
                b.ID = (short)reader["ID"];
                int.TryParse(reader["Braveness"].ToString(), out t);
                b.Braveness = t;
                b.ID = (short)reader["ID"];
                int.TryParse(reader["Calmness"].ToString(), out t);
                b.Calmness = t;
                b.ID = (short)reader["ID"];
                int.TryParse(reader["PersonalLoyalty"].ToString(), out t);
                b.PersonalLoyalty = t;
                b.ID = (short)reader["ID"];
                int.TryParse(reader["Ambition"].ToString(), out t);
                b.Ambition = t;
                b.Male = (bool)reader["Male"];
                b.Female = (bool)reader["Female"];
                StaticMethods.LoadFromString(b.Text, reader["BioText"].ToString());
                StaticMethods.LoadFromString(b.SuffixText, reader["SuffixText"].ToString());
                this.AllBiographyAdjectives.Add(b);
            }
            connection.Close();

            return new List<string>();
        }
Пример #15
0
 public List<string> LoadAttackDefaultKind(OleDbConnection connection, GameScenario scen)
 {
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From AttackDefaultKind", connection).ExecuteReader();
     while (reader.Read())
     {
         AttackDefaultKind kind10 = new AttackDefaultKind();
         kind10.Scenario = scen;
         kind10.ID = (short)reader["ID"];
         kind10.Name = reader["Name"].ToString();
         this.AllAttackDefaultKinds.Add(kind10);
     }
     connection.Close();
     return new List<string>();
 }
Пример #16
0
 public List<string> LoadArchitectureKind(OleDbConnection connection, GameScenario scen)
 {
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From ArchitectureKind", connection).ExecuteReader();
     while (reader.Read())
     {
         ArchitectureKind architectureKind = new ArchitectureKind();
         architectureKind.Scenario = scen;
         architectureKind.ID = (short)reader["ID"];
         architectureKind.Name = reader["Name"].ToString();
         architectureKind.AgricultureBase = (short)reader["AgricultureBase"];
         architectureKind.AgricultureUnit = (short)reader["AgricultureUnit"];
         architectureKind.CommerceBase = (short)reader["CommerceBase"];
         architectureKind.CommerceUnit = (short)reader["CommerceUnit"];
         architectureKind.TechnologyBase = (short)reader["TechnologyBase"];
         architectureKind.TechnologyUnit = (short)reader["TechnologyUnit"];
         architectureKind.DominationBase = (short)reader["DominationBase"];
         architectureKind.DominationUnit = (short)reader["DominationUnit"];
         architectureKind.MoraleBase = (short)reader["MoraleBase"];
         architectureKind.MoraleUnit = (short)reader["MoraleUnit"];
         architectureKind.EnduranceBase = (short)reader["EnduranceBase"];
         architectureKind.EnduranceUnit = (short)reader["EnduranceUnit"];
         architectureKind.PopulationBase = (int)reader["PopulationBase"];
         architectureKind.PopulationUnit = (int)reader["PopulationUnit"];
         architectureKind.PopulationBoundary = (int)reader["PopulationBoundary"];
         architectureKind.ViewDistance = (short)reader["ViewDistance"];
         architectureKind.ViewDistanceIncrementDivisor = (short)reader["VDIncrementDivisor"];
         architectureKind.HasObliqueView = (bool)reader["HasObliqueView"];
         architectureKind.HasLongView = (bool)reader["HasLongView"];
         architectureKind.HasPopulation = (bool)reader["HasPopulation"];
         architectureKind.HasAgriculture = (bool)reader["HasAgriculture"];
         architectureKind.HasCommerce = (bool)reader["HasCommerce"];
         architectureKind.HasTechnology = (bool)reader["HasTechnology"];
         architectureKind.HasDomination = (bool)reader["HasDomination"];
         architectureKind.HasMorale = (bool)reader["HasMorale"];
         architectureKind.HasEndurance = (bool)reader["HasEndurance"];
         architectureKind.HasHarbor = (bool)reader["HasHarbor"];
         architectureKind.FacilityPositionUnit = (short)reader["FacilityPositionUnit"];
         architectureKind.FundMaxUnit = (int)reader["FundMaxUnit"];
         architectureKind.FoodMaxUnit = (int)reader["FoodMaxUnit"];
         try
         {
             architectureKind.CountToMerit = (bool)reader["CountToMerit"];
         }
         catch (Exception)
         {
             architectureKind.CountToMerit = architectureKind.ID == 1 ? true : false;
         }
         try
         {
             architectureKind.Expandable = (int)reader["Expandable"];
         }
         catch (Exception)
         {
             try
             {
                 architectureKind.Expandable = (bool)reader["Expandable"] ? 99 : 0;
             }
             catch
             {
                 architectureKind.Expandable = architectureKind.ID == 1 ? 99 : 0;
             }
         }
         try
         {
             architectureKind.ShipCanEnter = (bool)reader["ShipCanEnter"];
         }
         catch
         {
             architectureKind.ShipCanEnter = true;
         }
         this.AllArchitectureKinds.AddArchitectureKind(architectureKind);
     }
     connection.Close();
     return new List<string>();
 }
Пример #17
0
 public List<string> LoadInfluence(OleDbConnection connection, GameScenario scen)
 {
     List<string> errorMsg = new List<string>();
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From Influence", connection).ExecuteReader();
     while (reader.Read())
     {
         Influence influence = new Influence();
         influence.Scenario = scen;
         influence.ID = (short)reader["ID"];
         influence.Name = reader["Name"].ToString();
         influence.Description = reader["Description"].ToString();
         influence.Parameter = reader["Parameter"].ToString();
         influence.Parameter2 = reader["Parameter2"].ToString();
         influence.Kind = this.AllInfluenceKinds.GetInfluenceKind((short)reader["Kind"]);
         if (influence.Kind != null)
         {
             this.AllInfluences.AddInfluence(influence);
         }
         else
         {
             errorMsg.Add("影响ID" + influence.ID + "使用了不存在的影响类型" + (short)reader["Kind"]);
         }
     }
     connection.Close();
     return errorMsg;
 }
Пример #18
0
 public List<string> LoadCondition(OleDbConnection connection, GameScenario scen)
 {
     List<string> errorMsg = new List<string>();
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From Condition", connection).ExecuteReader();
     while (reader.Read())
     {
         Condition condition = new Condition();
         condition.Scenario = scen;
         condition.ID = (short)reader["ID"];
         condition.Name = reader["Name"].ToString();
         condition.Parameter = reader["Parameter"].ToString();
         condition.Parameter2 = reader["Parameter2"].ToString();
         condition.Kind = this.AllConditionKinds.GetConditionKind((short)reader["Kind"]);
         if (condition.Kind != null || condition.ID == 9998 || condition.ID == 9999)
         {
             this.AllConditions.AddCondition(condition);
         }
         else
         {
             errorMsg.Add("条件ID" + condition.ID + "使用了不存在的条件类型" + (short)reader["Kind"]);
         }
     }
     connection.Close();
     return errorMsg;
 }
Пример #19
0
 public List<string> LoadInfluenceKind(OleDbConnection connection, GameScenario scen)
 {
     List<string> errorMsg = new List<string>();
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From InfluenceKind", connection).ExecuteReader();
     while (reader.Read())
     {
         int num = (short)reader["ID"];
         InfluenceKind ik = InfluenceKindFactory.CreateInfluenceKindByID(num);
         if (ik != null)
         {
             ik.Scenario = scen;
             ik.ID = num;
             ik.Type = (InfluenceType)((short)reader["Type"]);
             ik.Name = reader["Name"].ToString();
             try
             {
                 ik.Combat = (bool)reader["Combat"];
             }
             catch
             {
                 ik.Combat = true;
             }
             try
             {
                 ik.AIPersonValue = (float)reader["AIPersonValue"];
                 ik.AIPersonValuePow = (float)reader["AIPersonValuePow"];
             }
             catch { }
             this.AllInfluenceKinds.AddInfluenceKind(ik);
         }
         else
         {
             errorMsg.Add("影响类型ID" + num + "不存在于游戏中。");
         }
     }
     connection.Close();
     return errorMsg;
 }
Пример #20
0
 public List<string> LoadConditionKind(OleDbConnection connection, GameScenario scen)
 {
     List<string> errorMsg = new List<string>();
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From ConditionKind", connection).ExecuteReader();
     while (reader.Read())
     {
         int num = (short)reader["ID"];
         ConditionKind ck = ConditionKindFactory.CreateConditionKindByID(num);
         if (ck != null)
         {
             ck.Scenario = scen;
             ck.ID = num;
             ck.Name = reader["Name"].ToString();
             this.AllConditionKinds.AddConditionKind(ck);
         }
         else
         {
             errorMsg.Add("条件类型ID" + num + "不存在于游戏中。");
         }
     }
     connection.Close();
     return errorMsg;
 }
Пример #21
0
        public List<string> LoadMilitaryKind(OleDbConnection connection, GameScenario scen)
        {
            List<string> errorMsg = new List<string>();
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From MilitaryKind", connection).ExecuteReader();
            while (reader.Read())
            {
                List<string> e = new List<string>();

                MilitaryKind militaryKind = new MilitaryKind();
                militaryKind.Scenario = scen;
                militaryKind.ID = (short)reader["ID"];
                militaryKind.Type = (MilitaryType)((short)reader["Type"]);
                militaryKind.Name = reader["Name"].ToString();
                militaryKind.Description = reader["Description"].ToString();
                militaryKind.Merit = (short)reader["Merit"];

                try
                {
                    militaryKind.ObtainProb = (int)reader["ObtainProb"];
                }
                catch
                {
                    militaryKind.ObtainProb = 0;
                }
                militaryKind.Speed = (short)reader["Speed"];
                militaryKind.TitleInfluence = (short)reader["TitleInfluence"];
                militaryKind.CreateCost = (int)reader["CreateCost"];
                militaryKind.CreateTechnology = (int)reader["CreateTechnology"];
                militaryKind.IsShell = (bool)reader["IsShell"];
                militaryKind.CreateBesideWater = (bool)reader["CreateBesideWater"];
                militaryKind.Offence = (short)reader["Offence"];
                militaryKind.Defence = (short)reader["Defence"];
                militaryKind.OffenceRadius = (short)reader["OffenceRadius"];
                militaryKind.CounterOffence = (bool)reader["CounterOffence"];
                militaryKind.BeCountered = (bool)reader["BeCountered"];
                militaryKind.ObliqueOffence = (bool)reader["ObliqueOffence"];
                militaryKind.ArrowOffence = (bool)reader["ArrowOffence"];
                militaryKind.AirOffence = (bool)reader["AirOffence"];
                militaryKind.ContactOffence = (bool)reader["ContactOffence"];
                militaryKind.OffenceOnlyBeforeMove = (bool)reader["OffenceOnlyBeforeMove"];
                militaryKind.ArchitectureDamageRate = (float)reader["ArchitectureDamageRate"];
                militaryKind.ArchitectureCounterDamageRate = (float)reader["ArchitectureCounterDamageRate"];
                militaryKind.StratagemRadius = (short)reader["StratagemRadius"];
                militaryKind.ObliqueStratagem = (bool)reader["ObliqueStratagem"];
                militaryKind.ViewRadius = (short)reader["ViewRadius"];
                militaryKind.ObliqueView = (bool)reader["ObliqueView"];
                militaryKind.Movability = (short)reader["Movability"];
                militaryKind.OneAdaptabilityKind = (short)reader["OneAdaptabilityKind"];
                militaryKind.PlainAdaptability = (short)reader["PlainAdaptability"];
                militaryKind.GrasslandAdaptability = (short)reader["GrasslandAdaptability"];
                militaryKind.ForrestAdaptability = (short)reader["ForrestAdaptability"];
                militaryKind.MarshAdaptability = (short)reader["MarshAdaptability"];
                militaryKind.MountainAdaptability = (short)reader["MountainAdaptability"];
                militaryKind.WaterAdaptability = (short)reader["WaterAdaptability"];
                militaryKind.RidgeAdaptability = (short)reader["RidgeAdaptability"];
                militaryKind.WastelandAdaptability = (short)reader["WastelandAdaptability"];
                militaryKind.DesertAdaptability = (short)reader["DesertAdaptability"];
                militaryKind.CliffAdaptability = (short)reader["CliffAdaptability"];
                militaryKind.PlainRate = (float)reader["PlainRate"];
                militaryKind.GrasslandRate = (float)reader["GrasslandRate"];
                militaryKind.ForrestRate = (float)reader["ForrestRate"];
                militaryKind.MarshRate = (float)reader["MarshRate"];
                militaryKind.MountainRate = (float)reader["MountainRate"];
                militaryKind.WaterRate = (float)reader["WaterRate"];
                militaryKind.RidgeRate = (float)reader["RidgeRate"];
                militaryKind.WastelandRate = (float)reader["WastelandRate"];
                militaryKind.DesertRate = (float)reader["DesertRate"];
                militaryKind.CliffRate = (float)reader["CliffRate"];
                militaryKind.InjuryChance = (short)reader["InjuryRate"];
                try
                {
                    militaryKind.FireDamageRate = (float)reader["FireDamageRate"];
                    militaryKind.RecruitLimit = (int)reader["RecruitLimit"];
                }
                catch
                {
                    try
                    {
                        militaryKind.FireDamageRate = (bool)reader["AfraidOfFire"] ? 3.0f : 1.0f;
                        militaryKind.RecruitLimit = (bool)reader["Unique"] ? 1 : 1000;
                    }
                    catch
                    {
                        militaryKind.FireDamageRate = 1.0f;
                        militaryKind.RecruitLimit = 10000;
                    }
                }
                militaryKind.FoodPerSoldier = (short)reader["FoodPerSoldier"];
                militaryKind.RationDays = (int)reader["RationDays"];
                militaryKind.PointsPerSoldier = (int)reader["PointsPerSoldier"];
                militaryKind.MinScale = (int)reader["MinScale"];
                militaryKind.MaxScale = (int)reader["MaxScale"];
                militaryKind.OffencePerScale = (short)reader["OffencePerScale"];
                militaryKind.DefencePerScale = (short)reader["DefencePerScale"];
                militaryKind.CanLevelUp = (bool)reader["CanLevelUp"];
                StaticMethods.LoadFromString(militaryKind.LevelUpKindID, reader["LevelUpKindID"].ToString());
                militaryKind.LevelUpKindID.RemoveAll(i => i == -1);
                militaryKind.LevelUpExperience = (int)reader["LevelUpExperience"];
                militaryKind.OffencePer100Experience = (short)reader["OffencePer100Experience"];
                militaryKind.DefencePer100Experience = (short)reader["DefencePer100Experience"];
                militaryKind.AttackDefaultKind = (TroopAttackDefaultKind)((short)reader["AttackDefaultKind"]);
                militaryKind.AttackTargetKind = (TroopAttackTargetKind)((short)reader["AttackTargetKind"]);
                militaryKind.CastDefaultKind = (TroopCastDefaultKind)((short)reader["CastDefaultKind"]);
                militaryKind.CastTargetKind = (TroopCastTargetKind)((short)reader["CastTargetKind"]);
                try
                {
                    militaryKind.MorphToKindId = (int)reader["MorphTo"];
                    militaryKind.MinCommand = (int)reader["MinCommand"];
                }
                catch
                {
                }

                e.AddRange(militaryKind.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString()));
                if (e.Count > 0)
                {
                    errorMsg.Add("兵种ID" + militaryKind.ID);
                    errorMsg.AddRange(e);
                }

                try
                {
                    e.AddRange(militaryKind.CreateConditions.LoadFromString(this.AllConditions, reader["CreateConditions"].ToString()));
                }
                catch { }
                if (e.Count > 0)
                {
                    errorMsg.Add("称号ID" + militaryKind.ID);
                    errorMsg.AddRange(e);
                }

                militaryKind.zijinshangxian = (int)reader["zijinshangxian"];
                this.AllMilitaryKinds.AddMilitaryKind(militaryKind);
            }
            connection.Close();
            connection.Open();
            reader = new OleDbCommand("Select * From MilitaryKind", connection).ExecuteReader();
            while (reader.Read())
            {
                MilitaryKind current = this.AllMilitaryKinds.GetMilitaryKindList().GetGameObject((short)reader["ID"]) as MilitaryKind;
                current.successor = new MilitaryKindTable();
                List<string> e = current.successor.LoadFromString(this.AllMilitaryKinds, reader["Successor"].ToString());
                if (e.Count > 0)
                {
                    errorMsg.Add("兵种ID" + current.ID);
                    errorMsg.AddRange(e);
                }
            }
            connection.Close();
            return errorMsg;
        }
Пример #22
0
        public List<string> LoadDisasterKind(OleDbConnection connection, GameScenario scen)
        {
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From DisasterKind", connection).ExecuteReader();
            while (reader.Read())
            {
                zainanzhongleilei zainanzhonglei = new zainanzhongleilei();

                zainanzhonglei.Scenario = scen;
                zainanzhonglei.ID = (short)reader["ID"];
                zainanzhonglei.Name = reader["名称"].ToString();
                zainanzhonglei.shijianxiaxian = (int)reader["时间下限"];
                zainanzhonglei.shijianshangxian = (int)reader["时间上限"];

                zainanzhonglei.renkoushanghai = (int)reader["人口伤害"];
                zainanzhonglei.tongzhishanghai = (int)reader["统治伤害"];
                zainanzhonglei.naijiushanghai = (int)reader["耐久伤害"];
                zainanzhonglei.nongyeshanghai = (int)reader["农业伤害"];
                zainanzhonglei.shangyeshanghai = (int)reader["商业伤害"];
                zainanzhonglei.jishushanghai = (int)reader["技术伤害"];
                zainanzhonglei.minxinshanghai = (int)reader["民心伤害"];

                try
                {
                    zainanzhonglei.FoodDamage = (int)reader["军粮伤害"];
                    zainanzhonglei.FundDamage = (int)reader["资金伤害"];
                    zainanzhonglei.TroopDamage = (int)reader["军队伤害"];
                    zainanzhonglei.OfficerDamage = (int)reader["武将伤害"];
                }
                catch
                {
                }

                this.suoyouzainanzhonglei.Addzainanzhonglei(zainanzhonglei);
            }

            connection.Close();
            return new List<string>();
        }
Пример #23
0
        public List<string> LoadPersonGeneratorSetting(OleDbConnection connection, GameScenario scen)
        {
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From PersonGenerator", connection).ExecuteReader();
            while (reader.Read())
            {
                this.PersonGeneratorSetting.bornLo = (int)reader["BornLo"];
                this.PersonGeneratorSetting.bornHi = (int)reader["BornHi"];
                this.PersonGeneratorSetting.debutLo = (int)reader["DebutLo"];
                this.PersonGeneratorSetting.debutHi = (int)reader["DebutHi"];
                this.PersonGeneratorSetting.dieLo = (int)reader["DieLo"];
                this.PersonGeneratorSetting.dieHi = (int)reader["DieHi"];
                this.PersonGeneratorSetting.femaleChance = (int)reader["FemaleChance"];
                this.PersonGeneratorSetting.debutAtLeast = (int)reader["DebutAtLeast"];
            }
            connection.Close();

            return new List<string>();
        }
Пример #24
0
 public List<string> LoadEventEffect(OleDbConnection connection, GameScenario scen)
 {
     List<string> errorMsg = new List<string>();
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From EventEffect", connection).ExecuteReader();
     while (reader.Read())
     {
         GameObjects.ArchitectureDetail.EventEffect.EventEffect effect = new GameObjects.ArchitectureDetail.EventEffect.EventEffect();
         effect.Scenario = scen;
         effect.ID = (short)reader["ID"];
         effect.Name = reader["Name"].ToString();
         effect.Parameter = reader["Parameter"].ToString();
         effect.Parameter2 = reader["Parameter2"].ToString();
         effect.Kind = this.AllEventEffectKinds.GetEventEffectKind((short)reader["Kind"]);
         if (effect.Kind != null)
         {
             this.AllEventEffects.AddEventEffect(effect);
         }
         else
         {
             errorMsg.Add("建筑事件效果ID" + effect.ID + "使用了不存在的建筑事件效果类型" + (short)reader["Kind"]);
         }
     }
     connection.Close();
     return errorMsg;
 }
Пример #25
0
        public object DLookup(string table, string fieldName, string clauses, string[] orderByFieldNames, bool orderByAsc)
        {
            object data = null;
            bool connectedP = isConnectedDo;
            try
            {
                string query = "SELECT TOP 1 " + fieldName + " FROM " + table + " WHERE (" + clauses + ")" + ((orderByFieldNames.Length > 0) ? " ORDER BY " + getOrderByData(orderByFieldNames) + " " + ((orderByAsc) ? "ASC" : "DESC") : "");

                if (dbType == DatabaseType.MSSQL)
                {
                    getQueryDbChanger(query, SqlTypes.SELECT);
                    SqlDataReader Dr = new SqlCommand(query, MSSQLConn).ExecuteReader();
                    if (Dr.Read())
                    {
                        data = Dr[0];
                    }
                    Dr.Close();
                }
                else if (dbType == DatabaseType.MYSQL)
                {
                    MySqlDataReader Dr = new MySqlCommand(query, MySQLConn).ExecuteReader();
                    if (Dr.Read())
                    {
                        data = Dr[0];
                    }
                    Dr.Close();
                }
                else if (dbType == DatabaseType.MSACCESS2003 | dbType == DatabaseType.MSACCESS2007)
                {
                    OleDbDataReader Dr = new OleDbCommand(query, MSDBSQLConn).ExecuteReader();
                    if (Dr.Read())
                    {
                        data = Dr[0];
                    }
                    Dr.Close();
                }
            }
            catch (Exception eee)
            {
                OnError(eee);
                data = eee.Message;
            }
            finally
            {
                if (!connectedP)
                    closeConnection();
            }
            return data;
        }
Пример #26
0
        public List<string> LoadTitle(OleDbConnection connection, GameScenario scen)
        {
            List<string> errorMsg = new List<string>();
            connection.Open();
            OleDbDataReader reader = new OleDbCommand("Select * From Title", connection).ExecuteReader();
            while (reader.Read())
            {
                Title title = new Title();
                title.Scenario = scen;
                title.ID = (short)reader["ID"];
                title.Kind = this.AllTitleKinds.GetTitleKind((short)reader["Kind"]);
                if (title.Kind == null)
                {
                    errorMsg.Add("称号ID" + title.ID + "使用了不存在的称号类型" + ((short)reader["Kind"]));
                }
                title.Level = (short)reader["Level"];
                title.Combat = (bool)reader["Combat"];
                title.Name = reader["Name"].ToString();

                List<string> e = title.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
                e.AddRange(title.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString()));
                try
                {
                    e.AddRange(title.ArchitectureConditions.LoadFromString(this.AllConditions, reader["ArchitectureConditions"].ToString()));
                    e.AddRange(title.FactionConditions.LoadFromString(this.AllConditions, reader["FactionConditions"].ToString()));
                    e.AddRange(title.LoseConditions.LoadFromString(this.AllConditions, reader["LoseConditions"].ToString())); //失去条件
                }
                catch { }
                if (e.Count > 0)
                {
                    errorMsg.Add("称号ID" + title.ID);
                    errorMsg.AddRange(e);
                }

                try
                {
                    title.AutoLearn = (int)reader["AutoLearn"];
                    title.AutoLearnText = reader["AutoLearnText"].ToString();
                    title.AutoLearnTextByCourier = reader["AutoLearnTextByCourier"].ToString();
                }
                catch
                {
                    title.AutoLearn = 0;
                    title.AutoLearnText = "";
                    title.AutoLearnTextByCourier = "";
                }
                try
                {
                    title.MapLimit = (int)reader["MapLimit"];
                    title.FactionLimit = (int)reader["FactionLimit"];
                    title.InheritChance = (int)reader["InheritChance"];
                }
                catch
                {
                    title.MapLimit = 9999;
                    title.FactionLimit = 9999;
                    title.InheritChance = 0;
                }

                title.GenerationChance[0] = (int)reader["General"];
                title.GenerationChance[1] = (int)reader["Brave"];
                title.GenerationChance[2] = (int)reader["Advisor"];
                title.GenerationChance[3] = (int)reader["Politician"];
                title.GenerationChance[4] = (int)reader["IntelGeneral"];
                title.GenerationChance[5] = (int)reader["Emperor"];
                title.GenerationChance[6] = (int)reader["AllRounder"];
                title.GenerationChance[7] = (int)reader["Normal"];
                title.GenerationChance[8] = (int)reader["Cheap"];
                try
                {
                    title.GenerationChance[9] = (int)reader["Normal2"];
                }
                catch
                {
                    title.GenerationChance[9] = title.GenerationChance[7];
                }
                title.RelatedAbility = (int)reader["Ability"];
                this.AllTitles.AddTitle(title);
            }
            connection.Close();
            return errorMsg;
        }
Пример #27
0
        public object[] DLookupA(string table, string fieldName, string clauses, string[] orderByFieldNames, bool orderByAsc)
        {
            List<object> data = new List<object>();
            bool connectedP = isConnectedDo;
            string query = "";
            try
            {
                query = "SELECT " + fieldName + " FROM " + table + " WHERE (" + clauses + ")" + ((orderByFieldNames.Length > 0) ? " ORDER BY " + getOrderByData(orderByFieldNames) + " " + ((orderByAsc) ? "ASC" : "DESC") : "");

                if (dbType == DatabaseType.MSSQL)
                {
                    getQueryDbChanger(query, SqlTypes.SELECT);
                    SqlDataReader Dr = new SqlCommand(query, MSSQLConn).ExecuteReader();
                    while (Dr.Read())
                    {
                        data.Add(Dr[0]);
                    }
                    Dr.Close();
                }
                else if (dbType == DatabaseType.MYSQL)
                {
                    MySqlDataReader Dr = new MySqlCommand(query, MySQLConn).ExecuteReader();
                    while (Dr.Read())
                    {
                        data.Add(Dr[0]);
                    }
                    Dr.Close();
                }
                else if (dbType == DatabaseType.MSACCESS2003 | dbType == DatabaseType.MSACCESS2007)
                {
                    OleDbDataReader Dr = new OleDbCommand(query, MSDBSQLConn).ExecuteReader();
                    while (Dr.Read())
                    {
                        data.Add(Dr[0]);
                    }
                    Dr.Close();
                }
            }
            catch (Exception eee)
            {
                OnError(eee);
                data.Clear();
                data.Add("ERROR: " + eee.Message);
                data.Add("ERRORI: " + table);
                data.Add("ERRORI: " + fieldName);
                data.Add("ERRORI: " + clauses);
                data.Add("ERRORI: " + query);
            }
            finally
            {
                if (!connectedP)
                    closeConnection();
            }
            return data.ToArray();
        }
Пример #28
0
 public List<string> LoadFacilityKind(OleDbConnection connection, GameScenario scen)
 {
     List<string> errorMsg = new List<string>();
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From FacilityKind", connection).ExecuteReader();
     while (reader.Read())
     {
         FacilityKind facilityKind = new FacilityKind();
         facilityKind.Scenario = scen;
         facilityKind.ID = (short)reader["ID"];
         facilityKind.Name = reader["Name"].ToString();
         try
         {
             facilityKind.AILevel = (float)reader["AILevel"];
         }
         catch
         {
             facilityKind.AILevel = 1;
         }
         facilityKind.PositionOccupied = (int)reader["PositionOccupied"];
         facilityKind.TechnologyNeeded = (int)reader["TechnologyNeeded"];
         facilityKind.FundCost = (int)reader["FundCost"];
         facilityKind.PointCost = (int)reader["PointCost"];
         facilityKind.MaintenanceCost = (int)reader["MaintenanceCost"];
         facilityKind.Days = (short)reader["Days"];
         facilityKind.Endurance = (int)reader["Endurance"];
         try
         {
             facilityKind.ArchitectureLimit = (int)reader["ArchitectureLimit"];
             facilityKind.FactionLimit = (int)reader["FactionLimit"];
         }
         catch
         {
             facilityKind.ArchitectureLimit = (bool)reader["UniqueInArchitecture"] ? 1 : 9999;
             facilityKind.FactionLimit = (bool)reader["UniqueInFaction"] ? 1 : 9999;
         }
         facilityKind.PopulationRelated = (bool)reader["PopulationRelated"];
         List<string> e = facilityKind.Influences.LoadFromString(this.AllInfluences, reader["Influences"].ToString());
         facilityKind.rongna = (short)reader["rongna"];
         facilityKind.bukechaichu = (bool)reader["bukechaichu"];
         e.AddRange(facilityKind.Conditions.LoadFromString(this.AllConditions, reader["Conditions"].ToString()));
         if (e.Count > 0)
         {
             errorMsg.Add("设施ID" + facilityKind.ID);
             errorMsg.AddRange(e);
         }
         this.AllFacilityKinds.AddFacilityKind(facilityKind);
     }
     connection.Close();
     return errorMsg;
 }
Пример #29
0
 public List<string> LoadEventEffectKind(OleDbConnection connection, GameScenario scen)
 {
     List<string> errorMsg = new List<string>();
     connection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From EventEffectKind", connection).ExecuteReader();
     while (reader.Read())
     {
         int num = (short)reader["ID"];
         GameObjects.ArchitectureDetail.EventEffect.EventEffectKind e = GameObjects.ArchitectureDetail.EventEffect.EventEffectKindFactory.CreateEventEffectKindByID(num);
         if (e != null)
         {
             e.Scenario = scen;
             e.ID = num;
             e.Name = reader["Name"].ToString();
             this.AllEventEffectKinds.AddEventEffectKind(e);
         }
         else
         {
             errorMsg.Add("建筑事件效果种类ID" + num + "不存在于游戏中");
         }
     }
     connection.Close();
     return errorMsg;
 }
Пример #30
0
        public List<string> LoadTitleKind(OleDbConnection connection, GameScenario scen)
        {
            connection.Open();
            try
            {
                OleDbDataReader reader = new OleDbCommand("Select * From TitleKind", connection).ExecuteReader();
                while (reader.Read())
                {
                    TitleKind tk = new TitleKind();
                    tk.Scenario = scen;
                    tk.ID = (short)reader["ID"];
                    tk.Name = reader["KName"].ToString();
                    tk.Combat = (bool)reader["Combat"];
                    tk.StudyDay = (short)reader["StudyDay"];
                    tk.SuccessRate = (short)reader["SuccessRate"];
                    this.AllTitleKinds.AddTitleKind(tk);
                }
            }
            catch
            {
                TitleKind tk = new TitleKind();
                tk.Scenario = scen;
                tk.ID = 1;
                tk.Name = "个人称号";
                tk.Combat = false;
                tk.StudyDay = 90;
                this.AllTitleKinds.AddTitleKind(tk);
                tk = new TitleKind();
                tk.Scenario = scen;
                tk.ID = 2;
                tk.Name = "战斗称号";
                tk.Combat = true;
                tk.StudyDay = 90;
                this.AllTitleKinds.AddTitleKind(tk);
            }
            connection.Close();

            return new List<string>();
        }