Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public bool ContainsOnlyCharactersWithAge(CharacterAge age)
        {
            var characterDetails = m_project.AllCharacterDetailDictionary;

            return(CharacterIds.All(c =>
            {
                if (CharacterVerseData.IsCharacterStandard(c))
                {
                    return age == CharacterAge.Adult;
                }

                CharacterDetail characterDetail;
                if (!characterDetails.TryGetValue(c, out characterDetail))
                {
                    return false;
                }
                return characterDetail.Age == age;
            }));
        }
Exemplo n.º 3
0
        public void SetGroupIdLabel()
        {
            if (GroupIdLabel != Label.None)
            {
                return;
            }

            if (AssignedToCameoActor)
            {
                GroupIdLabel     = Label.Other;
                GroupIdOtherText = VoiceActor.Name;
                return;
            }

            if (CharacterIds.All(c => CharacterVerseData.IsCharacterOfType(c, CharacterVerseData.StandardCharacter.Narrator)))
            {
                GroupIdLabel = Label.Narrator;
            }
            else if (IsVoiceActorAssigned)
            {
                VoiceActor.VoiceActor actor = VoiceActor;
                if (actor.Age == ActorAge.Child)
                {
                    GroupIdLabel = Label.Child;
                }
                else if (actor.Gender == ActorGender.Male)
                {
                    GroupIdLabel = Label.Male;
                }
                else
                {
                    GroupIdLabel = Label.Female;
                }
            }
            else
            {
                if (ContainsOnlyCharactersWithAge(CharacterAge.Child))
                {
                    GroupIdLabel = Label.Child;
                }
                else if (ContainsCharacterWithGender(CharacterGender.Male))
                {
                    GroupIdLabel = Label.Male;
                }
                else if (ContainsCharacterWithGender(CharacterGender.Female))
                {
                    GroupIdLabel = Label.Female;
                }
                else if (ContainsCharacterWithGender(CharacterGender.PreferMale))
                {
                    GroupIdLabel = Label.Male;
                }
                else if (ContainsCharacterWithGender(CharacterGender.PreferFemale))
                {
                    GroupIdLabel = Label.Female;
                }
                else
                {
                    GroupIdLabel = Label.Male;
                }
            }
        }