Created
October 14, 2013 23:58
-
-
Save goblinHordes/6984389 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// establish ActiveObject namespace | |
var ActiveObjects = ActiveObjects || {} | |
// create namespace shortcut | |
AO = ActiveObjects; | |
/* | |
ActiveObjects.Object - adds persistent state storage to R20 objects | |
@param {id} ID of Roll20 object. | |
*/ | |
AO.Object = function (state){ | |
var state = state || this.loadState(); | |
} | |
AO.Object.prototype.loadState = function (){} | |
AO.Object.prototype.saveState = function (){} | |
/* | |
ActiveObjects.ActiveObject - a virtual composite base object that includes state and | |
functionality. ActiveObject should be used as a parent prototype for real ActiveObjects | |
@param {} | |
*/ | |
AO.ActiveObject = function (state){ | |
var state = state || this.loadState(); | |
var objStore = objStore || {}; | |
} | |
AO.ActiveObject.prototype.loadState = function (){ | |
return this.defaultState || {}; | |
} | |
AO.Object.prototype.saveState = function (){} | |
AO.ActiveObject.prototype.getState = function (){ | |
return this.defaultState; | |
} | |
/* | |
ActiveObjects.ActiveDoor - an ActiveObject to control doors | |
*/ | |
AO.ActiveDoor = function (state){} | |
AO.ActiveDoor.prototype = new AO.ActiveObject(); | |
AO.ActiveDoor.prototype.constructor = AO.ActiveDoor; | |
AO.ActiveDoor.prototype.closeDoor = function (){} | |
AO.ActiveDoor.prototype.defaultState = { | |
type: this.type, | |
position: "open", | |
is_locked: false, | |
objStore: { | |
tokCommand: undefined, | |
objState: { | |
open: {}, | |
closed: {}, | |
locked: {}, | |
unlocked: {} | |
} | |
} | |
} | |
AO.ActiveDoor.prototype.openDoor = function (){ | |
if(!this.getState('locked')){ | |
//transitionObjects(oldState, newState); | |
} else { | |
// handle locked door | |
} | |
} | |
AO.ActiveDoor.prototype.toggleDoor = function (){ | |
if(this.getState('position') == 'open'){ | |
closeDoor(); | |
} else { | |
openDoor(); | |
} | |
} | |
ad = new AO.ActiveDoor(); | |
console.log(Object.keys(ad.getState())[0]); | |
//*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment