static int PlayerChoiceMenu(int chosenCar, List <Car> cars, int checkedCars)
        {
            Console.Clear();
            string[] choices = { "check", "let go" };

            Console.WriteLine("Do you want to check or let the car go?\nCheck or Let Go");

            string playerChoice = Console.ReadLine();

            playerChoice = Klasser.IsTrueString(choices, playerChoice, "That is not an availalble choice!");

            bool foundContraband;

            if (playerChoice == choices[0])
            {
                foundContraband = cars[chosenCar].Examine();

                if (foundContraband.Equals(true))
                {
                    Klasser.WriteLine("There was a hidden contraband in the car!\nPress Enter", false);
                }
                else
                {
                    Klasser.WriteLine("There were no hidden contraband in the car! You paid the driver 10 dollar\nPress Enter", false);
                }
            }
            else
            {
                cars[chosenCar].AlreadyChecked = true;
                Klasser.WriteLine("You decided to trust the driver!", false);
            }
            return(checkedCars++);
        }
        public async Task GetKlasserOK()
        {
            var klasse1 = new Klasser
            {
                Id          = 1,
                Klassetrinn = "1-7",
            };
            var klasse2 = new Klasser
            {
                Id          = 2,
                Klassetrinn = "1-7",
            };
            var klasse3 = new Klasser
            {
                Id          = 3,
                Klassetrinn = "5-7",
            };

            var klasseList = new List <Klasser>();

            klasseList.Add(klasse1);
            klasseList.Add(klasse2);
            klasseList.Add(klasse3);



            var mock = new Mock <IKlasserRepository>();

            mock.Setup(k => k.GetKlasser()).ReturnsAsync(klasseList);
            var            klasserController = new KlasserController(mock.Object);
            List <Klasser> resultat          = await klasserController.GetKlasser();

            Assert.Equal <List <Klasser> >(klasseList, resultat);
        }
        } //This code block presents the three different fighter klass

        public Fighters chooseFighter(bool player) //This code block lets the player choose one of the three fighterklasses
        {
            string[] answears = { "1", "2", "3", "fighter 1", "fighter1", "fighter 2", "fighter2", "fighter 3", "fighter3" };
            string   choice;
            Fighters fighter = new Fighters();

            if (player == false)
            {
                choice = Klasser.ChoiseCorrect(answears);
            }
            else
            {
                choice = RandomiseChoise();
            }

            if (choice == "fighter 1" || choice == "fighter1" || choice == "1")
            {
                fighter = new Fighter_1();
            }

            if (choice == "fighter 2" || choice == "fighter2" || choice == "2")
            {
                fighter = new Fighter_2();
            }

            if (choice == "fighter 3" || choice == "fighter3" || choice == "3")
            {
                fighter = new Fighter_3();
            }

            return(fighter);
        } //This code block lets the player choose one of the three fighterklasses
    } // check if the intake is an int

    public static string ChoiseCorrect(string[] correctAnswears) //Forces the user to write one of the correct answears
    {
        string answear    = "";
        bool   wrongInput = true;

        while (wrongInput == true)
        {
            answear = Console.ReadLine().ToLower().Trim();

            for (int i = 0; i < correctAnswears.Length; i++)
            {
                if (answear == correctAnswears[i])
                {
                    wrongInput = false;
                    break;
                }
            }

            if (wrongInput == true)
            {
                Klasser.WriteLine("Wrong input, Write something else", true);
            }
        }

        return(answear);
    } //Forces the user to write one of the correct answears
        } //This block of code checks if the character missesor hit a attack

        public void PrintStats() //Prints the stats
        {
            Console.Clear();
            Klasser.WriteLine("Name: " + name + "\nHP: " + hp + "\nHit Chance: " + hitChance + "\nMax Damage: " + maxDamage + "\nMin Damage: " + minDamage + "\n \n(*Enter*)\n", false);

            return;
        } //Prints the stats
    } //Forces the user to write one of the correct answears

    public static string ChoiseIsNot(string[] wrongAnswears, string answear) //Forces the user to not write one of the wrong answears
    {
        bool whileAnswearWrong = true;

        while (whileAnswearWrong == true)
        {
            bool wrong = false;
            for (int i = 0; i < wrongAnswears.Length; i++)
            {
                if (answear == wrongAnswears[i])
                {
                    if (answear == "")
                    {
                        Klasser.WriteLine("You can't leave it blank!!", true);
                    }
                    else
                    {
                        Klasser.WriteLine("You can't write that!", true);
                    }

                    Klasser.Write("New name: ", true);
                    answear = Console.ReadLine();
                    wrong   = true;
                    break;
                }

                if (wrong == false)
                {
                    whileAnswearWrong = false;
                }
            }
        }
        return(answear);
    } //Forces the user to not write one of the wrong answears
        } //This is the processor of the fight. It says which characters turn it is and after the fight the block says who won the fight

        public void FightMenues(Fighters player, Fighters enemy, bool isPlayer) //For the player this code block lets the player choose if they want to check their stats or attack
        {
            if (isPlayer == true)
            {
                Console.Clear();
                Klasser.WriteLine("Name: " + player.Name + "\nHp: " + player.Name + "\nEnemy Hp: " + enemy.Hp + "\n\nWhat do you want to do? \n1. Fight\n2. Check Status", true);
                string[] answears = { "1", "2", "fight", "check staus", "checkstatus" };

                string answear = Klasser.ChoiseCorrect(answears);

                Console.Clear();

                if (answear == answears[0] || answear == answears[2])
                {
                    DealDamage(player, enemy, true);
                }

                if (answear == answears[1] || answear == answears[3] || answear == answears[4])
                {
                    player.PrintStats();
                    FightMenues(player, enemy, true);
                }
            }
            else
            {
                DealDamage(player, enemy, false);
            }
        } //For the player this code block lets the player choose if they want to check their stats or attack
