예제 #1
0
        public DefaultCharacter Build()
        {
            if (_raceId == 0)
            {
                _raceId = Randomizer.TakeRandomFrom(RaceRepository.Data).Id;
            }
            if (_classId == 0)
            {
                _classId = Randomizer.TakeRandomFrom(ClassRepository.Data).Id;
            }
            if (_genderId == 0)
            {
                _genderId = Randomizer.Random(1, 2);
            }
            if (_classLevels == 0)
            {
                _classLevels = Randomizer.Random(1, 5);
            }

            if (string.IsNullOrEmpty(_name))
            {
                _name = NameGenerator.Generate(_genderId == 1 ? Gender.Male : Gender.Female);
            }

            var character = new DefaultCharacter
            {
                Id           = ++currentId,
                NameLocaleId = _name,
                Race         = RaceRepository.Retrieve(_raceId),
                Class        = new DefaultClass(_classLevels, ClassRepository.Retrieve(_classId)),
                GenderType   = (byte)_genderId,
                Equipment    = new DummyEquipment()
            };

            character.Stats = StatsComputer.ComputeStats(character.GetActiveEffects().ToArray());
            return(character);
        }