コード例 #1
0
 public static FactionList composeFactionList(params Faction[] f)
 {
     FactionList r = new FactionList();
     foreach (Faction i in f)
     {
         if (i != null)
         {
             r.Add(i);
         }
     }
     return r;
 }
コード例 #2
0
        public static FactionList composeFactionList(params Faction[] f)
        {
            FactionList r = new FactionList();

            foreach (Faction i in f)
            {
                if (i != null)
                {
                    r.Add(i);
                }
            }
            return(r);
        }
コード例 #3
0
 private void EditFactions()
 {
     FactionList list = new FactionList();
     for (int i = 0; i < this.dgvFactions.SelectedRows.Count; i++)
     {
         list.Add(this.Factions[this.dgvFactions.SelectedRows[i].Index]);
     }
     if (list.Count > 0)
     {
         frmEditFaction faction = new frmEditFaction();
         faction.Factions = list;
         faction.ShowDialog();
         this.dgvFactions.Invalidate();
     }
 }
コード例 #4
0
 public FactionList GetOtherFactions()
 {
     FactionList list = new FactionList();
     foreach (Faction faction in base.Scenario.Factions)
     {
         if (faction != this)
         {
             list.Add(faction);
         }
     }
     return list;
 }
コード例 #5
0
 public FactionList GetHostileFactions()
 {
     FactionList list = new FactionList();
     foreach (Faction faction in base.Scenario.Factions)
     {
         if (!((faction == this) || this.IsFriendly(faction)))
         {
             list.Add(faction);
         }
     }
     return list;
 }
コード例 #6
0
 public void CheckEncircleDiplomaticByFactionName(string EncircleFactionName)
 {
     FactionList encircleList = new FactionList();
     int fc = 0;
     foreach (Faction f in base.Scenario.Factions)
     {
         if ((f.Name != EncircleFactionName) && (f.Leader.StrategyTendency != PersonStrategyTendency.维持现状) && ! f.IsAlien)
         {
             fc++;
             if (((base.Scenario.DiplomaticRelations.GetDiplomaticRelation(this.GetFactionByName(EncircleFactionName).ID, f.ID).Relation +
                 Person.GetIdealOffset(this.GetFactionByName(EncircleFactionName).Leader, f.Leader) * 1.5) < 0
                 && GameObject.Chance(60))
                 )
             {
                 encircleList.Add(f);
             }
         }
     }
     if ((encircleList.Count * 2 > fc) && fc > 3)
     {
         this.Scenario.GameScreen.xianshishijiantupian(this.Leader, this.Leader.Name, "EncircleDiplomaticRelation", "EncircleDiplomaticRelation.jpg", "EncircleDiplomaticRelation.wav", EncircleFactionName, true);
         foreach (Faction i in encircleList)
         {
             foreach (Faction j in encircleList)
             {
                 if (i != j)
                 {
                     if (this.Scenario.DiplomaticRelations.GetDiplomaticRelation(i.ID, j.ID).Truce < 90)
                     {
                         this.Scenario.DiplomaticRelations.GetDiplomaticRelation(i.ID, j.ID).Truce = 90;
                     }
                 }
             }
         }
     }
 }
コード例 #7
0
        private void CheckGameEnd()
        {
            FactionList noArchFaction = new FactionList();
            foreach (Faction f in this.Factions)
            {
                if (f.ArchitectureCount == 0)
                {
                    noArchFaction.Add(f);
                }
            }

            foreach (Faction f in noArchFaction)
            {
                this.Factions.Remove(f);
            }

            if (this.Factions.Count == 1)
            {
                ExtensionInterface.call("GameEnd", new Object[]{this});
                if (this.CurrentPlayer != null && !this.runScenarioEnd(this.CurrentPlayer.Capital))
                {
                    this.GameScreen.GameEndWithUnite(this.Factions[0] as Faction);
                }
            }
        }
