public Motivation(MotivationTypeEnum _type, string _nameKey, string _descriptionKey, List <GenreEnum> _availableGenres) { this._type = _type; this._nameKey = (_nameKey == null || _nameKey == "") ? "INVALID_MOTIVATION" : _nameKey; this._descriptionKey = (_descriptionKey == null || _descriptionKey == "") ? "INVALID_DESCRIPTION" : _descriptionKey;; this._availableGenres = (_availableGenres == null || _availableGenres.Count == 0) ? new List <GenreEnum>(PAPIApplication.GetAllGenres()) : _availableGenres; WfLogger.Log(this, LogLevel.DETAILED, "Created new Motivation " + this._type + ": " + _nameKey); }
/// <summary> /// Returns a random Motivation of the given type, if no Motivation is found, null is returned /// </summary> /// <param name="type"></param> /// <returns></returns> public static Motivation RandomMotivation(MotivationTypeEnum type) { Random random = new Random(); int index = random.Next(0, _allMotivations.Count - 1); for (int i = index, remainingRounds = 2; i < _allMotivations.Count && remainingRounds > 0; i = i + 1 % _allMotivations.Count, remainingRounds--) { if (_allMotivations[i]._type == type) { return(_allMotivations[i]); } } return(null); }