Example #1
0
        public async Task <ActionResult <Samurai> > PostSamurai(Samurai samurai)
        {
            await _busLogic.CreateSamurai(samurai);

            return(CreatedAtAction("GetSamurai", new { id = samurai.Id }, samurai));
        }
Example #2
0
        public static void EnsurePopulated2(SamuraiContext context)
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            var existingSamurais = context.Samurais.ToList();
            var newSamurais      = new Samurai[]
            {
                new Samurai {
                    Name   = "Luke",
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                },
                new Samurai {
                    Name   = "Luke2",
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                },
                new Samurai {
                    Name   = "Luke3",
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                },
                new Samurai {
                    Name   = "Luke4",
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                }
            };

            // Look for existing matches
            if (context.Samurais.Any())
            {
                for (int i = 0; i < newSamurais.Length; i++)
                {
                    if (existingSamurais.Contains(newSamurais[i]))
                    {
                        Console.WriteLine("Match found");
                        continue;
                    }
                    else
                    {
                        Console.WriteLine($"New Entry {newSamurais[i].Name}");
                        existingSamurais.Add(newSamurais[i]);
                    }
                }
                context.SaveChanges();
                return;   // DB has been seeded
            }
            else
            {
                foreach (Samurai samurai in newSamurais)
                {
                    context.Samurais.Add(samurai);
                }
                context.SaveChanges();
                return;
            }
        }
 public async Task CreateSamurai(Samurai sam)
 {
     _context.Add(sam);
     await _context.SaveChangesAsync();
 }
        public IActionResult PlayersTurn(int attk)
        {
            int?MonsterId = HttpContext.Session.GetInt32("MonsterId");

            if (attk == 2)
            {
                MonsterId = 0;
            }

            Story      Story     = new Story();
            int        PlayerId  = (int)HttpContext.Session.GetInt32("PlayerId");
            Player     Player1   = _context.player.SingleOrDefault(p => p.PlayerId == PlayerId);
            int?       enconId   = HttpContext.Session.GetInt32("EncounterId");
            Encounters encounter = _context.encounters.SingleOrDefault(e => e.EncountersId == enconId);
            Enemies    monster   = _context.enemies.SingleOrDefault(m => m.EnemiesId == (int)MonsterId);
            Story      newStory  = new Story();
            Story      newStory2 = new Story();

            if (MonsterId != null)
            {
                if (Player1.Class == "mage")
                {
                    Mage Player = _context.mage.SingleOrDefault(p => p.PlayerId == PlayerId);
                    if (attk == 1)
                    {
                        int attackVal = Player.Attack(monster);
                        attackVal.ToString();
                        newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                    else if (attk == 2)
                    {
                        Player.Heal();
                        newStory.storyBook = "You used heal";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 4;
                    }
                    else if (attk == 3)
                    {
                        int attackVal = Player.Fireball(monster);
                        newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                    else if (attk == 4)
                    {
                        int attackVal = Player.FrostBolt(monster);
                        newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                }
                if (Player1.Class == "hunter")
                {
                    Hunter Player = _context.hunter.SingleOrDefault(p => p.PlayerId == PlayerId);
                    if (attk == 1)
                    {
                        int attackVal = Player.Attack(monster);
                        attackVal.ToString();
                        newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                    else if (attk == 2)
                    {
                        Player.Mend();
                        newStory.storyBook = "You were mended fight on Hunter.";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 4;
                    }
                    else if (attk == 3)
                    {
                        int attackVal = Player.Snipe(monster);
                        newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                    else if (attk == 4)
                    {
                        int attackVal = Player.Silencing_Shot(monster);
                        newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                }
                if (Player1.Class == "samurai")
                {
                    Samurai Player = _context.samurai.SingleOrDefault(p => p.PlayerId == PlayerId);
                    if (attk == 1)
                    {
                        int attackVal = Player.Attack(monster);
                        attackVal.ToString();
                        newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                    else if (attk == 2)
                    {
                        Player.Meditate();
                        newStory.storyBook = "You used meditate.";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 4;
                    }
                    else if (attk == 3)
                    {
                        int attackVal = Player.Smash(monster);
                        newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                    else if (attk == 4)
                    {
                        int attackVal = Player.Death_Blow(monster);
                        newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                }
                if (Player1.Class == "ninja")
                {
                    Ninja Player = _context.ninja.SingleOrDefault(p => p.PlayerId == PlayerId);
                    if (attk == 1)
                    {
                        int attackVal = Player.Attack(monster);
                        attackVal.ToString();
                        newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                    else if (attk == 2)
                    {
                        Player.Hide();
                        newStory.storyBook = "You hide from the enemies.";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 4;
                    }
                    else if (attk == 3)
                    {
                        int attackVal = Player.Backstab(monster);
                        newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage.";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                    else if (attk == 4)
                    {
                        int attackVal = Player.Rend(monster);
                        newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage.";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                }
                if (Player1.Class == "priest")
                {
                    Priest Player = _context.priest.SingleOrDefault(p => p.PlayerId == PlayerId);
                    if (attk == 1)
                    {
                        int attackVal = Player.Attack(monster);
                        attackVal.ToString();
                        newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                    else if (attk == 2)
                    {
                        Player.Holy_Heal();
                        newStory.storyBook = "You healed yourself";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 4;
                    }
                    else if (attk == 3)
                    {
                        int attackVal = Player.Holy_Light(monster);
                        newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                    else if (attk == 4)
                    {
                        int attackVal = Player.Smight(monster);
                        newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                        SetTemp(0);
                        newStory.created_at = DateTime.Now;
                        newStory.PlayerId   = PlayerId;
                        newStory.flag       = 2;
                    }
                }
                _context.Add(newStory);
                _context.SaveChanges();
                if (MonsterId != 0)
                {
                    if (monster.health <= 0)
                    {
                        monster.health      = 0;
                        monster.life        = false;
                        newStory2.storyBook = "You killed a " + monster.name;
                        SetTemp(-10);
                        newStory2.created_at = DateTime.Now;
                        newStory2.PlayerId   = PlayerId;
                        newStory2.flag       = 2;
                        _context.Add(newStory2);
                        _context.SaveChanges();
                    }
                }
                HttpContext.Session.Remove("MonsterId");
                List <Enemies> enemyCount = _context.enemies.Where(m => m.EncountersId == enconId && m.life == true).ToList();
                if (enemyCount.Count() > 0)
                {
                    return(RedirectToAction("EnemiesTurn"));
                }
                int level = (int)HttpContext.Session.GetInt32("Level");
                level++;
                HttpContext.Session.SetInt32("Level", level);
                return(RedirectToAction("firstEncounter"));
            }
            else
            {
                Story.storyBook  = "You have to target a ememy before you can attack";
                Story.PlayerId   = PlayerId;
                Story.flag       = 2;
                Story.created_at = DateTime.Now;
                _context.Add(Story);
                _context.SaveChanges();
            }
            return(RedirectToAction("Moves"));
        }
 public async Task Post(Samurai samurai)
 {
     _repo.Insert(samurai);
     await _unitOfWork.SaveChangesAsync();
 }
Example #6
0
 public void AddSamurai(Samurai samurai)
 {
     context.Add(samurai);
     context.SaveChanges();
 }
 public void Put(int id, [FromBody] Samurai value)
 {
     _repo.SaveSamuraiGraph(value);
 }
Example #8
0
        public void CanAddEntityToContext()
        {
            var samurai = new Samurai();

            Assert.Equal(EntityState.Added, AddToSetEFCore(samurai));
        }
Example #9
0
 public Parry(float cooldown, float duration, Samurai owner, bool playerAction) : base(cooldown, duration, owner, playerAction)
 {
 }
        static void Main(string[] args)
        {
            RayGun     green    = new RayGun("green ray gun", 2);
            RayGun     red      = new RayGun("red ray gun", 4);
            SpaceArmor titanium = new SpaceArmor("titanium space armor", 50);
            SpaceArmor alien    = new SpaceArmor("alien tech space armor", 100);
            GravBoots  nike     = new GravBoots("Nike grav boots", 2);
            GravBoots  adidas   = new GravBoots("Adidas grav boots", 4);
            AlienText  romulan  = new AlienText("book of Romulan wisdom", 2);
            AlienText  vulcan   = new AlienText("book of Vulcan wisdom", 4);

            IEquipable[] treasure = new IEquipable[8] {
                green, red, titanium, alien, nike, adidas, romulan, vulcan
            };

            ConsoleYellow("********NINJAS IN SPACE********");

            Hero player = PlayerSetup();

            ConsoleYellow($"You, {player.Name}, have been chosen(randomly selected) to join a team of developer ninjas on a space quest!  To seek out new algorithms, new data structures, and go where no else wants to go! DEEP SPACE!!!\n\nHere you will encounter aliens, space monsters, and the unknown to bring back algorithms to benefit all humans. You now must choose your team.\n\nPress Enter to Start");

            ConsoleKey key = Console.ReadKey(true).Key;

            while (key != ConsoleKey.Enter)
            {
                key = Console.ReadKey(true).Key;
            }
            Console.WriteLine("Please select two crew members");

            Hero teammate1 = TeamSetup();
            Hero teammate2 = TeamSetup();

            List <Hero> party = new List <Hero>()
            {
                player, teammate1, teammate2
            };

            int planet = 0;

            while (planet < 5)
            {
                Console.WriteLine("");
                ConsoleYellow($"Welcome to Planet {planet+1}!");
                ConsoleYellow("=====================");
                List <Enemy> enemies = new List <Enemy>();

                Spider    enemy1 = new Spider("Space Spider 1");
                Zombie    enemy2 = new Zombie("Space Zombie 1");
                Xenomorph enemy3 = new Xenomorph("Xenomorph 1");
                enemies.Add(enemy1);
                enemies.Add(enemy2);
                enemies.Add(enemy3);

                Random die   = new Random();
                int    round = 0;
                while (SumHealthParty(party) > 0 && SumHealthEnemies(enemies) > 0)
                {
                    int turn = round % 6;
                    if (turn >= 0 && turn < 3)
                    {
                        if (party[turn].Health > 0)
                        {
                            Console.WriteLine("");
                            EncounterStatus(party, enemies);
                            if (party[turn] is Ninja)
                            {
                                Ninja ninjaClone = (Ninja)party[turn];
                                Console.WriteLine($"{ninjaClone.Name}'s turn. (A)ttack or (B)ackstab?");
                                string Action = Console.ReadLine();
                                Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}");
                                string Target = Console.ReadLine();
                                if (Action == "A")
                                {
                                    ninjaClone.Attack(enemies[int.Parse(Target) - 1]);
                                }
                                else if (Action == "B")
                                {
                                    ninjaClone.Backstab(enemies[int.Parse(Target) - 1]);
                                }
                                else if (Action == "Z")
                                {
                                    enemies[int.Parse(Target) - 1].Health = 0;
                                    Console.WriteLine("Let's get this over with");
                                    Console.WriteLine("");
                                }
                            }
                            else if (party[turn] is Samurai)
                            {
                                Samurai samuraiClone = (Samurai)party[turn];
                                Console.WriteLine($"{samuraiClone.Name}'s turn. (A)ttack or (M)editate?");
                                string Action = Console.ReadLine();
                                if (Action == "A")
                                {
                                    Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}");
                                    string Target = Console.ReadLine();
                                    samuraiClone.Attack(enemies[int.Parse(Target) - 1]);
                                }
                                else if (Action == "M")
                                {
                                    samuraiClone.Meditate();
                                }
                                else if (Action == "Z")
                                {
                                    Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}");
                                    string Target = Console.ReadLine();
                                    enemies[int.Parse(Target) - 1].Health = 0;
                                    Console.WriteLine("Let's get this over with");
                                    Console.WriteLine("");
                                }
                            }
                            else if (party[turn] is Wizard)
                            {
                                Wizard wizardClone = (Wizard)party[turn];
                                Console.WriteLine($"{wizardClone.Name}'s turn. (A)ttack or (S)hield?");
                                string Action = Console.ReadLine();
                                if (Action == "A")
                                {
                                    Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}");
                                    string Target = Console.ReadLine();
                                    wizardClone.Attack(enemies[int.Parse(Target) - 1]);
                                }
                                else if (Action == "S")
                                {
                                    Console.WriteLine($"Target? (1){party[0].Name} (2){party[1].Name} (3){party[2].Name}");
                                    string Target = Console.ReadLine();
                                    wizardClone.Shield(party[int.Parse(Target) - 1]);
                                }
                                else if (Action == "Z")
                                {
                                    Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}");
                                    string Target = Console.ReadLine();
                                    enemies[int.Parse(Target) - 1].Health = 0;
                                    Console.WriteLine("Let's get this over with");
                                    Console.WriteLine("");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (enemies[turn - 3].Health > 0)
                        {
                            Console.WriteLine("");
                            EncounterStatus(party, enemies);
                            if (enemies[turn - 3] is Zombie)
                            {
                                Zombie zombieClone = (Zombie)enemies[turn - 3];
                                Console.WriteLine($"{zombieClone.Name}'s turn.");
                                Random rand     = new Random();
                                bool   attacked = false;
                                while (!attacked)
                                {
                                    int target = rand.Next(3);
                                    if (party[target].Health > 0)
                                    {
                                        zombieClone.Attack(party[target]);
                                        attacked = true;
                                    }
                                }
                                Console.WriteLine("Please press \"Enter\" to continue");
                                string Action = Console.ReadLine();
                            }
                            else if (enemies[turn - 3] is Spider)
                            {
                                Spider spiderClone = (Spider)enemies[turn - 3];
                                Console.WriteLine($"{spiderClone.Name}'s turn.");
                                Random rand     = new Random();
                                bool   attacked = false;
                                while (!attacked)
                                {
                                    int target = rand.Next(3);
                                    if (party[target].Health > 0)
                                    {
                                        spiderClone.Attack(party[target]);
                                        attacked = true;
                                    }
                                }
                                Console.WriteLine("Please press \"Enter\" to continue");
                                string Action = Console.ReadLine();
                            }
                            else if (enemies[turn - 3] is Xenomorph)
                            {
                                Xenomorph xenoClone = (Xenomorph)enemies[turn - 3];
                                Console.WriteLine($"{xenoClone.Name}'s turn.");
                                Random rand     = new Random();
                                bool   attacked = false;
                                while (!attacked)
                                {
                                    int target = rand.Next(3);
                                    if (party[target].Health > 0)
                                    {
                                        xenoClone.Attack(party[target]);
                                        attacked = true;
                                    }
                                }
                                Console.WriteLine("Please press \"Enter\" to continue");
                                string Action = Console.ReadLine();
                            }
                        }
                    }
                    if (SumHealthEnemies(enemies) <= 0)
                    {
                        Console.WriteLine("All enemies vanquished! Congratulations!");
                        int        d8            = die.Next(8);
                        IEquipable foundTreasure = treasure[d8];
                        Equipment  equipClone    = (Equipment)foundTreasure;
                        Console.WriteLine($"You found {equipClone.Name}! {equipClone.Desc} Who should equip it?");
                        string choice = "0";
                        while (choice != "1" && choice != "2" && choice != "3")
                        {
                            Console.WriteLine($"Please type the number of the hero you would like to equip:\n1. {party[0].Name}\n2. {party[1].Name}\n3. {party[2].Name}");
                            choice = Console.ReadLine();
                        }
                        switch (choice)
                        {
                        case ("1"):
                            foundTreasure.Equip(party[0]);
                            Console.WriteLine($"{party[0].Name} has equipped the {equipClone.Name}");
                            party[0].ShowStats();
                            Console.WriteLine("");
                            break;

                        case ("2"):
                            foundTreasure.Equip(party[1]);
                            Console.WriteLine($"{party[1].Name} has equipped the {equipClone.Name}");
                            party[1].ShowStats();
                            Console.WriteLine("");
                            break;

                        case ("3"):
                            foundTreasure.Equip(party[2]);
                            Console.WriteLine($"{party[2].Name} has equipped the {equipClone.Name}");
                            party[2].ShowStats();
                            Console.WriteLine("");
                            break;
                        }
                        Console.WriteLine("Onward to the next planet! Good thing you brought clones of everyone!");
                        player.Health    = player.MaxHealth;
                        teammate1.Health = teammate1.MaxHealth;
                        teammate2.Health = teammate2.MaxHealth;
                        Console.WriteLine("");
                        planet++;
                        if (planet == 5)
                        {
                            ConsoleYellow("You've certainly accomplished something! Saved the universe? Sure! Congratulations!");
                        }
                    }
                    if (SumHealthParty(party) <= 0)
                    {
                        ConsoleYellow("Your party was killed in self-defense! Game over!");
                        planet = 5;
                    }
                    round++;
                }
            }
        }
        /// <summary>
        /// Retrieves a list of all titles from all available regions.
        /// </summary>
        /// <param name="shopID">Use 1 for the 3DS eShop, 2 for the WiiU eShop.</param>
        /// <returns>A list of titles</returns>
        public async Task <List <EshopTitle> > GetAllTitles(int shopID)
        {
            // get title counts for all regions
            Console.WriteLine("Getting title count for {0} regions ...", Enum.GetValues(typeof(Region)).Length - 2);
            Dictionary <Region, int> titleCounts = new Dictionary <Region, int>();

            foreach (Region region in Enum.GetValues(typeof(Region)))
            {
                if (region == Region.None || region == Region.ALL)
                {
                    continue;
                }
                await Retry(async() => {
                    titleCounts.Add(region, await Samurai.GetTitleCountForRegion(webClient, region, shopID));
                });
            }

            int totalTitleCount = titleCounts.Values.Sum();

            Console.WriteLine("Downloading metadata for {0} titles ...", totalTitleCount);
            progressManager.SetTitle(string.Format("Downloading metadata for {0} titles ...", totalTitleCount));
            progressManager.Reset(totalTitleCount);

            DateTime          currentDate = DateTime.Today;
            List <EshopTitle> titleList   = new List <EshopTitle>();

            // loop through regions
            foreach (KeyValuePair <Region, int> pair in titleCounts)
            {
                Region region     = pair.Key;
                int    titleCount = pair.Value;

                // get titles from samurai
                for (int offset = 0; offset < titleCount; offset += TitleRequestLimit)
                {
                    XDocument titlesXml = null;
                    await Retry(async() => {
                        titlesXml = await Samurai.GetTitlesXmlForRegion(webClient, region, shopID, TitleRequestLimit, offset);
                    });

                    /*  structure:
                     *  <eshop><contents ...>
                     *      <content index=1><title ...>[title info]</title></content>
                     *      <content index=2><title ...>[title info]</title></content>
                     *  </contents></eshop>
                     */
                    XElement contentsElement = titlesXml.Root.Element("contents");

                    // iterate over titles in xml
                    foreach (XElement titleElement in contentsElement.Elements().Select(e => e.Element("title")))
                    {
                        // check release date
                        string releaseDateString = titleElement.Element("release_date_on_eshop")?.Value;
                        if (!String.IsNullOrEmpty(releaseDateString))
                        {
                            DateTime releaseDate;
                            if (!DateTime.TryParseExact(releaseDateString, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out releaseDate))
                            {
                                continue;
                            }
                            if (releaseDate > currentDate)
                            {
                                continue;
                            }
                        }

                        // create title and add data
                        EshopTitle title = new EshopTitle();
                        title.Region = region;
                        // set title fields from xml (incomplete, some fields must be retrieved from ninja)
                        title.AddDataFromXml(titleElement);

                        progressManager.Step(string.Format("{0}-{1}", region.ToCountryCode(), title.EshopId));

                        // some exceptions:
                        if (title.Platform == 63 || title.Platform == 1003) // ignore 3DS software updates
                        {
                            continue;
                        }
                        if (title.Platform == 143) // ignore some unknown platform with just 1 title
                        {
                            continue;
                        }

                        // get remaining data from ninja
                        XElement titleECInfoElement;
                        await Retry(async() => {
                            titleECInfoElement = await Ninja.GetECInfoForRegionAndTitleID(certWebClient, region, title.EshopId);
                            title.AddDataFromXml(titleECInfoElement);
                            if (title.JsonType != DatabaseJsonType.None)
                            {
                                titleList.Add(title);
                            }
                        });
                    }
                }
            }

            // merge titles that occur in all regions into one title with the 'ALL' region
            IEnumerable <EshopTitle> titleListEnumerable = titleList;
            var allRegions = Enum.GetValues(typeof(Region)).OfType <Region>().Where(r => r != Region.None && r != Region.ALL);
            var groups     = titleListEnumerable.GroupBy(t => t.TitleId).Select(g => g.ToList()).ToList();

            foreach (var group in groups)
            {
                var groupRegions = group.Select(t => t.Region);
                if (allRegions.All(groupRegions.Contains))
                {
                    titleListEnumerable = titleListEnumerable.Except(group.Skip(1));
                    group[0].Region     = Region.ALL;
                }
            }

            titleList = titleListEnumerable.ToList();

            return(titleList);
        }
Example #12
0
        private static void AddOneSamuraiWithRelatedData()
        {
            var context = new SamuraiContext();

            var haircut = new Haircut {
                Name = "Short"
            };
            var secretIdentity = new SecretIdentity {
                Name = "Harry Potter"
            };

            var quoteType = new QuoteType {
                Name = "Lame"
            };
            var listOfQuotes = new List <Quote> {
                new Quote {
                    Text = "Friends come first", Type = quoteType
                }, new Quote {
                    Text = "I'm a wizard", Type = quoteType
                }
            };

            var battleEvents = new List <BattleEvent>
            {
                new BattleEvent {
                    Description = "The tribe GoronsFTW initiated the first attack", Summary = "The tribe GoronsFTW won this event", TimeOfEvent = new DateTime(1430, 3, 20)
                }
            };

            var battleLog = new BattleLog
            {
                Name         = "Goron War log",
                BattleEvents = battleEvents
            };

            var battle1 = new Battle
            {
                Name        = "The Goron War",
                Description = "The disagreements between the leaders of the Gorons eventually led to the civil war of the Gorons",
                Brutal      = true,
                StartDate   = new DateTime(1430, 3, 16),
                EndDate     = new DateTime(1432, 5, 20),
                BattleLog   = battleLog
            };

            List <Battle> samuraiBattles = new List <Battle>();

            samuraiBattles.Add(battle1);

            var samurai = new Samurai
            {
                Name           = "Arnold",
                Haircut        = haircut,
                SecretIdentity = secretIdentity,
                Quotes         = listOfQuotes,
                Battles        = samuraiBattles
            };

            context.Samurais.Add(samurai);

            var samuraiBattle = new SamuraiBattle
            {
                Samurai = samurai,
                Battle  = battle1
            };

            context.SamuraiBattles.Add(samuraiBattle); //borde väl inte behöva göra detta manuellt? Får det att fungera iallafall
            context.SaveChanges();
        }
Example #13
0
        public static bool Validate(SamuraiViewModel svm, ModelStateDictionary ModelState, DojoContext context)
        {
            Samurai samurai = context.Samurais.Include(x => x.Arme).Include(x => x.ArtMartials).FirstOrDefault(s => s.Id == svm.Samurai.Id);

            if (context.Samurais.FirstOrDefault(s => s.Nom.Equals(svm.Samurai.Nom) && s.Id != svm.Samurai.Id) != null)
            {
                ModelState.AddModelError("Samurai.Nom", "Un samuraï portant se nom existe déjà.");
            }

            if (svm.Samurai.Force < 0 || svm.Samurai.Force > 1000000)
            {
                ModelState.AddModelError("Samurai.Force", "La force du samurai doit être entre 0 et 1 000 000.");
            }


            if (svm.armeId != null)
            {
                Arme    arme = context.Armes.FirstOrDefault(a => a.Id == svm.armeId);
                Samurai samuraiWithArme;
                if (samurai == null)
                {
                    samuraiWithArme = context.Samurais.Include(x => x.Arme).Where(s => s.Arme.Id.Equals(arme.Id)).FirstOrDefault();
                }
                else
                {
                    samuraiWithArme = context.Samurais.Include(x => x.Arme).Where(s => s.Arme.Id.Equals(arme.Id) && s.Id != samurai.Id).FirstOrDefault();
                }
                if (arme == null)
                {
                    ModelState.AddModelError("armeId", "L'arme que vous avez indiqué n'existe pas.");
                }
                else if (samuraiWithArme != null)
                {
                    if (samurai == null)
                    {
                        ModelState.AddModelError("armeId", "L'arme que vous avez indiqué est déjà utilisée.");
                    }
                }
                else
                {
                    if (svm.Samurai.Id != 0)
                    {
                        samurai.Nom   = svm.Samurai.Nom;
                        samurai.Force = svm.Samurai.Force;
                        svm.Samurai   = samurai;
                    }
                    svm.Samurai.Arme = arme;
                }
            }
            else
            {
                if (samurai != null)
                {
                    svm.Samurai = samurai;
                }
                svm.Samurai.Arme = null;
            }

            if (svm.ArtMartiauxIds != null)
            {
                svm.Samurai.ArtMartials = svm.ArtMartials.Where(a => svm.ArtMartiauxIds.Contains(a.Id)).Select(a => a).ToList();
            }
            else
            {
                svm.Samurai.ArtMartials = null;
            }


            if (ModelState.IsValid)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #14
0
 public Samurai CreateSamurai(Samurai samurai)
 {
     return(_samuraiRepo.AddSamurai(samurai));
 }
Example #15
0
 public void AddSamurai(Samurai samurai)
 {
     samurais.Add(samurai);
 }
Example #16
0
        private static void AddOneSamuraiWithRelatedData()
        {
            var samurai = new Samurai
            {
                Name   = "Obi-Wan Kenobi",
                Quotes = new List <Quote>
                {
                    new Quote
                    {
                        Text = "Well, hello there.",
                        Type = QuoteType.Cheesy
                    },
                    new Quote
                    {
                        Text = "So uncivilzed!",
                        Type = QuoteType.Awesome
                    },
                    new Quote
                    {
                        Text = "I have a bad feeling about this.",
                        Type = QuoteType.Lame
                    }
                },
                Hairstyle      = Hairstyle.Western,
                SecretIdentity = new SecretIdentity {
                    Name = "Ben Kenobi"
                }
            };

            samurai.AddBattle(new Battle
            {
                Name        = "Battle of Utapau",
                Description = "The final battle of the war against the separatists.",
                Brutal      = true,
                StartDate   = new DateTime(1545, 05, 15),
                EndDate     = new DateTime(1545, 05, 15),
                BattleLog   = new BattleLog
                {
                    Name   = "Chronicle of the Battle of Utapau",
                    Events = new List <BattleEvent>
                    {
                        new BattleEvent
                        {
                            Time        = new DateTime(1545, 05, 15),
                            Summary     = "Lord Kenobi greets General Grievous",
                            Description = "Well, hello there, lord Kenobi greeted the general..."
                        },
                        new BattleEvent
                        {
                            Time        = new DateTime(1545, 05, 15),
                            Summary     = "The Betrayal",
                            Description =
                                "It was at that moment, that the mercenaries recieved the order from the Emperor, and they turned their weapons upon the samurai."
                        }
                    }
                }
            });

            using (var context = new SamuraiContext())
            {
                context.Samurais.Add(samurai);
                context.SaveChanges();
            }
        }
Example #17
0
 public void UpdateSamurai(Samurai samurai)
 {
     context.SaveChanges();
 }
 private void NewSamuraiButton_Click(object sender, RoutedEventArgs e)
 {
     _currentSamurai = _data.CreateNewSamurai();
     _samuraiViewSource.ObjectInstance = _currentSamurai;
     samuraiListBox.SelectedItem       = _currentSamurai;
 }
 public void Post([FromBody] Samurai value)
 {
     _repo.SaveSamuraiGraph(value);
 }
Example #20
0
 public int MakeSamurai(Samurai samurai)
 {
     _context.Samurais.Add(samurai);
     return(_context.SaveChanges());
 }
Example #21
0
        public async Task <ActionResult <Samurai> > PostSamurai(Samurai samurai)
        {
            var addedSamurai = await _bizdata.AddSamurai(samurai);

            return(CreatedAtAction("GetSamurai", new { id = addedSamurai.Id }, addedSamurai));
        }
Example #22
0
        private void b_Lutar_Click(object sender, EventArgs e)
        {
            if (personagem2 == "Militar")
            {
                Militar mili2 = new Militar();
                if ("Fuzil" == cb_ArmaMilitar2.Text)
                {
                    mili2.setArma(new Fuzil());
                }
                if ("Sniper" == cb_ArmaMilitar2.Text)
                {
                    mili2.setArma(new Sniper());
                }
                if ("Lança Foguetes" == cb_ArmaMilitar2.Text)
                {
                    mili2.setArma(new Lança_Foguetes());
                }
                if ("Espingarda" == cb_ArmaMilitar2.Text)
                {
                    mili2.setArma(new Espingarda());
                }
                a2 = cb_ArmaMilitar2.Text;
            }
            if (personagem2 == "Mago")
            {
                Mago mag2 = new Mago();
                if ("Fogo" == cb_ArmaMago2.Text)
                {
                    mag2.setMagia(new Fogo());
                }
                if ("Trevas" == cb_ArmaMago2.Text)
                {
                    mag2.setMagia(new Trevas());
                }
                if ("Água" == cb_ArmaMago2.Text)
                {
                    mag2.setMagia(new Agua());
                }
                if ("Gelo" == cb_ArmaMago2.Text)
                {
                    mag2.setMagia(new Gelo());
                }
                a2 = cb_ArmaMago2.Text;
            }
            if (personagem2 == "Dragão")
            {
                Dragao drag2 = new Dragao();
                if ("Fogo" == cb_ArmaDragao2.Text)
                {
                    drag2.setMagia(new Fogo());
                }
                if ("Trevas" == cb_ArmaDragao2.Text)
                {
                    drag2.setMagia(new Trevas());
                }
                if ("Eletrico" == cb_ArmaDragao2.Text)
                {
                    drag2.setMagia(new Agua());
                }
                if ("Gelo" == cb_ArmaDragao2.Text)
                {
                    drag2.setMagia(new Gelo());
                }
                a2 = cb_ArmaDragao2.Text;
            }
            if (personagem2 == "Samurai")
            {
                Samurai samu2 = new Samurai();
                if ("Semehada" == cb_ArmaSamurai2.Text)
                {
                    samu2.setArma(new Semehada());
                }
                if ("Cutelo" == cb_ArmaSamurai2.Text)
                {
                    samu2.setArma(new Cutelo());
                }
                if ("Katana" == cb_ArmaSamurai2.Text)
                {
                    samu2.setArma(new Katana());
                }
                if ("Lamina do Dragão" == cb_ArmaSamurai2.Text)
                {
                    samu2.setArma(new Lamina_do_Dragao());
                }
                a2 = cb_ArmaSamurai2.Text;
            }
            Form3 f3 = new Form3(personagem1, personagem2, p1, p2, a1, a2, 0);

            f3.ShowDialog();
            Close();
        }
Example #23
0
        public IActionResult Create(ValidPlayer Player1)
        {
            if (ModelState.IsValid)
            {
                PasswordHasher <ValidPlayer> Hasher = new PasswordHasher <ValidPlayer>();
                Player1.Password = Hasher.HashPassword(Player1, Player1.Password);
                Mage    newMage    = new Mage();
                Hunter  newHunter  = new Hunter();
                Priest  newPriest  = new Priest();
                Ninja   newNinja   = new Ninja();
                Samurai newSamurai = new Samurai();
                if (Player1.Class == "mage")
                {
                    newMage.Username = Player1.Username;
                    newMage.Password = Player1.Password;
                    newMage.Class    = Player1.Class;
                    _context.Add(newMage);
                    _context.SaveChanges();
                    HttpContext.Session.SetInt32("PlayerId", newMage.PlayerId);
                }
                if (Player1.Class == "priest")
                {
                    newPriest.Username = Player1.Username;
                    newPriest.Password = Player1.Password;
                    newPriest.Class    = Player1.Class;
                    _context.Add(newPriest);
                    _context.SaveChanges();
                    HttpContext.Session.SetInt32("PlayerId", newPriest.PlayerId);
                }

                if (Player1.Class == "hunter")
                {
                    newHunter.Username = Player1.Username;
                    newHunter.Password = Player1.Password;
                    newHunter.Class    = Player1.Class;
                    _context.Add(newHunter);
                    _context.SaveChanges();
                    HttpContext.Session.SetInt32("PlayerId", newHunter.PlayerId);
                }

                if (Player1.Class == "ninja")
                {
                    newNinja.Username = Player1.Username;
                    newNinja.Password = Player1.Password;
                    newNinja.Class    = Player1.Class;
                    _context.Add(newNinja);
                    _context.SaveChanges();
                    HttpContext.Session.SetInt32("PlayerId", newNinja.PlayerId);
                }

                if (Player1.Class == "samurai")
                {
                    newSamurai.Username = Player1.Username;
                    newSamurai.Password = Player1.Password;
                    newSamurai.Class    = Player1.Class;
                    _context.Add(newSamurai);
                    _context.SaveChanges();
                    HttpContext.Session.SetInt32("PlayerId", newSamurai.PlayerId);
                }
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View("Registration"));
        }
Example #24
0
    public override void CalculateDamage(UnitBase unitToDealDamage)
    {
        //Reseteo la variable de daño a realizar
        damageWithMultipliersApplied = baseDamage;

        //Si estoy en desventaja de altura hago menos daño
        if (unitToDealDamage.myCurrentTile.height > myCurrentTile.height)
        {
            damageWithMultipliersApplied -= penalizatorDamageLessHeight;
            healthBar.SetActive(true);
            downToUpDamageIcon.SetActive(true);
        }

        //Si estoy en ventaja de altura hago más daño
        else if (unitToDealDamage.myCurrentTile.height < myCurrentTile.height)
        {
            damageWithMultipliersApplied += bonusDamageMoreHeight;
            healthBar.SetActive(true);
            upToDownDamageIcon.SetActive(true);
        }

        //Si le ataco por la espalda hago más daño
        if (unitToDealDamage.currentFacingDirection == currentFacingDirection)
        {
            if (unitToDealDamage.GetComponent <EnDuelist>() &&
                unitToDealDamage.GetComponent <EnDuelist>().hasTier2 &&
                hasAttacked)
            {
                if (currentFacingDirection == FacingDirection.North)
                {
                    unitToDealDamage.unitModel.transform.DORotate(new Vector3(0, 180, 0), timeDurationRotation);
                    unitToDealDamage.currentFacingDirection = FacingDirection.South;
                }

                else if (currentFacingDirection == FacingDirection.South)
                {
                    unitToDealDamage.unitModel.transform.DORotate(new Vector3(0, 0, 0), timeDurationRotation);
                    unitToDealDamage.currentFacingDirection = FacingDirection.North;
                }

                else if (currentFacingDirection == FacingDirection.East)
                {
                    unitToDealDamage.unitModel.transform.DORotate(new Vector3(0, -90, 0), timeDurationRotation);
                    unitToDealDamage.currentFacingDirection = FacingDirection.West;
                }

                else if (currentFacingDirection == FacingDirection.West)
                {
                    unitToDealDamage.unitModel.transform.DORotate(new Vector3(0, 90, 0), timeDurationRotation);
                    unitToDealDamage.currentFacingDirection = FacingDirection.East;
                }
            }
            else
            {
                //Añado este if para que, cada vez que ataque un jugador y si le va a realizar daño por la espalda, el count del honor se resetea
                if (hasAttacked)
                {
                    LM.honorCount = 0;
                }
                //Ataque por la espalda
                damageWithMultipliersApplied += bonusDamageBackAttack;
                healthBar.SetActive(true);
                backStabIcon.SetActive(true);
            }
        }

        //Estas líneas las añado para comprobar si el samurai tiene la mejora de la pasiva 1
        Samurai samuraiUpgraded = FindObjectOfType <Samurai>();

        if (samuraiUpgraded != null && samuraiUpgraded.itsForHonorTime2)
        {
            damageWithMultipliersApplied += LM.honorCount;
        }

        if (isInRage)
        {
            //Añado el daño de rage.
            damageWithMultipliersApplied += extraDamageWithRage;
        }

        if (areaAttack)
        {
            //Añado el daño de rage.
            damageWithMultipliersApplied += bonusDamageAreaAttack;
        }

        damageWithMultipliersApplied += buffbonusStateDamage;
    }
Example #25
0
        public static void EnsurePopulated3(SamuraiContext context)
        {
            //context.Database.EnsureDeleted();

            var existingSamurais = context.Samurais;
            var newSamurais      = new Samurai[]
            {
                new Samurai {
                    Name   = "Luke",
                    Id     = 100,
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                },
                new Samurai {
                    Name   = "Luke2",
                    Id     = 100,
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                },
                new Samurai {
                    Name   = "Luke3",
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                },
                new Samurai {
                    Name   = "Luke11",
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                }
            };

            // Look for existing matches

            var            union     = existingSamurais.Union(newSamurais);
            List <Samurai> unionList = union.Select(s => new Samurai {
                Name = s.Name, Quotes = s.Quotes
            }).ToList();

            foreach (Samurai samurai in unionList)
            {
                context.Samurais.Add(samurai);
            }
            context.SaveChanges();
            //context.Database.CommitTransaction();
        }
Example #26
0
        private static void AddOneSamuraiWithRelatedData()
        {
            var samurai = new Samurai
            {
                Name      = "Akakaboto",
                HairStyle = new HairStyle
                {
                    HairStyleName = "Oicho"
                },
                SecretIdentity = new SecretIdentity
                {
                    SecretName = "Japanese Bear"
                },
                Quotes = new List <Quote>()
                {
                    new Quote
                    {
                        Text     = "Bare with me!",
                        Category = new QuoteCategory
                        {
                            Name = "Combat phrase"
                        }
                    },
                    new Quote
                    {
                        Text     = "I can't bare it!",
                        Category = new QuoteCategory
                        {
                            Name = "Surrendering quote"
                        }
                    }
                },
                SamuraiBattles = new List <SamuraiBattle>()
                {
                    new SamuraiBattle
                    {
                        Battle = new Battle
                        {
                            BattleName = "Third Blood",
                            BattleLog  = new BattleLog
                            {
                                BattleLogName = "Third Blood Battlelog",
                                BattleEvents  = new List <BattleEvent>()
                                {
                                    new BattleEvent
                                    {
                                        Text     = "Number three is the charm, third strike K.O.!",
                                        Summary  = "K.O.!",
                                        DateTime = DateTime.Parse("500-02-01")
                                    },
                                    new BattleEvent
                                    {
                                        Text     = "Hundred years of battle over",
                                        Summary  = "HundredOver",
                                        DateTime = DateTime.Parse("600-10-10")
                                    }
                                }
                            }
                        },
                    },
                    new SamuraiBattle
                    {
                        Battle = new Battle
                        {
                            BattleName = "Fourth Blood",
                            BattleLog  = new BattleLog
                            {
                                BattleLogName = "Fourth Blood Battlelog",
                                BattleEvents  = new List <BattleEvent>()
                                {
                                    new BattleEvent
                                    {
                                        Text     = "Fourth of July strike",
                                        Summary  = "USA??",
                                        DateTime = DateTime.Parse("912-07-04")
                                    },
                                    new BattleEvent
                                    {
                                        Text     = "Everyone for themselves",
                                        Summary  = "Free 4 All",
                                        DateTime = DateTime.Parse("1013-08-01")
                                    }
                                }
                            }
                        },
                    }
                }
            };

            var context = new SamuraiContext();

            context.Samurais.Add(samurai);
            context.SaveChanges();
        }
Example #27
0
        public static void EnsurePopulated(SamuraiContext context)
        {
            //context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            var existingSamurais = context.Samurais.ToList();
            var newSamurais      = new Samurai[]
            {
                new Samurai {
                    Name   = "Luke",
                    Id     = 5,
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                },
                new Samurai {
                    Name   = "Luke2",
                    Id     = 2,
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                },
                new Samurai {
                    Name   = "Luke3",
                    Id     = 3,
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                },
                new Samurai {
                    Name   = "Luke4",
                    Id     = 4,
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                },
                new Samurai {
                    Name   = "Luke5",
                    Id     = 13,
                    Quotes = new List <Quote>
                    {
                        new Quote {
                            Text = "Amazing"
                        }
                    }
                }
            };

            // Look for existing matches

            var diff = from samurai in newSamurais
                       where !existingSamurais.Any(s => s.Id == samurai.Id)
                       select samurai;

            List <Samurai> diffList = diff.Select(s => new Samurai {
                Name = s.Name, Quotes = s.Quotes
            }).ToList();

            foreach (Samurai samurai in diffList)
            {
                context.Samurais.Add(samurai);
            }

            context.SaveChanges();
        }
Example #28
0
        public static void AddOneSamuraiWithRelatedData()
        {
            var samuraiGopitha = new Samurai
            {
                Name = "Gopitha",

                HairStyle = HairStyle.Chonmage,

                Quotes = new List <Quote>()
                {
                    new Quote {
                        Text = "Samurai Gopitha Quote", QuoteStyle = QuoteStyle.Lame
                    },
                    new Quote {
                        Text = "Samurai Gopitha Quote 2", QuoteStyle = QuoteStyle.Awesome
                    }
                },

                SecretIdentity = new SecretIdentity()
                {
                    RealName = "GS"
                },

                SamuraiBattles = new List <SamuraiBattle>()
                {
                    new SamuraiBattle
                    {
                        Battle = new Battle()
                        {
                            Name        = "Battle 4",
                            Description = "Game of the Battle 4",
                            IsBrutal    = true,
                            StartDate   = new DateTime(2020, 08, 05),
                            EndDate     = new DateTime(2020, 08, 06),
                            BattleLog   = new BattleLog()
                            {
                                Name         = "BattleLog for battle 4",
                                BattleEvents = new List <BattleEvent>()
                                {
                                    new BattleEvent
                                    {
                                        Summary     = "Summary BattleEvent 4",
                                        Description = "Description BattleEvent 4",
                                        Order       = 1
                                    },
                                    new BattleEvent
                                    {
                                        Summary     = "Summary BattleEvent 4.2",
                                        Description = "Description BattleEvent 4.2",
                                        Order       = 2
                                    }
                                }
                            }
                        }
                    }
                }
            };

            using var context = new SamuraiContext();
            context.Samurais.Add(samuraiGopitha);
            context.SaveChanges();
        }
 public async Task UpdateSamurai(Samurai sam)
 {
     _context.Entry(sam).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }
Example #30
0
        public void Test_BattlesAndSamurais()
        {
            var samurai = new Samurai()
            {
                Name           = "Leonardo",
                Hair           = Hairstyle.Oicho,
                SecretIdentity = new SecretIdentity()
                {
                    RealName = "Svangunn"
                },
                Quotes = new List <Quote>()
                {
                    new Quote()
                    {
                        Quality = QuoteStyle.Cheesy,
                        Text    = "You can always die. It's living that takes real courage."
                    }
                },
                SamuraiBattles = new List <SamuraiBattle>()
                {
                    new SamuraiBattle()
                    {
                        Battle = new Battle()
                        {
                            Name        = "Battle of Academy",
                            Description = "A fierce battle of wits!",
                            StartDate   = new DateTime(2019, 06, 11), EndDate = new DateTime(2019, 09, 13), IsBrutal = true,
                            BattleLog   = new BattleLog()
                            {
                                Name         = "The Hackathon",
                                BattleEvents = new List <BattleEvent>()
                                {
                                    new BattleEvent()
                                    {
                                        Order       = 1,
                                        Description = "What started as a friendly competition emerged into a deadly battle, where laptops were used as blunt weapons.",
                                        Summary     = "The fight ended in a lot of tears and broken laptops. There were no victors..."
                                    }
                                }
                            }
                        },
                    },
                    new SamuraiBattle()
                    {
                        Battle = new Battle()
                        {
                            Name        = "The revenge of the N.E.R.D.S",
                            Description = "Notable Enigmatic Revolting Dapping Students",
                            StartDate   = new DateTime(2019, 09, 15), EndDate = new DateTime(2019, 09, 16), IsBrutal = true,
                            BattleLog   = new BattleLog()
                            {
                                BattleEvents = new List <BattleEvent>()
                                {
                                    new BattleEvent()
                                    {
                                        Order       = 2,
                                        Description = "As there were no laptops left. Pillows were used.",
                                        Summary     = "The fight ended in a deadlock. There were no victors."
                                    },
                                    new BattleEvent()
                                    {
                                        Order       = 3,
                                        Description = "Suddenly someone got the bright idea to stuff their pillows with rocks!",
                                        Summary     = "It was a brutal fight with lots of casualties on all sides."
                                    }
                                }
                            }
                        }
                    }
                }
            };

            using (var context = new SamuraiContext())
            {
                context.Samurais.Add(samurai);
                context.SaveChanges();
            }

            string result = EfMethods.ListAllBattlesWithinPeriod(new DateTime(2019, 01, 01), new DateTime(2019, 09, 14), true);

            // isBrutal,
            Assert.AreEqual("Leonardo alias Svangunn fought in Battle of Academy", result);
        }