Beispiel #8
0
 public Fighter_3()
 {
     hp         = Klasser.RandInt(minHp, maxHp - 3);
     maxDamage += 2;
     minDamage += 2;
     hitChance  = Klasser.RandInt(minHitChance, maxHitChance + 5);
 }
        } //This code block lets the player choose one of the three fighterklasses

        public string RandomiseChoise() //Randomise a number between 1-3 and convert it to a string
        {
            int i = Klasser.RandInt(1, 3);

            string rand = "" + i;

            return(rand);
        } //Randomise a number between 1-3 and convert it to a string
Beispiel #10
0
 public Fighter_3() //Randomises the health points, maxDamage, minDamage and hitchance
 {
     //Hp: Low, Damage: High, Hitchance: High
     hp         = Klasser.RandInt(minHp - 2, maxHp - 3);
     maxDamage += 2;
     minDamage += 2;
     hitChance  = Klasser.RandInt(minHitChance, maxHitChance + 5);
 } //Randomises the health points, maxDamage, minDamage and hitchance
 public Fighter_2() //Randomises the health points, maxDamage, minDamage and hitchance
 {
     //Hp: Medium, Damage: Medium, Hitchance: Medium
     hp         = Klasser.RandInt(minHp, maxHp);
     maxDamage += 2;
     minDamage += 2;
     hitChance  = Klasser.RandInt(minHitChance, maxHitChance);
 } //Randomises the health points, maxDamage, minDamage and hitchance
Beispiel #12
0
 public Fighter_1() //Randomises the health points, maxDamage, minDamage and hitchance
 {
     //Hp: High, Damage: Medium, Hitchance: Low
     hp         = Klasser.RandInt(minHp, maxHp + 10);
     maxDamage -= 1;
     minDamage -= 1;
     hitChance  = Klasser.RandInt(minHitChance - 1, maxHitChance - 1);
 } //Randomises the health points, maxDamage, minDamage and hitchance
        //Preperations
        public void NameYourFighter(Fighters fighter) //This code block is for allowing the player rename their character
        {
            Console.Clear();
            Klasser.WriteLine("Name your fighter!", true);
            Klasser.Write("Name: ", true);
            string newName = Console.ReadLine();

            fighter.Name = newName;
        } //This code block is for allowing the player rename their character
        public async Task GetEnKlasseIKKEOK()
        {
            var mock = new Mock <IKlasserRepository>();

            mock.Setup(k => k.GetKlasser(1)).ReturnsAsync(() => null);
            var     klasserController = new KlasserController(mock.Object);
            Klasser resultat          = await klasserController.GetKlasser(1);

            Assert.Null(resultat);
        }
        public async Task <Klasser> GetKlasser(int id)
        {
            Klasser enKlasse = await _db.Klasse.FindAsync(id);

            var hentKlasse = new Klasser()
            {
                Id          = enKlasse.Id,
                Klassetrinn = enKlasse.Klassetrinn,
            };

            return(hentKlasse);
        }
        public ActionResult Edit([Bind(Include = "ID,Namn,EvenemangsId")] Klasser klass)
        {
            SetViewBag(klass.EvenemangsId);

            if (ModelState.IsValid)
            {
                db.Entry(klass).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = klass.EvenemangsId }));
            }

            return(View(klass));
        }
        // GET: Klasser/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Klasser klasser = db.Klasser.Find(id);

            if (klasser == null)
            {
                return(HttpNotFound());
            }
            return(View(klasser));
        }
