Core Functions Home
BADAM has a turn counter variable to keep track of turns.
The badengine.js file provides functions which can be used to manipulate various game elements. This is being used by the presentation javascript file (implement.js) to run the game and handle the UI.
By making use of this library, it is possible to create a new presentation of BADAM games.
Library Functions Documentation
getObjById(objArray array, id string) - Returns object identified by string id from the array of objects, objArray. Returns null if object is not found. It can be used against almost all elements - scenes, objects, events etc.
openDoor(door string) - Opens door identified by door. Returns true if door has been opened. Returns false if there is no such door. On success connects scenes/doors provided in connects field of the door.
getKeys(door string) - Gets array of keys identifiers associated with the door
unlock(door string, key string) - Unlocks door with key. Returns true on success. Returns false if key is not part of the door's key list, or the door does not have any keys.
getAvailKeys(door string) - Get all available keys with the player for the door identified by door.
useKey(door string, key string) - Uses unlock function to unlock the door with the key and removes the key from inventory. Returns true if success. Returns false if unlock fails.
getSceneObjs(scene string) - Get the list of objects from current scene. Returns list of object identifiers from the scene identified by scene.
addExit(exit string) - Adds exit identified by exit to current scene.
addEvent(ev string) - Start an event. Adds event ev to the current list of events evnt.
removeEvent(ev string) - Stop an ongoing event. Removes event ev from the current list of events evnt.
addObjToScene(ob string) - Add an object to the current scene. Add the object identifer ob to objects array of the current scene.
remObjFromScene(ob string) - Removes an object from the current scene. Remove the object identifer ob from objects array of the current scene.
selectObject(ob string) - Invoked to select the object ob by the player. It adds ob to the inventory and runs the behaviour script in code field of the object. It also removes ob from the scene.
combineObjects(obj1 string, obj2 string) - Invoked when one object interacts with another. Consults workswith field of obj1 to determine interaction results with obj2. Returns workswith object which contains the message to be displayed and script to be run.
getObjTitle(ob string) - Returns title of ob
getObjTitle(ob string) - Returns msg of ob. Otherwise returns titlenof ob.
getHealthLabel() - Returns label related to current health status of the player.