Exemplo n.º 1
0
        public bool CheckLinkAttack(Faction attacker, Func <TreatyEffectType, bool> preventingTreaty, Func <TreatyEffectType, bool> passageTreaty)
        {
            if (attacker.GaveTreatyRight(this, preventingTreaty))
            {
                return(false);                          // attacker allied cannot strike
            }
            if (OwnerFactionID == attacker.FactionID)   // bomb own planet - only allow if other factions have IP
            {
                var otherFactions = PlanetFactions.Count(x => x.FactionID != attacker.FactionID && x.Influence > 0);
                return(otherFactions > 0);
            }

            if (Faction == null && !attacker.Planets.Any())
            {
                return(true);                                            // attacker has no planets, planet neutral, allow strike
            }
            // iterate links to this planet
            foreach (var link in LinksByPlanetID1.Union(LinksByPlanetID2))
            {
                var otherPlanet = PlanetID == link.PlanetID1 ? link.PlanetByPlanetID2 : link.PlanetByPlanetID1;

                // planet has wormhole active
                if (!GlobalConst.RequireWormholeToTravel || otherPlanet.PlanetStructures.Any(x => x.IsActive && x.StructureType.EffectAllowShipTraversal == true))
                {
                    // planet belongs to attacker or person who gave attacker rights to pass + if planet's faction has blocking treaty with attacker dont allow attack
                    if (otherPlanet.Faction != null && (otherPlanet.OwnerFactionID == attacker.FactionID || attacker.HasTreatyRight(otherPlanet.Faction, passageTreaty, otherPlanet)) && !otherPlanet.Faction.GaveTreatyRight(this, preventingTreaty))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 2
0
 public bool CanFirePlanetBuster(Faction attacker)
 {
     if (!Galaxy.IsDefault)
     {
         return(false);                      // no exo-galaxy strikes
     }
     if (OwnerFactionID == attacker.FactionID || attacker.GaveTreatyRight(this, x => x.EffectPreventBomberAttack == true))
     {
         return(false);                                                                                                                  // attacker allied cannot strike
     }
     //if (PlanetStructures.Any(x => x.StructureType.EffectIsVictoryPlanet == true)) return false; // artefact protects planet
     return(true);
 }
Exemplo n.º 3
0
 public bool CheckWarpAttack(Faction attacker, Func <TreatyEffectType, bool> preventingTreaty)
 {
     if (!Galaxy.IsDefault)
     {
         return(false);                      // no exo-galaxy strikes
     }
     if (OwnerFactionID == attacker.FactionID || attacker.GaveTreatyRight(this, preventingTreaty))
     {
         return(false);                                                                                          // attacker allied cannot strike
     }
     if (PlanetStructures.Any(x => x.IsActive && x.StructureType.EffectBlocksJumpgate == true))
     {
         return(false);                                                                                       // inhibitor active
     }
     return(true);
 }
Exemplo n.º 4
0
        public bool CheckWarpAttack(Faction attacker, Func<TreatyEffectType, bool> preventingTreaty)
        {
            if (!Galaxy.IsDefault) return false;    // no exo-galaxy strikes
            if (OwnerFactionID == attacker.FactionID || attacker.GaveTreatyRight(this, preventingTreaty)) return false; // attacker allied cannot strike
            if (PlanetStructures.Any(x => x.IsActive && x.StructureType.EffectBlocksJumpgate == true)) return false; // inhibitor active

            return true;
        }
Exemplo n.º 5
0
        public bool CheckLinkAttack(Faction attacker, Func<TreatyEffectType, bool> preventingTreaty, Func<TreatyEffectType, bool> passageTreaty)
        {

            if (attacker.GaveTreatyRight(this, preventingTreaty)) return false; // attacker allied cannot strike

            if (OwnerFactionID == attacker.FactionID)   // bomb own planet - only allow if other factions have IP
            {
                var otherFactions = PlanetFactions.Count(x => x.FactionID != attacker.FactionID && x.Influence > 0);
                return (otherFactions > 0);
            }

            if (Faction == null && !attacker.Planets.Any()) return true; // attacker has no planets, planet neutral, allow strike


            // iterate links to this planet
            foreach (var link in LinksByPlanetID1.Union(LinksByPlanetID2))
            {
                var otherPlanet = PlanetID == link.PlanetID1 ? link.PlanetByPlanetID2 : link.PlanetByPlanetID1;

                // planet has wormhole active
                if (!GlobalConst.RequireWormholeToTravel || otherPlanet.PlanetStructures.Any(x => x.IsActive && x.StructureType.EffectAllowShipTraversal == true))
                {

                    // planet belongs to attacker or person who gave attacker rights to pass + if planet's faction has blocking treaty with attacker dont allow attack
                    if (otherPlanet.Faction != null && (otherPlanet.OwnerFactionID == attacker.FactionID || attacker.HasTreatyRight(otherPlanet.Faction, passageTreaty, otherPlanet)) && !otherPlanet.Faction.GaveTreatyRight(this, preventingTreaty))
                    {
                        return true;
                    }
                }
            }
            return false;

        }
Exemplo n.º 6
0
 public bool CanFirePlanetBuster(Faction attacker)
 {
     if (!Galaxy.IsDefault) return false;    // no exo-galaxy strikes
     if (OwnerFactionID == attacker.FactionID || attacker.GaveTreatyRight(this, x => x.EffectPreventBomberAttack == true)) return false; // attacker allied cannot strike
     //if (PlanetStructures.Any(x => x.StructureType.EffectIsVictoryPlanet == true)) return false; // artefact protects planet
     return true;
 }