Ejemplo n.º 1
0
        private void LoadData(string tabDelimitedCharacterDetailData)
        {
            var list       = new List <CharacterDetail>();
            int lineNumber = 0;

            foreach (var line in tabDelimitedCharacterDetailData.Split(new[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                string[]        items  = line.Split(new[] { "\t" }, StringSplitOptions.None);
                CharacterDetail detail = ProcessLine(items, lineNumber++);
                if (detail != null)
                {
                    list.Add(detail);
                }
            }
            list.AddRange(GetStandardCharacters());
            m_data = list;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// We used to use this in character group generation. We no longer use it, but since there are a lot of tests for it and it might
        /// be useful in the future, we'll keep it around for now.
        /// </summary>
        public bool Matches(CharacterDetail character, CharacterGenderMatchingOptions genderMatchingOptions, CharacterAgeMatchingOptions ageMatchingOptions)
        {
            if (!CharacterIds.Any())
            {
                return(false);                // Probably a group set aside for a special purpose in the group generator (e.g., narrator)
            }
            if (CharacterVerseData.IsCharacterStandard(character.CharacterId))
            {
                switch (CharacterVerseData.GetStandardCharacterType(character.CharacterId))
                {
                case CharacterVerseData.StandardCharacter.Narrator:
                    return(CharacterIds.All(i => CharacterVerseData.GetStandardCharacterType(i) == CharacterVerseData.StandardCharacter.Narrator));

                default:
                    return(CharacterIds.All(i =>
                    {
                        var type = CharacterVerseData.GetStandardCharacterType(i);
                        return type != CharacterVerseData.StandardCharacter.Narrator && type != CharacterVerseData.StandardCharacter.NonStandard;
                    }));
                }
            }
            if (CharacterIds.Any(i => CharacterVerseData.IsCharacterStandard(i)))
            {
                return(false);
            }

            bool result = true;

            var characterDetails = m_project.AllCharacterDetailDictionary;

            result &= CharacterIds.All(i =>
            {
                CharacterGender gender = characterDetails[i].Gender;
                return(genderMatchingOptions.Matches(character.Gender, gender));
            });

            result &= CharacterIds.All(i =>
            {
                CharacterAge age = characterDetails[i].Age;
                return(ageMatchingOptions.Matches(character.Age, age));
            });

            return(result);
        }
 private static string GetTabDelimitedFields(CharacterDetail detail)
 {
     return(detail.CharacterId + '\t' + detail.MaxSpeakers + '\t' + detail.Gender + '\t' + detail.Age);
 }