Example #1
0
        protected async Task <Passenger> PassengerDetailAsync(Dice random, string travelType, bool advancedCharacters)
        {
            var user = await NameService.CreateRandomPersonAsync().ConfigureAwait(false);

            bool isPatron = false;

            var result = new Passenger()
            {
                TravelType  = travelType,
                Name        = $"{user.FirstName} {user.LastName}",
                Gender      = user.Gender,
                ApparentAge = 12 + random.D(1, 60),
            };

            Passenger.AddPassengerType(result, random);

            SimpleCharacterEngine.AddTrait(result, random);

            if (!advancedCharacters)
            {
                SimpleCharacterEngine.AddCharacteristics(result, random);
            }
            else
            {
                result.Seed = random.Next();
                var options = new CharacterBuilderOptions()
                {
                    MaxAge = result.ApparentAge, Name = result.Name, Seed = result.Seed
                };
                var character = m_CharacterBuilder.Build(options);

                result.Strength  += character.Strength;
                result.Dexterity += character.Dexterity;
                result.Endurance += character.Endurance;
                result.Intellect += character.Intellect;
                result.Education += character.Education;
                result.Social    += character.SocialStanding;

                result.Skills = string.Join(", ", character.Skills.Where(s => s.Level > 0).Select(s => s.ToString()).OrderBy(s => s));

                result.Title = character.Title;
            }


            if (isPatron)
            {
                //TODO: add support for patron features
            }

            return(result);
        }
Example #2
0
        public async Task <ActionResult> Character(int?minAge = null, int?maxAge = null, string name = null, string career = null, int?seed = null)
        {
            var dice    = new Dice();
            var options = new CharacterBuilderOptions();

            if (!string.IsNullOrEmpty(name))
            {
                options.Name = name;
            }
            else
            {
                options.Name = (await NameService.CreateRandomPersonAsync()).FullName;
            }

            if (minAge.HasValue && minAge == maxAge)
            {
                options.MaxAge = maxAge;
            }
            else if (minAge.HasValue && maxAge.HasValue)
            {
                options.MaxAge = minAge.Value + dice.D(1, maxAge.Value - minAge.Value);
            }
            else if (maxAge.HasValue)
            {
                options.MaxAge = 12 + dice.D(1, maxAge.Value - 12);
            }
            else
            {
                options.MaxAge = 12 + dice.D(1, 60);
            }

            options.FirstCareer = career;

            options.Seed = seed;

            var model = Global.CharacterBuilder.Build(options);

            return(View(model));
        }