Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,RiddleQuestion,RiddleAnswer")] Riddle riddle)
        {
            if (id != riddle.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(riddle);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RiddleExists(riddle.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(riddle));
        }
Exemplo n.º 2
0
        public RiddlePage(Riddle riddle, IAnswerService answerService)
        {
            _answerService = answerService;

            _riddle = riddle;

            Label label = new Label
            {
                Text = _riddle.Description
            };

            _answerEntry = new Entry
            {
                Keyboard    = Keyboard.Text,
                Placeholder = "take your shot, chief"
            };

            _saveButton = new Button
            {
                Text = "Submit"
            };

            _saveButton.Clicked += SubmitAnswer;

            StackLayout stackLayout = new StackLayout();

            stackLayout.Children.Add(label);
            stackLayout.Children.Add(_answerEntry);
            stackLayout.Children.Add(_saveButton);

            Content = stackLayout;
        }
Exemplo n.º 3
0
    public void ApplyAllRiddles()
    {
        List <Riddle> easyRiddles   = Riddles.GetEasyRiddles();
        List <Riddle> mediumRiddles = Riddles.GetMediumRiddles();
        List <Riddle> hardRiddles   = Riddles.GetHardRiddles();

        foreach (Citizen c in easyCitizens)
        {
            Riddle r = easyRiddles[Random.Range(0, easyRiddles.Count)];

            c.SetRiddle(r);
            easyRiddles.Remove(r);
        }

        foreach (Citizen c in mediumCitizens)
        {
            Riddle r = mediumRiddles[Random.Range(0, mediumRiddles.Count)];
            c.SetRiddle(r);
            mediumRiddles.Remove(r);
        }

        foreach (Citizen c in hardCitizens)
        {
            Riddle r = hardRiddles[Random.Range(0, hardRiddles.Count)];
            c.SetRiddle(r);
            hardRiddles.Remove(r);
        }
    }
Exemplo n.º 4
0
        public async Task <IActionResult> Update([FromRoute] int id, [FromBody]  Riddle q)//редактирование загадки
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var item = _context.Riddle.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            item.Text                = q.Text;
            item.Description         = q.Description;
            item.Answer              = _context.Answer.Find(q.Id_Answer_FK);
            item.Level_of_complexity = _context.Level_of_complexity.Find(q.Id_Level_FK);
            item.Type_of_question    = _context.Type_of_question.Find(q.Id_Type_FK);
            item.User                = _context.User.Find(q.Id_Autor_FK);
            item.Status              = item.User.AccessLevel;
            item.QuestRiddle         = q.QuestRiddle;
            _context.Riddle.Update(item);
            Log.WriteLog("Riddle:Update", "Загадка №" + item.Id_riddle + "обновлена");
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Exemplo n.º 5
0
        public async Task <object> Create([Bind("ID,Question,Answer,ComplimentForWinning,InsultForLosing")] Riddle riddle)
        {
            riddle.Author = CurrentUser;
            //riddle.AuthorID = riddle.Author.Id;

            ModelState.Remove("Author");

            if (ModelState.IsValid)
            {
                _context.Add(riddle);

                var authorStatus = new SolvingStatus()
                {
                    Riddle = riddle, User = CurrentUser, Status = UserRiddleStatus.Created
                };

                _context.Add(authorStatus);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(riddle);
        }
Exemplo n.º 6
0
 public void setRiddle(Riddle riddle)
 {
     this.riddle = riddle;
     riddleText.text = riddle.riddle;
     tip.text = riddle.tip;
     answerInput.text = riddle.answer;
     instruction.text = riddle.instruction;
 }
Exemplo n.º 7
0
    static void Main()
    {
        var riddle = new Riddle();

        ((ICounter)riddle.counter).Increment();

        Console.WriteLine(((Counter)riddle.counter).Count);     // Line B
    }
Exemplo n.º 8
0
        public void Delete(int id)
        {
            Riddle k = db.Riddle.Find(id);

            if (k != null)
            {
                db.Riddle.Remove(k);
            }
        }
    public static void Main()
    {
        var riddle = new Riddle();

        Console.WriteLine(((Counter)riddle.counter).Increment());
        ///////////////////////////////////////////
        Console.WriteLine(((Counter)riddle.counter).Count);
        // Why the output is 0?///////////////////
    }
Exemplo n.º 10
0
        public IActionResult Answer(Riddle riddle)
        {
            if (riddle.MultipleRiddleAnswer == null)
            {
                return(Answer(riddle.SingleRiddleAnswer));
            }

            return(Answer(riddle.MultipleRiddleAnswer));
        }
Exemplo n.º 11
0
 public void CreateRiddle(Riddle item)
 {
     if (String.IsNullOrWhiteSpace(item.Description))
     {
         item.Description = GenerDescription();
     }
     db.Riddls.Create(item);
     db.Save();
 }
Exemplo n.º 12
0
    static void Main()
    {
        Riddle firstRiddle  = new Riddle("What kind of goose fights with snakes?", "mongoose");
        Riddle secondRiddle = new Riddle("I am wet when drying. What am I?", "towel");
        Riddle thirdRiddle  = new Riddle("What word is always pronounced wrong?", "wrong");


        dynamic randomize()
        {
            Random rnd    = new Random();
            int    random = rnd.Next(1, 3);

            if (random == 1)
            {
                return(firstRiddle);
            }
            else if (random == 2)
            {
                return(secondRiddle);
            }
            else
            {
                return(thirdRiddle);
            }
        }

        Console.WriteLine("I am the mythical Sphinx! Bow before me!");
        Thread.Sleep(3000);
        questioning();

        void questioning()
        {
            Riddle theRiddle = randomize();

            Console.WriteLine(theRiddle.Question);
            string answer = Console.ReadLine();

            answering(answer, theRiddle);
        }

        void answering(string answer, Riddle theRiddle)
        {
            if (answer == theRiddle.Answer)
            {
                Console.WriteLine("Congratulations!");
                Thread.Sleep(1000);
                Console.WriteLine("Are you ready for the next question?");
                Thread.Sleep(2000);
                questioning();
            }
            else
            {
                Console.WriteLine("Hahaha! I will now eat you!");
            }
        }
    }
Exemplo n.º 13
0
 public void UpdateRiddle(Riddle item)
 {
     if (String.IsNullOrWhiteSpace(item.Description))
     {
         item.Description = GenerDescription();
     }
     // Riddle r = db.Riddls.GetItem(item.Id_riddle);
     db.Riddls.Update(item);
     db.Save();
 }
        public Task <HttpResponseMessage> CreateAnswer(Riddle riddle)
        {
            Answer answer = new Answer
            {
                Riddle = riddle.Id,
                Solver = _settings.GetItem(SettingTypes.UserId)
            };

            return(_baseApiAccessor.PostJson(_apiConnection, answer));
        }
Exemplo n.º 15
0
        public void DeleteRiddle(int id)
        {
            Riddle k = db.Riddls.GetItem(id);

            if (k != null)
            {
                db.Riddls.Delete(k.Id_riddle);
            }
            db.Save();
        }
Exemplo n.º 16
0
        public async Task <IActionResult> Create([Bind("Id,RiddleQuestion,RiddleAnswer")] Riddle riddle)
        {
            if (ModelState.IsValid)
            {
                _context.Add(riddle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(riddle));
        }
Exemplo n.º 17
0
        public JsonResult TestRiddle(Guid id, string pattern)
        {
            Riddle       selectedRiddle = _riddleRepository.GetById(id);
            RiddleResult riddleResult   = selectedRiddle.Evaluate(pattern);

            return(Json(new
            {
                FailedResults = riddleResult.FailedClues.Select(c => c.GetHashCode()).ToArray(),
                SucceededResults = riddleResult.SuccessfulClues.Select(c => c.GetHashCode()).ToArray()
            }));
        }
Exemplo n.º 18
0
 public void SaveRiddle(bool access_level, bool isNewChecked, Riddle r)
 {
     if (access_level && !isNewChecked)
     {
         UpdateRiddle(r);
     }
     else
     {
         CreateRiddle(r);
     }
 }
Exemplo n.º 19
0
    public static void Main()
    {
        Riddle question1 = new Riddle();

        question1.Question = "What kind of goose fights with snakes?";
        question1.Answer   = "mongoose";

        Riddle question2 = new Riddle();

        question2.Question = "I am wet when drying. What am I?";
        question2.Answer   = "towel";

        Riddle question3 = new Riddle();

        question3.Question = "What word is always pronounced wrong?";
        question3.Answer   = "wrong";

        List <Riddle> Riddles = new List <Riddle>()
        {
            question1, question2, question3
        };

        AskAnotherQuestion();


        void AskAnotherQuestion()
        {
            Random rnd       = new Random();
            int    intRiddle = rnd.Next(Riddles.Count);

            Console.WriteLine(Riddles[intRiddle].Question);
            string userInput = Console.ReadLine();

            if (userInput.Contains(Riddles[intRiddle].Answer))
            {
                Console.WriteLine("Correct!");
                Console.WriteLine("Would you like to answer another question? If yes, type 'y', if no, type 'n'");
                string anotherQuestion = Console.ReadLine().ToLower();
                if (anotherQuestion == "y")
                {
                    AskAnotherQuestion();
                }
                else
                {
                    Console.WriteLine("Thanks for playing!");
                }
            }
            else
            {
                Console.WriteLine("You've been eaten by the Sphinx!");
            }
        }
    }
Exemplo n.º 20
0
        public async Task <IActionResult> Create([FromBody] Riddle q) //создание загадки
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _context.Riddle.Add(q);
            await _context.SaveChangesAsync();

            Log.WriteLog("Riddle:Create", "Создана новая загадка");
            return(CreatedAtAction("GetRiddle", new { id = q.Id_riddle }, q));
        }
Exemplo n.º 21
0
            public void Should_return_failing_clue_when_expected_to_match()
            {
                var clues = new List <Clue> {
                    new Clue("cat", true)
                };
                var riddle = new Riddle("Test", clues);

                var riddleResult = riddle.Evaluate("dog");

                Assert.That(riddleResult.Passed, Is.False);
                Assert.That(riddleResult.FailedClues, Is.EquivalentTo(clues));
            }
Exemplo n.º 22
0
            public void Should_return_successful_result_when_all_clues_match_correctly()
            {
                var clues = new List <Clue> {
                    new Clue("cat", true)
                };
                var riddle = new Riddle("Test", clues);

                var riddleResult = riddle.Evaluate("cat");

                Assert.That(riddleResult.Passed, Is.True);
                Assert.That(riddleResult.FailedClues, Is.Empty);
                Assert.That(riddleResult.SuccessfulClues, Is.EquivalentTo(clues));
            }
Exemplo n.º 23
0
            public void Should_return_failing_clue_when_expected_not_to_match()
            {
                const string expectedFailingPrompt = "cat";
                var          clues = new List <Clue> {
                    new Clue(expectedFailingPrompt, false)
                };
                var riddle = new Riddle("Test", clues);

                var riddleResult = riddle.Evaluate(expectedFailingPrompt);

                Assert.That(riddleResult.Passed, Is.False);
                Assert.That(riddleResult.FailedClues, Is.EquivalentTo(clues));
            }
Exemplo n.º 24
0
 public void Update(Riddle item)
 {
     /*db.SaveChanges();
      * //db.Entry(item).State = EntityState.Modified;
      * var local = db.Set<Riddle>()
      *      .Local
      *      .FirstOrDefault(f => f.Id_riddle == item.Id_riddle);
      * if (local != null)
      * {
      *  db.Entry(local).State = EntityState.Detached;
      * }*/
     db.Entry(item).State = System.Data.Entity.EntityState.Modified;
 }
Exemplo n.º 25
0
        //Initializes the game, creates rooms, their exits, and add items to rooms
        public void Setup()
        {
            #region Rooms
            Room dungeon         = new Room("The Dungeon", "You sit in a cold damp cell, it is very dimly lit and you can hear an ocean of whispers and screams that has become a part of your madness, you must escape this place. The only exit is the door to your cell which has a small lock.\nYou notice a small hairpin wedged into the wall, you see the words \"Death is L\" scribbled beside it.", "You sit in a cold damp cell, it is very dimly lit and you can hear an ocean of whispers and screams that has become a part of your madness, you must escape this place. The only exit is the door to your cell which has a small lock.");
            Room smallHallway    = new Room("A Small Hallway", "", "A thin hallway that seems to get smaller the further you walk, this isnt the time to get claustrophobic. You can barely make out 2 doors in the darkness, one to the west and one to the south");
            Room crypt           = new Room("The Crypt", "", $"A glow escapes this room through its open doorways. The masonry between every stone emanates an unnatural yellow radiance. Glancing quickly about the room, you note that each stone bears the carving of someone's name.\nYou notice the door you unlocked to the north as well as a large glowing door to the east");
            Room puzzleRoomOne   = new Room("A Puzzle Room", "Unlike the flagstone common throughout the dungeon, this room is walled and floored with black marble veined with white. The ceiling is similarly marbled, but the thick pillars that hold it up are white.\nA brown stain drips down one side of a nearby pillar. In the corner of the room you see a slender and small lizard type creature whispering to himself clutching something that gives off a yellow glow, when he realizes you are there he snaps his upperbody towards you and begins \n\n\"H-h-hello warmblood, you wantsss the shiny? You must s-s-sssolve my riddle first\"", "Unlike the flagstone common throughout the dungeon, this room is walled and floored with black marble veined with white. The ceiling is similarly marbled, but the thick pillars that hold it up are white.\nA brown stain drips down one side of a nearby pillar. You see a single exit to the east");
            Room bedChamber      = new Room("The BedChamber", "As you enter, the room comes alive with light and music. A sourceless, warm glow suffuses the chamber, and a harp you cannot see plays soothing sounds. Unfortunately, the rest of the chamber isn't so inviting.\nThe floor is strewn with the smashed remains of rotting furniture. It looks like the room once held a bed, a desk, a chest, and a chair. You can see a fine looking sword amongst the tattered furniture. You notice a menacing door to the east that appears to be covered in blood, and a seemingly normal door to the north.", "As you enter, the room comes alive with light and music. A sourceless, warm glow suffuses the chamber, and a harp you cannot see plays soothing sounds. Unfortunately, the rest of the chamber isn't so inviting.\nThe floor is strewn with the smashed remains of rotting furniture. It looks like the room once held a bed, a desk, a chest, and a chair. You notice a menacing door to the east that appears to be covered in blood, and a seemingly normal door to the north.");
            Room puzzleRoomTwo   = new Room("Puzzle Room two", "The manacles set into the walls of this room give you the distinct impression that it was used as a prison and torture chamber, although you can see no evidence of torture devices.\nOne particularly large set of manacles -- big enough for an ogre -- have been broken open. As you step further into the room, you hear from above another riddle.", "The manacles set into the walls of this room give you the distinct impression that it was used as a prison and torture chamber, although you can see no evidence of torture devices.\nOne particularly large set of manacles -- big enough for an ogre -- have been broken open. You notice unlocked doors to the east and south");
            Room puzzleRoomThree = new Room("Puzzle Room three", "This is it! The final room, you hear from above another riddle, if you are to solve this you will surely receive the key for the large gate that is directly ahead of you.", "You are in a large chamber with flagstone covering every service, it is well lit with torches lining the walls however it seems that no one has stepped foot in here for some time. You see a very Large gate with light escaping through the cracks.");
            Room outside         = new Room("Outside", "", "");
            #endregion

            #region Items
            Item hairpin   = new Item("Hairpin", "A small metal hairpin that could be fashioned into a lockpick", dungeon, smallHallway, "You bend the metal in a way and tinker with the lock for sometime before you hear a click, you quickly bolt out of your cell. You see hundreds of gaunt faces watching you from other cells as you sprint towards the stairs leading up. You grab the handle to the door out of the dungeon and luckily it is unlocked, you open the door and step through.");
            Item yellowKey = new Item("Yellow-Key", "A large key that gives off a nearly blinding yellow glow", crypt, bedChamber, "You start to move the shining yellow key towards the door. The key starts to become hotter and hotter as you move it towards the door, there is a flash of light that temporarily blinds you.\nWhen your vision returns you notice that the door has completely dissapeared leaving just a moldy doorway.\nAs you step through the doorway the wall seems to come alive and closes the doorway in stone behind you, as if there never was a door.");
            Item bloodKey  = new Item("Blood-Key", "A large key that drips an endless supply of a red liquid that can only be blood. The blood seems to fade into nothing when hitting the ground. What sort of magic is this?", bedChamber, puzzleRoomThree, "You insert the key into the bloody door and then take a step back as the door liquifies and washes over the interior of the room, you use your blood soaked feet to step into the next room");
            Item gateKey   = new Item("Gate-Key", "A large key ordained with all manner of jewels", puzzleRoomThree, outside, "You fit the key into the large gate and the door is unlocked, you carefully open the door to see a drawbridge leading over an empty moat. You sprint through and make your escape from this wicked place.");
            // Item sword = new Item("Sword", "A large, thin, jagged blade made of crystal is held by a grip wrapped in elegant, dark brown sting ray leather. With a single, sharp edge this weapon is the perfect choice for slicing and dicing", 20.0);
            #endregion

            #region Add Items to Rooms
            dungeon.Items.Add(hairpin);
            // bedChamber.Items.Add(sword);
            #endregion

            #region Room Exits
            smallHallway.Exits.Add("west", puzzleRoomOne);
            smallHallway.Exits.Add("south", crypt);
            puzzleRoomOne.Exits.Add("east", smallHallway);
            crypt.Exits.Add("north", smallHallway);
            bedChamber.Exits.Add("north", puzzleRoomTwo);
            puzzleRoomTwo.Exits.Add("south", bedChamber);
            puzzleRoomThree.Exits.Add("west", bedChamber);

            #endregion

            #region Riddles
            Riddle riddleOne   = new Riddle("\"Feed me and I will live, give me a drink and I will die.\"", "\"What is not alive but grows, does not breaths but needs air.\"", "fire", "As soon as you finish uttering the words, the strange lizard morphs into a common lizard and scurries away, a glowing yellow key falls onto the ground and you add it to your inventory", yellowKey, false);
            Riddle riddleTwo   = new Riddle("\"What has hands but no arms and a face but no eyes?\"", "\"Without fingers, I point, without arms, I strike, without feet, I run.\"", "clock", "As you shout the answer a bloody key falls from the ceiling, you scramble to catch it and add it to your inventory.", bloodKey, false);
            Riddle riddleThree = new Riddle("\"What word in the English language does the following: the first two letters signify a male, the first three letters signify a female, the first four letters signify a great, while the entire world signifies a great woman. What is the word?\"", "\"What word in the English language does the following: the first two letters signify a male, the first three letters signify a female, the first four letters signify a great, while the entire world signifies a great woman. What is the word?\"", "heroine", "You got the Gate Key!!", gateKey, false);
            #endregion

            #region Adding Riddles to Rooms
            puzzleRoomOne.Riddle   = riddleOne;
            puzzleRoomTwo.Riddle   = riddleTwo;
            puzzleRoomThree.Riddle = riddleThree;
            #endregion

            CurrentRoom = dungeon;
        }
Exemplo n.º 26
0
        public async Task CreateAsync(CreateRiddleInputModel input, string userId)
        {
            var riddle = new Riddle()
            {
                Content       = input.Content,
                Answer        = input.Answer,
                CategoryId    = input.CategoryId,
                AddedByUserId = userId,
            };

            await this.riddlesRepository.AddAsync(riddle);

            await this.riddlesRepository.SaveChangesAsync();
        }
Exemplo n.º 27
0
        public static void Main()
        {
            Riddle        fire    = new Riddle("I am not alive, but I grow; I don't have lungs, but I need air; I don't have a mouth, but water kills me. What am I?", "fire");
            Riddle        fence   = new Riddle("What runs around the whole yard without moving?", "a fence");
            Riddle        cold    = new Riddle("What can you catch but never throw?", "a cold");
            Riddle        door    = new Riddle("A man in a car saw a Golden Door, Silver Door and a Bronze Door. What door did he open first?", "the car door");
            List <Riddle> Riddles = new List <Riddle>()
            {
                fire, fence, cold, door
            };

            Console.WriteLine("Welcome to the Sphynx's layer. Answer my question!");

            int fullCount = Riddles.Count;

            for (int i = 1; i <= fullCount; i++)
            {
                Random randomNumber = new Random();
                int    index        = randomNumber.Next(Riddles.Count);
                Console.WriteLine(Riddles[index].GetRiddleQuestion());
                Console.WriteLine("Enter your answer: ");
                string userAnswer = Console.ReadLine();
                if (i == fullCount)
                {
                    Console.WriteLine("Wow, you win, nice.");
                }
                else
                {
                    if (Riddles[index].CheckAnswer(userAnswer))
                    {
                        Console.WriteLine("Correct.");
                        Riddles.Remove(Riddles[index]);
                    }
                    else
                    {
                        Console.WriteLine("Off with your head!");
                        break;
                    }
                }
            }


            // foreach(Riddle questions in Riddles)
            // {
            //   Console.WriteLine(questions.GetRiddleQuestion());
            //   Console.WriteLine("Enter your answer: ");
            //   string userAnswer = Console.ReadLine();
            //   Console.WriteLine(questions.CheckAnswer(userAnswer));
            // }
        }
Exemplo n.º 28
0
        public static void Main()
        {
            Riddle one   = new Riddle("The more of this there is, the less you see", "DARKNESS");
            Riddle two   = new Riddle("It stalks the countryside with ears that can’t hear. What is it?", "CORN");
            Riddle three = new Riddle("I am an odd number. Take away a letter and I become even. What number am I?", "SEVEN");
            Riddle four  = new Riddle("What 4-letter word can be written forward, backward or upside down, and can still be read from left to right?", "NOON");
            Riddle five  = new Riddle("What is so fragile that saying its name breaks it?", "SILENCE");

            List <Riddle> riddles = new List <Riddle>()
            {
                one, two, three, four, five
            };

            Console.WriteLine("Welcome to the Riddle Sphinx! For your first riddle press [Y]");
            string startGame = Console.ReadLine();

            if (startGame == "Y" || startGame == "y")
            {
                for (int index = 0; index < riddles.Count; index++)
                {
                    Console.WriteLine(riddles[index].GetQuestion());
                    string userInput    = Console.ReadLine();
                    string userResponse = userInput.ToUpper();

                    if (riddles[index].CheckAnswer(userResponse))
                    {
                        Console.WriteLine("You're right!");
                    }
                    else
                    {
                        Console.WriteLine("The Sphinx has eaten you! The correct answer was " + riddles[index].GetAnswer());
                    }
                }
                Console.WriteLine("Do you want to keep playing? [Y] for Yes, press [N] to Quit");
                string endGame = Console.ReadLine();
                if (endGame == "N" || endGame == "n")
                {
                    Console.WriteLine("Goodbye!");
                }
                else
                {
                    Console.WriteLine("Try to conquer the Sphinx again!");
                    Main();
                }
            }
            else
            {
                Console.WriteLine("Boo!");
            }
        }
Exemplo n.º 29
0
        public RiddleController(GQ context)
        {
            _context = context;
            if (_context.Riddle.Count() == 0)//инициализация данных, если их еще нет
            {
                if (_context.Quest.Count() == 0)
                {
                    Quest q = new Quest
                    {
                        Status    = true,
                        Date      = DateTime.Now,
                        Thematics = "no",
                        //  User = new User { UserName = "******", PasswordHash = "123123" },
                        Level_of_complexity = new Level_of_complexity {
                            Name_level = "hard"
                        }
                    };
                    _context.Quest.Add(q);
                    _context.SaveChanges();
                }

                Riddle r1 = new Riddle
                {
                    Text        = "something very great",
                    Description = "dfdfd",
                    Status      = true,
                    Answer      = new Answer {
                        Object = "table"
                    },
                    Level_of_complexity = new Level_of_complexity {
                        Name_level = "hard"
                    },
                    Type_of_question = new Type_of_question {
                        Name = "212"
                    },
                    // User=new User { Name="admin", Password="******"}
                };
                _context.Riddle.Add(r1);
                _context.SaveChanges();

                QuestRiddle q1 = new QuestRiddle
                {
                    Riddle = r1,
                    Quest  = _context.Quest.Last()
                };
                _context.QuestRiddle.Add(q1);
                _context.SaveChanges();
            }
        }
Exemplo n.º 30
0
        public static void Main()
        {
            Riddle one   = new Riddle("What is your favorite color", "blue");
            Riddle two   = new Riddle("I’m tall when I’m young, and I’m short when I’m old. What am I?", "a candle");
            Riddle three = new Riddle("What month of the year has 28 days?", "all of them");
            Riddle four  = new Riddle("What is always in front of you but can’t be seen?", "the future");
            Riddle five  = new Riddle("What is full of holes but still holds water?", "a sponge");
            Riddle six   = new Riddle("I shave every day, but my beard stays the same. What am I?", "a barber");

            List <Riddle> Riddles = new List <Riddle>()
            {
                one, two, three, four, five, six
            };

            int correctCounter = 0;

            while (correctCounter < 3)
            {
                Console.WriteLine(Riddles[correctCounter].Question);
                string guess = Console.ReadLine();
                if (correctCounter == 3)
                {
                    Console.WriteLine("Your general knowledge has vanquished me!");
                    break;
                }
                else if (guess != Riddles[correctCounter].Answer)
                {
                    Console.WriteLine("You are wrong and so I must eat you.");
                    break;
                }
                else if (guess == Riddles[correctCounter].Answer)
                {
                    correctCounter++;
                }
                //Console.WriteLine("Your general knowledge has vanquished me!");
            }


            // Console.WriteLine(one.Question);
            // string guess = Console.ReadLine();
            // if (guess != one.Answer)
            // {
            //   Console.WriteLine("You are wrong and so I must eat you.");
            // }
            // else if (guess == one.Answer)
            // {
            //   Console.WriteLine("Your general knowledge has vanquished me!");
            // }
        }
Exemplo n.º 31
0
        public static void Main()
        {
            Riddle one = new Riddle("What is your favorte color", "blue");

            Console.WriteLine(one.question);
            string guess = Console.ReadLine();

            if (guess != one.answer)
            {
                Console.WriteLine("You are WRONG. Try again...");
            }
            else if (guess == one.answer)
            {
                Console.WriteLine("You are correct and may live... for now.");
            }
        }
Exemplo n.º 32
0
 void Start()
 {
     peddlerWindow = adjRect(peddlerWindow);
     Riddles = new Riddle[10];
     for (int i = 0; i < 10; i++)
     {
         Riddles[i] = new Riddle(riddles[i], answers[i], correctAnswers[i]);
     }
     riddleNumber = Random.Range(0, 5);
 }
Exemplo n.º 33
0
 // Use this for initialization
 void Start()
 {
     riddle = GetComponent<Riddle>();
 }