コード例 #1
0
        /// <summary>
        /// Obtain the correct garment position given the passed garment, starting from zero.
        /// </summary>
        /// <returns>A number between 0 and 12</returns>
        public static int GetPrecombinationPosition(Garment garment)
        {
            if (garment.Tags.Silouhette.Layers.Count == 0)
            {
                throw new Exception(string.Format("No layer defined for garment {0}.", garment.Id));
            }

            if (OutfitValidationService.IsAccessory(garment))
            {
                throw new Exception("A precombination can not have accessories.");
            }

            return(dict[garment.Tags.Silouhette.Layers[0]]);
        }
コード例 #2
0
        public static bool IsValidOutfit(PreOutfit outfit, StyleRule sr, HashSet <int> seasons, HashSet <int> eventTypes)
        {
            Combination comb = outfit.Combination;

            if (!OutfitValidationService.VerifyAndSetSeasonsAndEventTypes(seasons, eventTypes, outfit))
            {
                return(false);
            }

            HashSet <ColorFamily> colorFamiliesHash = new HashSet <ColorFamily>();

            if (comb.GarmentA != null)
            {
                colorFamiliesHash.Add(comb.GarmentA.Tags.Colors[0].Family);
            }
            if (comb.GarmentB != null)
            {
                colorFamiliesHash.Add(comb.GarmentB.Tags.Colors[0].Family);
            }
            if (comb.GarmentC != null)
            {
                colorFamiliesHash.Add(comb.GarmentC.Tags.Colors[0].Family);
            }
            if (comb.GarmentD != null)
            {
                colorFamiliesHash.Add(comb.GarmentD.Tags.Colors[0].Family);
            }
            if (comb.GarmentE != null)
            {
                colorFamiliesHash.Add(comb.GarmentE.Tags.Colors[0].Family);
            }
            if (outfit.Accesory1 != null && !IsJewleryColor(outfit.Accesory1))
            {
                colorFamiliesHash.Add(outfit.Accesory1.Tags.Colors[0].Family);
            }
            if (outfit.Accesory2 != null && !IsJewleryColor(outfit.Accesory2))
            {
                colorFamiliesHash.Add(outfit.Accesory2.Tags.Colors[0].Family);
            }
            if (outfit.Accesory3 != null && !IsJewleryColor(outfit.Accesory3))
            {
                colorFamiliesHash.Add(outfit.Accesory3.Tags.Colors[0].Family);
            }
            if (outfit.Accesory4 != null && !IsJewleryColor(outfit.Accesory4))
            {
                colorFamiliesHash.Add(outfit.Accesory4.Tags.Colors[0].Family);
            }
            if (outfit.Accesory5 != null && !IsJewleryColor(outfit.Accesory5))
            {
                colorFamiliesHash.Add(outfit.Accesory5.Tags.Colors[0].Family);
            }
            if (outfit.Accesory6 != null && !IsJewleryColor(outfit.Accesory6))
            {
                colorFamiliesHash.Add(outfit.Accesory6.Tags.Colors[0].Family);
            }
            if (outfit.Accesory7 != null && !IsJewleryColor(outfit.Accesory7))
            {
                colorFamiliesHash.Add(outfit.Accesory7.Tags.Colors[0].Family);
            }
            if (outfit.Accesory8 != null && !IsJewleryColor(outfit.Accesory8))
            {
                colorFamiliesHash.Add(outfit.Accesory8.Tags.Colors[0].Family);
            }

            if (!OutfitValidationService.IsValidCombination(colorFamiliesHash, null, null, null, sr, null, false, true))
            {
                return(false);
            }

            if (seasons.Contains((int)Season.Summer))
            {
                bool hasD = false;
                if (
                    (comb.GarmentA != null && comb.GarmentA.Tags.Silouhette.Layers.Contains(LayerCode.D)) ||
                    (comb.GarmentB != null && comb.GarmentB.Tags.Silouhette.Layers.Contains(LayerCode.D)) ||
                    (comb.GarmentC != null && comb.GarmentC.Tags.Silouhette.Layers.Contains(LayerCode.D)) ||
                    (comb.GarmentD != null && comb.GarmentD.Tags.Silouhette.Layers.Contains(LayerCode.D)) ||
                    (comb.GarmentE != null && comb.GarmentE.Tags.Silouhette.Layers.Contains(LayerCode.D))
                    )
                {
                    hasD = true;
                }

                bool hasB = false;
                if (
                    (comb.GarmentA != null && comb.GarmentA.Tags.Silouhette.Layers.Contains(LayerCode.B)) ||
                    (comb.GarmentB != null && comb.GarmentB.Tags.Silouhette.Layers.Contains(LayerCode.B)) ||
                    (comb.GarmentC != null && comb.GarmentC.Tags.Silouhette.Layers.Contains(LayerCode.B)) ||
                    (comb.GarmentD != null && comb.GarmentD.Tags.Silouhette.Layers.Contains(LayerCode.B)) ||
                    (comb.GarmentE != null && comb.GarmentE.Tags.Silouhette.Layers.Contains(LayerCode.B))
                    )
                {
                    hasB = true;
                }

                bool hasC = false;
                if (
                    (comb.GarmentA != null && comb.GarmentA.Tags.Silouhette.Layers.Contains(LayerCode.C)) ||
                    (comb.GarmentB != null && comb.GarmentB.Tags.Silouhette.Layers.Contains(LayerCode.C)) ||
                    (comb.GarmentC != null && comb.GarmentC.Tags.Silouhette.Layers.Contains(LayerCode.C)) ||
                    (comb.GarmentD != null && comb.GarmentD.Tags.Silouhette.Layers.Contains(LayerCode.C)) ||
                    (comb.GarmentE != null && comb.GarmentE.Tags.Silouhette.Layers.Contains(LayerCode.C))
                    )
                {
                    hasC = true;
                }

                if (hasD || (hasB && hasC))
                {
                    seasons.Remove((int)Season.Summer);
                }
            }

            return(true);
        }