초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View File

@@ -0,0 +1,17 @@

using ServerBase;
using MetaAssets;
namespace ServerCommon;
public static class AttributeEnchantDataValidator
{
[MetaValidator]
public static void Validate(AttributeEnchantMetaData enchant, ValidatorErrorCollection errors)
{
// 1. Item Id 체크
if(false == CommonValidator.isExistItemId(enchant.ItemID))
errors.add($"Attribute Enchant Data Is Invalid : item id is not exist - {enchant.ItemID}");
}
}

View File

@@ -0,0 +1,36 @@
using MetaAssets;
namespace ServerCommon;
public class CommonValidator
{
public static bool isExistCurrencyId(int currencyId)
{
return MetaData.Instance.Meta.CurrencyMetaTable.CurrencyMetaDataListbyId.ContainsKey(currencyId);
}
public static bool isExistItemId(int itemId)
{
return MetaData.Instance.Meta.ItemMetaTable.ItemMetaDataListbyId.ContainsKey(itemId);
}
public static bool isExistProductGroupId(int id)
{
return MetaData.Instance.Meta.ShopProductMetaTable.ShopProductMetaDataList.Any(shopProduct => shopProduct.Group_Id == id);
}
public static bool isExistBrandById(int id)
{
return MetaData.Instance.Meta.BrandMetaTable.BrandMetaDataListbyId.ContainsKey(id);
}
public static bool isExistBuffById(int buffId)
{
return MetaData.Instance.Meta.BuffMetaTable.BuffMetaDataListbyBuffId.ContainsKey(buffId);
}
public static bool isExistProductId(int id)
{
return MetaData.Instance.Meta.ProductMetaTable.ProductMetaDataListbyId.ContainsKey(id);
}
}

View File

@@ -0,0 +1,18 @@

using ServerBase;
using MetaAssets;
namespace ServerCommon;
public static class InstanceDataValidator
{
[MetaValidator]
public static void Validate(InstanceMetaData instance, ValidatorErrorCollection errors)
{
// 1. access type and id 체크
if(instance.AccessType == AccessType.Item && false == CommonValidator.isExistItemId(instance.AccessId))
errors.add($"Invalid Instance data : access type and id is invalid - AccessType[{instance.AccessType}] AccessId[{instance.AccessId}]");
}
}

View File

@@ -0,0 +1,200 @@
using ServerBase;
using MetaAssets;
namespace ServerCommon;
public static class ItemMetaTableValidator
{
private static Dictionary<EItemLargeType, List<EItemSmallType>> 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<EItemLargeType, List<EItemSmallType>> initLargeTypeAndSmallType()
{
var dict = new Dictionary<EItemLargeType, List<EItemSmallType>>();
var smallList = new List<EItemSmallType>();
smallList.Add(EItemSmallType.COSMETIC);
dict.Add(EItemLargeType.BEAUTY, smallList);
smallList = new List<EItemSmallType>();
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<EItemSmallType>();
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<EItemSmallType>();
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<EItemSmallType>();
smallList.Add(EItemSmallType.PRODUCT);
dict.Add(EItemLargeType.PRODUCT, smallList);
smallList = new List<EItemSmallType>();
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<EItemSmallType>();
smallList.Add(EItemSmallType.RANDOMBOX);
dict.Add(EItemLargeType.RAND_BOX, smallList);
smallList = new List<EItemSmallType>();
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<EItemSmallType>();
smallList.Add(EItemSmallType.TICKET);
dict.Add(EItemLargeType.TICKET, smallList);
smallList = new List<EItemSmallType>();
smallList.Add(EItemSmallType.LIGHTSTICK);
smallList.Add(EItemSmallType.LIGHTSABER);
smallList.Add(EItemSmallType.MUSICPLAYER);
dict.Add(EItemLargeType.TOOL, smallList);
smallList = new List<EItemSmallType>();
smallList.Add(EItemSmallType.SETBOX);
dict.Add(EItemLargeType.SET_BOX, smallList);
return dict;
}
}

