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); }
public double GetEffectiveShipIpBonus(Faction attacker) { double planetDropshipDefs = (PlanetStructures.Where(x => x.IsActive).Sum(x => x.StructureType.EffectDropshipDefense) ?? 0); int dropshipsSent = (PlanetFactions.Where(x => x.Faction == attacker).Sum(x => (int?)x.Dropships) ?? 0); return(Math.Max(0, (dropshipsSent - planetDropshipDefs)) * GlobalConst.InfluencePerShip); }
public bool CanMatchMakerPlay(Faction attacker) { if (CanDropshipsAttack(attacker) || PlanetFactions.Where(x => x.FactionID == attacker.FactionID).Sum(y => y.Dropships) > PlanetStructures.Where(x => x.IsActive).Sum(y => y.StructureType.EffectDropshipDefense)) { return(true); } else { return(false); } }
public IEnumerable <PlanetFaction> GetFactionInfluences() { return(PlanetFactions.Where(x => x.Influence > 0).OrderByDescending(x => x.Influence)); }