예제 #1
0
 public void Execute(string input)
 {
     if (input == "lol")
     {
         tempVal.WriteLine("You laugh. Tee Hee!");
     }
     else
     {
         tempVal.WriteLine("You laugh at {0}. Tee Hee!", GetAllButFirstWord(input));
     }
 }
예제 #2
0
        public void Execute(string[] args)
        {
            var user = factory.CreateUserStore();

            user.Authenticate(eConfig.UserName, eConfig.Password);

            var note = factory.CreateNoteStore();

            string cmdName;

            if ((args.Count() > 0) == false)
            {
                cmdName = "today";
            }
            else
            {
                cmdName = args[0].Trim().ToLower();
            }
            var rest = args.Skip(1);

            var cmd = commands.FirstOrDefault(m => m.Name == cmdName);

            if (cmd == null)
            {
                console.WriteLine("Unknown Command");
            }
            else
            {
                cmd.Execute(rest);
            }
        }
예제 #3
0
        public void Execute(string input)
        {
            var output = GetAllButFirstWord(input);

            using (roomRepository)
            {
                var LookedAt = roomRepository.AsQueryable()
                               .FirstOrDefault(qq => qq.RoomName == output);
                if (LookedAt == null)
                {
                    console.WriteLine("It must be an item");
                    return;
                }
                console.WriteLine(LookedAt.Description);
            }
        }
예제 #4
0
        public void Execute(string input)
        {
            var output = GetAllButFirstWord(input).ToUpper();

            console.ForegroundColor = ConsoleColor.Red;
            console.WriteLine(output);
            console.ResetColor();
        }
예제 #5
0
        public void Execute(string input)
        {
            var output      = GetAllButFirstWord(input);
            var name        = output.Split('.')[0];
            var itemNewName = string.Join("=", input.Trim().Split('=').Skip(1)).Trim();

            using (repository)
            {
                var item = repository.AsQueryable()
                           .FirstOrDefault(qq => qq.ItemName == name);
                if (item == null)
                {
                    console.WriteLine("I do not recognize \"{0}\".", item);
                    return;
                }
                console.WriteLine("The item's name has been changed from {0} to {1}.",
                                  item.ItemName, itemNewName);

                item.ItemName = itemNewName;
            }
        }
예제 #6
0
        public void Execute(string input)
        {
            var output = GetAllButFirstWord(input);

            using (repository)
            {
                repository.Add(new Room()
                {
                    RoomName = output
                });
            }
            console.WriteLine("Room Created.");
        }