Beispiel #18
0
        static string PresentFighterKlass()
        {
            Console.Clear();
            Console.WriteLine("Choose a fighter klass");

            Klasser.WriteLine("Fighter 1: \nHp: High\nDamage: Medium\nHitchance: Low", false);
            Klasser.WriteLine("Fighter 2: \nHp: Medium\nDamage: Medium\nHitchance: Medium", false);
            Klasser.WriteLine("Fighter 3: \nHp: Low\nDamage: High\nHitchance: High", false);

            string choice = Console.ReadLine();


            return(choice);
        }
        } //A variable to see the if the character is defeated

        public bool HitOrMiss() //This block of code checks if the character missesor hit a attack
        {
            bool hit             = false;
            int  hitValueLimiter = Klasser.RandInt(10, 20);
            int  hitValRand      = Klasser.RandInt(3, 7);

            int hitVal = hitValRand * hitChance;

            if (hitVal > hitValueLimiter)
            {
                hit = true;
            }

            return(hit);
        } //This block of code checks if the character missesor hit a attack
        } //This code block is for allowing the player rename their character

        public Fighters PresentFighterKlass(bool player) //This code block presents the three different fighter klass
        {
            if (player == false)
            {
                Console.Clear();
                Console.WriteLine("Choose a fighter klass");

                Klasser.WriteLine("\nFighter 1: \nHp: High\nDamage: Medium\nHitchance: Low", true);
                Klasser.WriteLine("\nFighter 2: \nHp: Medium\nDamage: Medium\nHitchance: Medium", true);
                Klasser.WriteLine("\nFighter 3: \nHp: Low\nDamage: High\nHitchance: High\n", true);
                Klasser.Write("Choose fighter: ", true);
            }

            return(chooseFighter(player));
        } //This code block presents the three different fighter klass
        public async Task GetEnKlasseOK()
        {
            var returnKlasse = new Klasser
            {
                Id          = 1,
                Klassetrinn = "1-7",
            };
            var mock = new Mock <IKlasserRepository>();

            mock.Setup(k => k.GetKlasser(1)).ReturnsAsync(returnKlasse);
            var     klasserController = new KlasserController(mock.Object);
            Klasser resultat          = await klasserController.GetKlasser(1);

            Assert.Equal <Klasser>(returnKlasse, resultat);
        }
        static void Main(string[] args)
        {
            Random     rand         = new Random();
            int        day          = 1;
            int        nummerOfCars = 0;
            int        checkedCars  = 0;
            List <Car> cars         = new List <Car>();
            List <Car> resetCars    = new List <Car>()
            {
            };
            List <int> unCheckedCars = new List <int>();
            bool       wantToPlay    = true;

            Console.WriteLine("welcom to border patrol! You will be checking passing cars for contrabands!\nPress Enter");
            Console.ReadLine();

            while (wantToPlay)
            {
                nummerOfCars = rand.Next(1, 10);
                cars         = CreateCars(nummerOfCars, rand, cars);

                Klasser.WriteLine("Day " + day.ToString() + "\n You will check " + nummerOfCars + " cars today!", false);

                while (CheckIfAllCarsAreChecked(cars))
                {
                    PrintUnchecked(cars);

                    int math = nummerOfCars - checkedCars;
                    Console.WriteLine("Which car do you want to check? There are " + math.ToString() + " left out of " + nummerOfCars + "!");

                    string car       = Console.ReadLine();
                    int    chosenCar = Klasser.IsInt(car, "That is not a number or not an available number!", true, nummerOfCars) - 1;

                    while (cars[chosenCar].AlreadyChecked.Equals(true))
                    {
                        Console.WriteLine("You have already checked that car!");
                        car       = Console.ReadLine();
                        chosenCar = Klasser.IsInt(car, "That is not a number or not an available number!", true, nummerOfCars);
                    }
                    checkedCars = PlayerChoiceMenu(chosenCar, cars, checkedCars);
                    Console.Clear();
                }
                cars = resetCars;
                day++;
            }
        }
        // GET: Klasser/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Klasser klasser = db.Klasser.Find(id);

            if (klasser == null)
            {
                return(HttpNotFound());
            }

            SetViewBag(klasser.EvenemangsId);

            return(View(klasser));
        }
        public async Task <MasterFag> GetMasterFagByKategori(int id)
        {
            MasterFag masterFagKategori = await _db.MasterFag.FindAsync(id);

            Klasser klasser = new Klasser()
            {
                Id = masterFagKategori.Id,
            };

            if (id != klasser.Id)
            {
                return(null);
            }
            var masterByKat = _db.MasterFag.Where(q => q.KlasseId == id);

            return((MasterFag)masterByKat);
        }
        public ActionResult Create([Bind(Include = "ID,Namn")] Klasser klasser, int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (ModelState.IsValid)
            {
                klasser.EvenemangsId = id.Value;
                db.Klasser.Add(klasser);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = id }));
            }

            SetViewBag(id);
            return(View(klasser));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Klasser klasser = db.Klasser.Find(id);
            var     evId    = klasser.EvenemangsId;

            try
            {
                db.Klasser.Remove(klasser);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = evId }));
            }
            catch (Exception)
            {
                SetViewBag(evId);
                ViewBag.Error = "Kunde inte ta bort denna klass. Det kan vara så att den används i en registrering.";
                return(View(klasser));
            }
        }
        static void Main(string[] args)
        {
            Fighters player = m.PresentFighterKlass(false); //The player gets to choose a fighter
            Fighters enemy  = m.PresentFighterKlass(true);  //The game randomises a fighter

            m.NameYourFighter(player);                      //Lets the player name their character
            player.PrintStats();                            //Prints the player's stats

            Console.Clear();

            Klasser.WriteLine("You'r oponent is ...\n\n(*Enter*)", false);

            enemy.PrintStats();              //Prints the enemy's stats

            m.AnitiateFight(player, enemy);  //This code block is for Anitiating the fight by randomise if the playeer or the enemy start the fight

            if (Klasser.restartGame == true) //After the fight, if the player wants to restart the game, the bool restartGame becomes true
            {
                Program.Main(args);
            } //After the fight, if the player wants to restart the game, the bool restartGame becomes true
        }
