public HealthPotion DropHealthPotion() { List <string> names = new List <string>(); names.Add("Shiny Potion"); names.Add("Glistering Potion"); names.Add("Shining Potion"); names.Add("Life Potion"); Random RNG = new Random(); string name = names[RNG.Next(names.Count())]; int healingPower = RNG.Next(this.lootQuality); double weight = RNG.Next(healingPower); weight = weight / 20; HealthPotion output = new HealthPotion(name, weight, healingPower); Console.WriteLine("The " + this.DisplayName + " has dropped a " + name + "!"); return(output); }
private void CreateRooms() { Room outside, theatre, pub, lab, office, treeHouse; List <Room> rooms = new List <Room>(); // create the rooms outside = new Room("outside the main entrance of the university"); theatre = new Room("in a lecture theatre"); pub = new Room("in the campus pub"); lab = new Room("in a computing lab"); office = new Room("in the computing admin office"); treeHouse = new Room("in the secret tree house built by the seniors"); //Add rooms to the Rooms List rooms.Add(outside); rooms.Add(theatre); rooms.Add(pub); rooms.Add(lab); rooms.Add(office); rooms.Add(treeHouse); // create the items for in the rooms Weapon sword = new Weapon("Sword", 4, 50); HealthPotion hp1 = new HealthPotion("Weird Potion", 0.1, 40); // initialise room exits and put items in the rooms. outside.SetExit("east", theatre); outside.SetExit("south", lab); outside.SetExit("west", pub); outside.SetExit("up", treeHouse); theatre.SetExit("west", outside); theatre.inventory.AddItem(sword); pub.SetExit("east", outside); pub.AddEnemy("Fritz"); lab.SetExit("north", outside); lab.SetExit("east", office); lab.inventory.AddItem(hp1); office.SetExit("west", lab); treeHouse.SetExit("down", outside); //assign ID's to all rooms for (int i = 0; i < (rooms.Count - 1); i++) { rooms[i].ID = i; } if (loadedFromSave) { for (int i = 0; i < (rooms.Count - 1); i++) { if (player.CurrentRoom.ID == i) { player.CurrentRoom = rooms[i]; break; } } } else { player.CurrentRoom = outside; } // start game outside //lock certain rooms treeHouse.SetLocked(office, "Tree Key"); office.SetLocked(pub, "Cool Key"); }