View File

@@ -0,0 +1,218 @@
using System.Collections.Concurrent;
using System.Text;
using Microsoft.Extensions.Primitives;
using ServerCore;
using ServerBase;
namespace ServerCommon;
/*
* QustSript 체크후
* m_event_check_keys, m_function_check_keys 이 두 변수에 데이터가 남아 있으면 안된다.
*/
public class QuestMetaValidateHandler
{
private UInt32 m_quest_id { get; } = 0;
private ConcurrentDictionary<string, int> m_event_checkers { get; } = new();
private ConcurrentDictionary<string, int> m_function_checkers { get; }= new();
public QuestMetaValidateHandler()
{
}
public QuestMetaValidateHandler(UInt32 questId)
{
m_quest_id = questId;
}
//해당 이벤트가 체크되어야햘 항목에 있는지 확인하고 있으면 삭제 처리
public void checkEventTarget(string eventTarget, string eventName, string eventCond1, string eventCond2, string eventCond3)
{
StringBuilder str_builder = new();
if (eventTarget.Equals(EQuestEventTargetType.TASK.ToString()) && eventName.Equals(EQuestEventNameType.ACTIVED.ToString()))
{
str_builder.Append(eventTarget).Append(eventName).Append(eventCond1);
}
else if (eventTarget.Equals(EQuestEventTargetType.TRIGGER.ToString()) && eventName.Equals(EQuestEventNameType.ENTERED.ToString()))
{
str_builder.Append(eventTarget).Append(eventName).Append(eventCond1);
}
else if (eventTarget.Equals(EQuestEventTargetType.DIALOGUE.ToString()) &&
eventName.Equals(EQuestEventNameType.ENDED.ToString()))
{
str_builder.Append(eventTarget).Append(eventName).Append(eventCond1);
}
decreaseEventChecker(str_builder.ToString());
}
//해당 펑션이 체크되어야햘 항목에 있는지 확인하고 있으면 삭제 처리
public void checkFuncTarget(string funcTarget, string funcName, string funcCond1, string funcCond2, string funcCond3)
{
StringBuilder str_builder = new();
if (funcTarget.Equals(EQuestFunctionTargetType.TASK.ToString()) && funcName.Equals(EQuestFunctionNameType.TITLE_UPDATE.ToString()))
{
str_builder.Append(funcTarget).Append(funcName).Append(funcCond1);
}
else if (funcTarget.Equals(EQuestFunctionTargetType.TASK.ToString()) && funcName.Equals(EQuestFunctionNameType.LOCATION.ToString()))
{
str_builder.Append(funcTarget).Append(funcName);
}
else if (funcTarget.Equals(EQuestFunctionTargetType.QUEST.ToString()) && funcName.Equals(EQuestFunctionNameType.COMPLETE.ToString()))
{
str_builder.Append(funcTarget).Append(funcName).Append(funcCond1);
}
decreaseFuncChecker(str_builder.ToString());
}
//해당 이벤트 타겟에 대한 체크항목 생성
//여기에 계속 추가해야한다.
public void makeEventTargetValidator(string eventTarget, string eventName, string eventCond1, string eventCond2, string eventCond3)
{
if (eventTarget.Equals(EQuestEventTargetType.TASK.ToString()) && eventName.Equals(EQuestEventNameType.ACTIVED.ToString()))
{
_ = new QuestValidatorForTaskActived(this, eventCond1);
}
}
//해당 펑션 타겟에 대한 체크항목 생성
//여기에 계속 추가해야 한다.
public void makeFuncTargetValidator(string funcTarget, string funcName, string funcCond1, string funcCond2, string funcCond3)
{
if (funcTarget.Equals(EQuestEventTargetType.TRIGGER.ToString()) && funcName.Equals(EQuestFunctionNameType.SET.ToString()))
{
_ = new QuestValidatorForTriggerSet(this, funcCond1);
}
else if (funcTarget.Equals(EQuestEventTargetType.NPC.ToString()) &&
funcName.Equals(EQuestFunctionNameType.DIALOGUE_SET.ToString()))
{
_ = new QuestValidatorForNpcDialogueSet(this, funcCond2);
}
}
public void addEventChecker(string eventStr)
{
int update_cnt = 0;
if (false == m_event_checkers.TryGetValue(eventStr, out var cnt))
{
update_cnt = 1;
m_event_checkers.TryAdd(eventStr, update_cnt);
}
else
{
update_cnt = ++cnt;
m_event_checkers.AddOrUpdate(eventStr, update_cnt, (s, i) => update_cnt);
}
}
public void decreaseEventChecker(string eventStr)
{
if (m_event_checkers.ContainsKey(eventStr))
{
m_event_checkers.TryGetValue(eventStr, out var cnt);
var update_cnt = --cnt;
if (update_cnt <= 0)
{
m_event_checkers.TryRemove(eventStr, out _);
}
else
{
m_event_checkers.AddOrUpdate(eventStr, update_cnt, (s, i) => update_cnt);
}
}
}
public void addFunctionChecker(string functionStr)
{
int update_cnt = 0;
if (false == m_function_checkers.TryGetValue(functionStr, out var cnt))
{
update_cnt = 1;
m_function_checkers.TryAdd(functionStr, update_cnt);
}
else
{
update_cnt = ++cnt;
m_function_checkers.AddOrUpdate(functionStr, update_cnt, (s, i) => update_cnt);
}
}
public void decreaseFuncChecker(string funcStr)
{
if (m_function_checkers.ContainsKey(funcStr))
{
m_function_checkers.TryGetValue(funcStr, out var cnt);
var update_cnt = --cnt;
if (update_cnt <= 0)
{
m_function_checkers.TryRemove(funcStr, out _);
}
else
{
m_function_checkers.AddOrUpdate(funcStr, update_cnt, (s, i) => update_cnt);
}
}
}
public void remainDataCheck(ValidatorErrorCollection errors)
{
List<ValidattionError> error_list = new();
if (m_event_checkers.Keys.Count > 0)
{
foreach (var checker in m_event_checkers)
{
ValidattionError validation_error = new();
validation_error.Name = "Quest Script Event Validation Error";
validation_error.ArrayIndex = (int)m_quest_id;
validation_error.Message = $"quest : {m_quest_id}, {checker.Key} is not checked, cnt : {checker.Value}";
error_list.Add(validation_error);
}
}
if (m_function_checkers.Keys.Count > 0)
{
foreach (var checker in m_function_checkers)
{
ValidattionError validation_error = new();
validation_error.Name = "Quest Script Func Validation Error";
validation_error.ArrayIndex = (int)m_quest_id;
validation_error.Message = $"quest : {m_quest_id}, {checker.Key} is not checked, cnt : {checker.Value}";
error_list.Add(validation_error);
}
}
if (error_list.Count > 0)
{
//원래 검증 완료하면 여기에 추가를 해서 서버가 안뜨게 해야 되는게 맞는데
//지금 엑섹을 만들었다 지우면서 발생한 쓰레기 json이 퀘스트로 등록이 되는 상황이라 이런경우 어떠허게 처리해야될지 정리후에
//errors 로 넘긴다
//그 전까진 error log만 남긴다.
//errors.Errors.TryAdd("Quest Script Error", error_list);
foreach (var error in error_list)
{
Log.getLogger().warn($"[ Quest : {m_quest_id}] Script Validation Error : {error.Message}");
}
}
}
}

