public PrintInstructions PrintInstructions(string banner, string spaces = " ") { PrintInstructions result = new PrintInstructions(); int row, col, rowOffset, colOffset; RoomPosition position; char c; for (row = 0; row < 3; row++) { result.NewLine(spaces); for (col = 0; col < 7; col++) { c = RoomsTemplate[row][col]; position = RoomPosition.One; // rowOffset = 0; // colOffset = 0; result.Add(DeligateMap[c](c, row, col, position)); } for (col = 7; col < 13; col++) { c = RoomsTemplate[row][col]; position = RoomPosition.Two; // rowOffset = 0; colOffset = 6; result.Add(DeligateMap[c](c, row, col - colOffset, position)); } } for (row = 3; row < 5; row++) { result.NewLine(spaces); for (col = 0; col < 7; col++) { c = RoomsTemplate[row][col]; position = RoomPosition.Three; rowOffset = 2; // colOffset = 0; result.Add(DeligateMap[c](c, row - rowOffset, col, position)); } for (col = 7; col < 13; col++) { c = RoomsTemplate[row][col]; position = RoomPosition.Four; rowOffset = 2; colOffset = 6; result.Add(DeligateMap[c](c, row - rowOffset, col - colOffset, position)); } } return(result); }
public MoveResults MoveResults(Direction direction) { MoveResults result = new MoveResults(); PrintInstructions pi = result.PrintInstructions; result.Success = false; result.DoorState = DoorState(direction); switch (result.DoorState) { case Types.DoorState.Locked: case Types.DoorState.Sealed: break; case Types.DoorState.Open: result.Success = true; break; } pi.NewLine("The ") .Add($"{direction}", GetDoorColor(CurrentRoomPosition, direction)); if (result.Success) { pi.Add($" door was {result.DoorState}"); } else { pi.Add($" door is {result.DoorState}"); } return(result); }
public PrintInstructions MergedDescription() { PrintInstructions result = new PrintInstructions(); if (FullyMerged()) { result.NewLine("Woah! WHAT IS GOING ON???"); result.NewLine("The transdimensional waves have aligned!"); result.NewLine("You are experiencing the ") .Add(RoomInfo[RoomIdentifier.A].Character.ToString(), RoomColors[RoomIdentifier.A]) .Add(RoomInfo[RoomIdentifier.D].Character.ToString(), RoomColors[RoomIdentifier.D]) .Add(RoomInfo[RoomIdentifier.C].Character.ToString(), RoomColors[RoomIdentifier.C]) .Add(RoomInfo[RoomIdentifier.B].Character.ToString(), RoomColors[RoomIdentifier.B]) .Add(" intermodultion... Noice!"); result.NewLine(); } return(result); }
public void SetPrintInstructions(PrintInstructions instructions = null) { PrintInstructions = _rooms.PrintInstructions(""); Calculator calc = _game.CurrentPlayer.Inventory.Find(item => { return(item is Calculator); }) as Calculator; if (calc != null) { if (calc.On) { PrintInstructions.NewLine(); PrintInstructions.AddInstructions(calc.Display); } } if (instructions != null) { PrintInstructions.NewLine(); PrintInstructions.AddInstructions(instructions); } }
internal void Unlock(string option) { PrintInstructions pi = new PrintInstructions(); string[] options = option.Trim().Split(" "); string direction; string noun; if (options[0] == "") { pi.Add("What did you want to unlock?", ConsoleColor.Blue); SetPrintInstructions(pi); return; } if (options.Length < 2) { direction = options[0]; noun = ""; } else { direction = options[0]; noun = options[1]; } Noun nounEnum; Direction directionEnum; // Check for direction if (Enum.TryParse(_textInfo.ToTitleCase(direction), out directionEnum)) { // Check the noun if (Enum.TryParse(_textInfo.ToTitleCase(noun), out nounEnum)) { switch (nounEnum) { case Noun.Door: // They have given us a valid direction and "Door" if (_rooms.Lock.DoorIsLocked(_rooms.CurrentRoomPosition, directionEnum)) { UnlockDoor(); return; // Ok This door is locked } else { pi.Add($"The {directionEnum} is not locked", ConsoleColor.Blue); SetPrintInstructions(pi); return; } default: // We dont have anything else to unlock at this direction pi.Add($"There is no {directionEnum} {nounEnum} to Unlock"); SetPrintInstructions(pi); return; } } // We were given a valid direction but an invalid noun pi.Add($"There is no {directionEnum} {noun} to Unlock"); SetPrintInstructions(pi); return; } else if (Enum.TryParse(_textInfo.ToTitleCase(direction), out nounEnum)) // Check for a noun in the direction place { switch (nounEnum) { case Noun.Door: // Which door??? pi.Add($"Which {nounEnum} did you want to unlock?", ConsoleColor.Blue); pi.NewLine($"Did you mean 'unlock [north|east|south|west] door'?", ConsoleColor.Blue); SetPrintInstructions(pi); return; case Noun.Calculator: // The calculator is unlocked... if (PlayerHasItem(noun.ToLower())) { pi.Add("The calculator is unlocked", ConsoleColor.DarkGreen); SetPrintInstructions(pi); return; } else { pi.Add("You don't have a calculator to unlock", ConsoleColor.DarkRed); SetPrintInstructions(pi); return; } default: pi.Add($"There is no '{noun}' to unlock", ConsoleColor.DarkRed); SetPrintInstructions(pi); return; } } else { // We were given an unknown noun and direction pi.Add($"There is no '{option}' to unlock", ConsoleColor.DarkRed); SetPrintInstructions(pi); return; } }
private void UnlockDoor() { bool trying = true; KeyPadLock kpl = _rooms.CurrentRoom.FindItem(KeyPadLock.KeyPadName) as KeyPadLock; string msg = ""; while (trying) { // Print Title // Print Rooms // Print KeyPad Console.Clear(); Log log = new Log(); PrintInstructions calcPrintInstructions = null; // Print Title Program.TitleController.DrawHeader(); // Print Rooms _rooms.PrintInstructions("").Lines.ForEach(line => { line.Instructions.ForEach(instruction => { log.Add(instruction.Text, instruction.Foreground, instruction.Background); }); log.Print(); }); Calculator calc = _game.CurrentPlayer.Inventory.Find(item => { return(item is Calculator); }) as Calculator; if (calc != null) { if (calc.On) { calcPrintInstructions = calc.Display; } } PrintInstructions unlockInstructions = new PrintInstructions().AddInstructions(kpl.Display); if (calcPrintInstructions != null) { unlockInstructions.RightJoin(calcPrintInstructions); } unlockInstructions.NewLine(msg, ConsoleColor.DarkRed); unlockInstructions.Lines.ForEach(line => { line.Instructions.ForEach(instruction => { log.Add(instruction.Text, instruction.Foreground, instruction.Background); }); log.Print(); }); log.NewLine(); log.Add("Enter the "); log.Add("code", ConsoleColor.DarkRed); log.Add(" to unlock the door (type 'quit' to stop trying)"); log.Print(); string userInput = Console.ReadLine(); if (userInput.ToLower().Trim() == "quit") { SetPrintInstructions(new PrintInstructions("You couldn't unlock the door", ConsoleColor.DarkRed)); return; } if (userInput == "use calculator") { SetCalculator(true); continue; } try { int numVal = Int32.Parse(userInput.Substring(0, 5)); bool unlocked = kpl.Unlock(numVal); if (unlocked) { Classes.Lock lk = _rooms.Lock; calcPrintInstructions = new PrintInstructions(); calcPrintInstructions.NewLine("You Unlocked the ") .Add($"{lk.KeyPadDoorDirection}", _rooms.GetDoorColor(lk.KeyPadRoomPosition, lk.KeyPadDoorDirection)) .Add(" DOOR!!!"); calcPrintInstructions.NewLine("NICE JOB!!!", ConsoleColor.Green); lk.Unlock(); return; } else { msg = $" '{userInput}' does not unlock the door. Good try though."; } } catch (FormatException e) { msg = $" '{userInput}' does not unlock the door"; } } }
public PrintInstructions GetRoomDescription() { PrintInstructions result = new PrintInstructions(); result.NewLine("You are in the ") .Add(RoomInfo[CurrentRoom.Id].Name, CurrentRoom.Color) .Add($" ({RoomInfo[CurrentRoom.Id].Character}) Room"); result.NewLine(); result.NewLine("Exits:"); ConsoleColor northDoor = GetDoorColor(CurrentRoomPosition, Direction.North); ConsoleColor eastDoor = GetDoorColor(CurrentRoomPosition, Direction.East); ConsoleColor southDoor = GetDoorColor(CurrentRoomPosition, Direction.South); ConsoleColor westDoor = GetDoorColor(CurrentRoomPosition, Direction.West); result.NewLine($" {northDoor}", northDoor).Add(" door to the North"); result.NewLine($" {eastDoor}", eastDoor).Add(" door to the East"); result.NewLine($" {southDoor}", southDoor).Add(" door to the South"); result.NewLine($" {westDoor}", westDoor).Add(" door to the West"); result.NewLine(); if (CurrentRoom.Items.Count == 0) { result.NewLine("The Room is empty"); } else { result.NewLine("Items in the room"); CurrentRoom.Items.ForEach(item => { result.NewLine(" ").Add(item.ItemDescription); }); } return(result); }