Beispiel #1
0
        public string GetEcopediaData(Player player, EcopediaPage page)
        {
            var sb = new StringBuilder();

            sb.AppendLine(typeof(GameAction).DerivedTypes().Where(x => !x.IsAbstract).OrderBy(x => x.GetLocDisplayName()).Select(x => x.UILink()).MakeListLoc($"Available Causes"));
            sb.AppendLine(typeof(LegalAction).DerivedTypes().Where(x => !x.IsAbstract).OrderBy(x => x.GetLocDisplayName()).Select(x => x.UILink()).MakeListLoc($"Available Effects"));
            return(sb.ToString());
        }
Beispiel #2
0
        public string GetEcopediaData(Player player, EcopediaPage page)
        {
            var sb = new StringBuilder();

            sb.AppendLineLoc($"A citizen may grant reputation to others with a limit of {Text.StyledNum(Reputation.MaxGivableRep)} points (positive or negative) per day.");
            sb.AppendLine();
            var reps = UserManager.Config.Reputations.Select(x => x.ToString());

            sb.AppendListLoc($"Reputation Titles", reps, false, false);
            return(sb.ToString());
        }
Beispiel #3
0
        public string GetEcopediaData(Player player, EcopediaPage page)
        {
            var i         = 0;
            var penalties = HousingCalculation.OccupancyPenalties;

            if (penalties == null)
            {
                return(string.Empty);
            }
            var list = penalties.Skip(1).Take(penalties.Count() - 2)
                       .Select(x => $"{Text.PluralLocStr(Localizer.DoStr("Occupant"), "Occupants", i++)}: {Text.StyledPercent(x)}")
                       .Append(Localizer.Do($"{penalties.Count() - 1} or more Occupants: {Text.StyledPercent(penalties.Last())}"));

            return(list.MakeListLoc($"Occupancy Penalties:", false));
        }
        public string GetEcopediaData(Player player, EcopediaPage page)
        {
            var regs = Registrars.AllRegistrars.Where(x => x.EcopediaPageName == page.Name);
            var sb   = new StringBuilder();

            foreach (var reg in regs)
            {
                sb.AppendLine(reg.All().
                              Where(x => (x as IEcopediaEntry)?.IsVisibleInEcopedia ?? true)
                              .OrderBy(x => this.SortOrder(x as IProposable))
                              .ThenBy(x => x.Name)
                              .Select(x => new LocString(x.MarkedUpName))
                              .MakeList(reg.RegistrarName));
            }
            return(sb.ToString());
        }
Beispiel #5
0
        public string GetEcopediaData(Player player, EcopediaPage page)
        {
            var cur            = ConstitutionManager.Obj.Current;
            var valToOverthrow = Text.StyledNum(CivicsPlugin.Obj.Config.ValueAdditionToOverthrow);
            var curVal         = Text.StyledNum(cur?.RoomValue.Get ?? 0f);
            var newVal         = Text.StyledNum(ConstitutionManager.Obj.Current?.RoomValue.Get ?? 0);

            var sb = new StringBuilder();

            sb.AppendLine(TextLoc.HeaderLocStr("World Settings"));
            sb.AppendLineLoc($"Constitutions can be overthrown when their value is exceeded by {valToOverthrow}%.");
            sb.AppendLocStr("Current constituion:");
            sb.Append(" ");
            if (cur == null)
            {
                sb.AppendLine(TextLoc.BoldLocStr("None."));
            }
            else
            {
                sb.AppendLineLoc($"{cur.UILink()} with room value {curVal}");
            }
            return(sb.ToString());
        }
        public static void EcopediaDetails()
        {
            // dictionary of page details
            Dictionary <string, string> entry = new Dictionary <string, string>()
            {
                { "displayName", "nil" },
                { "displayNameUntranslated", "nil" },
                { "summary", "nil" },
                { "subpages", "nil" },
                { "associatedTypes", "nil" },
                { "sectionsText", "nil" },
            };

            foreach (var cat in Ecopedia.Obj.Categories.Values)
            {
                foreach (var page in cat.Pages)
                {
                    EcopediaPage p        = page.Value;
                    string       pageName = p.DisplayName;
                    if (!EveryPage.ContainsKey(p.DisplayName))
                    {
                        EveryPage.Add(pageName, new Dictionary <string, string>(entry));

                        StringBuilder sb = new StringBuilder();
                        if (p.Sections != null)
                        {
                            foreach (var sec in p.Sections)
                            {
                                if (sec is EcopediaBanner || sec is EcopediaButton)
                                {
                                    continue;
                                }

                                sb.Append($"{{'{sec.GetType().Name}', '{Regex.Replace(JSONStringSafe(CleanTags(sec.Text)),"[\n\r]+", "\\n\\n")}'}}");

                                if (sec != p.Sections.Last())
                                {
                                    sb.Append(", ");
                                }
                            }
                            EveryPage[pageName]["sectionsText"] = $"{{{sb}}}";
                        }

                        if (p.SubPages != null)
                        {
                            sb = new StringBuilder();
                            foreach (var sp in p.SubPages)
                            {
                                sb.Append($"'{Localizer.DoStr(sp.Key)}'");

                                if (sp.Key != p.SubPages.Last().Key)
                                {
                                    sb.Append(", ");
                                }
                            }
                            EveryPage[pageName]["subpages"] = $"{{{sb}}}";
                        }

                        EveryPage[pageName]["displayName"]             = p.DisplayName != null ? $"'{p.DisplayName}'" : $"nil";
                        EveryPage[pageName]["displayNameUntranslated"] = p.DisplayName.NotTranslated != null ? $"'{p.DisplayName.NotTranslated}'" : $"nil";

                        if (p.Summary != null && p.Summary != "")
                        {
                            var sum = p.Summary.Trim().TrimEnd('\r', '\n').Trim();
                            EveryPage[pageName]["summary"] = $"'{sum}'";
                        }

                        // There appears to be no need for the generated data as it's world specific info

                        /*
                         * EveryPage[pageName]["hasGeneratedData"] = p.HasGeneratedData? Localizer.DoStr("Yes") : Localizer.DoStr("No");
                         *
                         * sb = new StringBuilder();
                         * var genData = (List<IEcopediaGeneratedData>)GetFieldValue(p, "generatedData");
                         * if (genData != null)
                         * {
                         *  foreach (var gd in genData)
                         *  {
                         *      sb.Append(gd.GetEcopediaData(user.Player, p));
                         *
                         *      if (gd != genData.Last())
                         *          sb.Append(", ");
                         *  }
                         *  EveryPage[pageName]["generatedData"] = $"{sb}";
                         * }
                         */

                        if (p.AssociatedTypes != null && p.AssociatedTypes.Count > 0)
                        {
                            sb = new StringBuilder();
                            foreach (var(Type, Display) in p.AssociatedTypes)
                            {
                                sb.Append($"'{Localizer.DoStr(Type.Name)}'");

                                if (Type.Name != p.AssociatedTypes.Last().Type.Name)
                                {
                                    sb.Append(", ");
                                }
                            }
                            EveryPage[pageName]["associatedTypes"] = $"{{{sb}}}";
                        }
                    }
                }
            }

            // writes to WikiItems.txt to the Eco Server directory.
            WriteDictionaryToFile("Wiki_Module_Ecopedia.txt", "ecopedia", EveryPage);
        }