Beispiel #1
0
        public void PlayerLoad(string playerInventorySave, Inventory inventory, Player player)
        {
            if (File.Exists(playerInventorySave))
            {   // Create a (shopSave & playerSave) object for the file at our path
                AllItem newitem;
                string  temp;
                string  name;
                int     stat;
                int     cost;
                string  desc;
                bool    loading = true;

                Clear();
                StreamReader playerSaveLoad = File.OpenText(playerInventorySave);
                player.getDatMoney = Convert.ToInt32(playerSaveLoad.ReadLine());
                player._potionHeld = Convert.ToInt32(playerSaveLoad.ReadLine());
                while (loading)
                {
                    loading = false;
                    temp    = playerSaveLoad.ReadLine();
                    if (temp != null)
                    {
                        loading = true;
                        name    = (playerSaveLoad.ReadLine());
                        stat    = Convert.ToInt32(playerSaveLoad.ReadLine());
                        cost    = Convert.ToInt32(playerSaveLoad.ReadLine());
                        desc    = (playerSaveLoad.ReadLine());
                        if (temp == "Weapon")
                        {
                            newitem = new AttackItem(name, stat, cost, desc);
                        }
                        else if (temp == "Armor")
                        {
                            newitem = new DefenseItem(name, stat, cost, desc);
                        }
                        else
                        {
                            newitem = new AllItem();
                        }
                        Add(newitem);
                    }
                }
                playerSaveLoad.Close();
                Console.WriteLine("Player File Loaded.");
            }
            else
            {
                Console.WriteLine("Save File not found.");
            }
        }
Beispiel #2
0
        // The SuperUser Command Function
        public void SuperAdmin(Player player)
        {
            AllItem item     = new AllItem();
            string  choice   = "";
            string  itemname = "";
            string  itemDesc = "";
            int     itemstat;
            int     itemcost;

            Console.WriteLine("Debug Mode Activated\n");
            while (choice != "home")
            {
                int debug = 0;
                Console.WriteLine("Debug Mode (Active)");
                Console.WriteLine("additem, modifygold, home");
                choice = Console.ReadLine();
                if (choice == "additem")
                {
                    while (choice != "back")
                    {
                        Console.WriteLine("weapon, armor, back");
                        choice = Console.ReadLine();
                        if (choice == "weapon")
                        {
                            Console.WriteLine("\nGive the new item a name.");
                            itemname = Console.ReadLine();
                            Console.WriteLine("\nGive the new item an Attack stat.");
                            itemstat = Convert.ToInt32(Console.ReadLine());
                            while (itemstat < 0)
                            {
                                Console.WriteLine("No negative item damage boy. Try Again.");
                                itemstat = Convert.ToInt32(Console.ReadLine());
                            }
                            Console.WriteLine("\nGive the new item a price.");
                            itemcost = Convert.ToInt32(Console.ReadLine());
                            while (itemcost < 0)
                            {
                                Console.WriteLine("No negative item cost boy. Try Again.");
                                itemcost = Convert.ToInt32(Console.ReadLine());
                            }
                            Console.WriteLine("\nGive the new item a description.");
                            itemDesc = Console.ReadLine();

                            Console.WriteLine("Your new item has been added to the shop.\n");
                            Console.ReadKey();

                            item = new AttackItem(itemname, itemstat, itemcost, itemDesc);
                            shopInv.Add(item);
                            choice = "back";
                        }
                        else if (choice == "armor")
                        {
                            Console.WriteLine("\nGive the new item a name.");
                            itemname = Console.ReadLine();
                            Console.WriteLine("\nGive the new item an Defense stat.");
                            itemstat = Convert.ToInt32(Console.ReadLine());
                            while (itemstat < 0)
                            {
                                Console.WriteLine("No negative item defense boy. Try Again.");
                                itemstat = Convert.ToInt32(Console.ReadLine());
                            }
                            Console.WriteLine("\nGive the new item a price.");
                            itemcost = Convert.ToInt32(Console.ReadLine());
                            while (itemcost < 0)
                            {
                                Console.WriteLine("No negative item cost boy.");
                            }
                            Console.WriteLine("\nGive the new item a description.");
                            itemDesc = Console.ReadLine();

                            Console.WriteLine("Your new item has been added to the shop.\n");
                            Console.ReadKey();

                            item = new DefenseItem(itemname, itemstat, itemcost, itemDesc);
                            shopInv.Add(item);
                            choice = "back";
                        }
                        else if (choice == "home")
                        {
                        }
                    }
                }
                else if (choice == "modifygold")
                {
                    Console.WriteLine("How much player gold will you add/remove?");
                    debug = Convert.ToInt32(Console.ReadLine());
                    player.getDatMoney += debug;
                    Console.WriteLine("You have given yourself " + debug + " gold.");
                    if (player.getDatMoney <= 0)
                    {
                        Console.WriteLine("Money set automatically to zero.");
                        player.getDatMoney = 0;
                    }
                    Console.WriteLine(" ");
                }
                else if (choice == "home")
                {
                    Console.WriteLine("Now returning to main menu.\n");
                }
            }
        }