public void ToStringMethodReturnsText() { var value = "Hello World!"; var displayTextLine = new DisplayTextLine(value); Assert.Equal(value, displayTextLine.ToString()); }
public void CanInstantiateWithString() { var value = "Hello World!"; var displayTextLine = new DisplayTextLine(value); Assert.Equal(value, displayTextLine.Text); }
public void CanInstantiateWithStringAndColor() { var value = "Hello World!"; ConsoleColor color = ConsoleColor.Blue; var displayTextLine = new DisplayTextLine(value, color); Assert.Equal(value, displayTextLine.Text); Assert.Equal(color, displayTextLine.Color); }
public void CanInstantiateWithDisplayTextLineAndEnumerateOverValues() { var value = "Hello World!"; var displayTextLine = new DisplayTextLine(value); var displayText = new DisplayText(displayTextLine); foreach (var line in displayText) { Assert.Equal(value, line.ToString()); } }
/// <summary> /// Returns a DisplayText object with a list of Items in the Location /// </summary> /// <returns>a DisplayText object</returns> private DisplayText GetListOfItemsDisplay() { //get list of items in room var itemListDisplayText = new DisplayText(); foreach (var item in Items) { var itemDisplayTextLine = new DisplayTextLine(item.Name + " is here"); itemListDisplayText.Add(itemDisplayTextLine); } return(itemListDisplayText); }
//////////////////////////////////////////////////////////////////////////////////////// // PRIVATE METHODS //////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Returns a DisplayText object with a list of Actors in the Location /// </summary> /// <returns>a DisplayText object</returns> private DisplayText GetListOfActorsDisplay() { //get list of npcs in room var npcListDisplayText = new DisplayText(); foreach (var person in Actors) { //var personDisplayTextLine = new DisplayTextLine(person.Name + " is here"); //npcListDisplayText.Add(personDisplayTextLine); var personDisplayTextLine = new DisplayTextLine(TextStringManager.GetGeneralTextString(GeneralTextStrings.ActorIsHere, person).ToString()); npcListDisplayText.Add(personDisplayTextLine); } return(npcListDisplayText); }
/// <summary> /// Executes Inventory command and returns appropriate DisplayText to caller /// </summary> /// <returns>a DisplayText object</returns> public override DisplayText ShowInventory() { var inventoryDisplayText = new DisplayText(); var inventoryDisplayTextLine = new DisplayTextLine(); if (Inventory.Count < 1) { inventoryDisplayTextLine.Add(TextStringManager.GetCommandTextString(CommandTextStrings.InventoryEmpty, this).ToString()); } else if (Inventory.Count == 1) { inventoryDisplayTextLine.Add(TextStringManager.GetCommandTextString(CommandTextStrings.ShowInventory, this) + Inventory[0].Name + "."); } else { inventoryDisplayTextLine.Add(TextStringManager.GetCommandTextString(CommandTextStrings.ShowInventory, this).ToString()); var index = 0; foreach (var item in Inventory) { if (index == Inventory.Count - 1) { inventoryDisplayTextLine.Add(item.Name + "."); } else { inventoryDisplayTextLine.Add(item.Name + ", "); } index++; } } inventoryDisplayText.Add(inventoryDisplayTextLine); //now show equiped items inventoryDisplayText.Add("Your equiped items: (head) " + (EquipSlotHead != null ? EquipSlotHead.Name : "Empty") + ", " + "(main weapon) " + (EquipSlotMainWeapon != null ? EquipSlotMainWeapon.Name : "Empty") + ", " + "(body) " + (EquipSlotBody != null ? EquipSlotBody.Name : "Empty") + ", " + "(hands) " + (EquipSlotHands != null ? EquipSlotHands.Name : "Empty") + ", " + "(feet) " + (EquipSlotFeet != null ? EquipSlotFeet.Name : "Empty")); return(inventoryDisplayText); }
public override void WriteDisplayTextLine(DisplayTextLine line) { Out = line.Text; }
public override void WriteDisplayTextLine(DisplayTextLine line) { Console.ForegroundColor = line.Color; WriteDisplayTextLine(line.Text); Console.ForegroundColor = DEFAULT_TEXT_COLOR; }
public abstract void WriteDisplayTextLine(DisplayTextLine line);