コード例 #8
0
 public static FactionList GetGameScenarioFactions(OleDbConnection DbConnection)
 {
     DbConnection.Open();
     OleDbDataReader reader = new OleDbCommand("Select * From Faction", DbConnection).ExecuteReader();
     FactionList list = new FactionList();
     while (reader.Read())
     {
         Faction t = new Faction();
         t.ID = (short) reader["ID"];
         t.LeaderID = (short) reader["LeaderID"];
         t.Name = reader["FName"].ToString();
         try
         {
             if (!((bool)reader["NotPlayerSelectable"]))
             {
                 list.Add(t);
             }
         }
         catch
         {
             list.Add(t);
         }
     }
     DbConnection.Close();
     return list;
 }
コード例 #9
0
        public void addBattleEntry(bool addYearTable, GameDate date, OngoingBattle ob, Person p, ArchitectureList architectures,
                                   Dictionary <Faction, int> factionDamages)
        {
            if (factionDamages.Count < 1)
            {
                return;
            }

            if (p.BelongedFaction == null)
            {
                return;
            }

            String      allFactionStrings = "";
            FactionList fl = new FactionList();

            foreach (Faction f in factionDamages.Keys)
            {
                allFactionStrings += "、" + (f == null ? "贼军" : f.Name);
                fl.Add(f);
            }
            allFactionStrings = allFactionStrings.Substring(1);

            String architectureStrings = "";

            if (architectures.Count > 0)
            {
                foreach (Architecture a in architectures)
                {
                    architectureStrings += "、" + a.Name;
                }
                architectureStrings = architectureStrings.Substring(1);
            }

            int dayDiff = (date.Year - ob.StartYear) * 360 + (date.Month - ob.StartMonth) * 30 + (date.Day - ob.StartDay) - 5;

            if (dayDiff <= 0)
            {
                return;
            }

            Dictionary <Faction, int> totalDamages = new Dictionary <Faction, int>();

            foreach (Faction f in factionDamages.Keys)
            {
                totalDamages.Add(f, 0);
                foreach (KeyValuePair <Faction, int> pair in factionDamages)
                {
                    if (f != pair.Key)
                    {
                        totalDamages[f] += pair.Value;
                    }
                }
            }

            List <KeyValuePair <Faction, int> > damageList = totalDamages.ToList();

            damageList.Sort((firstPair, nextPair) => - firstPair.Value.CompareTo(nextPair.Value));

            List <KeyValuePair <Faction, int> > selfDamageList = factionDamages.ToList();

            selfDamageList.Sort((firstPair, nextPair) => firstPair.Value.CompareTo(nextPair.Value));

            String victorDescription = "";
            String selfDescription   = "";

            if (ob.Skirmish)
            {
                if (damageList.Count > 1)
                {
                    if (damageList[0].Value > damageList[1].Value * 1.5)
                    {
                        victorDescription = (damageList[0].Key == null ? "贼军" : damageList[0].Key.Name) + "大胜";
                    }
                    else if (damageList[0].Value > damageList[1].Value * 1.2)
                    {
                        victorDescription = (damageList[0].Key == null ? "贼军" : damageList[0].Key.Name) + "小胜";
                    }
                    else
                    {
                        victorDescription = "互有胜负";
                    }

                    int rank = 0;
                    foreach (KeyValuePair <Faction, int> i in damageList)
                    {
                        if (i.Key == p.BelongedFaction)
                        {
                            if (rank == 0)
                            {
                                if (damageList[0].Value > damageList[1].Value * 1.5)
                                {
                                    selfDescription = "并大胜敌人";
                                }
                                else if (damageList[0].Value > damageList[1].Value * 1.2)
                                {
                                    selfDescription = "并小胜敌人";
                                }
                                else
                                {
                                    selfDescription = "互有胜负";
                                }
                            }
                            else if (rank == damageList.Count - 1)
                            {
                                if (damageList[0].Value > damageList[rank].Value * 1.5)
                                {
                                    selfDescription = "却遭到大败";
                                }
                                else if (damageList[0].Value > damageList[rank].Value * 1.2)
                                {
                                    selfDescription = "却遭遇小败";
                                }
                                else
                                {
                                    selfDescription = "互有胜负";
                                }
                            }
                        }
                        rank++;
                    }
                }
            }

            if (ob.Skirmish)
            {
                if (addYearTable)
                {
                    this.addTableEntry(date, fl, String.Format(yearTableStrings["battleSkirmish"],
                                                               p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                                               allFactionStrings + "之间",
                                                               "",
                                                               architectureStrings,
                                                               "",
                                                               "",
                                                               dayDiff + "天",
                                                               victorDescription), false);
                }
                this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleSkirmish_p"],
                                                                     p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                                                     allFactionStrings + "之间",
                                                                     "",
                                                                     architectureStrings,
                                                                     "",
                                                                     "",
                                                                     dayDiff + "天",
                                                                     selfDescription));
            }
            else
            {
                foreach (Architecture a in architectures)
                {
                    if (a.BelongedFaction == null ||
                        (a.OldFactionName != a.BelongedFaction.Name))
                    {
                        if (addYearTable)
                        {
                            this.addTableEntry(date, fl, String.Format(yearTableStrings["battleOccupy"],
                                                                       p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                                                       allFactionStrings + "之间",
                                                                       a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                       a.Name,
                                                                       a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                       a.OldFactionName,
                                                                       dayDiff + "天"), false);
                        }

                        if (p.BelongedFaction == a.BelongedFaction)
                        {
                            this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_p"],
                                                                                 p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                                                                 allFactionStrings + "之间",
                                                                                 a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                                 a.Name,
                                                                                 a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                                 a.OldFactionName,
                                                                                 dayDiff + "天"));
                        }
                        else if (p.BelongedFaction.Name == a.OldFactionName)
                        {
                            this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_q"],
                                                                                 p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                                                                 allFactionStrings + "之间",
                                                                                 a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                                 a.Name,
                                                                                 a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                                 a.OldFactionName,
                                                                                 dayDiff + "天"));
                        }
                        else
                        {
                            this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_r"],
                                                                                 p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                                                                 allFactionStrings + "之间",
                                                                                 a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                                 a.Name,
                                                                                 a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                                 a.OldFactionName,
                                                                                 dayDiff + "天"));
                        }
                    }
                    else
                    {
                        String offenderString = "";

                        if (fl.Count > 1)
                        {
                            foreach (Faction f in fl)
                            {
                                if (f != a.BelongedFaction)
                                {
                                    offenderString += "、" + f.Name;
                                }
                            }
                            offenderString = offenderString.Substring(1);
                        }

                        if (addYearTable)
                        {
                            this.addTableEntry(date, fl, String.Format(yearTableStrings["battleRetreat"],
                                                                       p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                                                       allFactionStrings + "之间",
                                                                       a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                       a.Name,
                                                                       offenderString,
                                                                       a.OldFactionName,
                                                                       dayDiff + "天"), false);
                        }

                        if (a.BelongedFaction == p.BelongedFaction)
                        {
                            this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleRetreat_p"],
                                                                                 p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                                                                 allFactionStrings + "之间",
                                                                                 a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                                 a.Name,
                                                                                 offenderString,
                                                                                 a.OldFactionName,
                                                                                 dayDiff + "天"));
                        }
                        else
                        {
                            this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleRetreat_q"],
                                                                                 p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                                                                 allFactionStrings + "之间",
                                                                                 a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                                                                 a.Name,
                                                                                 offenderString,
                                                                                 a.OldFactionName,
                                                                                 dayDiff + "天"));
                        }
                    }
                }
            }
        }
