Esempio n. 1
0
            static string job(IRobber robber)
            {
                string Target = robber.ToString();

                string[] SplitTarget = Target.Split(".");
                return(SplitTarget[1]);
            }
Esempio n. 2
0
 // Checks if user wants to create a new operative & creates it
 static bool UserCreatingOperatives(List <IRobber> rolodex, ConsoleKeyInfo keyInfo)
 {
     if (keyInfo.Key == ConsoleKey.Y)
     {
         IRobber newOperative = CreateOperative();
         rolodex.Add(newOperative);
         Console.WriteLine("Operative Created.");
         Console.WriteLine();
         Console.WriteLine($"New Operative, {newOperative.Name}:");
         Console.WriteLine($"Skill Level: {newOperative.SkillLevel}");
         Console.WriteLine($"Percentage of Heist: {newOperative.PercentageCut}%");
         return(true);
     }
     else if (keyInfo.Key == ConsoleKey.N)
     {
         Console.WriteLine();
         Console.Write("Starting the Heist");
         Loading();
         Console.Write("Configuring Bank");
         Loading();
         Thread.Sleep(1000);
         return(false);
     }
     return(false);
 }
Esempio n. 3
0
        public MoveRobberState(IGameTurn turn, IRobber robber)
        {
            if (turn == null)
                throw new ArgumentNullException(nameof(turn));
            if (robber == null)
                throw new ArgumentNullException(nameof(robber));

            this.turn = turn;
            this.robber = robber;
        }
Esempio n. 4
0
 public MoveRobberCommand(IPlayer player, IRobber robber, ITile tile)
 {
     if (player == null)
         throw new ArgumentNullException(nameof(player));
     if (robber == null)
         throw new ArgumentNullException(nameof(robber));
     if (tile == null)
         throw new ArgumentNullException(nameof(tile));
     Player = player;
     this.robber = robber;
     this.tile = tile;
 }
Esempio n. 5
0
File: Board.cs Progetto: Corne/VOC
        public Board(IBoardBuilder builder)
        {
            if (builder == null)
                throw new ArgumentNullException(nameof(builder));

            builder.Build();
            Tiles = builder.Tiles;
            Vertices = builder.Vertices;
            Edges = builder.Edges;
            Harbors = builder.Harbors;

            Robber = new Robber(Tiles.Single(t => t.Rawmaterial == MaterialType.Unsourced));
        }
Esempio n. 6
0
        static void RecruitGoons(List <IRobber> rolodex)
        {
            Console.Clear();
            Console.WriteLine("Recruitment");
            Console.WriteLine("-----------");
            Console.WriteLine($"We have {rolodex.Count} unsavory fellas in the Rolodex.");
            Console.WriteLine("I know you got your own guys. Let's add them.");
            Console.WriteLine("What's the name of your crony?  ");
            string newGuyName = Console.ReadLine();

            while (newGuyName != "")
            {
                IRobber newGoon = CreateNewGoon(newGuyName);
                rolodex.Add(newGoon);
                Console.Clear();
                Console.WriteLine($"That brings the Rolodex up to {rolodex.Count} distinguished gentlemen.");
                Console.WriteLine("If ya got another guy, give me a name now. ");
                newGuyName = Console.ReadLine();
            }
        }
