using ServerBase; using MetaAssets; namespace ServerCommon; public static class ItemMetaTableValidator { private static Dictionary> m_LargeTypeAndSmallType { get; set; } = initLargeTypeAndSmallType(); [MetaValidator] public static void Validate(ItemMetaData item, ValidatorErrorCollection errors) { // 1. item worth 체크 if (false == checkItemWorth(item)) errors.add($"Invalid Item : Worth data is invalid - Current => SellPriceType[{item.SellPriceType}], SellId[{item.SellId}] / Buy_Price_Type[{item.Buy_Price_Type}], Buy_id[{item.Buy_id}]"); // 2. tattoo 체크 if (item.TypeLarge == EItemLargeType.TATTOO) checkTattooValues(item, errors); // 3. buff_drink 체크 if (item.TypeSmall == EItemSmallType.BUFF_DRINK && false == CommonValidator.isExistBuffById(item.buff_id)) errors.add($"Invalid Item : Buff Drink's buff id is Invalid - Current => BuffId[{item.buff_id}]"); // 4. type_large & type_small 관계성 체크 if(false == checkLargeAndSmallType(item.TypeLarge, item.TypeSmall)) errors.add($"Invalid Item : Large and Small Type is invalid - Current => Large[{item.TypeLarge}] Small[{item.TypeSmall}]"); // 5. expire time check if (item.ExpireFixedTermStart > item.ExpireFixedTermEnd) errors.add($"Invalid Item : ExpireFixedTerm Time is Invalid - Current => start[{item.ExpireFixedTermStart}] end[{item.ExpireFixedTermEnd}]"); // 6. brand 체크 : 0이 될 수 있어. if(item.Brand_ > 0 && false == CommonValidator.isExistBrandById(item.Brand_)) errors.add($"Invalid Item : Brand Id is Invalid - brand [{item.Brand_}]"); } private static bool checkItemWorth(ItemMetaData item) { // 1. Sell 체크 if (item.SellPriceType == ShopBuyType.Currency && false == CommonValidator.isExistCurrencyId(item.SellId)) return false; if (item.SellPriceType == ShopBuyType.Item && false == CommonValidator.isExistItemId(item.SellId)) return false; // 2. Buy 체크 if (item.Buy_Price_Type == ShopBuyType.Currency && false == CommonValidator.isExistCurrencyId(item.Buy_id)) return false; if (item.Buy_Price_Type == ShopBuyType.Item && false == CommonValidator.isExistItemId(item.Buy_id)) return false; return true; } private static void checkTattooValues(ItemMetaData item, ValidatorErrorCollection errors) { if (string.IsNullOrEmpty(item.Rarity)) errors.add( "Invalid Item : Tattoo Rarity is invalid"); if (string.IsNullOrEmpty(item.DefaultAttribute)) errors.add( "Invalid Item : Tattoo DefaultAttribute is invalid"); if (string.IsNullOrEmpty(item.AttributeRandomGroupID)) errors.add( "Invalid Item : Tattoo AttributeRandomGroupId is invalid"); if (false == MetaData.Instance.Meta.AttributeDefinitionMetaTable.AttributeDefinitionMetaDataListbyKey.ContainsKey(item.DefaultAttribute)) errors.add( $"Invalid Item : Default Attribute is invalid - [{item.DefaultAttribute}]"); } private static bool checkLargeAndSmallType(EItemLargeType largeType, EItemSmallType smallType) { if (false == m_LargeTypeAndSmallType.TryGetValue(largeType, out var list)) return false; return list.Contains(smallType); } private static Dictionary> initLargeTypeAndSmallType() { var dict = new Dictionary>(); var smallList = new List(); smallList.Add(EItemSmallType.COSMETIC); dict.Add(EItemLargeType.BEAUTY, smallList); smallList = new List(); smallList.Add(EItemSmallType.BACKPACK); smallList.Add(EItemSmallType.BAG); smallList.Add(EItemSmallType.CAP); smallList.Add(EItemSmallType.DRESS); smallList.Add(EItemSmallType.GLASSES); smallList.Add(EItemSmallType.GLOVES); smallList.Add(EItemSmallType.MASK); smallList.Add(EItemSmallType.NECKLACE); smallList.Add(EItemSmallType.OUTER); smallList.Add(EItemSmallType.PANTS); smallList.Add(EItemSmallType.SHIRT); smallList.Add(EItemSmallType.SHOES); smallList.Add(EItemSmallType.SHOULDERBAG); dict.Add(EItemLargeType.CLOTH, smallList); smallList = new List(); smallList.Add(EItemSmallType.GOLD); smallList.Add(EItemSmallType.SAPPHIRE); smallList.Add(EItemSmallType.CALIUM); smallList.Add(EItemSmallType.BEAM); smallList.Add(EItemSmallType.RUBY); dict.Add(EItemLargeType.CURRENCY, smallList); smallList = new List(); smallList.Add(EItemSmallType.BEACON_BODY); smallList.Add(EItemSmallType.BEACON_ITEM); smallList.Add(EItemSmallType.BUFF_DRINK); smallList.Add(EItemSmallType.CARTRIDGE); smallList.Add(EItemSmallType.MEGAPHONE); smallList.Add(EItemSmallType.QUEST_ASSIGN); smallList.Add(EItemSmallType.QUEST_COOLTIME_RESET); smallList.Add(EItemSmallType.RECIPE); smallList.Add(EItemSmallType.REGISTER_ITEM_INTERIOR); smallList.Add(EItemSmallType.REGISTER_ITEM_SOCIAL_ACTION); smallList.Add(EItemSmallType.SUMMONSTONE); smallList.Add(EItemSmallType.TICKET); smallList.Add(EItemSmallType.LANDCERTIFICATE); dict.Add(EItemLargeType.EXPENDABLE, smallList); smallList = new List(); smallList.Add(EItemSmallType.PRODUCT); dict.Add(EItemLargeType.PRODUCT, smallList); smallList = new List(); smallList.Add(EItemSmallType.BED); smallList.Add(EItemSmallType.COOKWARE); smallList.Add(EItemSmallType.CRAFTING_CLOTHES); smallList.Add(EItemSmallType.CRAFTING_COOKING); smallList.Add(EItemSmallType.CRAFTING_FURNITURE); smallList.Add(EItemSmallType.DECO); smallList.Add(EItemSmallType.FURNITURE); smallList.Add(EItemSmallType.INDUCTION); smallList.Add(EItemSmallType.INTERPHONE); smallList.Add(EItemSmallType.LAPTOP); smallList.Add(EItemSmallType.LARGE_APPLIANCE); smallList.Add(EItemSmallType.LEISURE_APPLIANCE); smallList.Add(EItemSmallType.LIGHT_CEILING); smallList.Add(EItemSmallType.LIGHT_FLOOR); smallList.Add(EItemSmallType.LIGHT_TABLE); smallList.Add(EItemSmallType.LIGHT_PENDENT); smallList.Add(EItemSmallType.LIGHT_LIMITED); smallList.Add(EItemSmallType.MICROWAVE); smallList.Add(EItemSmallType.MUSIC); smallList.Add(EItemSmallType.OFFICECHAIR); smallList.Add(EItemSmallType.OUTDOOR_GOODS); smallList.Add(EItemSmallType.OUTDOORCHAIR); smallList.Add(EItemSmallType.SHELF_L); smallList.Add(EItemSmallType.SHELF_S); smallList.Add(EItemSmallType.SOFA_COUCH); smallList.Add(EItemSmallType.SOFA_SINGLE); smallList.Add(EItemSmallType.TABLE_L); smallList.Add(EItemSmallType.TABLE_LIVINGROOM); smallList.Add(EItemSmallType.TABLE_OFFICE); smallList.Add(EItemSmallType.TABLE_S); smallList.Add(EItemSmallType.TV); smallList.Add(EItemSmallType.VIGNETTE); smallList.Add(EItemSmallType.WALLMOUNTTV); smallList.Add(EItemSmallType.SPEAKER); smallList.Add(EItemSmallType.KITCHEN_TOOL); dict.Add(EItemLargeType.PROP, smallList); smallList = new List(); smallList.Add(EItemSmallType.RANDOMBOX); dict.Add(EItemLargeType.RAND_BOX, smallList); smallList = new List(); smallList.Add(EItemSmallType.BACK); smallList.Add(EItemSmallType.CHEST); smallList.Add(EItemSmallType.LEFT_ARM); smallList.Add(EItemSmallType.LEFT_LEG); smallList.Add(EItemSmallType.RIGHT_ARM); smallList.Add(EItemSmallType.RIGHT_LEG); dict.Add(EItemLargeType.TATTOO, smallList); smallList = new List(); smallList.Add(EItemSmallType.TICKET); dict.Add(EItemLargeType.TICKET, smallList); smallList = new List(); smallList.Add(EItemSmallType.LIGHTSTICK); smallList.Add(EItemSmallType.LIGHTSABER); smallList.Add(EItemSmallType.MUSICPLAYER); dict.Add(EItemLargeType.TOOL, smallList); smallList = new List(); smallList.Add(EItemSmallType.SETBOX); dict.Add(EItemLargeType.SET_BOX, smallList); return dict; } }