Example #1
0
        public static void Create()
        {
            while (true)
            {
                Console.Clear(); Console.Write("Your name is ");
                //TODO: more extensive character creation
                var name = Console.ReadLine();
                if (name == null)
                {
                    continue;
                }
                var nonlettersAreSpammed = false;
                var names = name.Split(' ');
                foreach (var s in names)
                {
                    nonlettersAreSpammed = s.Where(letter => Nonletters.Any(nonletter => letter == nonletter)).ToList().Count > 1;
                    if (nonlettersAreSpammed)
                    {
                        break;
                    }
                }
                //TODO: shorten, notify player
                name = new Regex(" {2,}").Replace(name.Trim(' ', '-', '\''), " ");
                Console.Clear(); Console.Write("Your name is {0}.", name);
                if (Console.ReadKey(true).Key != ConsoleKey.Enter ||
                    String.IsNullOrWhiteSpace(name) ||
                    !name.Any(Char.IsLetter) ||
                    nonlettersAreSpammed ||
                    name.Any(letter => !Char.IsLetter(letter) && Nonletters.All(nonletter => nonletter != letter)))
                {
                    continue;
                }
                Player.Instance.Name = name;
                break;
            }
            #region Choose Origin
            Console.Clear(); Console.WriteLine("You come from");
            Player.Instance.PlayerOrigin = (Player.Origin) new[]
            {
                "an average house in the safe provinces, loyal to the king",
                "an average house in a war-torn province, loyal to your lord", //TODO: find correct title
                "a refugee tent in a war-torn province, loyal to nobody"
            }.Choose();
            #endregion
            #region Choose Class
            Console.Clear(); Console.WriteLine("You are");
            var options = new string[3];
            switch (Player.Instance.PlayerOrigin)
            {
            case Player.Origin.Nation:
                options = new[] {
                    "a skilled warrior, able to knock back a training dummy 10 metres with one blow",
                    "a skilled archer, able to hit a training dummy's heart from 100 metres away",
                    "a skilled mage, able to burn training dummies to a crisp in 10 seconds flat"
                };
                break;

            case Player.Origin.Treaty:
                options = new[] {
                    "a warrior, able to knock back an invader 10 metres with one blow",
                    "an archer, able to hit an invader's heart from 100 metres away",
                    "a mage, able to burn invaders to a crisp in 10 seconds flat"
                };                                                                       //TODO: rename invaders, and king maybe
                break;

            case Player.Origin.Refugee:
                options = new[] {
                    "a born warrior, able to knock a sack of potatoes 10 metres back with one blow",
                    "a born archer, able to hit a bullseye from 100 metres away",
                    "a born mage, able to burn a tree in 10 seconds flat"
                };
                break;
            }
            Player.Instance.PlayerClass = (Player.Class)options.Choose();
            #endregion
            //TODO: AssignStartingEquipment();
            Player.Instance.InitialiseAttributes();
            int attPoints;
            Consoles.WordWrap("Set your attributes manually. Points left are indicated below.");
            var permanentPoints = Consoles.Spend(
                new List <string> {
                "You have ", " points", " left to use"
            },
                new List <string> {
                "Strength:", "Dexterity:", "Wisdom:"
            },
                new List <int> {
                Player.Instance.Strength, Player.Instance.Dexterity, Player.Instance.Wisdom
            },
                new List <int> {
                1, 1, 1
            }, 16, out attPoints, arrowPosition: 14);
            Player.Instance.Strength        = permanentPoints[0]; Player.Instance.Dexterity = permanentPoints[1]; Player.Instance.Wisdom = permanentPoints[2];
            Player.Instance.AttributePoints = attPoints;
            Player.Instance.RoomId          = 1;
        }