I did it like this, probably less code a little bit

        public float GetStat(Stat stat, CharacterClass characterClass, int level)
        {
            BuildLookup();

            if( lookupTable.ContainsKey(characterClass) && lookupTable[characterClass].ContainsKey(stat) && lookupTable[characterClass][stat].Length>= level)
            {
                return lookupTable[characterClass][stat][level - 1];
            }
            return 0;
        }

        void BuildLookup()
        {
            if (lookupTable != null)
                return;

            lookupTable = new Dictionary<CharacterClass, Dictionary<Stat, float[]>>();

            foreach (ProgressionCharacterClass c in characterClasses)
            {
                lookupTable.Add(c.characterClass, new Dictionary<Stat, float[]>());

                foreach (var item in c.stats)
                {
                    lookupTable[c.characterClass].Add(item.stat, item.levels);
                }
            }
        }

I should work! Well done.

Privacy & Terms