Exemple #1
0
        public bool HasTreatyRight(Faction giverFaction, Func <TreatyEffectType, bool> test, Planet planet = null)
        {
            if (giverFaction == null)
            {
                return(false);
            }
            var effects = TreatyEffectsByReceivingFactionID.Where(x => x.FactionTreaty.TreatyState == TreatyState.Accepted && x.GivingFactionID == giverFaction.FactionID && (x.Planet == null || x.Planet == planet)).ToList();

            return(effects.Any(x => test(x.TreatyEffectType)));
        }
        public List <FactionUnlockEntry> GetFactionUnlocks()
        {
            var ret = Planets.SelectMany(y => y.PlanetStructures).Where(x => x.IsActive && x.StructureType.EffectUnlockID != null).GroupBy(x => x.StructureType.Unlock).Select(x =>
                                                                                                                                                                               new FactionUnlockEntry()
            {
                Unlock = x.Key, Faction = this
            })
                      .ToList();

            foreach (var provider in TreatyEffectsByReceivingFactionID.Where(x => x.FactionTreaty.TreatyState == TreatyState.Accepted && x.TreatyEffectType.EffectShareTechs == true).GroupBy(x => x.FactionByGivingFactionID).Select(x => x.Key))
            {
                foreach (var tech in Planets.SelectMany(y => y.PlanetStructures).Where(x => x.IsActive && x.StructureType.EffectUnlockID != null).GroupBy(x => x.StructureType.Unlock).Select(x => x.Key))
                {
                    if (!ret.Any(x => x.Unlock == tech))
                    {
                        ret.Add(new FactionUnlockEntry()
                        {
                            Unlock = tech, Faction = provider
                        });
                    }
                }
            }
            return(ret);
        }