예제 #1
0
        public static List <Tribe> setBaseDataset()
        {
            List <Tribe> tribeList  = new List <Tribe>();
            var          gimliDwarf = new Dwarf(
                "Gimli",
                140,
                new List <Weapon>()
            {
                new Weapon("Axt", 12),
                new Weapon("Schwert", 15)
            });

            var gumliDwarf = new Dwarf(
                "Gumli",
                163,
                new List <Weapon>()
            {
                new Weapon("Axt", 17)
            });

            var zwingliDwarf = new Dwarf(
                "Zwingli",
                70,
                new List <Weapon>()
            {
                new Weapon("Zauberstab", 45),
                new Weapon("Streithammer", 15)
            });

            var altobardenTribe = new Tribe(
                "Altobarden",
                1247,
                new List <Dwarf>()
            {
                gimliDwarf,
                zwingliDwarf
            },
                gimliDwarf,
                25);

            var elbknechteTribe = new Tribe(
                "Elbknechte",
                1023,
                new List <Dwarf>()
            {
                gumliDwarf
            });

            tribeList.Add(elbknechteTribe);
            tribeList.Add(altobardenTribe);

            return(tribeList);
        }
예제 #2
0
 public static List <Tribe> removeTribe(List <Tribe> tribeList, Tribe tribe)
 {
     tribeList.Remove(tribe);
     return(tribeList);
 }
예제 #3
0
 public static List <Tribe> addTribe(List <Tribe> tribeList, Tribe tribe)
 {
     tribeList.Add(tribe);
     return(tribeList);
 }
예제 #4
0
        static void Main()
        {
            //Tribes
            Tribe t1 = new Tribe()
            {
                Name = "Altobarden", ExistingSince = "1247 ndK"
            };
            Tribe t2 = new Tribe()
            {
                Name = "Elbknechte", ExistingSince = "1023 ndK"
            };

            // Weapons
            var w1 = new Weapon()
            {
                Type = "Axt", MagicValue = 12
            };
            var w2 = new Weapon()
            {
                Type = "Schwert", MagicValue = 15
            };
            var w3 = new Weapon()
            {
                Type = "Axt", MagicValue = 17
            };
            var w4 = new Weapon()
            {
                Type = "Zauberstab", MagicValue = 45
            };
            var w5 = new Weapon()
            {
                Type = "Streithammer", MagicValue = 15
            };

            //Dwarfs
            var d1 = new Dwarf()
            {
                Name = "Gimli", Age = 140, Tribe = t1, Weapons = new List <Weapon>()
                {
                    w1, w2
                }
            };
            var d2 = new Dwarf()
            {
                Name = "Zwingli", Age = 70, Tribe = t1, Weapons = new List <Weapon>()
                {
                    w3
                }
            };
            var d3 = new Dwarf()
            {
                Name = "Gumli", Age = 163, Tribe = t2, Weapons = new List <Weapon>()
                {
                    w4, w5
                }
            };

            t1.Leader      = d1;
            t1.LeaderSince = 25;

            t2.Leader      = d3;
            t2.LeaderSince = 0;

            // User Input
            string dwarfName;
            string weaponName;
            Random random;
            Dwarf  dwarf;
            Weapon weapon;

            while (true)
            {
                // Output
                Console.Clear();
                Tribe.PrintTribes();
                Weapon.PrintWeapons();

                // User Input
                Console.Write("Enter Dwarf name (blank for a random dwarf): ");
                dwarfName = Console.ReadLine();

                Console.Write("Choose a weapon (blank for a random weapon): ");
                weaponName = Console.ReadLine();

                // Check input. If the input is blank, choose randomly
                if (dwarfName == string.Empty)
                {
                    random    = new Random();
                    dwarfName = Dwarf.Dwarfs[random.Next(Dwarf.Dwarfs.Count)].Name;
                }

                if (weaponName == string.Empty)
                {
                    random     = new Random();
                    weaponName = Weapon.Weapons[random.Next(Weapon.Weapons.Count)].Type;
                }

                // Find the object
                dwarf  = Dwarf.Dwarfs.Find(x => x.Name == dwarfName);
                weapon = Weapon.Weapons.Find(y => y.Type == weaponName);

                // Check if the objects exists and give weapon
                if ((dwarf != null) && (weapon != null))
                {
                    dwarf.GiveWeapon(weapon);
                }
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            //Tribes
            Tribe t1 = new Tribe()
            {
                Name = "Altobarden", ExistingSince = "1247 ndK"
            };
            Tribe t2 = new Tribe()
            {
                Name = "Elbknechte", ExistingSince = "1023 ndK"
            };

            // Weapons
            var w1 = new Weapon()
            {
                Type = "Axt", MagicValue = 12
            };
            var w2 = new Weapon()
            {
                Type = "Schwert", MagicValue = 15
            };
            var w3 = new Weapon()
            {
                Type = "Axt", MagicValue = 17
            };
            var w4 = new Weapon()
            {
                Type = "Zauberstab", MagicValue = 45
            };
            var w5 = new Weapon()
            {
                Type = "Streithammer", MagicValue = 15
            };

            //Dwarfs
            var d1 = new Dwarf()
            {
                Name = "Gimli", Age = 140, Tribe = t1, Weapons = new List <Weapon>()
                {
                    w1, w2
                }
            };
            var d2 = new Dwarf()
            {
                Name = "Zwingli", Age = 70, Tribe = t1, Weapons = new List <Weapon>()
                {
                    w3
                }
            };
            var d3 = new Dwarf()
            {
                Name = "Gumli", Age = 163, Tribe = t2, Weapons = new List <Weapon>()
                {
                    w4, w5
                }
            };

            t1.Leader      = d1;
            t1.LeaderSince = "25 years";

            t2.Leader      = d3;
            t2.LeaderSince = "? years";


            //Output
            t1.printTribe();
            t2.printTribe();

            // Give weapon
            d1.giveWeapon(w1);
            d2.giveWeapon(w3);
            d3.giveWeapon(w5);
            d3.giveWeapon(w2);

            //Output
            t1.printTribe();
            t2.printTribe();

            Console.ReadKey();
        }