Exemple #1
0
        protected override void FillProcessorMap()
        {
            if (this.processorMap.Count > 0)
            {
                Service.Logger.Error("Attempting to fill an already-full processorMap!");
            }
            CurrentPlayer currentPlayer = Service.CurrentPlayer;
            string        planetId      = currentPlayer.PlanetId;

            if (currentPlayer.Objectives.ContainsKey(planetId))
            {
                ObjectiveGroup objectiveGroup = currentPlayer.Objectives[planetId];
                int            i     = 0;
                int            count = objectiveGroup.ProgressObjects.Count;
                while (i < count)
                {
                    ObjectiveProgress objectiveProgress = objectiveGroup.ProgressObjects[i];
                    if (objectiveProgress.State == ObjectiveState.Active)
                    {
                        BaseGoalProcessor processor = GoalFactory.GetProcessor(objectiveProgress.VO, this);
                        this.processorMap.Add(processor, objectiveProgress);
                    }
                    i++;
                }
            }
        }
Exemple #2
0
        private static List <PlayEvent> GetGoalsAndPenalties(IList <Event> events, string homeTeam)
        {
            var goals             = GoalFactory.Create(events, homeTeam);
            var penalties         = PenaltiesFactory.Create(events, homeTeam);
            var goalsAndPenalties = goals;

            goalsAndPenalties.AddRange(penalties);
            return(goalsAndPenalties);
        }
        public void CreateInstance_WhenInvokedWithValidParameters()
        {
            // Arrange
            var startingWeight = 82;
            var goalWeight     = 78;
            var height         = 177;
            var age            = 25;
            var gender         = GenderType.male;
            var goalType       = GoalType.loseweight;
            var activityLevel  = ActivityLevel.heavy;

            var goalFactory = new GoalFactory();
            // Act
            var goal = goalFactory.CreateGoal(startingWeight, goalWeight, height, age, gender, goalType, activityLevel);

            // Assert
            Assert.IsNotNull(goal);
            Assert.IsInstanceOfType(goal, typeof(IGoal));
        }
        private async Task <bool> TrySave()
        {
            if (!Validate(out decimal amount, out string name))
            {
                return(false);
            }

            var date = selectedDate;

            var isImageSelected    = selectedImageUri != Uri.Empty;
            var viewHasBeenAltered = new Func <bool>(
                () => currentImageGenerationId == cropView?.VisibleRectangleBitmap?.GenerationId).Invoke();

            var imageName =
                (isImageSelected || viewHasBeenAltered)
                    ? await TryUpdateImage()
                    : goal?.Image;

            var tmp = GoalFactory.Create(amount, date,
                                         imageName, name);



            if (goal != null)
            {
                var updatedGoal = GoalFactory.Copy(goal, tmp);
                if (Compare(updatedGoal, goal))
                {
                    return(true);
                }

                RepositoryFactory.GetSingleton().GetRepository().Update(updatedGoal);
            }

            else
            {
                RepositoryFactory.GetSingleton().GetRepository().Add(tmp);
            }

            return(true);
        }