View File

@@ -0,0 +1,16 @@

namespace ServerCommon;
public abstract class QuestScriptValidatorBase : IQuestScriptValidator
{
protected QuestMetaValidateHandler m_handler { get; set; } = new();
public QuestScriptValidatorBase(QuestMetaValidateHandler handler)
{
m_handler = handler;
}
public abstract void init();
}

View File

@@ -0,0 +1,47 @@
using System.Text;
using Microsoft.Extensions.Primitives;
using ServerCore;
using ServerBase;
namespace ServerCommon;
/*
* Rule
* TASK, ACTIVED 1
* QUEST, COMPLETE (questId) 는 무조건 존재해야 한다.
*
*/
public class QuestValidatorForMustHave : QuestScriptValidatorBase
{
private UInt32 m_quest_id = 0;
public QuestValidatorForMustHave(QuestMetaValidateHandler handler, UInt32 questId) : base(handler)
{
m_quest_id = questId;
init();
}
public override void init()
{
StringBuilder str_builder_task = new();
str_builder_task
.Append(EQuestEventTargetType.TASK.ToString())
.Append(EQuestEventNameType.ACTIVED.ToString())
.Append("1");
m_handler.addEventChecker(str_builder_task.ToString());
StringBuilder str_builder_quest = new();
str_builder_quest
.Append(EQuestFunctionTargetType.QUEST.ToString())
.Append(EQuestFunctionNameType.COMPLETE.ToString())
.Append(m_quest_id.ToString());
m_handler.addFunctionChecker(str_builder_quest.ToString());
}
}

