I'm exploring how to create a text-based game, and I was tinkering around with moving between rooms. I have this part down and a very elaborate map created where you can type, "go north" etc. The only thing is that the game is very dry, and I wanted to incorporate items. To make the rooms I did this:
var rooms = {
"room0":{
"description": "description here",
"directions":{
"direction": "newRoom"
}
}
}
So, I was thinking if I made a separate element called "items" and then list the items in that room, the way I did with "directions". I wrote this code to add items to the player inventory:
function grabItem(item){
if(inventory.length < 12 && rooms[currentRoom].items[item] !== undefined) {
inventory.append(item);
//INSERT CODE HERE TO REMOVE THE ITEM FROM THE ROOM
}
}
SO! The big question is, what method can I use to remove an individual item?