Beispiel #1
0
        public static void Main(string[] args)
        {
            string[] Places = { "Griglagg", "Ravenwood", "Dunwich", "Greenwood" };
            Console.WriteLine("Welcome to Dragon Eye, a terminal RPG!");
            System.Threading.Thread.Sleep(2000);
            Console.WriteLine("This game was created for the AI competition on repl.it");
            System.Threading.Thread.Sleep(2000);
            Player MainPlayer = PersonFabric.CreatePlayer();

            RenderStats(MainPlayer);
            RenderInventory(MainPlayer);
            Random rnd = new Random();

            Console.WriteLine("Your adventure begins..");
            while (true)
            {
                System.Threading.Thread.Sleep(1000);
                int travel = rnd.Next(0, 5);
                if (travel == 1)
                {
                    string place = Places[rnd.Next(0, Places.Length)];
                    Console.WriteLine("You travel to {0}.", place);
                }
                else
                {
                    int action = rnd.Next(0, 4); // 0 combat, 1 quest, 2 someone asks for gold, 3 find something
                    switch (action)
                    {
                    case 0:
                        Combat(MainPlayer);
                        break;

                    case 1:
                        Console.WriteLine("A fellow {0} asks {1} for 10 Gold Pieces, do you accept?", MainPlayer.Race, MainPlayer.Name);
                        Console.WriteLine("1. Yes\n2. No");
                        string Answer = Console.ReadLine();
                        switch (Answer)
                        {
                        case "1":
                            if (MainPlayer.GP < 10)
                            {
                                Console.WriteLine("You have only {0} Gold Pieces", MainPlayer.GP);
                            }
                            else
                            {
                                MainPlayer.GP -= 10;
                                Console.WriteLine("You gave the {0} 10 Gold Pieces.", MainPlayer.Race);
                                int giftSomething = rnd.Next(0, 2);
                                if (giftSomething == 1)
                                {
                                    Item giftItem = ItemFabric.CreateItem(MainPlayer.Level);
                                    MainPlayer.Inventory.Add(giftItem);
                                    Console.WriteLine("{0} gifts you a new {1}!", MainPlayer.Race, giftItem.ItemName);
                                }
                            }
                            break;

                        case "2":
                            Console.WriteLine("You refused to give the {0} Gold Pieces.", MainPlayer.Race);
                            break;

                        default:
                            Console.WriteLine("You refused to give the {0} Gold Pieces.", MainPlayer.Race);
                            break;
                        }
                        break;

                    case 2:
                        Console.WriteLine("Someone walks up to {0}, and asks him/her to slay a monster.", MainPlayer.Name);
                        System.Threading.Thread.Sleep(500);
                        if (rnd.Next(0, 2) == 1)
                        {
                            Console.WriteLine("{0} accepted the offer.", MainPlayer.Name);
                            Combat(MainPlayer);
                        }
                        else
                        {
                            Console.WriteLine("{0} declined the offer.", MainPlayer.Name);
                        }
                        break;

                    case 3:
                        Item newItem = ItemFabric.CreateItem(MainPlayer.Level);
                        MainPlayer.Inventory.Add(newItem);
                        Console.WriteLine("You found a {0}.", newItem.ItemName);
                        break;
                    }
                }
            }
        }