View File

@@ -0,0 +1,28 @@
using System.Text;
using Google.Protobuf.WellKnownTypes;
namespace ServerCommon;
public class QuestValidatorForNpcDialogueSet : QuestScriptValidatorBase
{
private string m_func_cond2 = string.Empty;
public QuestValidatorForNpcDialogueSet(QuestMetaValidateHandler handler, string funcCond2) : base(handler)
{
m_func_cond2 = funcCond2;
init();
}
public override void init()
{
StringBuilder dialogue_ended = new();
dialogue_ended.Append(EQuestEventTargetType.DIALOGUE.ToString()).Append(EQuestEventNameType.ENDED.ToString())
.Append(m_func_cond2);
m_handler.addEventChecker(dialogue_ended.ToString());
}
}

View File

@@ -0,0 +1,48 @@
using System.Text;
using Microsoft.Extensions.Primitives;
using ServerCore;
using ServerBase;
namespace ServerCommon;
/*
* TASK, ACTIVED 가 있으면
* TASK, TITLA_UPDATE, (TASKID)
* TASK, LOCATION
* 필수
*
*/
public class QuestValidatorForTaskActived : QuestScriptValidatorBase
{
private string m_event_cond1 = string.Empty;
public QuestValidatorForTaskActived(QuestMetaValidateHandler handler, string eventCond1) : base(handler)
{
m_event_cond1 = eventCond1;
init();
}
public override void init()
{
StringBuilder title_update = new();
title_update
.Append(EQuestFunctionTargetType.TASK.ToString())
.Append(EQuestFunctionNameType.TITLE_UPDATE.ToString())
.Append(m_event_cond1);
m_handler.addFunctionChecker(title_update.ToString());
// StringBuilder location = new();
// location
// .Append(EQuestFunctionTargetType.TASK.ToString())
// .Append(EQuestFunctionNameType.LOCATION.ToString());
// m_handler.addFunctionChecker(location.ToString());
}
}

View File

@@ -0,0 +1,24 @@
using System.Text;
namespace ServerCommon;
public class QuestValidatorForTriggerSet: QuestScriptValidatorBase
{
private string m_func_cond1 = string.Empty;
public QuestValidatorForTriggerSet(QuestMetaValidateHandler handler, string funcCond1) : base(handler)
{
m_func_cond1 = funcCond1;
init();
}
public override void init()
{
StringBuilder trigger_entered = new();
trigger_entered.Append(EQuestEventTargetType.TRIGGER.ToString()).Append(EQuestEventNameType.ENTERED.ToString())
.Append(m_func_cond1);
m_handler.addEventChecker(trigger_entered.ToString());
}
}

