public void Handle(string command) { switch (command) { case "Initialize": InitializerHelper ih = new InitializerHelper(); ih.WorldInit(RoomList, ConnectionList); CommandEvent($"*IntroText* {RH.GetCurrentRoomInfo()}"); break; case "getHP": CommandEvent("getHP"); break; case "testDamage": CommandEvent("testDamage"); //commands.testDamage(player); break; case "freePotion": CommandEvent("freePotion"); Potion poti = new Potion(2, "Potion", 6); //commands.AddItem(poti); break; case "freeArmor": CommandEvent("freeArmor"); Armor armor = new Armor(5, "Armor", 4); //commands.AddItem(armor); break; case "freeSword": CommandEvent("freeSword"); Weapon sword = new Weapon(3, "Sword", 3); //commands.AddItem(sword); break; case "testKey": Key testKey = RoomList[new Location(4, 4)].MyObject as Key; playerHelper.AddItem(testKey); CommandEvent("testKey"); break; case "Right": /*string messageR = MH.Move("Right"); * messageR = $"{messageR} {RoomList[player.EntityPosition].Description}"; //OBSOLETE, if all else fails * CommandEvent(messageR);*/ string messageRight = MH.Move("Right"); messageRight = $"{messageRight} {RH.GetCurrentRoomInfo()}"; CommandEvent(messageRight); break; case "Up": /*string messageU = MH.Move("Up"); * messageU = $"{messageU} {RoomList[player.EntityPosition].Description}"; //OBSOLETE, if all else fails * CommandEvent(messageU);*/ string messageUp = MH.Move("Up"); messageUp = $"{messageUp} {RH.GetCurrentRoomInfo()}"; CommandEvent(messageUp); break; case "Left": /*string messageL = MH.Move("Left"); * messageL = $"{messageL} {RoomList[player.EntityPosition].Description}"; //OBSOLETE, if all else fails * CommandEvent(messageL);*/ string messageLeft = MH.Move("Left"); messageLeft = $"{messageLeft} {RH.GetCurrentRoomInfo()}"; CommandEvent(messageLeft); break; case "Down": /*string messageD = MH.Move("Down"); * messageD = $"{messageD} {RoomList[player.EntityPosition].Description}"; //OBSOLETE, if all else fails * CommandEvent(messageD);*/ string messageDown = MH.Move("Down"); messageDown = $"{messageDown} {RH.GetCurrentRoomInfo()}"; CommandEvent(messageDown); break; case "OpenLeft": string messageOpenLeft = OH.OpenTheRoom(ConnectionList[new ConnectionLocation(RoomList[player.EntityPosition], RoomList[playerHelper.GetLeftLocation()])]); CommandEvent(messageOpenLeft); break; case "OpenUp": string messageOpenUp = OH.OpenTheRoom(ConnectionList[new ConnectionLocation(RoomList[player.EntityPosition], RoomList[playerHelper.GetUpLocation()])]); CommandEvent(messageOpenUp); break; case "OpenRight": string messageOpenRight = OH.OpenTheRoom(ConnectionList[new ConnectionLocation(RoomList[player.EntityPosition], RoomList[playerHelper.GetRightLocation()])]); CommandEvent(messageOpenRight); break; case "OpenDown": string messageOpenDown = OH.OpenTheRoom(ConnectionList[new ConnectionLocation(RoomList[player.EntityPosition], RoomList[playerHelper.GetDownLocation()])]); CommandEvent(messageOpenDown); break; default: CommandEvent("UnknownCommand"); break; } }
public string GetCurrentRoomInfo() { string message = roomList[player.EntityPosition]?.Description; if (roomList[player.EntityPosition].MyObject != null) { message += $" This place contains a/an {roomList[player.EntityPosition].MyObject.ObjName}."; } try { if (roomList[PH.GetLeftLocation()] != null) { var leftConnection = connectionList[new ConnectionLocation(roomList[player.EntityPosition], roomList[PH.GetLeftLocation()])]; if (leftConnection != null) { if (leftConnection.IsOpen) { message += $" There is a/an {roomList[PH.GetLeftLocation()].RoomName} to your left"; } else { message += $" There is a/an {leftConnection.ConnectionName} is in your left, that you may open with a/an {leftConnection.OpeningKey}"; } } } if (roomList[PH.GetUpLocation()] != null) { var upConnection = connectionList[new ConnectionLocation(roomList[player.EntityPosition], roomList[PH.GetUpLocation()])]; if (upConnection != null) { if (upConnection.IsOpen) { message += $" There is a/an {roomList[PH.GetUpLocation()].RoomName} to your left"; } else { message += $" There is a/an {upConnection.ConnectionName} is in your left, that you may open with a/an {upConnection.OpeningKey}"; } } } if (roomList[PH.GetRightLocation()] != null) { var rightConnection = connectionList[new ConnectionLocation(roomList[player.EntityPosition], roomList[PH.GetRightLocation()])]; if (rightConnection != null) { if (rightConnection.IsOpen) { message += $" There is a/an {roomList[PH.GetRightLocation()].RoomName} to your left"; } else { message += $" There is a/an {rightConnection.ConnectionName} is in your left, that you may open with a/an {rightConnection.OpeningKey}"; } } } if (roomList[PH.GetDownLocation()] != null) { var downConnection = connectionList[new ConnectionLocation(roomList[player.EntityPosition], roomList[PH.GetDownLocation()])]; if (downConnection != null) { if (downConnection.IsOpen) { message += $" There is a/an {roomList[PH.GetDownLocation()].RoomName} to your left"; } else { message += $" There is a/an {downConnection.ConnectionName} is in your left, that you may open with a/an {downConnection.OpeningKey}"; } } } } catch (System.Exception) { } return(message); }