예제 #7
0
        public void Loop()
        {
            field = inputs.GetUserInput();
            field = fieldAlterations.GenerateField(field);

            while (true)
            {
                facade.Clear();
                display.DrawGame(field);
                simulation.StartNewGen(field);
                display.WriteProperties(numOfIterations);
                numOfIterations++;

                if (Console.KeyAvailable)
                {
                    var key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.P)
                    {
                        facade.Clear();
                        facade.WriteLine(Texts.Pause);
                        var answ = facade.ReadLine().ToLower();
                        if (texts.True(answ))
                        {
                            file.Save(field);
                            facade.WriteLine(Texts.Approval);
                            continue;
                        }
                        else if (texts.False(answ))
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
        }
예제 #8
0
        public void Execute(string input)
        {
            var output = GetAllButFirstWord(input);

            using (repository)
            {
                repository.Add(new Item()
                {
                    ItemName = output, RoomId = 2
                });
                // RoomId 2 is the inventory "Room".
            }
            console.WriteLine("You create the item \"{0}\" in your inventory.", output);
        }
예제 #9
0
        public void Execute(string input)
        {
            console.WriteLine("You are carrying:");
            using (repository)
            {
                var sack = repository.AsQueryable().Where(qq => qq.RoomId == 2);
                foreach (var item in sack)
                {
                    console.Write("{0}  ", item.ItemName);
                }

                /* Reminder: RoomId 2 is the inventory "room".
                 */
            }
        }
예제 #10
0
        public void DrawGame(Field field)
        {
            for (int currentRow = 0; currentRow < field.Height; currentRow++)
            {
                for (int currentColumn = 0; currentColumn < field.Width; currentColumn++)
                {
                    var currentCell = field.Cells[currentRow, currentColumn];
                    if (currentCell)
                    {
                        facade.Write(Texts.Symbol);
                        AddLiveCells();
                    }
                    else
                    {
                        facade.Write(Texts.Empthy);
                    }

                    if (currentColumn == field.Width - 1)
                    {
                        facade.WriteLine(Texts.Return);
                    }
                }
            }
        }
예제 #11
0
        public void Execute(string input)
        {
            var output          = GetAllButFirstWord(input);
            var name            = output.Split('.')[0];
            var itemDescription = string.Join("=", input.Trim().Split('=').Skip(1)).Trim();

            using (repository)
            {
                var item = repository.AsQueryable()
                           .FirstOrDefault(qq => qq.ItemName == name);
                if (item == null)
                {
                    console.WriteLine("I do not recognize \"{0}\".", item);
                    return;
                }
                item.ItemDescription = itemDescription;
            }
        }
예제 #12
0
 public void Run()
 {
     while (true)
     {
         console.Write(">> ");
         var input = console.ReadLine();
         if (input == "exit")
         {
             break;
         }
         if (command.IsValid(input))
         {
             command.Execute(input);
         }
         else
         {
             console.WriteLine(input);
         }
     }
 }
예제 #13
0
        public void DrawAnimals(Field field, List <Animal> additionalAnimal)
        {
            for (int currentRow = 0; currentRow < field.Height; currentRow++)
            {
                for (int currentColumn = 0; currentColumn < field.Width; currentColumn++)
                {
                    var currentAnimal = _genericAnimal.FindInField(field, currentColumn, currentRow);

                    if (currentAnimal == null)
                    {
                        _facade.Write(TextParameters.Empty);
                    }
                    else if (currentAnimal.Alive)
                    {
                        _facade.Write(currentAnimal.Symbol);
                    }
                    if (currentColumn == field.Width - 1)
                    {
                        _facade.WriteLine(TextParameters.Return);
                    }
                }
            }
        }
예제 #14
0
        public Field GetUserInput()
        {
            facade.WriteLine(Texts.Intro);
            facade.WriteLine();
            facade.WriteLine(Texts.StartFromSaved);
            var answ = facade.ReadLine().ToLower();

            if (validation.ValidateQuestion(answ))
            {
                field = fileWorker.Load();
                return(field);
            }
            else if (!validation.ValidateQuestion(answ))
            {
                facade.WriteLine(Texts.Param);
                facade.WriteLine(Texts.Height);
                inputHeight = facade.ReadLine();
                facade.WriteLine(Texts.Width);
                inputWidth = facade.ReadLine();

                var validH = validation.ValidateInt(inputHeight);
                var validW = validation.ValidateInt(inputWidth);

                if (validH && validW)
                {
                    field = CreateInputField(inputHeight, inputWidth);
                    return(field);
                }
                else
                {
                    facade.WriteLine(Texts.Error);
                    GetUserInput();
                    return(field);
                }
            }
            return(field);
        }
예제 #15
0
 public void Execute(string input)
 {
     console.WriteLine(GetAllButFirstWord(input));
 }
예제 #16
0
 public void Execute(string input)
 {
     storage.WriteLine("You wave at {0}.", GetAllButFirstWord(input));
 }
예제 #17
0
 public void Execute(string input)
 {
     console.WriteLine("You open the {0} and peek at what's inside.", GetAllButFirstWord(input));
 }
예제 #18
0
 public void Execute(string input)
 {
     console.WriteLine("You gracefully dance the {0}.", GetAllButFirstWord(input));
 }
예제 #19
0
 public void Execute(string input)
 {
     console.WriteLine("You dance around like a fool");
 }
예제 #20
0
        public void Execute(string input)
        {
            var output = GetAllButFirstWord(input);

            storage.WriteLine("One look at {0} sends you into a panic.", output);
        }
예제 #21
0
        public void Execute(string input)
        {
            var output = GetAllButFirstWord(input);

            storage.WriteLine("You bonk {0} on the head. Ouch!", output);
        }
예제 #22
0
 public void HandleUnknownInput(string input)
 {
     storage.WriteLine("I don't understand.");
 }
예제 #23
0
 public void Execute(string input)
 {
     console.WriteLine("You examine the {0}.", GetAllButFirstWord(input));
 }
예제 #24
0
        public void Execute(string input)
        {
            var output = GetAllButFirstWord(input);

            console.WriteLine(output);
        }
예제 #25
0
 public void Execute(string input)
 {
     console.WriteLine("You slap {0} upside the head.", GetAllButFirstWord(input));
 }
예제 #26
0
 public void Execute(string input)
 {
     console.WriteLine("You make a rude comment to {0}.", GetAllButFirstWord(input));
 }
예제 #27
0
 public void Execute(string input)
 {
     console.WriteLine("You cheer for {0}.", GetAllButFirstWord(input));
 }
예제 #28
0
        public void Execute(string input)
        {
            var output = GetAllButFirstWord(input);

            storage.WriteLine(String.Format("You fix {0} with a baleful glare.", output));
        }
예제 #29
0
        public void Execute(string input)
        {
            var output = GetAllButFirstWord(input);

            storage.WriteLine(String.Format("You shake your fist at {0} in anger.", output));
        }
예제 #30
0
        public void Execute(string input)
        {
            var output = GetAllButFirstWord(input);

            storage.WriteLine("You gracefully dance the {0}.", output);
        }