コード例 #1
0
        public static Player CreatePlayer()
        {
            Console.WriteLine("---Create your character---");
            Console.Write("Name: ");
            string plrName = Console.ReadLine();

            Console.Write("Race(Dwarf, Human, Giant, etc...): ");
            string plrRace = Console.ReadLine();
            Player player  = new Player()
            {
                Level      = 1,
                FullHealth = 100,
                Health     = 100,
                Damage     = 5,
                Defense    = 5,
                XP         = 0,
                GP         = 50,
                Race       = plrRace,
                Name       = plrName
            };
            Item stick = ItemFabric.CreateItem(1, ItemType.Weapon);

            stick.ItemName = "Stick";
            player.Inventory.Add(stick);
            player.PrimaryWeapon = stick;
            return(player);
        }
コード例 #2
0
        public static Enemy CreateEnemy(Person plr)
        {
            Random rnd        = new Random();
            int    randomRace = rnd.Next(0, enemyRace.Length);
            int    health     = plr.FullHealth + (plr.FullHealth * rnd.Next(-5, 6) / 100);

            Enemy enemy = new Enemy()
            {
                Race       = enemyRace[randomRace],
                Damage     = plr.Damage + rnd.Next(-5, 6),
                Defense    = plr.Defense + rnd.Next(-5, 6),
                Level      = Math.Max(1, plr.Level + rnd.Next(-2, 1)),
                FullHealth = health,
                Health     = health,
            };

            enemy.PrimaryWeapon = ItemFabric.CreateItem(enemy.Level, ItemType.Weapon);
            enemy.Inventory.Add(enemy.PrimaryWeapon);
            enemy.Inventory.Add(ItemFabric.CreateItem(enemy.Level, ItemType.Food));
            return(enemy);
        }
コード例 #3
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;
                    }
                }
            }
        }