Things to pick up and use
Currently the adventure world is rather dull. Besides the rooms, there is nothing to see.
So we need to add some items for our adventurers to pick up, examine, use or give to other people.
For this we will need a tables.
This will contain the details of the item, plus whether it is in someone's possession or is in a particular room.
So the table will contain the following fields.
- item ID - an auto increment integer to identify the item
- item Name - a 20 character string for the name of the item
- item description - a 100 character string for the item description
- value - integer to hold the value in gold pieces
- room ID - integer Null foreign key on rooms.roomID
- character ID - integer Null foreign key on charcater.characterID
So to create the table:
CREATE TABLE items
(
itemID INT NOT NULL AUTO_INCREMENT,
itemName VARCHAR(20) NOT NULL,
itemDescription VARCHAR(100) NOT NULL,
itemValue INT NOT NULL,
itemRoomID INT NULL,
itemCharacterID INT NULL,
FOREIGN KEY (itemRoomID) REFERENCES rooms(roomID),
FOREIGN KEY (itemCharacterID ) REFERENCES characters(characterID),
PRIMARY KEY (itemID)
);
Add two items, both in room 1 (the kitchen).
insert into items(itemName,itemDescription,itemValue,itemRoomID) values ('Rolling Pin','a flour covered rolling pin',1,1);
insert into items(itemName,itemDescription,itemValue,itemRoomID) values ('Bag of Rice','a paper bag full of rice',1,1);
Then add an item in the first characters pocket.
insert into items(itemName,itemDescription,itemValue,itemCharacterID) values ('Handkerchief','a handkerchief',1,1);