First cut at turning lists into typed variables

This commit is contained in:
Karishma Chadha 2017-11-09 17:19:34 -05:00
parent a735459427
commit 70959cc7f5
9 changed files with 55 additions and 80 deletions
src/engine

View file

@ -9,19 +9,27 @@ class Variable {
/**
* @param {string} id Id of the variable.
* @param {string} name Name of the variable.
* @param {(string|number)} value Value of the variable.
* @param {(string|number)} type Type of the variable, one of "" or "list"
* @param {boolean} isCloud Whether the variable is stored in the cloud.
* @constructor
*/
constructor (id, name, value, isCloud) {
constructor (id, name, type, isCloud) {
this.id = id || uid();
this.name = name;
this.value = value;
this.type = type;
this.isCloud = isCloud;
switch (this.type) {
case "":
this.value = 0;
break;
case "list":
this.value = [];
break;
}
}
toXML () {
return `<variable type="" id="${this.id}">${this.name}</variable>`;
return `<variable type="${this.type}" id="${this.id}">${this.name}</variable>`;
}
}