Beispiel #28
0
        static SuperHero ChooseRace(SuperHero player)
        {
            string[] raceDataBase = { "mutant", "alien", "ritch" }; //The Race database

            string Choice = Console.ReadLine();                     //Players

            Klasser.IsTrueString(raceDataBase, Choice, "fel ras");  //Checks if the playes choice is one of the options

            if (Choice.Equals(raceDataBase[0]))                     //Player chose mutant
            {
                player = new Mutant();
            }
            else if (Choice.Equals(raceDataBase[1])) //Player chose Alien
            {
                player = new Alien();
            }
            else if (Choice.Equals(raceDataBase[2])) //Player chose Ritch
            {
                player = new Ritch();
            }
            return(player);
        } //Lets the player choose race
        } //For the player this code block lets the player choose if they want to check their stats or attack

        public void DealDamage(Fighters player, Fighters enemy, bool playerBool) //This code block is for dealing dammage between the player and the enemy. It randomise if the attack will hit or not. If it hit it randomises what kind of attack it was and where it hit.
        {
            Console.Clear();
            string[] attacks   = { "hook", "straight", "death stare", "roundhouse kick", "DDT" };
            string[] hit       = { "stomach", "knee", "shoulder", "liver", "Hand", "feet" };
            bool     playerHit = player.HitOrMiss();
            bool     enemyHit  = enemy.HitOrMiss();

            Thread.Sleep(200);

            if (playerHit == true && playerBool == true)
            {
                int damage = player.Damage;

                Klasser.WriteLine(player.Name + " hit a " + Klasser.RandString(attacks) + " on " + enemy.Name + "'s " + Klasser.RandString(hit) + " and dealt " + damage + " damage" + "\n\n(*Enter*)", false);

                enemy.Hp -= damage;
            }

            if (playerHit == false && playerBool == true)
            {
                Klasser.WriteLine(player.Name + " missed his attack\n\n(*Enter *)", false);
            }

            if (enemyHit == true && playerBool == false)
            {
                int damage = enemy.Damage;

                Klasser.WriteLine(enemy.Name + " hit a " + Klasser.RandString(attacks) + " on " + player.Name + "'s " + Klasser.RandString(hit) + " and dealt " + damage + " damage\n\n(*Enter*)", false);

                player.Hp -= damage;
            }

            if (enemyHit == false && playerBool == false)
            {
                Klasser.WriteLine(enemy.Name + " missed the attack\n\n(*Enter *)", false);
            }
        } //This code block is for dealing dammage between the player and the enemy. It randomise if the attack will hit or not. If it hit it randomises what kind of attack it was and where it hit.
        } //Randomise a number between 1-3 and convert it to a string

        public void AnitiateFight(Fighters player, Fighters enemy) //This code block is for Anitiating the fight by randomise if the playeer or the enemy start the fight
        {
            int  whoWillStart;
            bool playerStartFight;

            Console.Clear();
            Klasser.WriteLine("The fight will now commense! Todays fight is between " + player.Name + " versus " + enemy.Name + ".\n", true);

            whoWillStart = Klasser.RandInt(0, 1);

            if (whoWillStart == 0)
            {
                playerStartFight = true;
                Klasser.WriteLine(player.Name + " will start the fight.\n\n(*Enter*)", false);
            }
            else
            {
                playerStartFight = false;
                Klasser.WriteLine(enemy.Name + " will start the fight.\n\n(*Enter*)", false);
            }

            Fight(playerStartFight, player, enemy);
        } //This code block is for Anitiating the fight by randomise if the playeer or the enemy start the fight