Ejemplo n.º 1
0
        public bool IsMet(RequirementContext context)
        {
            var duplicateFood = new List <Food>();

            duplicateFood.AddRange(context.partyState.foodArrangement.food);

            for (int i = 0; i < requiredFood.food.Count; ++i)
            {
                var  required      = requiredFood.food[i];
                bool requiredFound = false;
                for (int j = 0; j < duplicateFood.Count; ++j)
                {
                    var foodInArrangement = duplicateFood[j];
                    if (foodInArrangement.DoesInclude(required))
                    {
                        // We found the required food in the arrangement, check the next one
                        // Make sure we don't count this food in the arrangement twice by removing it from the list for next time
                        duplicateFood.RemoveAt(j);
                        j--;
                        requiredFound = true;
                        break;
                    }
                }

                if (!requiredFound)
                {
                    // If we got here, it means that a required food was NOT found in the food arrangement. Requirement has not been met.
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        // Returns a list of feedback strings
        public static List <string> GetFeedbackStrings(PartyState state, List <IRequirement> requirements)
        {
            var reqContext = new RequirementContext()
            {
                partyState = state
            };

            var feedback = new List <String>();

            for (int i = 0; i < requirements.Count; ++i)
            {
                var req = requirements[i];
                if (!req.IsMet(reqContext))
                {
                    feedback.Add(req.FeedbackMessage);
                }
            }

            return(feedback);
        }
Ejemplo n.º 3
0
        // Returns a number between 0 and 1, representing the percentage score accomplished by the state passed in
        // Total point value is determined by the combined value of all requirements
        public static float CalcScorePercentage(PartyState state, List <IRequirement> requirements)
        {
            var reqContext = new RequirementContext()
            {
                partyState = state
            };

            int maxScore  = 0;
            int evalScore = 0;

            for (int i = 0; i < requirements.Count; ++i)
            {
                var req = requirements[i];
                maxScore += req.Value;
                if (req.IsMet(reqContext))
                {
                    evalScore += req.Value;
                }
            }
            return((float)evalScore / maxScore);
        }