Exemplo n.º 1
0
        private static string GetGroupDescription(List <CrewDescriptor> crew)
        {
            if (crew.Count == 1)
            {
                return(crew[0].Name);
            }

            CrewDescriptor        perp = ChooseOne(crew, null);
            List <CrewDescriptor> gang = crew.Where(c => c != perp).ToList();

            if (crew.Count == 2)
            {
                return($"{perp.Name} and {gang[0].Name}");
            }
            else if (gang.All(c => c.Gender == Gender.Male))
            {
                return($"{perp.Name} and the boys");
            }
            else if (gang.All(c => c.Gender == Gender.Female))
            {
                return($"{perp.Name} and the gals");
            }
            else
            {
                return($"{perp.Name} and the gang");
            }
        }
Exemplo n.º 2
0
        public static string CreateMessage(string baseMessageTag, List <ProtoCrewMember> crew, IEnumerable <string> experienceEffects, TechTier tier)
        {
            HashSet <string> possibleTraits = new HashSet <string>(
                experienceEffects.SelectMany(effect => GameDatabase.Instance
                                             .ExperienceConfigs
                                             .GetTraitsWithEffect(effect)));
            var            crewDescriptors = crew.Select(c => FromKsp(c, protocrew => possibleTraits.Contains(protocrew.trait))).ToList();
            CrewDescriptor perp            = null;
            CrewDescriptor victim          = null;

            string Replacer(Match match)
            {
                switch (match.Value)
                {
                case "[tier]":
                    return(tier.DisplayName());

                case "[perp_name]":
                    perp = perp ?? ChoosePerpetrator(crewDescriptors);
                    return(perp.Name);

                case "[victim_name]":
                    victim = victim ?? ChooseVictim(crewDescriptors);
                    return(victim.Name);

                case "[perp_heshe]":
                    perp = perp ?? ChoosePerpetrator(crewDescriptors);
                    return(perp.heshe);

                case "[perp_himher]":
                    perp = perp ?? ChoosePerpetrator(crewDescriptors);
                    return(perp.himher);

                case "[perp_hisher]":
                    perp = perp ?? ChoosePerpetrator(crewDescriptors);
                    return(perp.hisher);

                case "[victim_hisher]":
                    victim = victim ?? ChooseVictim(crewDescriptors);
                    return(victim.hisher);

                case "[perps]":
                    return(GetGroupDescription(crewDescriptors, true));

                case "[victims]":
                    return(GetGroupDescription(crewDescriptors, false));

                case "[victims_hashave]":
                    return(crewDescriptors.hashave());

                case "[victims_isare]":
                    return(crewDescriptors.isare());

                case "[victims_hishertheir]":
                    return(crewDescriptors.hishertheir());

                case "[crew]":
                    return(GetGroupDescription(crewDescriptors));

                case "[resource_name]":
                    return(GetMessage("LOC_KPBS_RANDOM_MINERAL"));

                case "[body]":
                    return(FlightGlobals.ActiveVessel.mainBody.name);

                default:
                    return($"?Unknown Substitution: {match.Value}?");
                }
            }

            string message = replacement.Replace(GetMessage(baseMessageTag), Replacer);

            return(message);
        }