From 90d7fe9a810eff6dfefbb192bc24edd887c1ff53 Mon Sep 17 00:00:00 2001 From: Talon Date: Thu, 4 Nov 2021 23:55:56 +0100 Subject: [PATCH] Add game ticks --- app_web/game.js | 4 ++-- src/engine/builders/item.js | 5 +++++ src/engine/index.js | 17 +++++++++++++++++ src/engine/item.js | 9 +++++++++ src/engine/room.js | 4 ++++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/app_web/game.js b/app_web/game.js index 0020963..421b24a 100644 --- a/app_web/game.js +++ b/app_web/game.js @@ -1,2 +1,2 @@ -(()=>{"use strict";const t=new class{constructor(){this.states=new Map}get(t){return this.states.get(t)}set(t,e){return this.states.set(t,e)}};class e{constructor(){this.inventory=[],this.currentRoom="start"}}class i{speak(t){}stop(){}setOptions(t){}}class s extends i{constructor(t={}){super(),this.timeout=100,this.timeout=t.timeout||100,this.init()}init(){this.container=document.createElement("div"),this.container.setAttribute("aria-live","polite"),this.speechDisplay=document.createElement("div"),this.speechDisplay.setAttribute("aria-live","polite"),this.container.append(this.speechDisplay),document.body.appendChild(this.container),document.body.insertBefore(this.container,document.body.firstChild)}speak(t){this.clearDisplay();const e=document.createTextNode(t),i=document.createElement("p");i.appendChild(e),this.speechDisplay.appendChild(i),setTimeout(this.clearDisplay.bind(this),this.timeout)}stop(){this.clearDisplay()}clearDisplay(){this.speechDisplay.innerHTML=""}}class n extends i{}class o{constructor(t=function(t="aria"){return"webtts"===t?n:s}()){this.output=t}speak(t){this.output.speak(t)}stop(){this.output.stop()}}class a{constructor(){this.tts=new o(new s),this.history=document.getElementById("output-area")}say(t){const e=document.createElement("p");e.appendChild(document.createTextNode(t)),this.history.appendChild(e)}}class r{constructor(t){this.handler=t,this.inputField=document.getElementById("input-area"),this.init()}init(){this.inputField.addEventListener("keydown",(t=>{if(13==t.which){const t=this.inputField.value;this.inputField.value="",this.handler.doCommand(t)}}))}}const h=[[["look","l"],function(t,e){if(1==t.length)e.examineRoom();else{const i=e.getRoom(e.player.currentRoom).getItems();let s=null;for(let e of i)if(e.name.includes(t[1])){s=e;break}s?(e.output.say(s.name),e.output.say(s.description)):e.output.say(`I could not find a ${t[1]}`)}}],[["use","interact"],async function(t,e){const i=e.getRoom(e.player.currentRoom).getItems();let s=null;for(let e of i)if(e.name.includes(t[1])){s=e;break}s?await s.onUse():e.output.say(`I could not find a ${t[1]}`)}]],c=[["n","north"],["ne","northeast"],["e","east"],["se","southeast"],["s","south"],["sw","southwest"],["w","west"],["nw","northwest"],["u","up"],["d","down"]];class l{constructor(t,e){this.context=t,this.commands=e||new Map,this.enabled=!0,this.addDefaultCommands()}doCommand(t){if(!this.enabled)return void this.context.print("You can't seem to do anything at the moment.");const e=this.context.getRoom(this.context.player.currentRoom),i=t.split(" ");this.commands.get(i[0])&&this.commands.get(i[0])(i,this.context);const s=this.matchDirection(i[0]);e.getExit(s)&&this.context.move(e.getExit(s))}addCommand(t,e){Array.isArray(t)?t.forEach((t=>this.commands.set(t,e))):this.commands.set(t,e)}addCommands(t){t.forEach((t=>{this.addCommand(t[0],t[1])}))}addDefaultCommands(){this.addCommands(h)}matchDirection(t){for(let e of c)if(e[0]==t)return e[1]}}class u{constructor(){this.id="room",this.title="A room",this.description="You see nothing special",this.firstDescription="As you walk into the room, you notice nothing special",this.objects=[],this.exits=new Map,this.enterCallback=null,this.exitCallback=null,this.canEnterLogic=null,this.canExitLogic=null,this.tickCallback=null,this.context=null}async onEnter(){if(this.enterCallback)return this.enterCallback(this.context)}async onExit(){if(this.exitCallback)return this.exitCallback(this.context)}canEnter(){return!this.canEnterLogic||this.canEnterLogic(this.context)}canExit(){return!this.canExitLogic||this.canExitLogic(this.context)}addExit(t,e){return this.exits.set(t,e),this}getExit(t){return this.exits.get(t)}addItem(t){this.objects.push(t)}addEnterCallback(t){this.enterCallback=t}addExitCallback(t){this.exitCallback=t}addEnterLogic(t){this.canEnterLogic=t}addExitLogic(t){this.canExitLogic=t}addTickCallback(t){this.tickCallback=t}getItems(){return this.objects.map((t=>this.context.getItem(t)))}}class m{constructor(){this.room=new u}withID(t){return this.room.id=t,this}withTitle(t){return this.room.title=t,this}withFirstDescription(t){return this.room.firstDescription=t,this}withDescription(t){return this.room.description=t,this}withExit(t,e){return this.room.addExit(t,e),this}withItem(t){return this.room.addItem(t),this}withEnterCallback(t){return this.room.addEnterCallback(t),this}withExitCallback(t){return this.room.addExitCallback(t),this}withEnterLogic(t){return this.room.addEnterLogic(t),this}withExitLogic(t){return this.room.addExitLogic(t),this}withTick(t){return this.room.addTickCallback(t),this}create(){return this.room}}const d=[(new m).withID("start").withTitle("The starting room").withFirstDescription("You set foot in your very first room").withDescription("The first room. Nothing special about it.").withExit("north","tunnel_1").withEnterCallback((async function(t){const{output:e,wait:i}=t;t.enableCommandInput(!1),e.say("You slowly wake up"),await i(5e3),e.say("It's strange. You never used to be able to be conscious about the fact that you were waking up."),await i(5e3),e.say("Yet here we are."),t.enableCommandInput(!0)})).withItem("stone").create(),(new m).withID("tunnel_1").withTitle("A long dark tunnel").withFirstDescription("You first step foot in this dark loomy tunnel.").withDescription("The walls are wet. Everything is wet. Ugh. Why do you even.").withExit("south","start").create()];class p{constructor(){this.id="item",this.name="An item",this.description="You see nothing special about this item",this.usable=!0,this.takeable=!0,this.useCallback=null,this.takeCallback=null,this.context=null}async onUse(){if(this.useCallback)return this.useCallback(this.context)}async onTake(){if(this.takeCallback)return this.takeCallback()}}const w=[(new class{constructor(){this.item=new p}withID(t){return this.item.id=t,this}withName(t){return this.item.name=t,this}withDescription(t){return this.item.description=t,this}isUsable(t){return this.item.usable=t,this}isTakeable(t){return this.item.takeable=t,this}withUseCallback(t){return this.item.useCallback=t,this}withTakeCallback(t){return this.item.takeCallback=t,this}create(){return this.item}}).withID("stone").withName("A dull stone").withDescription("There is nothing remarkable about this rough, bland stone.").isTakeable(!0).isUsable(!0).withTakeCallback((async function(t){t.output.say("It feels heavy in your hands.")})).withUseCallback((async function(t){t.output.say("You can't really figure out what to do with this yet.")})).create()];(new class{constructor(){this.player=new e,this.state=t,this.rooms=[],this.items=[],this.output=new a,this.commandHandler=new l(this),this.input=new r(this.commandHandler),this.visitedRooms=new Map}print(t){this.output.say(t)}init(t){console.log(t),this.rooms=t.rooms.map((t=>(t.context=this,t))),this.items=t.items.map((t=>(t.context=this,t))),this.state=t.state,this.commandHandler.addCommands(t.commands),this.player=new e,this.move(this.player.currentRoom)}examineRoom(){const t=this.getRoom(this.player.currentRoom);this.output.say(t.title),this.visitedRooms.get(this.player.currentRoom)||""==t.firstDescription?this.output.say(t.description):this.output.say(t.firstDescription),this.examineItems(),this.examineExits()}examineItems(){this.getRoom(this.player.currentRoom).getItems().forEach((t=>this.output.say(t.name)))}examineExits(){const t=this.getRoom(this.player.currentRoom);let e="You can go ";for(let i of t.exits.keys())e+=" "+i;this.output.say(e)}getRoom(t){return this.rooms.find((e=>e.id==t))}getItem(t){return this.items.find((e=>e.id==t))}wait(t){return new Promise(((e,i)=>{setTimeout(e,t)}))}async move(t){const e=this.getRoom(this.player.currentRoom),i=this.getRoom(t);e.canExit()&&i.canEnter()&&(await e.onExit(),await i.onEnter(),this.player.currentRoom=t,this.examineRoom(),this.visitedRooms.set(t,!0))}enableCommandInput(t){this.commandHandler.enabled=t}}).init({rooms:d,commands:[[["meow","mew"],async function(t,e){e.print("You meow.")}]],items:w})})(); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2FtZS5qcyIsIm1hcHBpbmdzIjoibUJBY0EsWUFkQSxNQUNJQSxjQUNJQyxLQUFLQyxPQUFTLElBQUlDLElBR3RCQyxJQUFJQyxHQUNBLE9BQU9KLEtBQUtDLE9BQU9FLElBQUlDLEdBRzNCQyxJQUFJRCxFQUFLRSxHQUNMLE9BQU9OLEtBQUtDLE9BQU9JLElBQUlELEVBQUtFLEtDVnJCLE1BQU1DLEVBQ2pCUixjQUNJQyxLQUFLUSxVQUFZLEdBQ2pCUixLQUFLUyxZQUFjLFNDSHBCLE1BQU1DLEV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bmQoYXJncywgY29udGV4dCkge1xyXG4gICAgaWYgKGFyZ3MubGVuZ3RoID09IDEpIHtcclxuICAgICAgICBjb250ZXh0LmV4YW1pbmVSb29tKCk7XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICAgIGNvbnN0IHJvb20gPSBjb250ZXh0LmdldFJvb20oY29udGV4dC5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIGNvbnN0IGl0ZW1zID0gcm9vbS5nZXRJdGVtcygpO1xyXG4gICAgICAgIGxldCBpdGVtID0gbnVsbDtcclxuICAgICAgICBmb3IgKGxldCBpIG9mIGl0ZW1zKSB7XHJcbiAgICAgICAgICAgIGlmIChpLm5hbWUuaW5jbHVkZXMoYXJnc1sxXSkpIHtcclxuICAgICAgICAgICAgICAgIGl0ZW0gPSBpO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKCFpdGVtKSB7XHJcbiAgICAgICAgICAgIGNvbnRleHQub3V0cHV0LnNheShgSSBjb3VsZCBub3QgZmluZCBhICR7YXJnc1sxXX1gKTtcclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICBjb250ZXh0Lm91dHB1dC5zYXkoaXRlbS5uYW1lKTtcclxuICAgICAgICAgICAgY29udGV4dC5vdXRwdXQuc2F5KGl0ZW0uZGVzY3JpcHRpb24pO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxufSIsImV4cG9ydCBkZWZhdWx0IGFzeW5jIGZ1bmN0aW9uIFVzZUNvbW1hbmQoYXJncywgY29udGV4dCkge1xyXG4gICAgY29uc3Qgcm9vbSA9IGNvbnRleHQuZ2V0Um9vbShjb250ZXh0LnBsYXllci5jdXJyZW50Um9vbSk7XHJcbiAgICBjb25zdCBpdGVtcyA9IHJvb20uZ2V0SXRlbXMoKTtcclxuICAgIGxldCBpdGVtID0gbnVsbDtcclxuICAgIGZvciAobGV0IGkgb2Y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HVybiB0aGlzO1xyXG4gICAgfVxyXG5cclxuICAgIHdpdGhGaXJzdERlc2NyaXB0aW9uKGRlc2NyaXB0aW9uKSB7XHJcbiAgICAgICAgdGhpcy5yb29tLmZpcnN0RGVzY3JpcHRpb24gPSBkZXNjcmlwdGlvbjtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoRGVzY3JpcHRpb24oZGVzY3JpcHRpb24pIHtcclxuICAgICAgICB0aGlzLnJvb20uZGVzY3JpcHRpb24gPSBkZXNjcmlwdGlvbjtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoRXhpdChkaXJlY3Rpb24sIHJvb21JRCkge1xyXG4gICAgICAgIHRoaXMucm9vbS5hZGRFeGl0KGRpcmVjdGlvbiwgcm9vbUlEKTtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoSXRlbShpdGVtSUQpIHtcclxuICAgICAgICB0aGlzLnJvb20uYWRkSXRlbShpdGVtSUQpO1xyXG4gICAgICAgIHJldHVybiB0aGlzO1xyXG4gICAgfVxyXG5cclxuICAgIHdpdGhFbnRlckNhbGxiYWNrKGNhbGxiYWNrKSB7XHJcbiAgICAgICAgdGhpcy5yb29tLmFkZEVudGVyQ2FsbGJhY2soY2FsbGJhY2spO1xyXG4gICAgICAgIHJldHVybiB0aGlzO1xyXG4gICAgfVxyXG5cclxuICAgIHdpdGhFeGl0Q2FsbGJhY2soY2FsbGJhY2spIHtcclxuICAgICAgICB0aGlzLnJvb20uYWRkRXhpdENhbGxiYWNrKGNhbGxiYWNrKTtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoRW50ZXJMb2dpYyhmdW5jKSB7XHJcbiAgICAgICAgdGhpcy5yb29tLmFkZEVudGVyTG9naWMoZnVuYyk7XHJcbiAgICAgICAgcmV0dXJuIHRoaXM7XHJcb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Mub3V0cHV0LnNheShpdGVtLm5hbWUpKTtcclxuICAgIH1cclxuXHJcbiAgICBleGFtaW5lRXhpdHMoKSB7XHJcbiAgICAgICAgY29uc3Qgcm9vbSA9IHRoaXMuZ2V0Um9vbSh0aGlzLnBsYXllci5jdXJyZW50Um9vbSk7XHJcbiAgICAgICAgbGV0IGV4aXREZXNjcmlwdGlvbiA9IFwiWW91IGNhbiBnbyBcIjtcclxuICAgICAgICBmb3IgKGxldCBleGl0IG9mIHJvb20uZXhpdHMua2V5cygpKSB7XHJcbiAgICAgICAgICAgIGV4aXREZXNjcmlwdGlvbiArPSBcIiBcIiArIGV4aXQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShleGl0RGVzY3JpcHRpb24pO1xyXG4gICAgfVxyXG5cclxuICAgIGdldFJvb20oaWQpIHtcclxuICAgICAgICByZXR1cm4gdGhpcy5yb29tcy5maW5kKChyb29tKSA9PiByb29tLmlkID09IGlkKTtcclxuICAgIH1cclxuXHJcbiAgICBnZXRJdGVtKGlkKSB7XHJcbiAgICAgICAgcmV0dXJuIHRoaXMuaXRlbXMuZmluZCgoaXRlbSkgPT4gaXRlbS5pZCA9PSBpZCk7XHJcbiAgICB9XHJcblxyXG4gICAgd2FpdChtcykge1xyXG4gICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XHJcbiAgICAgICAgICAgIHNldFRpbWVvdXQocmVzb2x2ZSwgbXMpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIGFzeW5jIG1vdmUocm9vbUlEKSB7XHJcbiAgICAgICAgY29uc3QgY3VycmVudFJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIGNvbnN0IG5ld1Jvb20gPSB0aGlzLmdldFJvb20ocm9vbUlEKTtcclxuICAgICAgICBpZiAoY3VycmVudFJvb20uY2Fu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c2giLCJhZGRFbnRlckNhbGxiYWNrIiwiY2FsbGJhY2siLCJhZGRFeGl0Q2FsbGJhY2siLCJhZGRFbnRlckxvZ2ljIiwiYWRkRXhpdExvZ2ljIiwiYWRkVGlja0NhbGxiYWNrIiwibWFwIiwiZ2V0SXRlbSIsIlJvb21CdWlsZGVyIiwid2l0aElEIiwiSUQiLCJ3aXRoVGl0bGUiLCJ3aXRoRmlyc3REZXNjcmlwdGlvbiIsIndpdGhEZXNjcmlwdGlvbiIsIndpdGhFeGl0Iiwid2l0aEl0ZW0iLCJpdGVtSUQiLCJ3aXRoRW50ZXJDYWxsYmFjayIsIndpdGhFeGl0Q2FsbGJhY2siLCJ3aXRoRW50ZXJMb2dpYyIsIndpdGhFeGl0TG9naWMiLCJ3aXRoVGljayIsImNyZWF0ZSIsIndhaXQiLCJlbmFibGVDb21tYW5kSW5wdXQiLCJJdGVtIiwidXNhYmxlIiwidGFrZWFibGUiLCJ1c2VDYWxsYmFjayIsInRha2VDYWxsYmFjayIsIndpdGhOYW1lIiwiaXNVc2FibGUiLCJpc1Rha2VhYmxlIiwid2l0aFVzZUNhbGxiYWNrIiwid2l0aFRha2VDYWxsYmFjayIsInN0YXRlIiwicm9vbXMiLCJpbnB1dCIsInZpc2l0ZWRSb29tcyIsImRhdGEiLCJjb25zb2xlIiwibG9nIiwiZXhhbWluZUl0ZW1zIiwiZXhhbWluZUV4aXRzIiwiZXhpdERlc2NyaXB0aW9uIiwiZXhpdCIsImtleXMiLCJmaW5kIiwibXMiLCJQcm9taXNlIiwicmVzb2x2ZSIsInJlamVjdCIsIm5ld1Jvb20iLCJvbkV4aXQiLCJvbkVudGVyIl0sInNvdXJjZVJvb3QiOiIifQ== \ No newline at end of file +(()=>{"use strict";const t=new class{constructor(){this.states=new Map}get(t){return this.states.get(t)}set(t,e){return this.states.set(t,e)}};class e{constructor(){this.inventory=[],this.currentRoom="start",this.context=null}addItem(t){this.inventory.push(t)}removeItem(t){this.inventory=this.inventory.filter((e=>e!=t))}getInventory(){return this.inventory.map((t=>this.context.getItem(t)))}}class i{speak(t){}stop(){}setOptions(t){}}class s extends i{constructor(t={}){super(),this.timeout=100,this.timeout=t.timeout||100,this.init()}init(){this.container=document.createElement("div"),this.container.setAttribute("aria-live","polite"),this.speechDisplay=document.createElement("div"),this.speechDisplay.setAttribute("aria-live","polite"),this.container.append(this.speechDisplay),document.body.appendChild(this.container),document.body.insertBefore(this.container,document.body.firstChild)}speak(t){this.clearDisplay();const e=document.createTextNode(t),i=document.createElement("p");i.appendChild(e),this.speechDisplay.appendChild(i),setTimeout(this.clearDisplay.bind(this),this.timeout)}stop(){this.clearDisplay()}clearDisplay(){this.speechDisplay.innerHTML=""}}class n extends i{}class o{constructor(t=function(t="aria"){return"webtts"===t?n:s}()){this.output=t}speak(t){this.output.speak(t)}stop(){this.output.stop()}}class a{constructor(){this.tts=new o(new s),this.history=document.getElementById("output-area")}say(t){const e=document.createElement("p");e.appendChild(document.createTextNode(t)),this.history.appendChild(e)}}class r{constructor(t,e){this.handler=t,this.output=e,this.echoInput=!0,this.inputField=document.getElementById("input-area"),this.init()}setEcho(t){this.echoInput=t}init(){this.inputField.addEventListener("keydown",(t=>{if(13==t.which){const t=this.inputField.value;this.inputField.value="",this.echoInput&&this.output.say(`> ${t}`),this.handler.doCommand(t)}}))}}const h=[[["look","l"],function(t,e){if(1==t.length)e.examineRoom();else{const i=e.getRoom(e.player.currentRoom).getItems();let s=null;for(let e of i)if(e.name.includes(t[1])){s=e;break}s?(e.output.say(s.name),e.output.say(s.description)):e.output.say(`I could not find a ${t[1]}`)}}],[["use","interact"],async function(t,e){const i=e.getRoom(e.player.currentRoom).getItems();let s=null;for(let e of i)if(e.name.includes(t[1])){s=e;break}s?await s.onUse():e.output.say(`I could not find a ${t[1]}`)}],[["take","get"],function(t,e){const i=e.getRoom(e.player.currentRoom),s=i.getItems();let n=null;for(let e of s)if(e.name.includes(t[1])){n=e;break}n?n.takeable?(i.removeItem(n.id),e.player.addItem(n.id),e.print(`You take ${n.name}`),n.onTake()):e.print(`You can't take ${n.name}`):e.print(`You can't find any ${t[1]}`)}],[["drop","put"],function(t,e){const i=e.getRoom(e.player.currentRoom),s=e.player.getInventory();let n=null;for(let e of s)if(e.name.includes(t[1])){n=e;break}n?(e.player.removeItem(n.id),i.addItem(n.id),e.print(`You set ${n.name} down on the floor.`),n.onDrop()):e.print(`You're not carrying a ${t[1]}`)}],["echo",function(t,e){"on"!=t[1]&&"off"!=t[1]?e.print("Usage: echo "):(e.setInputEcho("on"==t[1]),e.print(`Command echo is now ${t[1]}`))}]],c=[["n","north"],["ne","northeast"],["e","east"],["se","southeast"],["s","south"],["sw","southwest"],["w","west"],["nw","northwest"],["u","up"],["d","down"]];class l{constructor(t,e){this.context=t,this.commands=e||new Map,this.enabled=!0,this.addDefaultCommands()}doCommand(t){if(!this.enabled)return void this.context.print("You can't seem to do anything at the moment.");const e=this.context.getRoom(this.context.player.currentRoom),i=t.split(" ");this.commands.get(i[0])&&this.commands.get(i[0])(i,this.context);const s=this.matchDirection(i[0]);e.getExit(s)&&this.context.move(e.getExit(s))}addCommand(t,e){Array.isArray(t)?t.forEach((t=>this.commands.set(t,e))):this.commands.set(t,e)}addCommands(t){t.forEach((t=>{this.addCommand(t[0],t[1])}))}addDefaultCommands(){this.addCommands(h)}matchDirection(t){for(let e of c)if(e[0]==t)return e[1]}}class u{constructor(){this.id="room",this.title="A room",this.description="You see nothing special",this.firstDescription="As you walk into the room, you notice nothing special",this.objects=[],this.exits=new Map,this.enterCallback=null,this.exitCallback=null,this.canEnterLogic=null,this.canExitLogic=null,this.tickCallback=null,this.context=null}async onEnter(){if(this.enterCallback)return this.enterCallback(this.context)}async onExit(){if(this.exitCallback)return this.exitCallback(this.context)}canEnter(){return!this.canEnterLogic||this.canEnterLogic(this.context)}canExit(){return!this.canExitLogic||this.canExitLogic(this.context)}addExit(t,e){return this.exits.set(t,e),this}getExit(t){return this.exits.get(t)}addItem(t){this.objects.push(t)}removeItem(t){this.objects=this.objects.filter((e=>e!=t))}addEnterCallback(t){this.enterCallback=t.bind(this)}addExitCallback(t){this.exitCallback=t.bind(this)}addEnterLogic(t){this.canEnterLogic=t.bind(this)}addExitLogic(t){this.canExitLogic=t.bind(this)}addTickCallback(t){this.tickCallback=t.bind(this)}getItems(){return this.objects.map((t=>this.context.getItem(t)))}}class m{constructor(){this.room=new u}withID(t){return this.room.id=t,this}withTitle(t){return this.room.title=t,this}withFirstDescription(t){return this.room.firstDescription=t,this}withDescription(t){return this.room.description=t,this}withExit(t,e){return this.room.addExit(t,e),this}withItem(t){return this.room.addItem(t),this}withEnterCallback(t){return this.room.addEnterCallback(t),this}withExitCallback(t){return this.room.addExitCallback(t),this}withEnterLogic(t){return this.room.addEnterLogic(t),this}withExitLogic(t){return this.room.addExitLogic(t),this}withTick(t){return this.room.addTickCallback(t),this}create(){return this.room}}const d=[(new m).withID("start").withTitle("The starting room").withFirstDescription("You set foot in your very first room").withDescription("The first room. Nothing special about it.").withExit("north","tunnel_1").withEnterCallback((async function(t){const{output:e,wait:i}=t;t.enableCommandInput(!1),e.say("You slowly wake up"),await i(5e3),e.say("It's strange. You never used to be able to be conscious about the fact that you were waking up."),await i(5e3),e.say("Yet here we are."),t.enableCommandInput(!0)})).withItem("stone").create(),(new m).withID("tunnel_1").withTitle("A long dark tunnel").withFirstDescription("You first step foot in this dark loomy tunnel.").withDescription("The walls are wet. Everything is wet. Ugh. Why do you even.").withExit("south","start").create()];class p{constructor(){this.id="item",this.name="An item",this.description="You see nothing special about this item",this.usable=!0,this.takeable=!0,this.useCallback=null,this.takeCallback=null,this.dropCallback=null,this.tickCallback=null,this.context=null}async onUse(){if(this.useCallback)return this.useCallback(this.context)}async onTake(){if(this.takeCallback)return this.takeCallback()}addUseCallback(t){this.useCallback=t.bind(this)}addTakeCallback(t){this.takeCallback=t.bind(this)}addDropCallback(t){this.dropCallback=t.bind(this)}addTickCallback(t){this.tickCallback=t.bind(this)}}const b=[(new class{constructor(){this.item=new p}withID(t){return this.item.id=t,this}withName(t){return this.item.name=t,this}withDescription(t){return this.item.description=t,this}isUsable(t){return this.item.usable=t,this}isTakeable(t){return this.item.takeable=t,this}withUseCallback(t){return this.item.addUseCallback(t),this}withTakeCallback(t){return this.item.addTakeCallback(t),this}withTickCallback(t){return this.item.addTickCallback(t),this}create(){return this.item}}).withID("stone").withName("A dull stone").withDescription("There is nothing remarkable about this rough, bland stone.").isTakeable(!0).isUsable(!0).withTakeCallback((async function(t){t.print(`The ${this.id} feels heavy in your hands.`)})).withUseCallback((async function(t){t.print(`You can't really figure out what to do with ${this.name} yet`)})).create()];(new class{constructor(){this.player=new e,this.state=t,this.rooms=[],this.items=[],this.output=new a,this.commandHandler=new l(this),this.input=new r(this.commandHandler,this.output),this.visitedRooms=new Map}print(t){this.output.say(t)}init(t){console.log(t),this.rooms=t.rooms.map((t=>(t.context=this,t))),this.items=t.items.map((t=>(t.context=this,t))),this.state=t.state,this.commandHandler.addCommands(t.commands),this.player=new e,this.player.context=this,this.move(this.player.currentRoom)}examineRoom(){const t=this.getRoom(this.player.currentRoom);this.output.say(t.title),this.visitedRooms.get(this.player.currentRoom)||""==t.firstDescription?this.output.say(t.description):this.output.say(t.firstDescription),this.examineItems(),this.examineExits()}examineItems(){this.getRoom(this.player.currentRoom).getItems().forEach((t=>this.output.say(t.name)))}examineExits(){const t=this.getRoom(this.player.currentRoom);let e="You can go ";for(let i of t.exits.keys())e+=" "+i;this.output.say(e)}getRoom(t){return this.rooms.find((e=>e.id==t))}getItem(t){return this.items.find((e=>e.id==t))}wait(t){return new Promise(((e,i)=>{setTimeout(e,t)}))}async move(t){const e=this.getRoom(this.player.currentRoom),i=this.getRoom(t);e.canExit()&&i.canEnter()&&(await e.onExit(),await i.onEnter(),this.player.currentRoom=t,this.examineRoom(),this.visitedRooms.set(t,!0))}enableCommandInput(t){this.commandHandler.enabled=t}setInputEcho(t){this.input.setEcho(t)}}).init({rooms:d,commands:[[["meow","mew"],async function(t,e){e.print("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3Rvcihjb250ZXh0LCBjb21tYW5kcykge1xyXG4gICAgICAgIHRoaXMuY29udGV4dCA9IGNvbnRleHQ7XHJcbiAgICAgICAgdGhpcy5jb21tYW5kcyA9IGNvbW1hbmRzIHx8IG5ldyBNYXAoKTtcclxuICAgICAgICB0aGlzLmVuYWJsZWQgPSB0cnVlO1xyXG4gICAgICAgIHRoaXMuYWRkRGVmYXVsdENvbW1hbmRzKCk7XHJcbiAgICB9XHJcblxyXG4gICAgZG9Db21tYW5kKHN0cikge1xyXG4gICAgICAgIGlmICghdGhpcy5lbmFibGVkKSB7XHJcbiAgICAgICAgICAgIHRoaXMuY29udGV4dC5wcmludChgWW91IGNhbid0IHNlZW0gdG8gZG8gYW55dGhpbmcgYXQgdGhlIG1vbWVudC5gKTtcclxuICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgIH1cclxuICAgICAgICBjb25zdCByb29tID0gdGhpcy5jb250ZXh0LmdldFJvb20odGhpcy5jb250ZXh0LnBsYXllci5jdXJyZW50Um9vbSk7XHJcbiAgICAgICAgY29uc3Qgc3BsaXQgPSBzdHIuc3BsaXQoXCIgXCIpO1xyXG4gICAgICAgIGlmICh0aGlzLmNvbW1hbmRzLmdldChzcGxpdFswXSkpIHtcclxuICAgICAgICAgICAgdGhpcy5jb21tYW5kcy5nZXQoc3BsaXRbMF0pKHNwbGl0LCB0aGlzLmNvbnRleHQpO1xyXG4gICAgICAgIH1cclxuICAgICAgICBcclxuICAgICAgICBjb25zdCBkaXJlY3Rpb24gPSB0aGlzLm1hdGNoRGlyZWN0aW9uKHNwbGl0WzBdKTtcclxuXHJcbiAgICAgICAgaWYgKHJvb20uZ2V0RXhpdChkaXJlY3Rpb24pKSB7XHJcbiAgICAgICAgICAgIHRoaXMuY29udGV4dC5tb3ZlKHJvb20uZ2V0RXhpdChkaXJlY3Rpb24pKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgYWRkQ29tbWFuZChuYW1lLCBmdW5jKSB7XHJcbiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkobmFtZSkpIHtcclxuICAgICAgICAgICAgbmFtZS5mb3JFYWNoKChjb21tYW5kKSA9PiB0aGlzLmNvbW1hbmRzLnNldChjb21tYW5kLCBmdW5jKSk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgdGhpcy5jb21tYW5kcy5zZXQobmFtZSwgZnVuYyk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG5cclxuICAgIGFkZENvbW1hbmRzKGNvbW1hbmRzKSB7XHJcbiAgICAgICAgY29tbWFuZHMuZm9yRWFjaCgoY29tbWFuZCkgPT4ge1xyXG4gICAgICAgICAgICB0aGlzLmFkZENvbW1hbmQoY29tbWFuZFswXSwgY29tbWFuZFsxXSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9XHJcblxyXG4gICAgYWRkRGVmYXVsdENvbW1hbmRzKCkge1xyXG4gICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoZGVmYXVsdENvbW1hbmRzKTtcclxuICAgIH1cclxuXHJcbiAgICBtYXRjaERpcmVjdGlvbihzdHIpIHtcclxuICAgICAgICBmb3IgKGxldCBkaXIgb2YgZGlyZWN0aW9uTWFwKSB7XHJcbiAgICAgICAgICAgIGlmIChkaXJbMF0gPT0gc3RyKSByZXR1cm4gZGlyWzFdO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxufSIsImV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIExvb2tDb21tYW5kKGFyZ3MsIGNvbnRleHQpIHtcclxuICAgIGlmIChhcmdzLmxlbmd0aCA9PSAxKSB7XHJcbiAgICAgICAgY29udGV4dC5leGFtaW5lUm9vbSgpO1xyXG4gICAgfSBlbHNlIHtcclxuICAgICAgICBjb25zdCByb29tID0gY29udGV4dC5nZXRSb29tKGNvbnRleHQucGxheWVyLmN1cnJlbnRSb29tKTtcclxuICAgICAgICBjb25zdCBpdGVtcyA9IHJvb20uZ2V0SXRlbXMoKTtcclxuICAgICAgICBsZXQgaXRlbSA9IG51bGw7XHJcbiAgICAgICAgZm9yIChsZXQgaSBvZiBpdGVtcykge1xyXG4gICAgICAgICAgICBpZiAoaS5uYW1lLmluY2x1ZGVzKGFyZ3NbMV0pKSB7XHJcbiAgICAgICAgICAgICAgICBpdGVtID0gaTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmICghaXRlbSkge1xyXG4gICAgICAgICAgICBjb250ZXh0Lm91dHB1dC5zYXkoYEkgY291bGQgbm90IGZpbmQgYSAke2FyZ3NbMV19YCk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgY29udGV4dC5vdXRwdXQuc2F5KGl0ZW0ubmFtZSk7XHJcbiAgICAgICAgICAgIGNvbnRleHQub3V0cHV0LnNheShpdGVtLmRlc2NyaXB0aW9uKTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbn0iLCJleHBvcnQgZGVmYXVsdCBhc3luYyBmdW5jdGlvbiBVc2VDb21tYW5kKGFyZ3MsIGNvbnRleHQpIHtcclxuICAgIGNvbnN0IHJvb20gPSBjb250ZXh0LmdldFJvb20oY29udGV4dC5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgY29uc3QgaXRlbXMgPSByb29tLmdldEl0ZW1zKCk7XHJcbiAgICBsZXQgaXRlbSA9IG51bGw7XHJcbiAgICBmb3IgKGxldCBpIG9mIGl0ZW1zKSB7XHJcbiAgICAgICAgaWYgKGkubmFtZS5pbmNsdWRlcyhhcmdzWzFdKSkge1xyXG4gICAgICAgICAgICBpdGVtID0gaTtcclxuICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG4gICAgaWYgKCFpdGVtKSB7XHJcbiAgICAgICAgY29udGV4dC5vdXRwdXQuc2F5KGBJIGNvdWxkIG5vdCBmaW5kIGEgJHthcmdzWzFdfWApO1xyX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hdGU7XHJcbiAgICAgICAgdGhpcy5yb29tcyA9IFtdO1xyXG4gICAgICAgIHRoaXMuaXRlbXMgPSBbXTtcclxuICAgICAgICB0aGlzLm91dHB1dCA9IG5ldyBPdXRwdXQoKTtcclxuICAgICAgICB0aGlzLmNvbW1hbmRIYW5kbGVyID0gbmV3IENvbW1hbmRzKHRoaXMpO1xyXG4gICAgICAgIHRoaXMuaW5wdXQgPSBuZXcgSW5wdXQodGhpcy5jb21tYW5kSGFuZGxlciwgdGhpcy5vdXRwdXQpO1xyXG4gICAgICAgIHRoaXMudmlzaXRlZFJvb21zID0gbmV3IE1hcCgpO1xyXG4gICAgfVxyXG5cclxuICAgIHByaW50KHN0cmluZykge1xyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShzdHJpbmcpO1xyXG4gICAgfVxyXG5cclxuICAgIGluaXQoZGF0YSkge1xyXG4gICAgICAgIGNvbnNvbGUubG9nKGRhdGEpO1xyXG4gICAgICAgIHRoaXMucm9vbXMgPSBkYXRhLnJvb21zLm1hcCgocm9vbSkgPT4ge1xyXG4gICAgICAgICAgICByb29tLmNvbnRleHQgPSB0aGlzO1xyXG4gICAgICAgICAgICByZXR1cm4gcm9vbTtcclxuICAgICAgICB9KTtcclxuICAgICAgICB0aGlzLml0ZW1zID0gZGF0YS5pdGVtcy5tYXAoKGl0ZW0pID0+IHtcclxuICAgICAgICAgICAgaXRlbS5jb250ZXh0ID0gdGhpcztcclxuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgdGhpcy5zdGF0ZSA9IGRhdGEuc3RhdGU7XHJcbiAgICAgICAgdGhpcy5jb21tYW5kSGFuZGxlci5hZGRDb21tYW5kcyhkYXRhLmNvbW1hbmRzKTtcclxuICAgICAgICB0aGlzLnBsYXllciA9IG5ldyBQbGF5ZXIoKTtcclxuICAgICAgICB0aGlzLnBsYXllci5jb250ZXh0ID0gdGhpcztcclxuICAgICAgICB0aGlzLm1vd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BleGl0IG9mIHJvb20uZXhpdHMua2V5cygpKSB7XHJcbiAgICAgICAgICAgIGV4aXREZXNjcmlwdGlvbiArPSBcIiBcIiArIGV4aXQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShleGl0RGVzY3JpcHRpb24pO1xyXG4gICAgfVxyXG5cclxuICAgIGdldFJvb20oaWQpIHtcclxuICAgICAgICByZXR1cm4gdGhpcy5yb29tcy5maW5kKChyb29tKSA9PiByb29tLmlkID09IGlkKTtcclxuICAgIH1cclxuXHJcbiAgICBnZXRJdGVtKGlkKSB7XHJcbiAgICAgICAgcmV0dXJuIHRoaXMuaXRlbXMuZmluZCgoaXRlbSkgPT4gaXRlbS5pZCA9PSBpZCk7XHJcbiAgICB9XHJcblxyXG4gICAgd2FpdChtcykge1xyXG4gICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XHJcbiAgICAgICAgICAgIHNldFRpbWVvdXQocmVzb2x2ZSwgbXMpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIGFzeW5jIG1vdmUocm9vbUlEKSB7XHJcbiAgICAgICAgY29uc3QgY3VycmVudFJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIGNvbnN0IG5ld1Jvb20gPSB0aGlzLmdldFJvb20ocm9vbUlEKTtcclxuICAgICAgICBpZiAoY3VycmVudFJvb20uY2FuRXhpdCgpICYmIG5ld1Jvb20uY2FuRW50ZXIoKSkge1xyXG4gICAgICAgICAgICBhd2FpdCBjdXJyZW50Um9vbS5vbkV4aXQoKTtcclxuICAgICAgICAgICAgYXdhaXQgbmV3Um9vbS5vbkVudGVyKCk7XHJcbiAgICAgICAgICAgIHRoaXMucGxheWVyLmN1cnJlbnRSb29tID0gcm9vbUlEO1xyXG4gICAgICAgICAgICB0aGlzLmV4YW1pbmVSb29tKCk7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uRW50ZXIiLCJjYW5FeGl0IiwiYWRkRXhpdCIsInJvb21JRCIsImFkZEVudGVyQ2FsbGJhY2siLCJjYWxsYmFjayIsImFkZEV4aXRDYWxsYmFjayIsImFkZEVudGVyTG9naWMiLCJhZGRFeGl0TG9naWMiLCJhZGRUaWNrQ2FsbGJhY2siLCJSb29tQnVpbGRlciIsIndpdGhJRCIsIklEIiwid2l0aFRpdGxlIiwid2l0aEZpcnN0RGVzY3JpcHRpb24iLCJ3aXRoRGVzY3JpcHRpb24iLCJ3aXRoRXhpdCIsIndpdGhJdGVtIiwiaXRlbUlEIiwid2l0aEVudGVyQ2FsbGJhY2siLCJ3aXRoRXhpdENhbGxiYWNrIiwid2l0aEVudGVyTG9naWMiLCJ3aXRoRXhpdExvZ2ljIiwid2l0aFRpY2siLCJjcmVhdGUiLCJ3YWl0IiwiZW5hYmxlQ29tbWFuZElucHV0IiwiSXRlbSIsInVzYWJsZSIsInVzZUNhbGxiYWNrIiwidGFrZUNhbGxiYWNrIiwiZHJvcENhbGxiYWNrIiwiYWRkVXNlQ2FsbGJhY2siLCJhZGRUYWtlQ2FsbGJhY2siLCJhZGREcm9wQ2FsbGJhY2siLCJ3aXRoTmFtZSIsImlzVXNhYmxlIiwiaXNUYWtlYWJsZSIsIndpdGhVc2VDYWxsYmFjayIsIndpdGhUYWtlQ2FsbGJhY2siLCJ3aXRoVGlja0NhbGxiYWNrIiwic3RhdGUiLCJyb29tcyIsImlucHV0IiwidmlzaXRlZFJvb21zIiwiZGF0YSIsImNvbnNvbGUiLCJsb2ciLCJleGFtaW5lSXRlbXMiLCJleGFtaW5lRXhpdHMiLCJleGl0RGVzY3JpcHRpb24iLCJleGl0Iiwia2V5cyIsImZpbmQiLCJtcyIsIlByb21pc2UiLCJyZXNvbHZlIiwicmVqZWN0IiwibmV3Um9vbSIsIm9uRXhpdCIsIm9uRW50ZXIiXSwic291cmNlUm9vdCI6IiJ9 \ No newline at end of file diff --git a/src/engine/builders/item.js b/src/engine/builders/item.js index ae0b0fc..d8a6928 100644 --- a/src/engine/builders/item.js +++ b/src/engine/builders/item.js @@ -40,6 +40,11 @@ export default class ItemBuilder { return this; } + withTickCallback(callback) { + this.item.addTickCallback(callback); + return this; + } + create() { return this.item; } diff --git a/src/engine/index.js b/src/engine/index.js index 8ee4af8..34537dd 100644 --- a/src/engine/index.js +++ b/src/engine/index.js @@ -5,6 +5,7 @@ import Output from './output'; import Input from './input'; import Commands from './commands'; + export default class Game { constructor() { this.player = new Player(); @@ -15,6 +16,7 @@ export default class Game { this.commandHandler = new Commands(this); this.input = new Input(this.commandHandler, this.output); this.visitedRooms = new Map(); + this.interval = null; } print(string) { @@ -36,6 +38,21 @@ export default class Game { this.player = new Player(); this.player.context = this; this.move(this.player.currentRoom); + this.start(); + } + + advanceTick() { + this.items.forEach((item) => item.onTick()); + this.rooms.forEach((room) => room.onTick()); + } + + start() { + this.interval = setInterval(() => this.advanceTick(), 1000); + } + + stop() { + clearInterval(this.interval); + this.interval = null; } examineRoom() { diff --git a/src/engine/item.js b/src/engine/item.js index a768669..ec510eb 100644 --- a/src/engine/item.js +++ b/src/engine/item.js @@ -8,6 +8,7 @@ export default class Item { this.useCallback = null; this.takeCallback = null; this.dropCallback = null; + this.tickCallback = null; this.context = null; } @@ -19,6 +20,10 @@ export default class Item { if (this.takeCallback) return this.takeCallback(); } + async onTick() { + if (this.tickCallback) return this.tickCallback(this.context); + } + addUseCallback(callback) { this.useCallback = callback.bind(this); } @@ -30,4 +35,8 @@ export default class Item { addDropCallback(callback) { this.dropCallback = callback.bind(this); } + + addTickCallback(callback) { + this.tickCallback = callback.bind(this); + } } \ No newline at end of file diff --git a/src/engine/room.js b/src/engine/room.js index 53851b7..9f56ccc 100644 --- a/src/engine/room.js +++ b/src/engine/room.js @@ -76,4 +76,8 @@ export default class Room { getItems() { return this.objects.map((item) => this.context.getItem(item)); } + + async onTick() { + if (this.tickCallback) return this.tickCallback(this.context); + } } \ No newline at end of file