Exemplo n.º 1
0
        public static Tricker Tricker()
        {
            string input;

            var context = new TrickingContext();
            var trickers = context.Trickers.Include("Tricks");

            do
            {
                Console.WriteLine();
                Console.WriteLine("Please select a tricker from the following:");

                foreach (var tricker in trickers)
                    Console.WriteLine(tricker.Name);

                Console.WriteLine();
                Console.WriteLine("Exit: To leave");

                input = Console.ReadLine();
                if (!string.IsNullOrEmpty(input)) input = input.ToLower();
                Console.WriteLine();

                if (string.IsNullOrEmpty(input) || input == "exit")
                    Environment.Exit(1);

            } while (!trickers.Select(t => t.Name.ToLower()).Contains(input));

            var trickerSelected = context.Trickers.Single(t => t.Name.ToLower() == input);
            Console.WriteLine("You selected: " + trickerSelected.Name);
            Console.WriteLine();

            return trickerSelected;
        }
Exemplo n.º 2
0
        public void TestMethod()
        {
            var context = new TrickingContext();

            foreach (var tricker in context.Trickers)
            {
                Console.WriteLine(tricker.Name);
            }

            Assert.IsTrue(context.Trickers.Any());
        }
Exemplo n.º 3
0
        public static bool Trick(int trickerId, int trickId)
        {
            var context = new TrickingContext();
            var proficieny = context.TrickProficiencies.SingleOrDefault(t =>
                t.TrickerId == trickerId && t.TrickId == trickId);

            if (proficieny == null) return false;

            var chance = Dice.Roll();

            return chance * proficieny.Control > 50;
        }
        public ConsolePageModel()
        {
            var context = new TrickingContext();

            Trickers = new List<SelectListItem>();
            Trickers.AddRange(context.Trickers.ToList().Select(t =>
                new SelectListItem { Value = t.Id.ToString(), Text = t.Name }));

            Tricks = new List<SelectListItem>();
            Tricks.AddRange(context.Tricks.ToList().Select(t =>
                new SelectListItem { Value = t.Id.ToString(), Text = t.Name }));
        }