Exemple #1
0
        private static void VisitorGiftChance()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("Current wealth factor (wealth=" + Find.CurrentMap.wealthWatcher.WealthTotal.ToString("F0") + "): ");
            stringBuilder.AppendLine(VisitorGiftForPlayerUtility.PlayerWealthChanceFactor(Find.CurrentMap).ToStringPercent());
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Chance per faction:");
            foreach (Faction current in Find.FactionManager.AllFactions)
            {
                if (!current.IsPlayer && !current.HostileTo(Faction.OfPlayer) && !current.def.hidden)
                {
                    stringBuilder.Append(string.Concat(new string[]
                    {
                        current.Name,
                        " (",
                        current.PlayerGoodwill.ToStringWithSign(),
                        ", ",
                        current.PlayerRelationKind.GetLabel(),
                        ")"
                    }));
                    stringBuilder.Append(": " + VisitorGiftForPlayerUtility.ChanceToLeaveGift(current, Find.CurrentMap).ToStringPercent());
                    stringBuilder.AppendLine(" (rels factor: " + VisitorGiftForPlayerUtility.FactionRelationsChanceFactor(current).ToStringPercent() + ")");
                }
            }
            int num = 0;

            for (int i = 0; i < 6; i++)
            {
                Dictionary <IIncidentTarget, int> dictionary;
                int[] array;
                List <Pair <IncidentDef, IncidentParms> > list;
                int num2;
                StorytellerUtility.DebugGetFutureIncidents(60, true, out dictionary, out array, out list, out num2, null, null);
                for (int j = 0; j < list.Count; j++)
                {
                    if (list[j].First == IncidentDefOf.VisitorGroup || list[j].First == IncidentDefOf.TraderCaravanArrival)
                    {
                        Faction faction = list[j].Second.faction ?? Find.FactionManager.RandomNonHostileFaction(false, false, false, TechLevel.Undefined);
                        if (Rand.Chance(VisitorGiftForPlayerUtility.ChanceToLeaveGift(faction, Find.CurrentMap)))
                        {
                            num++;
                        }
                    }
                }
            }
            float num3 = (float)num / 6f;

            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Calculated number of gifts received on average within the next 1 year");
            stringBuilder.AppendLine("(assuming current wealth and faction relations)");
            stringBuilder.Append("  = " + num3.ToString("0.##"));
            Log.Message(stringBuilder.ToString(), false);
        }
        private static void VisitorGiftChance()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("Current wealth factor (wealth=" + Find.CurrentMap.wealthWatcher.WealthTotal.ToString("F0") + "): ");
            stringBuilder.AppendLine(PlayerWealthChanceFactor(Find.CurrentMap).ToStringPercent());
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Chance per faction:");
            foreach (Faction allFaction in Find.FactionManager.AllFactions)
            {
                if (!allFaction.IsPlayer && !allFaction.HostileTo(Faction.OfPlayer) && !allFaction.def.hidden)
                {
                    stringBuilder.Append(allFaction.Name + " (" + allFaction.PlayerGoodwill.ToStringWithSign() + ", " + allFaction.PlayerRelationKind.GetLabel() + ")");
                    stringBuilder.Append(": " + ChanceToLeaveGift(allFaction, Find.CurrentMap).ToStringPercent());
                    stringBuilder.AppendLine(" (rels factor: " + FactionRelationsChanceFactor(allFaction).ToStringPercent() + ")");
                }
            }
            int num = 0;

            for (int i = 0; i < 6; i++)
            {
                StorytellerUtility.DebugGetFutureIncidents(60, currentMapOnly: true, out Dictionary <IIncidentTarget, int> _, out int[] _, out List <Pair <IncidentDef, IncidentParms> > allIncidents, out int _);
                for (int j = 0; j < allIncidents.Count; j++)
                {
                    if (allIncidents[j].First == IncidentDefOf.VisitorGroup || allIncidents[j].First == IncidentDefOf.TraderCaravanArrival)
                    {
                        Faction faction = allIncidents[j].Second.faction ?? Find.FactionManager.RandomNonHostileFaction(allowHidden: false, allowDefeated: false, allowNonHumanlike: false);
                        if (Rand.Chance(ChanceToLeaveGift(faction, Find.CurrentMap)))
                        {
                            num++;
                        }
                    }
                }
            }
            float num2 = (float)num / 6f;

            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Calculated number of gifts received on average within the next 1 year");
            stringBuilder.AppendLine("(assuming current wealth and faction relations)");
            stringBuilder.Append("  = " + num2.ToString("0.##"));
            Log.Message(stringBuilder.ToString());
        }
Exemple #3
0
        public static void DebugLogTestFutureIncidents(bool currentMapOnly, StorytellerComp onlyThisComp = null)
        {
            StringBuilder stringBuilder = new StringBuilder();
            string        text          = "Test future incidents for " + Find.Storyteller.def;
            string        text2;

            if (onlyThisComp != null)
            {
                text2 = text;
                text  = string.Concat(new object[]
                {
                    text2,
                    " (",
                    onlyThisComp,
                    ")"
                });
            }
            text2 = text;
            text  = string.Concat(new string[]
            {
                text2,
                " (",
                Find.TickManager.TicksGame.TicksToDays().ToString("F1"),
                "d - ",
                (Find.TickManager.TicksGame + 6000000).TicksToDays().ToString("F1"),
                "d)"
            });
            stringBuilder.AppendLine(text + ":");
            Dictionary <IIncidentTarget, int> source;

            int[] array;
            List <Pair <IncidentDef, IncidentParms> > source2;
            int num;

            StorytellerUtility.DebugGetFutureIncidents(100, currentMapOnly, out source, out array, out source2, out num, stringBuilder, onlyThisComp);
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Target totals:");
            foreach (KeyValuePair <IIncidentTarget, int> current in from kvp in source
                     orderby kvp.Value
                     select kvp)
            {
                stringBuilder.AppendLine(string.Concat(new object[]
                {
                    "  ",
                    current.Value,
                    ": ",
                    current.Key
                }));
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Incident totals:");
            for (int i = 0; i < array.Length; i++)
            {
                float f    = (float)array[i] / (float)array.Sum();
                float num2 = (float)array[i] / 100f;
                float num3 = 1f / num2;
                stringBuilder.AppendLine(string.Concat(new object[]
                {
                    "   M",
                    i,
                    ": ",
                    array[i],
                    "  (",
                    f.ToStringPercent("F2"),
                    " of total, avg ",
                    num2.ToString("F2"),
                    " per day, avg interval ",
                    num3,
                    ")"
                }));
            }
            stringBuilder.AppendLine("Total threats: " + num);
            stringBuilder.AppendLine("Total threats avg per day: " + ((float)num / 100f).ToString("F2"));
            stringBuilder.AppendLine("Overall: " + array.Sum());
            stringBuilder.AppendLine("Overall avg per day: " + ((float)array.Sum() / 100f).ToString("F2"));
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Incident defs used:");
            foreach (IncidentDef current2 in from x in (from x in source2
                                                        select x.First).Distinct <IncidentDef>()
                     orderby x.category.defName, x.defName
                     select x)
            {
                stringBuilder.AppendLine(current2.defName + " (" + current2.category.defName + ")");
            }
            Log.Message(stringBuilder.ToString(), false);
        }