Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            var idr = new InitialDataReader();
            var talents = idr.GetTalents();
            var toons = idr.GetToons();

            var c = new Calculator(toons, talents);

            var cas = new CastleRuntime
            {
                Toon = new Guid("dfa1673e-4c53-4f63-97df-876948b8b3a7"),
                CastleStatDistribution = new Dictionary<StatTypeEnum, byte>(),
                TalentLevelDistribution = new Dictionary<Guid, byte>()
            };

            cas.CastleStatDistribution.Add(StatTypeEnum.Agility, 42);

            cas.TalentLevelDistribution.Add(new Guid("6f779e8f-11d6-4e10-965d-6eeabf465d49"), 5);

            var bat = new BattleRuntime
            {
                IsMaxScore = true,
                IsMaxTime = true,
                TerrainType = TerrainTypeEnum.Foreign | TerrainTypeEnum.Neutral
            };

            var result = c.Calculate(cas, bat);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculate all data
        /// </summary>
        /// <param name="castle">Current castle context</param>
        /// <param name="battle">Current battle context</param>
        /// <returns>Calculated data</returns>
        public CalculationResult Calculate(CastleRuntime castle, BattleRuntime battle)
        {
            if (castle == null)
                throw new ArgumentNullException("castle");

            var cr = new CalculationResult();
            var currentToon = GetUsedToon(castle.Toon);

            // Calculate and append stats provided by talents and its bonuses
            var talc = new TalentCalculator(commonFunctions.ApplyStatValue);
            talc.Calculate(GetUsedTalents(castle.TalentLevelDistribution), castle.TalentLevelDistribution, battle, cr);

            // Calculate and append stats provided by toon and talents might
            var toonc = new ToonCalculator(commonFunctions.ApplyStatValue);
            toonc.Calculate(currentToon, cr);

            // Calculate and append stats distributed in castle (such as guild bonuses, stats for character level, ect.)
            var sdc = new StatDistributionCalculator(commonFunctions.ApplyStatValue);
            sdc.Calculate(castle.CastleStatDistribution, cr);

            // Calculate and append values of dependent properties
            var dpc = new DependentPropertiesCaclulator();
            dpc.Calculate(cr, currentToon.MainAttackStat, currentToon.AttackModifier);

            return cr;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Calculate stats given by talents
        /// </summary>
        /// <param name="talentsUsed">Used talents</param>
        /// <param name="talentLevelDistribution">Levels for used talents</param>
        /// <param name="battleContext">Battle conditions description</param>
        /// <param name="calculationResult">Processing calculation result</param>
        public void Calculate(IEnumerable<Talent> talentsUsed, IDictionary<Guid, byte> talentLevelDistribution, BattleRuntime battleContext, CalculationResult calculationResult)
        {
            if (talentLevelDistribution == null)
                throw new ArgumentNullException("talentLevelDistribution");
            if (calculationResult == null)
                throw new ArgumentNullException("calculationResult");
            if (talentsUsed == null)
                throw new ArgumentNullException("talentsUsed");

            // Append stats given by talent levels
            ApplyCastleContext(talentsUsed, talentLevelDistribution);

            // Append stats given by special conditions (like native land)
            ApplyBattleContext(talentsUsed, battleContext);

            // Append all values to final result
            talentsUsed
                .ToList()
                .ForEach(x =>
                {
                    calculationResult.Might += x.Might;
                    x.Stats.ForEach(y => applyStatValue(y.Type, y.Value, calculationResult));
                });
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TalentConditionRelay" /> class
 /// </summary>
 /// <param name="context">Current battle settings</param>
 public TalentConditionRelay(BattleRuntime context)
 {
     this.context = context;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Apply conditions
        /// </summary>
        /// <param name="talentsUsed">Selected talents</param>
        /// <param name="battleContext">Conditions description</param>
        private void ApplyBattleContext(IEnumerable<Talent> talentsUsed, BattleRuntime battleContext)
        {
            if (talentsUsed == null)
                throw new ArgumentNullException("talentsUsed");
            if (battleContext == null)
                throw new ArgumentNullException("battleContext");

            var condition = new TalentConditionRelay(battleContext);
            condition.Change(talentsUsed);
        }