2014-11-20 20:46:51 +01:00
|
|
|
/**
|
|
|
|
* Created by knut on 14-11-19.
|
|
|
|
*/
|
|
|
|
var actors = {};
|
2014-11-24 22:03:32 +01:00
|
|
|
var actorKeys = [];
|
2014-11-20 20:46:51 +01:00
|
|
|
var messages = [];
|
2014-12-04 17:58:05 +01:00
|
|
|
var notes = [];
|
2014-11-20 20:46:51 +01:00
|
|
|
exports.addActor = function(id,name,description){
|
2014-11-27 18:21:15 +01:00
|
|
|
//console.log('Adding actor: '+id);
|
2014-11-20 20:46:51 +01:00
|
|
|
actors[id] = {name:name, description:description};
|
2014-11-24 22:03:32 +01:00
|
|
|
actorKeys.push(id);
|
2014-11-20 20:46:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.addMessage = function(idFrom, idTo, message, answer){
|
|
|
|
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
|
|
|
|
messages.push({from:idFrom, to:idTo, message:message, answer:answer});
|
|
|
|
};
|
|
|
|
|
2014-12-04 17:58:05 +01:00
|
|
|
exports.addSignal = function(idFrom, idTo, message, messageType){
|
|
|
|
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
|
|
|
|
messages.push({from:idFrom, to:idTo, message:message, type:messageType});
|
|
|
|
};
|
|
|
|
|
2014-11-20 20:46:51 +01:00
|
|
|
exports.getMessages = function(){
|
|
|
|
return messages;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.getActors = function(){
|
|
|
|
return actors;
|
|
|
|
};
|
2014-12-04 17:58:05 +01:00
|
|
|
exports.getActor = function(id){
|
|
|
|
return actors[id];
|
|
|
|
};
|
2014-11-24 22:03:32 +01:00
|
|
|
exports.getActorKeys = function(){
|
2014-12-04 17:58:05 +01:00
|
|
|
return Object.keys(actors);
|
2014-11-24 22:03:32 +01:00
|
|
|
};
|
|
|
|
|
2014-11-20 20:46:51 +01:00
|
|
|
exports.clear = function(){
|
|
|
|
actors = {};
|
|
|
|
messages = [];
|
2014-12-04 17:58:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.LINETYPE = {
|
|
|
|
SOLID : 0,
|
2014-12-14 19:13:04 +01:00
|
|
|
DOTTED : 1,
|
|
|
|
NOTE : 2
|
2014-12-04 17:58:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.ARROWTYPE = {
|
|
|
|
FILLED : 0,
|
|
|
|
OPEN : 1
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.PLACEMENT = {
|
|
|
|
LEFTOF : 0,
|
|
|
|
RIGHTOF : 1,
|
|
|
|
OVER : 2
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.addNote = function (actor, placement, message){
|
|
|
|
var note = {actor:actor, placement: placement, message:message};
|
|
|
|
|
|
|
|
notes.push(note);
|
2014-12-16 20:12:24 +01:00
|
|
|
messages.push({from:actor, to:actor, message:message, type:exports.LINETYPE.NOTE, placement: placement});
|
2014-12-04 17:58:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
exports.parseError = function(err, hash) {
|
|
|
|
console.log('Syntax error:' + err);
|
2014-11-20 20:46:51 +01:00
|
|
|
};
|