コード例 #10
0
        public void addBattleEntry(bool addYearTable, GameDate date, OngoingBattle ob, Person p, ArchitectureList architectures,
            Dictionary<Faction, int> factionDamages)
        {
            if (factionDamages.Count < 1) return;

            if (p.BelongedFaction == null) return;

            String allFactionStrings = "";
            FactionList fl = new FactionList();
            foreach (Faction f in factionDamages.Keys)
            {
                allFactionStrings += "、" + (f == null ? "贼军" : f.Name);
                fl.Add(f);
            }
            allFactionStrings = allFactionStrings.Substring(1);

            String architectureStrings = "";
            if (architectures.Count > 0)
            {
                foreach (Architecture a in architectures)
                {
                    architectureStrings += "、" + a.Name;
                }
                architectureStrings = architectureStrings.Substring(1);
            }

            int dayDiff = (date.Year - ob.StartYear) * 360 + (date.Month - ob.StartMonth) * 30 + (date.Day - ob.StartDay) - 5;
            if (dayDiff <= 0) return;

            Dictionary<Faction, int> totalDamages = new Dictionary<Faction, int>();
            foreach (Faction f in factionDamages.Keys)
            {
                totalDamages.Add(f, 0);
                foreach (KeyValuePair<Faction, int> pair in factionDamages)
                {
                    if (f != pair.Key)
                    {
                        totalDamages[f] += pair.Value;
                    }
                }
            }

            List<KeyValuePair<Faction, int>> damageList = totalDamages.ToList();
            damageList.Sort((firstPair, nextPair) => -firstPair.Value.CompareTo(nextPair.Value));

            List<KeyValuePair<Faction, int>> selfDamageList = factionDamages.ToList();
            selfDamageList.Sort((firstPair, nextPair) => firstPair.Value.CompareTo(nextPair.Value));

            String victorDescription = "";
            String selfDescription = "";

            if (ob.Skirmish)
            {
                if (damageList.Count > 1)
                {
                    if (damageList[0].Value > damageList[1].Value * 1.5)
                    {
                        victorDescription = (damageList[0].Key == null ? "贼军" : damageList[0].Key.Name) + "大胜";
                    }
                    else if (damageList[0].Value > damageList[1].Value * 1.2)
                    {
                        victorDescription = (damageList[0].Key == null ? "贼军" : damageList[0].Key.Name) + "小胜";
                    }
                    else
                    {
                        victorDescription = "互有胜负";
                    }

                    int rank = 0;
                    foreach (KeyValuePair<Faction, int> i in damageList)
                    {
                        if (i.Key == p.BelongedFaction)
                        {
                            if (rank == 0)
                            {
                                if (damageList[0].Value > damageList[1].Value * 1.5)
                                {
                                    selfDescription = "并大胜敌人";
                                }
                                else if (damageList[0].Value > damageList[1].Value * 1.2)
                                {
                                    selfDescription = "并小胜敌人";
                                }
                                else
                                {
                                    selfDescription = "互有胜负";
                                }
                            }
                            else if (rank == damageList.Count - 1)
                            {
                                if (damageList[0].Value > damageList[rank].Value * 1.5)
                                {
                                    selfDescription = "却遭到大败";
                                }
                                else if (damageList[0].Value > damageList[rank].Value * 1.2)
                                {
                                    selfDescription = "却遭遇小败";
                                }
                                else
                                {
                                    selfDescription = "互有胜负";
                                }
                            }
                        }
                        rank++;
                    }
                }
            }

            if (ob.Skirmish)
            {
                if (addYearTable)
                {
                    this.addTableEntry(date, fl, String.Format(yearTableStrings["battleSkirmish"],
                        p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                        allFactionStrings + "之间",
                        "",
                        architectureStrings,
                        "",
                        "",
                        dayDiff + "天",
                        victorDescription), false);
                }
                this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleSkirmish_p"],
                    p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                    allFactionStrings + "之间",
                    "",
                    architectureStrings,
                    "",
                    "",
                    dayDiff + "天",
                    selfDescription));
            }
            else
            {
                foreach (Architecture a in architectures)
                {
                    if (a.BelongedFaction == null
                        || (a.OldFactionName != a.BelongedFaction.Name))
                    {
                        if (addYearTable)
                        {
                            this.addTableEntry(date, fl, String.Format(yearTableStrings["battleOccupy"],
                                p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                allFactionStrings + "之间",
                                a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                a.Name,
                                a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                a.OldFactionName,
                                dayDiff + "天"), false);
                        }

                        if (p.BelongedFaction == a.BelongedFaction)
                        {
                            this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_p"],
                                    p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                    allFactionStrings + "之间",
                                    a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                    a.Name,
                                    a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                    a.OldFactionName,
                                    dayDiff + "天"));
                        }
                        else if (p.BelongedFaction.Name == a.OldFactionName)
                        {
                            this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_q"],
                                    p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                    allFactionStrings + "之间",
                                    a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                    a.Name,
                                    a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                    a.OldFactionName,
                                    dayDiff + "天"));
                        }
                        else
                        {
                            this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_r"],
                                    p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                    allFactionStrings + "之间",
                                    a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                    a.Name,
                                    a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                    a.OldFactionName,
                                    dayDiff + "天"));
                        }
                    }
                    else
                    {
                        String offenderString = "";

                        if (fl.Count > 1)
                        {
                            foreach (Faction f in fl)
                            {
                                if (f != a.BelongedFaction)
                                {
                                    offenderString += "、" + f.Name;
                                }
                            }
                            offenderString = offenderString.Substring(1);
                        }

                        if (addYearTable)
                        {
                            this.addTableEntry(date, fl, String.Format(yearTableStrings["battleRetreat"],
                                p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                allFactionStrings + "之间",
                                a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                a.Name,
                                offenderString,
                                a.OldFactionName,
                                dayDiff + "天"), false);
                        }

                        if (a.BelongedFaction == p.BelongedFaction)
                        {
                            this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleRetreat_p"],
                                p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                allFactionStrings + "之间",
                                a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                a.Name,
                                offenderString,
                                a.OldFactionName,
                                dayDiff + "天"));
                        }
                        else
                        {
                            this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleRetreat_q"],
                                p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name,
                                allFactionStrings + "之间",
                                a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name,
                                a.Name,
                                offenderString,
                                a.OldFactionName,
                                dayDiff + "天"));
                        }
                    }
                }
            }
        }
