예제 #1
0
 public void AjouterRessource(Ressource r)
 {
     Ressources.Add(r);
 }
예제 #2
0
        /// <summary>
        /// Rentre les valeurs
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="dico"></param>
        private bool SetCharacterize <T>(T t) where T : IRepository <T>
        {
            List <string>            items    = new List <string>();
            List <Features>          features = new List <Features>();
            Dictionary <string, int> dico     = new Dictionary <string, int>();

            bool   switchToArray = false;
            int    i             = 1;
            string message       = string.Concat("Il manque les caractéristiques suivantes :", Environment.NewLine);

            _missed = new List <string>();

            if (t.GetType() == typeof(Features))
            {
                _missed.Add(string.Concat("Il manque les caractéristiques suivantes :", Environment.NewLine));
                message = string.Concat("Il manque les caractéristiques suivantes :", Environment.NewLine);
            }
            if (!CheckCharacterize(t, ref dico))
            {
                throw new CharacterException(string.Concat(_missed));
            }

            foreach (KeyValuePair <string, int> item in dico)
            {
                switch (t)
                {
                case Features f:
                    f = new Features
                    {
                        Id    = i,
                        Name  = item.Key,
                        Value = item.Value
                    };
                    features.Add(f);
                    switchToArray = true;
                    break;

                case Skills s:
                    s = new Skills
                    {
                        Id    = i,
                        Name  = item.Key,
                        Value = item.Value
                    };
                    Skills.Add(s);
                    break;

                case SpecialAbilities sa:
                    sa = new SpecialAbilities
                    {
                        Id    = i,
                        Name  = item.Key,
                        Value = item.Value
                    };
                    SpecialAbilities.Add(sa);
                    break;

                case Ressources r:
                    r = new Ressources
                    {
                        Id    = i,
                        Name  = item.Key,
                        Value = item.Value
                    };
                    Ressources.Add(r);
                    break;

                default:
                    throw new CharacterException("Données inconnues");
                }
                i++;
            }

            if (switchToArray)
            {
                Features = features.ToArray();
            }
            return(true);
        }