예제 #1
0
        public static void printAttackMessage(Contestant attacker, Contestant defender, Item weapon, bool success)
        {
            Random ram = new Random(DateTime.Now.Second + DateTime.Now.Minute + DateTime.Now.Hour + DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Year + attacker.ram.Next() + defender.ram.Next() + weapon.getWeaponMod());

            Console.WriteLine();
            object[] args = { attacker.name, defender.name, weapon.getName() };
            if (weapon.getRandomAttackMessage(ram) != null)
            {
                Console.WriteLine(string.Format(weapon.getRandomAttackMessage(ram), args));
            }
            else
            {
                Console.WriteLine(string.Format(attackMessage[ram.Next(0, attackMessage.Length)], args));
            }
            if (success)
            {
                if (weapon.getRandomAttackWinMessage(ram) != null)
                {
                    Console.WriteLine(string.Format(weapon.getRandomAttackWinMessage(ram), args));
                }
                else
                {
                    Console.WriteLine(string.Format(attackWinMessage[ram.Next(0, attackWinMessage.Length)], args));
                }
            }
            else
            {
                if (weapon.getRandomAttackLoseMessage(ram) != null)
                {
                    Console.WriteLine(string.Format(weapon.getRandomAttackLoseMessage(ram), args));
                }
                else
                {
                    Console.WriteLine(string.Format(attackLoseMessage[ram.Next(0, attackLoseMessage.Length)], args));
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            if (args.Length <= 0)
            {
                Console.WriteLine("Hey! You need to provide argunments of the contestants!");
                Console.ReadKey();
                return;
            }
            Console.Clear();
            Console.WriteLine("The contestants are...");
            foreach (string arg in args)
            {
                Contestant newGuy = new Contestant(arg, contestants.Count);
                contestants.Add(newGuy);
                Console.WriteLine("- " + newGuy.ToString());
            }
            Console.WriteLine();
            Console.WriteLine("Press Enter when ready.");
            Console.ReadLine();
            Console.Clear();
            while (livingCount() > 1)
            {
                day++;
                Console.WriteLine("Day " + day);
                Console.WriteLine();
                contestants = contestants.OrderBy(a => Guid.NewGuid()).ToList();
                foreach (Contestant contestant in contestants)
                {
                    if (contestant.isDead())
                    {
                        continue;
                    }
                    contestant.modSanity(contestant.ram.Next(-15, 0));
                    int action = contestant.ram.Next(1, 5);
                    switch (action)
                    {
                    case 1:     //Does "nothing"
                        doNothing(contestant);
                        break;

                    case 2:     //Does "attack"
                        doAttack(contestant);
                        break;

                    case 3:     //Do "Gain Item"
                        doGainItem(contestant);
                        break;

                    case 4:     //Do "Die"
                        doDie(contestant);
                        break;

                    default:
                        doNothing(contestant);
                        break;
                    }
                }
                Console.WriteLine();
                Console.WriteLine("Currently living:");
                foreach (Contestant contestant in contestants)
                {
                    if (contestant.isDead())
                    {
                        continue;
                    }
                    Console.WriteLine(" - " + contestant.name);
                }
                Console.WriteLine();
                if (livingCount() > 1)
                {
                    Console.WriteLine("Press Enter to continue to the next day.");
                    Console.ReadLine();
                }
                Console.WriteLine();
            }

            if (livingCount() == 1)
            {
                Console.WriteLine("A winner has been decided!");
                foreach (Contestant contestant in contestants)
                {
                    if (!contestant.isDead())
                    {
                        Console.WriteLine(string.Format("{0} is the winner!", contestant.name));
                    }
                }
            }
        }
예제 #3
0
 private static void doNothing(Contestant contestant)
 {
     Messages.printNothingMessage(contestant);
 }