예제 #1
0
 public static string FactionColor(Faction fac, int myFactionID)
 {
     if (fac == null) return "";
     return fac.Color;
 }
예제 #2
0
 public bool HasTreatyRight(Faction giverFaction, Func<TreatyEffectType, bool> test, Planet planet = null)
 {
     var effects = TreatyEffectsByReceivingFactionID.Where(x => x.FactionTreaty.TreatyState == TreatyState.Accepted && x.GivingFactionID == giverFaction.FactionID && (x.Planet == null || x.Planet == planet));
     return effects.Any(x => test(x.TreatyEffectType));
 }
 public static MvcHtmlString PrintInfluence(this HtmlHelper helper, Faction faction, int influence, int shadowInfluence) {
     var formatString = "<span style='color:{0}'>{1}</span>";
     if (shadowInfluence > 0) formatString += "&nbsp({2}&nbsp+&nbsp<span style='color:gray'>{3}</span>)";
     var formattedString = string.Format(formatString, faction.Color, influence + shadowInfluence, influence, shadowInfluence);
     return new MvcHtmlString(formattedString);
 }
 public static MvcHtmlString PrintFactionRoleHolders(this HtmlHelper helper, RoleType rt, Faction f) {
     List<MvcHtmlString> holders = new List<MvcHtmlString>();
     foreach (AccountRole acc in rt.AccountRoles.Where(x=>x.Account.FactionID == f.FactionID)) 
     {
         holders.Add(PrintAccount(helper, acc.Account));
     }
     return new MvcHtmlString(String.Join(", ", holders));
 }
 public static MvcHtmlString PrintFaction(this HtmlHelper helper, Faction fac, bool big = true) {
     var url = Global.UrlHelper();
     if (fac != null) {
         if (big) {
             return
                 new MvcHtmlString(string.Format("<a href='{1}' nicetitle='$faction${2}'><img src='{0}'/></a>",
                                                 fac.GetImageUrl(),
                                                 url.Action("Detail", "Factions", new { id = fac.FactionID }),
                                                 fac.FactionID));
         }
         else {
             return
                 new MvcHtmlString(
                     string.Format(
                         "<a href='{3}' nicetitle='$faction${4}'><span style='color:{0}'><img src='{1}'  style='width:16px;height:16px'/>{2}</span></a>",
                         fac.Color,
                         fac.GetImageUrl(),
                         fac.Shortcut,
                         url.Action("Detail", "Factions", new { id = fac.FactionID }),
                         fac.FactionID));
         }
     }
     else return new MvcHtmlString("");
 }
 public static MvcHtmlString PrintInfluence(this HtmlHelper helper, Faction fac, double influence) {
     var formattedString = string.Format("<span style='color:{0}'>{1:0.#}%</span>", Faction.FactionColor(fac, Global.FactionID), influence);
     return new MvcHtmlString(formattedString);
 }
예제 #7
0
 public bool CanDropshipsAttack(Faction attacker)
 {
     if (attacker.FactionID == OwnerFactionID) return false; // cannot attack own
     return CheckLinkAttack(attacker, x => x.EffectPreventDropshipAttack == true, x => x.EffectAllowDropshipPass == true);
 }
 public static MvcHtmlString PrintDropships(this HtmlHelper helper, double? count, Faction faction) {
     return
         new MvcHtmlString(string.Format("<span>{0}<img src='{1}' class='icon20'/></span>", Math.Floor(count ?? 0), faction.GetShipImageUrl()));
 }
예제 #9
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;

        }
예제 #10
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;
        }
예제 #11
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;
 }
예제 #12
0
 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;
 }
예제 #13
0
 public bool CanBombersWarp(Faction attacker)
 {
     return CheckWarpAttack(attacker, x => x.EffectPreventBomberAttack == true);
 }
예제 #14
0
 public bool CanBombersAttack(Faction attacker)
 {
     return CheckLinkAttack(attacker, x => x.EffectPreventBomberAttack == true, x => x.EffectAllowBomberPass == true);
 }
예제 #15
0
 public bool CanDropshipsWarp(Faction attacker)
 {
     if (attacker.FactionID == OwnerFactionID) return false; // cannot attack own
     return CheckWarpAttack(attacker, x => x.EffectPreventDropshipAttack == true);
 }