Exemple #1
0
        public static async Task <Quest> Create(
            AddQuestDTORequest addQuestRequest,
            User user,
            IQuestTypeRepository questTypeRepository,
            ICategoryRepository categoryRepository)
        {
            QuestTypeAsEmum questTypeAsEnum = await questTypeRepository.GetAsEmum(addQuestRequest.TypeId);

            if (questTypeAsEnum == QuestTypeAsEmum.Undefined)
            {
                return(null);
            }

            CategoryAsEnum categoryAsEnum = await categoryRepository.GetAsEnum(addQuestRequest.CategoryId);

            if (categoryAsEnum == CategoryAsEnum.Undefined)
            {
                return(null);
            }

            Quest quest = new Quest()
            {
                TypeId         = addQuestRequest.TypeId,
                CategoryId     = addQuestRequest.CategoryId,
                UserId         = user.Id,
                XpValue        = 10,
                CreationDate   = DateTime.Now,
                ExpirationDate = DateTime.Now.AddDays(1)
            };

            return(Initialize(quest, user, questTypeAsEnum, addQuestRequest));
        }
 public static Quest Initialize(Quest quest, User user, QuestTypeAsEmum questTypeAsEmum, AddQuestDTORequest addQuestRequest)
 {
     if (addQuestRequest.Data.TryGetValue(PHYSICAL_ACTIVITIES_GOAL_KEY, out string physicalActivitiesGoalValue))
     {
         if (int.TryParse(physicalActivitiesGoalValue, out int physicalActivitiesGoal))
         {
             quest.ProgressValue  = 0;
             quest.ProgressCount  = physicalActivitiesGoal;
             quest.ExpirationDate = DateTime.Now.AddDays(7);
         }
     }
     return(quest);
 }
Exemple #3
0
 public static Quest Initialize(Quest quest, User user, QuestTypeAsEmum questTypeAsEmum, AddQuestDTORequest addQuestRequest)
 {
     if (addQuestRequest.Data.TryGetValue(CALORIES_LIMIT_KEY, out string caloriesLimitValue))
     {
         if (int.TryParse(caloriesLimitValue, out int caloriesLimit))
         {
             quest.ProgressValue = 0;
             quest.ProgressCount = caloriesLimit;
         }
     }
     return(quest);
 }
Exemple #4
0
 public static Quest Initialize(Quest quest, User user, QuestTypeAsEmum questTypeAsEmum, AddQuestDTORequest addQuestRequest)
 {
     quest.ProgressValue = 0;
     quest.ProgressCount = 1;
     return(quest);
 }
Exemple #5
0
        private static Quest Initialize(Quest quest, User user, QuestTypeAsEmum questTypeAsEmum, AddQuestDTORequest addQuestRequest)
        {
            switch (questTypeAsEmum)
            {
            case QuestTypeAsEmum.DailySleepGoal:
                return(DailySleepQuest.Initialize(quest, user, questTypeAsEmum, addQuestRequest));

            case QuestTypeAsEmum.CaloriesGoal:
                return(CaloriesGoalQuest.Initialize(quest, user, questTypeAsEmum, addQuestRequest));

            case QuestTypeAsEmum.DailyCaloriesLimit:
                return(DailyCaloriesLimitQuest.Initialize(quest, user, questTypeAsEmum, addQuestRequest));

            case QuestTypeAsEmum.WeeklyPhysicalActivity:
                return(WeeklyPhysicalActivity.Initialize(quest, user, questTypeAsEmum, addQuestRequest));

            case QuestTypeAsEmum.DailyPhysicalActivity:
                return(DailyPhysicalActivityQuest.Initialize(quest, user, questTypeAsEmum, addQuestRequest));

            case QuestTypeAsEmum.Undefined:
            default:
                return(null);
            }
        }