コード例 #11
0
 private void 删除势力ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FactionList list = new FactionList();
     for (int i = 0; i < this.dgvFactions.SelectedRows.Count; i++)
     {
         list.Add(this.Factions[this.dgvFactions.SelectedRows[i].Index]);
     }
     foreach (Faction faction in this.Scenario.Factions)
     {
         foreach (Faction faction2 in list)
         {
             this.Scenario.DiplomaticRelations.RemoveDiplomaticRelationByFactionID(faction2.ID);
         }
     }
     foreach (Faction faction in list)
     {
         this.Scenario.Factions.RemoveFaction(faction);
     }
     foreach (Legion legion in this.Scenario.Legions.GetList())
     {
         if (legion.BelongedFaction == null)
         {
             this.Scenario.Legions.Remove(legion);
         }
     }
     foreach (Section section in this.Scenario.Sections.GetList())
     {
         if (section.BelongedFaction == null)
         {
             this.Scenario.Sections.Remove(section);
         }
     }
     this.RebindDataSource();
 }
コード例 #12
0
        private void CheckGameEnd()
        {
            FactionList noArchFaction = new FactionList();
            foreach (Faction f in this.Factions)
            {
                if (f.ArchitectureCount == 0)
                {
                    noArchFaction.Add(f);
                }
            }

            foreach (Faction f in noArchFaction)
            {
                this.Factions.Remove(f);
            }

            if (this.Factions.Count == 1)
            {
                ExtensionInterface.call("GameEnd", new Object[]{this});
                this.GameScreen.GameEndWithUnite(this.Factions[0] as Faction);
            }
        }