public SkillCollection(ISkillsDataSource dataSource, ILevelFormula minutesFormula, ILevelFormula countableFormula)
 {
     this.dataSource       = dataSource;
     this.minutesFormula   = minutesFormula;
     this.countableFormula = countableFormula;
     dataSource.PrepareData(GetData);
 }
Beispiel #2
0
 public JsonDatabase(string userId, ILevelFormula minutesFormula, ILevelFormula countableFormula)
 {
     reader                = new FirebaseReader(userId);
     skills                = new Dictionary <string, Skill>();
     records               = new Dictionary <string, Record>();
     skillParents          = new Dictionary <string, List <string> >();
     this.minutesFormula   = minutesFormula;
     this.countableFormula = countableFormula;
 }
Beispiel #3
0
 public Skill(string guid, string name, ILevelFormula formula, Color color, HashSet <Skill> parents, bool isCountable = false)
 {
     this.guid        = guid;
     this.name        = name;
     this.formula     = formula;
     this.color       = color;
     this.parents     = parents;
     records          = new List <Record>();
     this.isCountable = isCountable;
 }
Beispiel #4
0
 public Skill(string name, ILevelFormula formula, bool isCountable = false)
 {
     guid             = Guid.NewGuid().ToString();
     this.name        = name;
     this.formula     = formula;
     parents          = new HashSet <Skill>();
     records          = new List <Record>();
     color            = Color.white;
     this.isCountable = isCountable;
 }
        public void AddSkill(string name, Color color, List <Skill> parents, bool isCountable = false)
        {
            ILevelFormula formula  = isCountable ? countableFormula : minutesFormula;
            Skill         newSkill = new Skill(name, formula, isCountable);

            newSkill.color = color;
            foreach (Skill skill in parents)
            {
                newSkill.AddParent(skill);
            }

            skills.Add(newSkill.guid, newSkill);
            dataSource.AddSkill(newSkill);

            if (OnSkillAdded != null)
            {
                OnSkillAdded(newSkill);
            }
        }
Beispiel #6
0
        private Skill CreateSkill(string guid, object json)
        {
            Debugger.Instance.Log("creating skill " + guid);
            var    jsonSkill = (Dictionary <string, object>)json;
            string name      = jsonSkill["name"].ToString();

            Color color;

            if (jsonSkill.ContainsKey("color"))
            {
                var jsonColor = (Dictionary <string, object>)jsonSkill["color"];
                color = new Color(
                    Convert.ToSingle(jsonColor["r"]),
                    Convert.ToSingle(jsonColor["g"]),
                    Convert.ToSingle(jsonColor["b"])
                    );
            }
            else
            {
                color = Color.white;
            }

            if (jsonSkill.ContainsKey("parents"))
            {
                var jsonParents = (Dictionary <string, object>)jsonSkill["parents"];
                skillParents.Add(guid, new List <string>());

                foreach (string parent in jsonParents.Keys)
                {
                    skillParents[guid].Add(parent);
                }
            }

            bool          countable = jsonSkill.ContainsKey("countable") && (Boolean)jsonSkill["countable"];
            ILevelFormula formula   = countable ? countableFormula : minutesFormula;

            Debugger.Instance.Log("skill complete " + name);
            return(new Skill(guid, name, formula, color, new HashSet <Skill>(), countable));
        }
 public CountableLevelFormula(float equivalentMin, ILevelFormula minFormula)
 {
     this.equivalentMin = equivalentMin;
     this.minFormula    = minFormula;
 }