public void TestBagFullDesc() { Bag test = new Bag (new string[]{"Bag", "Backpack"}, "bag", "This is a bag for...."); Item item1 = new Item( new String[] {"shovel", "spade" }, "a shovel", "This is a might fine ..." ); test.Inventory.Put (item1); Assert.AreEqual(test.FullDescription,"In the bag you can see:\r\na shovel (shovel)\r\n"); }
public void TestBagLocationItems() { Bag test = new Bag (new string[]{"Bag", "Backpack"}, "a bag", "This is a bag for...."); Item item1 = new Item( new String[] {"shovel", "spade" }, "a shovel", "This is a might fine ..." ); test.Inventory.Put (item1); Assert.AreEqual(test.Locate ("shovel"),item1); }
public void TestLookAtNoGemInBag() { LookCommand test = new LookCommand (); Player testPlayer = new Player ("Player 1", "a funny wizard"); Bag testBag = new Bag (new string[]{ "Bag", "Backpack" }, "a bag", "This is a bag for...."); testPlayer.Inventory.Put (testBag); Assert.AreEqual (test.Execute(testPlayer, new String[]{"look", "at", "shovel", "in", "bag"}),"I cannot find the shovel in the bag"); }
public void LocateTest() { Bag TestBag = new Bag (new string[] { "Test", "Bag" }, "Test Bag", "A Testing Bag"); Item TestItem = new Item (new string[] { "potato", "baked" }, "baked potato", "a baked potato"); TestBag.Inventory.PutItem (TestItem); Assert.IsTrue (TestBag.Locate ("potato") == TestItem); }
public void TestLookAtGemInBagFail() { Player TestPlayer = new Player ("TestPlayer", "For testing"); Item TestItem = new Item (new string[] { "gem", "Shiny" }, "Gem", "A Shiny Gem"); Bag TestBag = new Bag (new string[] { "bag", "test" }, "Test Bag", "A Testing Bag"); TestBag.Inventory.PutItem (TestItem); TestPlayer.Inventory.PutItem (TestBag); LookCommand TestLook = new LookCommand (); Assert.IsTrue (TestLook.Execute (TestPlayer, new string[5] {"look", "at", "gem", "in", "nobag"}) == "i cannot find the nobag"); }
public void FullDescriptionTest() { Item TestItem = new Item (new string[] { "potato", "baked" }, "baked potato", "a baked potato"); Item TestItem2 = new Item (new string[] { "chicken", "baked" }, "baked chicken", "a baked chicken"); Bag TestBag = new Bag (new string[] { "Test", "Bag" }, "Test Bag", "A Testing Bag"); TestBag.Inventory.PutItem (TestItem); TestBag.Inventory.PutItem (TestItem2); Assert.IsTrue (TestBag.FullDescription ().Contains("In "+ TestBag.Name +"You are Carrying: \n")); Assert.IsTrue (TestBag.FullDescription ().Contains("baked potato" + "\t" + "A baked potato potato." + "\n")); Assert.IsTrue (TestBag.FullDescription ().Contains("baked chicken" + "\t" + "A baked chicken chicken." + "\n")); }
public void BagBagTest() { Bag b1 = new Bag (new string[] { "b1", "Bag" }, "Test Bag", "A Testing Bag"); Bag b2 = new Bag (new string[] { "b2", "Bag" }, "b2 Bag", "A Testing Bag"); Item TestItem = new Item (new string[] { "potato", "baked" }, "baked potato", "a baked potato"); Item TestItem2 = new Item (new string[] { "chicken", "baked" }, "baked chicken", "a baked chicken"); b1.Inventory.PutItem (TestItem); b2.Inventory.PutItem (TestItem2); b1.Inventory.PutItem (b2); Assert.IsTrue (b1.Locate ("potato") == TestItem); Assert.IsFalse (b1.Locate ("chicken") == TestItem2); Assert.IsTrue (b1.Locate ("b2") == b2); }
public static void Main(string[] args) { string _playerName; string _playerDesc; LookCommand _lookCommand = new LookCommand (); Console.WriteLine ("Welcome to Swin-Adventure"); Console.WriteLine ("+―++―++―++―++―++―++―+\r\n"); Console.WriteLine ("Please enter your name:"); _playerName = Console.ReadLine(); Console.WriteLine ("Please enter your description:"); _playerDesc = Console.ReadLine(); Player _player = new Player (_playerName, _playerDesc); _player.Inventory.Put(new Item( new String[] {"map" }, "an incomplete map", "This is an incomplete map of......" )); _player.Inventory.Put(new Item( new String[] {"gun", "rifle" }, "a gun", "This is a a long spirally grooved ..." )); Bag _bag = new Bag (new string[]{"Bag", "Backpack"}, "a bag", "This is a bag for...."); Item item1 = new Item( new String[] {"shovel", "spade" }, "a shovel", "This is a might fine ..." ); _bag.Inventory.Put (item1); _player.Inventory.Put (_bag); string _command; string _output; String[] _commandArr; do { Console.WriteLine ("Enter a command or enter 'exit' to exit the game"); _command = Console.ReadLine (); if (_command.ToLower () == "exit") { Console.WriteLine ("Press enter to exit"); Console.ReadLine (); break; } else { _commandArr = ToStringArray (_command); _output = _lookCommand.Execute (_player, _commandArr); Console.WriteLine (_output); } } while (_command.ToLower () != "exit"); }
public static void Main(string[] args) { //Get the player's name and description from the user, and use these details to create a //Player object. //■ Create two items and add them to the the player's inventory //■ Create a bag and add it to the player's inventory //■ Create another item and add it to the bag //■ Loop reading commands from the user, and getting the look command to execute them. Console.WriteLine("Enter Player Name:"); string Name = Console.ReadLine(); Console.WriteLine ("Describe yourself:"); string Desc = Console.ReadLine(); Player GamePlayer = new Player (Name, Desc); Item Sword = new Item (new string[] { "Sword", "broadsword" }, "sword", "a broadsword"); Item Potato = new Item (new string[] { "potato", "baked" }, "baked potato", "a baked potato"); GamePlayer.Inventory.PutItem (Sword); GamePlayer.Inventory.PutItem (Potato); Bag Bag1 = new Bag (new string[] { "Test", "Bag" }, "Test Bag", "A Testing Bag"); GamePlayer.Inventory.PutItem (Bag1); Item Gem = new Item (new string[] { "gem", "Shiny" }, "Gem", "A Shiny Gem"); Bag1.Inventory.PutItem (Gem); Location PotatoFarm = new Location (new string[] { "potato", "farm" }, "potato farm", "a potato farm"); Location MelonFarm = new Location (new string[] { "melon", "farm" }, "melon farm", "a melon farm"); Location TomatoFarm = new Location (new string[] { "tomato", "farm" }, "tomato farm", "a tomato farm"); Path PotatoPath = new Path(new string[] { "potato", "path" }); Path MelonPath = new Path(new string[] { "melon", "path" }); Path TomatoPath = new Path(new string[] { "tomato", "path" }); PotatoFarm.Path = PotatoPath; PotatoPath.SetLocation('w', MelonFarm); PotatoPath.SetLocation('n', TomatoFarm); MelonFarm.Path = MelonPath; MelonPath.SetLocation('e', PotatoFarm); MelonPath.SetLocation('a', TomatoFarm); TomatoFarm.Path = TomatoPath; TomatoPath.SetLocation('s', PotatoFarm); TomatoPath.SetLocation('d', MelonFarm); GamePlayer.Location = PotatoFarm; CommandProcessor MainCommandProcessor = new CommandProcessor(); LookCommand Look = new LookCommand (); MoveCommand Move = new MoveCommand (); MainCommandProcessor.AddCommand (Look); MainCommandProcessor.AddCommand (Move); do { Console.WriteLine("Enter Command:"); string UserInput = Console.ReadLine(); String[] Command = UserInput.Split(' '); Console.WriteLine(MainCommandProcessor.Execute(GamePlayer,Command)); }while(true); }
public void TestBagLocateNothing() { Bag test = new Bag (new string[]{"Bag", "Backpack"}, "a bag", "This is a bag for...."); Assert.AreEqual(test.Locate ("Sth"),null); }
public void TestBagLocateItself() { Bag test = new Bag (new string[]{"Bag", "Backpack"}, "a bag", "This is a bag for...."); Assert.AreEqual(test.Locate ("Bag"),test); }
public static void Main(string[] args) { //Get the player's name and description from the user, and use these details to create a //Player object. //■ Create two items and add them to the the player's inventory //■ Create a bag and add it to the player's inventory //■ Create another item and add it to the bag //■ Loop reading commands from the user, and getting the look command to execute them. Console.WriteLine("Enter Player Name:"); string Name = Console.ReadLine(); Console.WriteLine("Describe yourself:"); string Desc = Console.ReadLine(); Player GamePlayer = new Player(Name, Desc); Item Sword = new Item(new string[] { "Sword", "broadsword" }, "sword", "a broadsword"); Item Potato = new Item(new string[] { "potato", "baked" }, "baked potato", "a baked potato"); GamePlayer.Inventory.PutItem(Sword); GamePlayer.Inventory.PutItem(Potato); Bag Bag1 = new Bag(new string[] { "Test", "Bag" }, "Test Bag", "A Testing Bag"); GamePlayer.Inventory.PutItem(Bag1); Item Gem = new Item(new string[] { "gem", "Shiny" }, "Gem", "A Shiny Gem"); Bag1.Inventory.PutItem(Gem); Location PotatoFarm = new Location(new string[] { "potato", "farm" }, "potato farm", "a potato farm"); Location MelonFarm = new Location(new string[] { "melon", "farm" }, "melon farm", "a melon farm"); Location TomatoFarm = new Location(new string[] { "tomato", "farm" }, "tomato farm", "a tomato farm"); Path PotatoPath = new Path(new string[] { "potato", "path" }); Path MelonPath = new Path(new string[] { "melon", "path" }); Path TomatoPath = new Path(new string[] { "tomato", "path" }); PotatoFarm.Path = PotatoPath; PotatoPath.SetLocation('w', MelonFarm); PotatoPath.SetLocation('n', TomatoFarm); MelonFarm.Path = MelonPath; MelonPath.SetLocation('e', PotatoFarm); MelonPath.SetLocation('a', TomatoFarm); TomatoFarm.Path = TomatoPath; TomatoPath.SetLocation('s', PotatoFarm); TomatoPath.SetLocation('d', MelonFarm); GamePlayer.Location = PotatoFarm; CommandProcessor MainCommandProcessor = new CommandProcessor(); LookCommand Look = new LookCommand(); MoveCommand Move = new MoveCommand(); MainCommandProcessor.AddCommand(Look); MainCommandProcessor.AddCommand(Move); do { Console.WriteLine("Enter Command:"); string UserInput = Console.ReadLine(); String[] Command = UserInput.Split(' '); Console.WriteLine(MainCommandProcessor.Execute(GamePlayer, Command)); }while(true); }
public void TestBagLocatesNothing() { Bag plr = new Bag(new string[] { "bag", "container" }, "Bag", "holds stuff"); Assert.IsNull(plr.Locate("obj1"), "should be null"); }
public void TestBagLocatesItself() { Bag plr = new Bag(new string[] { "bag", "container" }, "Bag", "holds stuff"); Assert.AreEqual(plr.Locate("bag"), plr, "should be equal"); }
public static void Main(string[] args) { // Create List of Locations List <Location> _locations = new List <Location>(); List <Path> _paths = new List <Path>(); List <Item> _items = new List <Item>(); //Item _sword = new Item(new string[] { "sword", "bronze sword" }, "a Sword", "A mighty fine Sword"); //Location _bathroom = new Location("Bathroom", "Room in a house"); //Location _study = new Location("Study", "Study nook"); //Path Hallway = new Path(new string[] { "north", "Hallway in house" }, _bathroom); //Path Corridor = new Path(new string[] { "south", "Corridor leading south" }, _study); //_locations.Add(_bathroom); //_locations.Add(_study); // Create list of Items //Item _shovel = new Item(new string[] { "shovel", "spade" }, "a Shovel", "A Mighty fine Shovel"); // Place Items in locations //_bathroom.Inventory.Put(_sword); //_study.Inventory.Put(_shovel); // Populate Maze PopulateMaze(_locations, _paths, _items); // Print Introduction Console.WriteLine("\n\nWelcome to the C# Adventure Game!"); Console.WriteLine("What is your name?"); // Save the User's input into the string variable called 'name': string _name = Console.ReadLine(); // Print Dialog Console.WriteLine("\nWelcome {0}!", _name); Console.WriteLine("How would you describe yourself?"); // Save the User's input into string _description = Console.ReadLine(); // Create Player Player _player = new Player(_name, _description); _player.Location = _locations[0]; // Create bag and new item, put bag in Player's inventory, put item in bag Bag bag = new Bag(new string[] { "bag", "container" }, "a Bag", "A Container for items"); _player.Inventory.Put(bag); Item computer = new Item(new string[] { "computer", "PC" }, "a Computer", "Small PC for Hacking"); bag.Inventory.Put(computer); Console.WriteLine("\nThere are doors to your left and right."); // Set Variables string command; string[] commandArray = { "Look", "at", "room" }; //LookCommand look = new LookCommand(); CommandProcessor commandProcessor = new CommandProcessor(_locations); // Game Loop while (true) { Console.WriteLine("What would you like to do?"); Console.Write("\nCommand --> "); command = Console.ReadLine(); if (command == "quit") { break; } //commandArray = command.Split(); Console.WriteLine("{0}", commandProcessor.Execute(_player, command)); } }
public void LocateSelfTest() { Bag TestBag = new Bag (new string[] { "Test", "Bag" }, "Test Bag", "A Testing Bag"); Assert.IsTrue (TestBag.Locate ("test") == TestBag); }
public void LocateNullTest() { Bag TestBag = new Bag (new string[] { "Test", "Bag" }, "Test Bag", "A Testing Bag"); Assert.IsTrue (TestBag.Locate ("testfail") == null); }