RPG Library: User Interface - ThePix/QuestJS GitHub Wiki

Authors can, of course, set this up however they like, but I envisage two modes, with the player able to choose which they prefer.

Classic Interface

This is the usual text input. Commands that will hopefully be supported include:

EQUIP SWORD
ATTACK ORC
CAST DARKNESS
CAST SHOCKBOLT AT GOBLIN

ENCHANT SWORD
BREW POTION OF MIGHT

BANISH DEMON
REPEL ZOMBIE

Supporting the classic interface is important for visually-impaired users; this is an area where text adventurers excel, so we should make the most of it.

It is also easy to unit test.

Graphical User Interface

In this mode the player will do everything with the mouse. The current weapon is displayed at the top right, and clicking on it allows another weapon to be selected. Click an enemy on the left, then select "Attack" to attack it with that weapon.

Skills and spells can also be selected on the right.

You can give the player a pack, simply with:

settings.storage = true

Items that are held will now have an additional "Stow", which will move them into a fake location called "_storage". The user can click on a suitcase icon (replacing the help button on the compass rose), to get a list of items, and can select one or more to retrieve from storage.

You can stop individual items going into storage by giving them a "testStow" function. They can also have "msgStow" strings too. Corresponding attributes for retrieving do not get used; if the player can put it in the pack, she can take it out again. You can set "player.unableToRetrieveFromStorage" to a string to stop the player removing anything at all. The string should be a message explaining why.

player.unableToRetrieveFromStorage = "You can't get anything from your pack whilst enveloped by a chaos blob!"

This system can be used with the command line, with STOW and RETRIEVE commands, though you are probably better using containers as usual.