Published
Edited
Feb 16, 2021
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
class World {
// constructor
constructor(name="UnNamed", size=[10,10]){
this.name = name;
this.type = "World"
this.grid = [];
this.elements = [];
this.id = uuid.v4();
this.pulse = pulse;

for(let i =0; i<size[0]; i++){
this.grid[i]=[]
for(let j =0; j < size[1]; j++){
this.grid[i][j] = "empty space"
}
}
}
//methods
setGridLocation(x,y,desc){
this.grid[x][y] = desc
}
getGridLocation(x,y){
return this.grid[x][y];
}
addElement(ele){
this.elements[this.elements.length] = ele
}
}
Insert cell
class Actor {
// constructor
constructor(name = "Anonymous", hp=100) {
this.name = name;
this.id = uuid.v4()
this.hp = hp;
this.type = "Actor";
this.responses = [
"hello world",
`my name is ${this.name}`,
"I am an Actor",
`My HP is ${this.hp}`,
`My ID is ${this.id}`
]
}
// methods
saySomething(){
console.log("responses:", this.responses)
console.log(this.responses.length)
return `<b>${this.name}</b> says "${this.responses[Math.floor(Math.random() * this.responses.length)]}"`
}

setHp(newVal){
this.hp = newVal;
}
getHp(){
return this.hp;
}
}
Insert cell
class Item {
// constructor
constructor(name="something", weight="10", description="an item"){
this.name = name;
this.type = "Item";
this.weight = weight;
this.description = description;
this.id = uuid.v4()
}
}
Insert cell
class Narrator {
// constructor
constructor(name="Narrator",view="omnicient", focus="self"){
this.name = name;
this.view = view;
this.focus=this;
this.id = uuid.v4();
this.type="Narrator";
}
setFocus(object){
this.focus = object
}
step(){
let response = "Narrator:";
let timestamp = new Date();
response += `at ${timestamp.toDateString()} - [${timestamp.getHours()}:${timestamp.getMinutes()}:${timestamp.getSeconds()}]: The ${this.focus.name} says ${this.focus.responses[Math.floor(Math.random() * this.focus.responses.length)]}`
return response;
}
}
Insert cell
class Scene {
// constructor
constructor(name="Scene1"){
this.type = "Scene";
this.name = name;
this.elements = []
}
add(obj){
this.elements.push(obj)
}
}
Insert cell
class Expression {
// constructor
constructor(name="Statement", intent= "neutral", mode= "statement", content="Hello"){
this.name = name; // pretty name of the expression
this.id = uuid.v4(); // unique id of the expression
this.intent = intent; // intent - positive, neutral, negative
this.type = "Expression"; // type of object
this.mode = mode; // mode - statement, question, command
this.content = content; // text content of the Expression
}
}
Insert cell
Insert cell
uuid = require('uuid@8.3.2/dist/umd/uuid.min.js')
Insert cell
import {rs , pulse} from "@dhowe/rita"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more