Esempio n. 7
0
        static List <IRobber> CreateCrew(List <IRobber> rolodex)
        {
            //declare the crew
            List <IRobber> crew = new List <IRobber>();

            //declare and initialize the total cut
            int totalCutLeft = 100;

            //prompt the user
            while (rolodex.Count > 0)
            {
                //make sure selection is valid
                int    indexOfSelection = 0;
                string selection        = "dummy";
                while (true)
                {
                    //prompt for selection
                    Console.Write("Pick criminal for your crew: ");
                    selection = Console.ReadLine();
                    //if blank, exit
                    if (selection == "")
                    {
                        break;
                    }
                    try
                    {
                        //try to parse
                        indexOfSelection = Int32.Parse(selection) - 1;
                        //make sure it is not out of bounds
                        if (indexOfSelection < 0 || indexOfSelection >= rolodex.Count)
                        {
                            throw new Exception();
                        }
                        //make sure there is enough cut left
                        if (rolodex[indexOfSelection].PercentageCut > totalCutLeft)
                        {
                            throw new GreedyCriminalException();
                        }

                        break;
                    }
                    catch (GreedyCriminalException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    catch
                    {
                        Console.WriteLine("Please enter a valid selection");
                    }
                }

                //if user enters nothing, exit
                if (selection == "")
                {
                    break;
                }

                //grab the selected criminal
                IRobber selectedCriminal = rolodex[indexOfSelection];

                //decrement the totalCut by the selected criminals cut
                totalCutLeft -= selectedCriminal.PercentageCut;

                //add the criminal to the crew and remove it from the rolodex
                crew.Add(selectedCriminal);
                rolodex.RemoveAt(indexOfSelection);

                //display the rolodex
                DisplayRolodex(rolodex);
            }
            return(crew);
        }
        static void Main(string[] args)
        {
            List <IRobber> rolodex   = GetRobbers();
            Bank           bankToRob = BankForHeist();

            Rolodex.Print(rolodex);
            List <IRobber> crew       = new List <IRobber>();
            int            percentage = 100;

            while (true)
            {
                Console.WriteLine($"Percentage left for crew members: {percentage}");
                Console.WriteLine("------------------");
                Console.Write("Select a member for your crew from current contacts: ");
                Console.WriteLine("-------------------");
                string input = Console.ReadLine();
                if (input == "")
                {
                    break;
                }
                try
                {
                    int choice = int.Parse(input);
                    if (choice < rolodex.Count && choice >= 0)
                    {
                        IRobber newMember = Rolodex.SelectMember(rolodex, choice);
                        percentage = percentage - newMember.PercentageCut;
                        if (percentage >= 0)
                        {
                            crew.Add(newMember);
                            rolodex.RemoveAt(choice);
                        }
                        else
                        {
                            percentage = percentage + newMember.PercentageCut;
                            Console.WriteLine("Percent cut can't be met for that crew member");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Enter a valid index number");
                        Console.WriteLine("------------------");
                    }
                }
                catch
                {
                    Console.WriteLine("Enter a valid index number");
                    Console.WriteLine("------------------");
                }
                Rolodex.Print(rolodex);
            }

            crew.ForEach(member => member.PerformSkill(bankToRob));
            if (!bankToRob.IsSecure)
            {
                Console.WriteLine("-------------------");
                Console.WriteLine("Heist was a success!!!");
                Console.WriteLine("-------------------");
                int ourCut = bankToRob.CashOnHand;
                foreach (IRobber member in crew)
                {
                    Console.WriteLine($"{member.Name} gets: ${(bankToRob.CashOnHand * member.PercentageCut) / 100}");
                    Console.WriteLine("-------------------");
                    ourCut = ourCut - ((bankToRob.CashOnHand * member.PercentageCut) / 100);
                }
                Console.WriteLine($"You get ${ourCut}");
            }
            else
            {
                Console.WriteLine("-------------------");
                Console.WriteLine("Your crew is locked up!!! **FAILURE**");
            }
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            int    i   = 0;
            Hacker bud = new Hacker()
            {
                Name          = "Bud",
                SkillLevel    = 40,
                PercentageCut = 20,
                Index         = i++
            };

            Muscle meathead = new Muscle()
            {
                Name          = "MeatHead",
                SkillLevel    = 57,
                PercentageCut = 15,
                Index         = i++
            };

            LockSpecialist alan = new LockSpecialist()
            {
                Name          = "Alan",
                SkillLevel    = 72,
                PercentageCut = 24,
                Index         = i++
            };

            Hacker burt = new Hacker()
            {
                Name          = "Burt",
                SkillLevel    = 64,
                PercentageCut = 70,
                Index         = i++
            };

            Muscle beefbrain = new Muscle()
            {
                Name          = "BeefBrain",
                SkillLevel    = 19,
                PercentageCut = 10,
                Index         = i++
            };

            LockSpecialist doug = new LockSpecialist()
            {
                Name          = "Doug",
                SkillLevel    = 32,
                PercentageCut = 26,
                Index         = i++
            };

            List <IRobber> rolodex = new List <IRobber>()
            {
                bud, meathead, alan, burt, beefbrain, doug
            };

            Console.WriteLine($"Number of operatives in the rolodex: {rolodex.Count}");

            Console.Write("Enter name of a new possible crew member: ");
            string newRolodexEntryName = Console.ReadLine();

            while (newRolodexEntryName != "")
            {
                Console.WriteLine("Select a Specialty:");
                Console.WriteLine("1. Hacker (Disables alarms)");
                Console.WriteLine("2. Muscle (Disarms guards)");
                Console.WriteLine("3. Lock Specialist (Cracks vault)");
                int newRolodexEntrySpecialty = int.Parse(Console.ReadLine());

                Console.Write("Enter the crew member's skill level (between 1 and 100): ");
                int newRolodexEntrySkillLevel = int.Parse(Console.ReadLine());

                Console.Write("Enter the crew member's demand for percentage cut: ");
                int newRolodexEntryPercentageCut = int.Parse(Console.ReadLine());

                switch (newRolodexEntrySpecialty)
                {
                case 1:
                    Hacker addedHacker = new Hacker()
                    {
                        Name          = newRolodexEntryName,
                        SkillLevel    = newRolodexEntrySkillLevel,
                        PercentageCut = newRolodexEntryPercentageCut,
                        Index         = i++
                    };
                    rolodex.Add(addedHacker);
                    break;

                case 2:
                    Muscle addedMuscle = new Muscle()
                    {
                        Name          = newRolodexEntryName,
                        SkillLevel    = newRolodexEntrySkillLevel,
                        PercentageCut = newRolodexEntryPercentageCut,
                        Index         = i++
                    };
                    rolodex.Add(addedMuscle);
                    break;

                case 3:
                    LockSpecialist addedLockSpecialist = new LockSpecialist()
                    {
                        Name          = newRolodexEntryName,
                        SkillLevel    = newRolodexEntrySkillLevel,
                        PercentageCut = newRolodexEntryPercentageCut,
                        Index         = i++
                    };
                    rolodex.Add(addedLockSpecialist);
                    break;
                }

                Console.Write("Enter another potential crew member name: ");
                newRolodexEntryName = Console.ReadLine();
            }

            Random randomNumberGenerator = new Random();
            Bank   bankTarget            = new Bank()
            {
                AlarmScore         = randomNumberGenerator.Next(0, 101),
                VaultScore         = randomNumberGenerator.Next(0, 101),
                SecurityGuardScore = randomNumberGenerator.Next(0, 101),
                CashOnHand         = randomNumberGenerator.Next(50_000, 1_000_000)
            };


            Dictionary <string, int> bankInfo = new Dictionary <string, int>()
            {
                { "Alarm", bankTarget.AlarmScore },
                { "Vault", bankTarget.VaultScore },
                { "Guards", bankTarget.SecurityGuardScore }
            };

            int    maxScore   = bankInfo.Max(kvp => kvp.Value);
            string mostSecure = bankInfo.First(kvp => kvp.Value == maxScore).Key;

            int    minScore    = bankInfo.Min(kvp => kvp.Value);
            string leastSecure = bankInfo.First(kvp => kvp.Value == minScore).Key;

            Console.WriteLine("Recon Report:");
            Console.WriteLine($"Most secure: {mostSecure}");
            Console.WriteLine($"Least secure: {leastSecure}");

            foreach (IRobber robber in rolodex)
            {
                Console.WriteLine($"{robber.Index}. {robber.Name}");
                Console.WriteLine($"Specialty: {robber.Specialty}");
                Console.WriteLine($"Skill Level: {robber.SkillLevel}");
                Console.WriteLine($"Percentage Cut: {robber.PercentageCut}");
                Console.WriteLine("--------------------------------------------------");
            }

            List <IRobber> crew = new List <IRobber>();

            Console.Write("Select a robber to add to the crew: ");
            string crewMemberNumberSelected = Console.ReadLine();

            int percentageLeft = 100;

            while (crewMemberNumberSelected != "" && percentageLeft > 0)
            {
                IRobber crewMemberToBeAdded = rolodex.First(robber => robber.Index == int.Parse(crewMemberNumberSelected));
                percentageLeft -= crewMemberToBeAdded.PercentageCut;

                crew.Add(crewMemberToBeAdded);

                List <IRobber> filteredRolodex = rolodex
                                                 .Where(robber => robber.PercentageCut <= percentageLeft)
                                                 .Where(robber => !crew.Contains(robber))
                                                 .ToList();

                foreach (IRobber robber in filteredRolodex)
                {
                    Console.WriteLine($"{robber.Index}. {robber.Name}");
                    Console.WriteLine($"Specialty: {robber.Specialty}");
                    Console.WriteLine($"Skill Level: {robber.SkillLevel}");
                    Console.WriteLine($"Percentage Cut: {robber.PercentageCut}");
                    Console.WriteLine("--------------------------------------------------");
                }

                if (filteredRolodex.Count > 0)
                {
                    Console.Write("Select another robber to add to the crew: ");
                    crewMemberNumberSelected = Console.ReadLine();
                }
            }

            foreach (IRobber robber in crew)
            {
                robber.PerformSkill(bankTarget);
            }

            if (bankTarget.IsSecure)
            {
                Console.WriteLine("The heist failed!");
            }
            else
            {
                Console.WriteLine("The heist succeeded!");
                int cashLeft = bankTarget.CashOnHand;
                foreach (IRobber robber in crew)
                {
                    int robbersTake = bankTarget.CashOnHand * robber.PercentageCut / 100;
                    cashLeft -= robbersTake;
                    Console.WriteLine($"{robber.Name} got {robbersTake}");
                }
                Console.WriteLine($"You get {cashLeft}");
            }
        }