Beispiel #1
0
        private UnderThreshold GetMaxUnderThreshold()
        {
            UnderThreshold result = UnderThreshold.NoUnder;

            Dictionary <UnderThreshold, int> underThresholdDictionary = new Dictionary <UnderThreshold, int>();

            if (_reputation.Peasants > _thresholdValue)
            {
                underThresholdDictionary.Add(UnderThreshold.ItsPeasants, _reputation.Peasants);
            }

            if (_reputation.Church > _thresholdValue)
            {
                underThresholdDictionary.Add(UnderThreshold.ItsChurch, _reputation.Church);
            }

            if (_reputation.Bandits > _thresholdValue)
            {
                underThresholdDictionary.Add(UnderThreshold.ItsBandits, _reputation.Bandits);
            }

            if (_reputation.Nobles > _thresholdValue)
            {
                underThresholdDictionary.Add(UnderThreshold.ItsNobles, _reputation.Nobles);
            }

            if (underThresholdDictionary.Count > 0)
            {
                result = underThresholdDictionary.OrderBy(c => c.Value).First().Key;
            }

            return(result);
        }
Beispiel #2
0
        public void AddReputation(Reputation additive)
        {
            UnderThreshold beforeSumm = GetMaxUnderThreshold();

            int[] thresholdArr = GetThresholCorrectingdArr(beforeSumm);

            AddPeasants(additive.Peasants, thresholdArr[0]);
            AddChurch(additive.Church, thresholdArr[1]);
            AddBandits(additive.Bandits, thresholdArr[2]);
            AddNobles(additive.Nobles, thresholdArr[3]);

            CorrectReputation();
        }
Beispiel #3
0
        /// <summary>
        /// Only one can be > _ThresholdValue
        /// </summary>
        private void CorrectReputation()
        {
            UnderThreshold maxUnderThreshold = GetMaxUnderThreshold();

            if (maxUnderThreshold != UnderThreshold.NoUnder)
            {
                int[] thresholdArr = GetThresholCorrectingdArr(maxUnderThreshold);

                _reputation.Peasants = CorrectAmount(_reputation.Peasants, thresholdArr[0]);
                _reputation.Church   = CorrectAmount(_reputation.Church, thresholdArr[1]);
                _reputation.Bandits  = CorrectAmount(_reputation.Bandits, thresholdArr[2]);
                _reputation.Nobles   = CorrectAmount(_reputation.Nobles, thresholdArr[3]);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Only one can be > _ThresholdValue
        /// </summary>
        private void CorrectReputation()
        {
            UnderThreshold maxUnderThreshold = GetMaxUnderThreshold();

            if (maxUnderThreshold != UnderThreshold.NoUnder)
            {
                int[] thresholdArr = GetThresholCorrectingdArr(maxUnderThreshold);

                _context.Reputations.OrderBy(o => o.Id).FirstOrDefault().Peasants = CorrectAmount(GetPeasantsReputation(), thresholdArr[0]);
                _context.Reputations.OrderBy(o => o.Id).FirstOrDefault().Church   = CorrectAmount(GetChurchReputation(), thresholdArr[1]);
                _context.Reputations.OrderBy(o => o.Id).FirstOrDefault().Bandits  = CorrectAmount(GetBanditsReputation(), thresholdArr[2]);
                _context.Reputations.OrderBy(o => o.Id).FirstOrDefault().Nobles   = CorrectAmount(GetNoblesReputation(), thresholdArr[3]);

                _context.SaveChanges();
            }
        }
Beispiel #5
0
        private static int[] GetThresholCorrectingdArr(UnderThreshold underThreshold)
        {
            int[] thresholdArr;

            if (underThreshold == UnderThreshold.NoUnder)
            {
                thresholdArr = new int[4] {
                    _maxAmount, _maxAmount, _maxAmount, _maxAmount
                };
            }
            else
            {
                thresholdArr = new int[4] {
                    _thresholdValue, _thresholdValue, _thresholdValue, _thresholdValue
                };

                if (underThreshold == UnderThreshold.ItsPeasants)
                {
                    thresholdArr[0] = _maxAmount;
                }
                if (underThreshold == UnderThreshold.ItsChurch)
                {
                    thresholdArr[1] = _maxAmount;
                }
                if (underThreshold == UnderThreshold.ItsBandits)
                {
                    thresholdArr[2] = _maxAmount;
                }
                if (underThreshold == UnderThreshold.ItsNobles)
                {
                    thresholdArr[3] = _maxAmount;
                }
            }

            return(thresholdArr);
        }