Beispiel #1
0
        public GrammarParseResult GetValue(string name)
        {
            CreatureAction action = Prototype.CreatureActions.SingleOrDefault(x => x.Name.Equals(name));

            if (action != null)
            {
                return(Engine.Parsers.ParserHelper.Evaluate(action.ActionText, Controller.Instance.CurrentRuleSet));
            }

            //Assume it's an attribute if it's not an action
            GrammarParseResult result = new GrammarParseResult($"{IndividualName}'s ({Prototype.EntityName}) {name}");

            //Check Abilities
            AbilityAttr ability = AbilityScores.SingleOrDefault(x => x.Key.Name.Equals(name)).Key;

            if (ability != null)
            {
                result.Value         = AbilityScores[ability];
                result.EvaluatedText = AbilityScores[ability].ToString();
                return(result);
            }

            //Check Ability Skills
            AbilitySkillAttr abilityskill = AbilitySkillScores.SingleOrDefault(x => x.Key.Name.Equals(name)).Key;

            if (ability != null)
            {
                result.Value         = AbilitySkillScores[abilityskill];
                result.EvaluatedText = AbilitySkillScores[abilityskill].ToString();
                return(result);
            }

            //Check Counters
            CounterAttr counter = CounterValues.SingleOrDefault(x => x.Key.Name.Equals(name)).Key;

            if (ability != null)
            {
                result.Value         = CounterValues[counter];
                result.EvaluatedText = CounterValues[counter].Value.ToString();
                return(result);
            }

            //Check Other Attributes
            OtherAttr otherAttr = OtherScores.SingleOrDefault(x => x.Key.Name.Equals(name)).Key;

            if (ability != null)
            {
                result.Value         = OtherScores[otherAttr];
                result.EvaluatedText = OtherScores[otherAttr].ToString();
                return(result);
            }


            result.IsSuccessful = false;
            result.Value        = 0;
            result.Output       = $"Creatures of type \"{Prototype.EntityName}\" do not have an action or attribute with name \"{name}\"";
            return(result);
        }
Beispiel #2
0
 public DynamicJsonValue ToJson()
 {
     return(new DynamicJsonValue
     {
         [nameof(DocumentId)] = DocumentId,
         [nameof(CounterName)] = CounterName,
         [nameof(TotalValue)] = TotalValue,
         [nameof(CounterValues)] = CounterValues?.ToJson()
     });
 }
        public static CounterValues CreateReport(CounterValues horizontalRows, CounterValues verticalRows, CounterValues diagonalRows)
        {
            var values = new List <CounterValue>();

            values.AddRange(horizontalRows.Values);
            values.AddRange(verticalRows.Values);
            values.AddRange(diagonalRows.Values);
            var counterFinal = new CounterValues(values);

            return(counterFinal);
        }
Beispiel #4
0
 internal CachedCounterReference(TValue target, CounterValues counterValues)
     : base(target)
 {
     _target        = target;
     _counterValues = counterValues;
 }
 public bool ShowTotalVoters(CounterValues globalCounter)
 {
     return(globalCounter.Total >= minVotes);
 }
 public bool ShowPercentVoters(CounterValues globalCounter)
 {
     return(true);
 }
 public bool ShowPercentGender(CounterValues genderCounter, CounterValues globalCounter)
 {
     return((Math.Abs(globalCounter.YourPercentage - genderCounter.YourPercentage) >= deltaPercent) &&
            (genderCounter.Total >= minVotes));
 }
 public bool ShowPercentCountry(CounterValues countryCounter, CounterValues globalCounter)
 {
     return((Math.Abs(globalCounter.YourPercentage - countryCounter.YourPercentage) >= deltaPercent) &&
            (countryCounter.Total >= minVotes));
 }
 public bool ShowPercentAgeRange(CounterValues ageRangeCounter, CounterValues globalCounter)
 {
     return((Math.Abs(globalCounter.YourPercentage - ageRangeCounter.YourPercentage) >= deltaPercent) &&
            (ageRangeCounter.Total >= minVotes));
 }