Exemple #1
0
        private static (string message, string clearMessage, List <ItemObject> combined) BuildItemHint(ItemObject item, RandomizedResult randomizedResult,
                                                                                                       GossipHintStyle hintStyle, List <ItemObject> itemsToCombineWith, List <ItemObject> hintableItems, Func <ItemObject, bool> shouldIndicateImportance, Random random)
        {
            ushort soundEffectId = 0x690C; // grandma curious
            var    itemNames     = new List <string>();
            var    locationNames = new List <string>();
            bool   hasOrder      = item.NewLocation.Value.HasAttribute <GossipCombineOrderAttribute>();
            var    combined      = new List <ItemObject>();

            combined.Add(item);

            var article    = randomizedResult.Settings.ProgressiveUpgrades && item.Item.HasAttribute <ProgressiveAttribute>() ? "a " : GetArticle(item.Item);
            var color      = TextCommands.ColorPink;
            var importance = "";

            if (randomizedResult.Settings.HintsIndicateImportance && shouldIndicateImportance?.Invoke(item) == true)
            {
                var locationForImportance = item.Item.MainLocation().HasValue ? item.Item : item.NewLocation.Value;
                var isRequired            = ItemUtils.IsRequired(item.Item, locationForImportance, randomizedResult, true);
                if (!ItemUtils.IsLogicallyJunk(item.Item))
                {
                    importance = isRequired ? " (required)" : " (not required)";
                }
                color = isRequired ? TextCommands.ColorYellow : TextCommands.ColorSilver;
            }
            itemNames.Add(article + color + item.Item.ProgressiveUpgradeName(randomizedResult.Settings.ProgressiveUpgrades) + TextCommands.ColorWhite + importance);
            locationNames.Add(item.NewLocation.Value.Location());
            if (hintStyle != GossipHintStyle.Relevant)
            {
                var gossipCombineAttribute = item.NewLocation.Value.GetAttribute <GossipCombineAttribute>();
                combined = itemsToCombineWith.Where(io => gossipCombineAttribute?.OtherItems.Contains(io.NewLocation.Value) == true).ToList();
                if (combined.Any())
                {
                    combined.Add(item);
                    combined = combined.OrderBy(io => io.NewLocation.Value.GetAttribute <GossipCombineOrderAttribute>()?.Order ?? random.Next()).ToList();
                    locationNames.Clear();
                    itemNames.Clear();
                    var combinedName = gossipCombineAttribute.CombinedName;
                    if (!string.IsNullOrWhiteSpace(combinedName))
                    {
                        locationNames.Add(combinedName);
                    }
                    else
                    {
                        locationNames.AddRange(combined.Select(io => io.NewLocation.Value.Location()));
                    }
                    itemNames.AddRange(combined.Select(io =>
                    {
                        article    = randomizedResult.Settings.ProgressiveUpgrades && io.Item.HasAttribute <ProgressiveAttribute>() ? "a " : GetArticle(io.Item);
                        color      = TextCommands.ColorPink;
                        importance = "";
                        if (randomizedResult.Settings.HintsIndicateImportance && shouldIndicateImportance?.Invoke(io) == true)
                        {
                            var locationForImportance = io.Item.MainLocation().HasValue ? io.Item : io.NewLocation.Value;
                            var isRequired            = ItemUtils.IsRequired(io.Item, locationForImportance, randomizedResult, true);
                            if (!ItemUtils.IsLogicallyJunk(io.Item))
                            {
                                importance = isRequired ? " (required)" : " (not required)";
                            }
                            color = isRequired ? TextCommands.ColorYellow : TextCommands.ColorSilver;
                        }
                        return(article + color + io.Item.ProgressiveUpgradeName(randomizedResult.Settings.ProgressiveUpgrades) + TextCommands.ColorWhite + importance);
                    }));
                }
                else
                {
                    combined.Add(item);
                }
            }
            string clearMessage = null;

            if (itemNames.Any() && locationNames.Any())
            {
                clearMessage = BuildGossipQuote(soundEffectId, locationNames, itemNames, hasOrder, random);
            }

            itemNames.Clear();
            locationNames.Clear();
            if (item.Mimic != null)
            {
                // If item has a mimic and not using clear hints, always use a fake hint.
                soundEffectId = 0x690A; // grandma laugh
                itemNames.Add(item.Mimic.Item.ItemHints().Random(random));
                locationNames.Add(item.NewLocation.Value.LocationHints().Random(random));
            }
            else if (hintStyle != GossipHintStyle.Random || random.Next(100) >= 5) // 5% chance of fake/junk hint if it's not a moon gossip stone or competitive style
            {
                itemNames.Add(item.Item.ItemHints().Random(random));
                locationNames.Add(item.NewLocation.Value.LocationHints().Random(random));
            }
            else
            {
                if (random.Next(2) == 0)    // 50% chance for fake hint. otherwise default to junk hint.
                {
                    soundEffectId = 0x690A; // grandma laugh
                    itemNames.Add(item.Item.ItemHints().Random(random));
                    locationNames.Add(hintableItems.Random(random).NewLocation.Value.LocationHints().Random(random));
                }
            }
            if (itemNames.Any())
            {
                itemNames[0] = $"{TextCommands.ColorPink}{itemNames[0]}{TextCommands.ColorWhite}";
            }

            string message = null;

            if (itemNames.Any() && locationNames.Any())
            {
                message = BuildGossipQuote(soundEffectId, locationNames, itemNames, hasOrder, random);
                //return (BuildGossipQuote(soundEffectId, locationNames, itemNames, hasOrder, random), combined);
            }

            if (message != null || clearMessage != null)
            {
                return(message, clearMessage, combined);
            }

            return(null, null, null);
        }