View File

@@ -0,0 +1,74 @@
using System.Text;
using Microsoft.IdentityModel.Tokens;
using ServerCore;
using ServerBase;
using MetaAssets;
namespace ServerCommon;
public static class QuestScriptMetaTableValidator
{
[MetaValidator]
public static void Validate((uint questId, Dictionary<Int32 , MetaAssets.QuestScriptMetaData> questScript) item, ValidatorErrorCollection errors)
{
QuestMetaValidateHandler handler = new(item.questId);
//퀘스트 스크립트가 무조건 가지고 있어야 하는 항목
_ = new QuestValidatorForMustHave(handler, item.questId);
// if (item.questId == 100)
// {
// Log.getLogger().info($"QuestScriptValidation start questId : {item.questId}");
// }
foreach(var line in item.questScript.Values)
{
string event_target = line.EventTarget;
string event_name = line.Event;
string event_cond_1 = line.EventCondition1;
string event_cond_2 = line.EventCondition2;
string event_cond_3 = line.EventCondition3;
if (false == event_target.isNullOrWhiteSpace())
{
handler.checkEventTarget(event_target, event_name, event_cond_1, event_cond_2, event_cond_3);
handler.makeEventTargetValidator(event_target, event_name, event_cond_1, event_cond_2, event_cond_3);
}
string func_target = line.FunctionTarget;
string func_name = line.Function;
string func_cond_1 = line.FunctionCondition1;
string func_cond_2 = line.FunctionCondition2;
string func_cond_3 = line.FunctionCondition3;
if (false == func_target.isNullOrWhiteSpace())
{
handler.checkFuncTarget(func_target, func_name, func_cond_1, func_cond_2, func_cond_3);
handler.makeFuncTargetValidator(func_target, func_name, func_cond_1, func_cond_2, func_cond_3);
}
}
handler.remainDataCheck(errors);
}
}

View File

@@ -0,0 +1,39 @@

using ServerBase;
using MetaAssets;
namespace ServerCommon;
public static class ShopValidator
{
[MetaValidator]
public static void Validate(ShopMetaData shop, ValidatorErrorCollection errors)
{
// 1. resetTime
if(shop.ResetTime <= 0)
errors.add($"Invalid shop : reset time is invalid [{shop.ResetTime}]");
// 2. product group
if(false == CommonValidator.isExistProductGroupId(shop.ShopProduct_Group_Id))
errors.add($"Invalid shop : product group id is invalid [{shop.ShopProduct_Group_Id}]");
}
[MetaValidator]
public static void Validate(ShopProductMetaData shopProduct, ValidatorErrorCollection errors)
{
// 1. Buy 정보 체크
if(shopProduct.Buy_Price_Type == ShopBuyType.Currency && false == CommonValidator.isExistCurrencyId(shopProduct.Buy_Id))
errors.add($"Invalid shop product : buy currency type is invalid - [{shopProduct.Buy_Id}]");
if(shopProduct.Buy_Price_Type == ShopBuyType.Item && false == CommonValidator.isExistItemId(shopProduct.Buy_Id))
errors.add($"Invalid shop product : buy item id is not exist - [{shopProduct.Buy_Id}]");
// 2. Product 정보 체크
if(shopProduct.ProductData.Currency != null && false == CommonValidator.isExistCurrencyId(shopProduct.ProductData.Currency.Id))
errors.add($"Invalid shop product : product currency type is invalid - [{shopProduct.ProductData.Currency.Id}]");
if(shopProduct.ProductData.Item != null && false == CommonValidator.isExistItemId(shopProduct.ProductData.Item.Id))
errors.add($"Invalid shop product : product item id is not exist - [{shopProduct.ProductData.Item.Id}]");
}
}