From abb3c475db72bba3265e279521e92600f8865bb8 Mon Sep 17 00:00:00 2001 From: Talon Date: Thu, 4 Nov 2021 22:29:05 +0100 Subject: [PATCH] Bind callbacks to object --- app_web/game.js | 4 ++-- src/engine/builders/item.js | 4 ++-- src/engine/item.js | 8 ++++++++ src/engine/room.js | 10 +++++----- src/game/items/stone.js | 4 ++-- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app_web/game.js b/app_web/game.js index 627ec3a..0020963 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,i){return this.states.set(t,i)}};class i{constructor(){this.inventory=[],this.currentRoom="start"}}class e{speak(t){}stop(){}setOptions(t){}}class s extends e{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 i=document.createTextNode(t),e=document.createElement("p");e.appendChild(i),this.speechDisplay.appendChild(e),setTimeout(this.clearDisplay.bind(this),this.timeout)}stop(){this.clearDisplay()}clearDisplay(){this.speechDisplay.innerHTML=""}}class o extends e{}class n{constructor(t=function(t="aria"){return"webtts"===t?o:s}()){this.output=t}speak(t){this.output.speak(t)}stop(){this.output.stop()}}class a{constructor(){this.tts=new n(new s),this.history=document.getElementById("output-area")}say(t){const i=document.createElement("p");i.appendChild(document.createTextNode(t)),this.history.appendChild(i)}}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,i){i.examineRoom()}]];class c{constructor(t,i){this.context=t,this.commands=i||new Map,this.addDefaultCommands()}doCommand(t){const i=this.context.getRoom(this.context.player.currentRoom),e=t.split(" ");this.commands.get(e[0])&&this.commands.get(e[0])(e,this.context),i.getExit(e[0])&&this.context.move(i.getExit(e[0]))}addCommand(t,i){Array.isArray(t)?t.forEach((t=>this.commands.set(t,i))):this.commands.set(t,i)}addCommands(t){t.forEach((t=>{this.addCommand(t[0],t[1])}))}addDefaultCommands(){this.addCommands(h)}}class l{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,i){return this.exits.set(t,i),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}}class d{constructor(){this.room=new l}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,i){return this.room.addExit(t,i),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 m=[(new d).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:i,wait:e}=t;i.say("You slowly wake up"),await e(5e3),i.say("It's strange. You never used to be able to be conscious about the fact that you were waking up."),await e(5e3),i.say("Yet here we are.")})).create(),(new d).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()];(new class{constructor(){this.player=new i,this.state=t,this.rooms=[],this.items=[],this.output=new a,this.commandHandler=new c(this),this.input=new r(this.commandHandler),this.visitedRooms=new Map}print(t){this.output.say(t)}init(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 i,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)}getRoom(t){return this.rooms.find((i=>i.id==t))}getItem(t){return this.items.find((i=>i.id==t))}wait(t){return new Promise(((i,e)=>{setTimeout(i,t)}))}async move(t){const i=this.getRoom(this.player.currentRoom),e=this.getRoom(t);i.canExit()&&e.canEnter()&&(await i.onExit(),await e.onEnter(),this.player.currentRoom=t,this.examineRoom(),this.visitedRooms.set(t,!0))}}).init({rooms:m,commands:[[["meow","mew"],async function(t,i){i.print("You meow.")}]],items:[]})})(); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2FtZS5qcyIsIm1hcHBpbmdzIjoibUJBY0EsWUFkQSxNQUNJQSxjQUNJQyxLQUFLQyxPQUFTLElBQUlDLElBR3RCQyxJQUFJQyxHQUNBLE9BQU9KLEtBQUtDLE9BQU9FLElBQUlDLEdBRzNCQyxJQUFJRCxFQUFLRSxHQUNMLE9BQU9OLEtBQUtDLE9BQU9JLElBQUlELEVBQUtFLEtDVnJCLE1BQU1DLEVBQ2pCUixjQUNJQyxLQUFLUSxVQUFZLEdBQ2pCUixLQUFLUyxZQUFjLFNDSHBCLE1BQU1D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ICB0aGlzLml0ZW1zID0gW107XHJcbiAgICAgICAgdGhpcy5vdXRwdXQgPSBuZXcgT3V0cHV0KCk7XHJcbiAgICAgICAgdGhpcy5jb21tYW5kSGFuZGxlciA9IG5ldyBDb21tYW5kcyh0aGlzKTtcclxuICAgICAgICB0aGlzLmlucHV0ID0gbmV3IElucHV0KHRoaXMuY29tbWFuZEhhbmRsZXIpO1xyXG4gICAgICAgIHRoaXMudmlzaXRlZFJvb21zID0gbmV3IE1hcCgpO1xyXG4gICAgfVxyXG5cclxuICAgIHByaW50KHN0cmluZykge1xyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShzdHJpbmcpO1xyXG4gICAgfVxyXG5cclxuICAgIGluaXQoZGF0YSkge1xyXG4gICAgICAgIHRoaXMucm9vbXMgPSBkYXRhLnJvb21zLm1hcCgocm9vbSkgPT4ge1xyXG4gICAgICAgICAgICByb29tLmNvbnRleHQgPSB0aGlzO1xyXG4gICAgICAgICAgICByZXR1cm4gcm9vbTtcclxuICAgICAgICB9KTtcclxuICAgICAgICB0aGlzLml0ZW1zID0gZGF0YS5pdGVtcy5tYXAoKGl0ZW0pID0+IHtcclxuICAgICAgICAgICAgaXRlbS5jb250ZXh0ID0gdGhpcztcclxuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgdGhpcy5zdGF0ZSA9IGRhdGEuc3RhdGU7XHJcbiAgICAgICAgdGhpcy5jb21tYW5kSGFuZGxlci5hZGRDb21tYW5kcyhkYXRhLmNvbW1hbmRzKTtcclxuICAgICAgICB0aGlzLnBsYXllciA9IG5ldyBQbGF5ZXIoKTtcclxuICAgICAgICB0aGlzLm1vdmUodGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgfVxyXG5cclxuICAgIGV4YW1pbmVSb29tKCkge1xyXG4gICAgICAgIGNvbnN0IHJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShyb29tLnRpdGxlKTtcclxuICAgICAgICBpZiAoIXRoaXMudmlzaXRlZFJvb21zLmdldCh0aGlzLnBsYXllci5jdXJyZW50Um9vbSkgJiYgcm9vbS5maXJzdERlc2NyaXB0aW9uICE9IFwiXCIpIHtcclxuICAgICAgICAgICAgdGhpcy5vdXRwdXQuc2F5KHJvb20uZmlyc3REZXNjcmlwdGlvbik7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgdGhpcy5vdXRwdXQuc2F5KHJvb20uZGVzY3JpcHRpb24pO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICBnZXRSb29tKGlkKSB7XHJcbiAgICAgICAgcmV0dXJuIHRoaXMucm9vbXMuZmluZCgocm9vbSkgPT4gcm9vbS5pZCA9PSBpZCk7XHJcbiAgICB9XHJcblxyXG4gICAgZ2V0SXRlbShpZCkge1xyXG4gICAgICAgIHJldHVybiB0aGlzLml0ZW1zLmZpbmQoKGl0ZW0pID0+IGl0ZW0uaWQgPT0gaWQpO1xyXG4gICAgfVxyXG5cclxuICAgIHdhaXQobXMpIHtcclxuICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4ge1xyXG4gICAgICAgICAgICBzZXRUaW1lb3V0KHJlc29sdmUsIG1zKTtcclxuICAgICAgICB9KTtcclxuICAgIH1cclxuXHJcbiAgICBhc3luYyBtb3ZlKHJvb21JRCkge1xyXG4gICAgICAgIGNvbnN0IGN1cnJlbnRSb29tID0gdGhpcy5nZXRSb29tKHRoaXMucGxheWVyLmN1cnJlbnRSb29tKTtcclxuICAgICAgICBjb25zdCBuZXdSb29tID0gdGhpcy5nZXRSb29tKHJvb21JRCk7XHJcbiAgICAgICAgaWYgKGN1cnJlbnRSb29tLmNhbkV4aXQoKSAmJiBuZXdSb29tLmNhbkVudGVyKCkpIHtcclxuICAgICAgICAgICAgYXdhaXQgY3V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Iiwid2l0aEVudGVyTG9naWMiLCJ3aXRoRXhpdExvZ2ljIiwid2l0aFRpY2siLCJjcmVhdGUiLCJ3YWl0Iiwic3RhdGUiLCJyb29tcyIsIml0ZW1zIiwiaW5wdXQiLCJ2aXNpdGVkUm9vbXMiLCJwcmludCIsImRhdGEiLCJtYXAiLCJmaW5kIiwiZ2V0SXRlbSIsIm1zIiwiUHJvbWlzZSIsInJlc29sdmUiLCJyZWplY3QiLCJuZXdSb29tIiwib25FeGl0Iiwib25FbnRlciJdLCJzb3VyY2VSb290IjoiIn0= \ 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"}}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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2FtZS5qcyIsIm1hcHBpbmdzIjoibUJBY0EsWUFkQSxNQUNJQSxjQUNJQyxLQUFLQyxPQUFTLElBQUlDLElBR3RCQyxJQUFJQyxHQUNBLE9BQU9KLEtBQUtDLE9BQU9FLElBQUlDLEdBRzNCQyxJQUFJRCxFQUFLRSxHQUNMLE9BQU9OLEtBQUtDLE9BQU9JLElBQUlELEVBQUtFLEtDVnJCLE1BQU1DLEVBQ2pCUixjQUNJQyxLQUFLUSxVQUFZLEdBQ2pCUixLQUFLUyxZQUFjLFNDSHBCLE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9va0NvbW1hbmQoYXJncywgY29udGV4dCkge1xyXG4gICAgaWYgKGFyZ3MubGVuZ3RoID09IDEpIHtcclxuICAgICAgICBjb250ZXh0LmV4YW1pbmVSb29tKCk7XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICAgIGNvbnN0IHJvb20gPSBjb250ZXh0LmdldFJvb20oY29udGV4dC5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIGNvbnN0IGl0ZW1zID0gcm9vbS5nZXRJdGVtcygpO1xyXG4gICAgICAgIGxldCBpdGVtID0gbnVsbDtcclxuICAgICAgICBmb3IgKGxldCBpIG9mIGl0ZW1zKSB7XHJcbiAgICAgICAgICAgIGlmIChpLm5hbWUuaW5jbHVkZXMoYXJnc1sxXSkpIHtcclxuICAgICAgICAgICAgICAgIGl0ZW0gPSBpO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICB9XHJcbiAgICAgICAgaWYgKCFpdGVtKSB7XHJcbiAgICAgICAgICAgIGNvbnRleHQub3V0cHV0LnNheShgSSBjb3VsZCBub3QgZmluZCBhICR7YXJnc1sxXX1gKTtcclxuICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICBjb250ZXh0Lm91dHB1dC5zYXkoaXRlbS5uYW1lKTtcclxuICAgICAgICAgICAgY29udGV4dC5vdXRwdXQuc2F5KGl0ZW0uZGVzY3JpcHRpb24pO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxufSIsImV4cG9ydCBkZWZhdWx0IGFzeW5jIGZ1bmN0aW9uIFVzZUNvbW1hbmQoYXJncywgY29udGV4dCkge1xyXG4gICAgY29uc3Qgcm9vbSA9IGNvbnRleHQuZ2V0Um9vbShjb250ZXh0LnBsYXllci5jdXJyZW50Um9vbSk7XHJcbiAgICBjb25zdCBpdGVtcyA9IHJvb20uZ2V0SXRlbXMoKTtcclxuICAgIGxldCBpdGVtID0gbnVsbDtcclxuICAgIGZvciAobG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AgICAgIHJldHVybiB0aGlzO1xyXG4gICAgfVxyXG5cclxuICAgIHdpdGhGaXJzdERlc2NyaXB0aW9uKGRlc2NyaXB0aW9uKSB7XHJcbiAgICAgICAgdGhpcy5yb29tLmZpcnN0RGVzY3JpcHRpb24gPSBkZXNjcmlwdGlvbjtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoRGVzY3JpcHRpb24oZGVzY3JpcHRpb24pIHtcclxuICAgICAgICB0aGlzLnJvb20uZGVzY3JpcHRpb24gPSBkZXNjcmlwdGlvbjtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoRXhpdChkaXJlY3Rpb24sIHJvb21JRCkge1xyXG4gICAgICAgIHRoaXMucm9vbS5hZGRFeGl0KGRpcmVjdGlvbiwgcm9vbUlEKTtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoSXRlbShpdGVtSUQpIHtcclxuICAgICAgICB0aGlzLnJvb20uYWRkSXRlbShpdGVtSUQpO1xyXG4gICAgICAgIHJldHVybiB0aGlzO1xyXG4gICAgfVxyXG5cclxuICAgIHdpdGhFbnRlckNhbGxiYWNrKGNhbGxiYWNrKSB7XHJcbiAgICAgICAgdGhpcy5yb29tLmFkZEVudGVyQ2FsbGJhY2soY2FsbGJhY2spO1xyXG4gICAgICAgIHJldHVybiB0aGlzO1xyXG4gICAgfVxyXG5cclxuICAgIHdpdGhFeGl0Q2FsbGJhY2soY2FsbGJhY2spIHtcclxuICAgICAgICB0aGlzLnJvb20uYWRkRXhpdENhbGxiYWNrKGNhbGxiYWNrKTtcclxuICAgICAgICByZXR1cm4gdGhpcztcclxuICAgIH1cclxuXHJcbiAgICB3aXRoRW50ZXJMb2dpYyhmdW5jKSB7XHJcbiAgICAgICAgdGhpcy5yb29tLmFkZEVudGVyTG9naWMoZnVuYyk7XHJcbiAgICAgICAgcmV0dXJuIHRo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ID0+IHRoaXMub3V0cHV0LnNheShpdGVtLm5hbWUpKTtcclxuICAgIH1cclxuXHJcbiAgICBleGFtaW5lRXhpdHMoKSB7XHJcbiAgICAgICAgY29uc3Qgcm9vbSA9IHRoaXMuZ2V0Um9vbSh0aGlzLnBsYXllci5jdXJyZW50Um9vbSk7XHJcbiAgICAgICAgbGV0IGV4aXREZXNjcmlwdGlvbiA9IFwiWW91IGNhbiBnbyBcIjtcclxuICAgICAgICBmb3IgKGxldCBleGl0IG9mIHJvb20uZXhpdHMua2V5cygpKSB7XHJcbiAgICAgICAgICAgIGV4aXREZXNjcmlwdGlvbiArPSBcIiBcIiArIGV4aXQ7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMub3V0cHV0LnNheShleGl0RGVzY3JpcHRpb24pO1xyXG4gICAgfVxyXG5cclxuICAgIGdldFJvb20oaWQpIHtcclxuICAgICAgICByZXR1cm4gdGhpcy5yb29tcy5maW5kKChyb29tKSA9PiByb29tLmlkID09IGlkKTtcclxuICAgIH1cclxuXHJcbiAgICBnZXRJdGVtKGlkKSB7XHJcbiAgICAgICAgcmV0dXJuIHRoaXMuaXRlbXMuZmluZCgoaXRlbSkgPT4gaXRlbS5pZCA9PSBpZCk7XHJcbiAgICB9XHJcblxyXG4gICAgd2FpdChtcykge1xyXG4gICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XHJcbiAgICAgICAgICAgIHNldFRpbWVvdXQocmVzb2x2ZSwgbXMpO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfVxyXG5cclxuICAgIGFzeW5jIG1vdmUocm9vbUlEKSB7XHJcbiAgICAgICAgY29uc3QgY3VycmVudFJvb20gPSB0aGlzLmdldFJvb20odGhpcy5wbGF5ZXIuY3VycmVudFJvb20pO1xyXG4gICAgICAgIGNvbnN0IG5ld1Jvb20gPSB0aGlzLmdldFJvb20ocm9vbUlEKTtcclxuICAgICAgICBpZiAoY3VycmVudF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RlbSIsInB1c2giLCJhZGRFbnRlckNhbGxiYWNrIiwiY2FsbGJhY2siLCJhZGRFeGl0Q2FsbGJhY2siLCJhZGRFbnRlckxvZ2ljIiwiYWRkRXhpdExvZ2ljIiwiYWRkVGlja0NhbGxiYWNrIiwibWFwIiwiZ2V0SXRlbSIsIlJvb21CdWlsZGVyIiwid2l0aElEIiwiSUQiLCJ3aXRoVGl0bGUiLCJ3aXRoRmlyc3REZXNjcmlwdGlvbiIsIndpdGhEZXNjcmlwdGlvbiIsIndpdGhFeGl0Iiwid2l0aEl0ZW0iLCJpdGVtSUQiLCJ3aXRoRW50ZXJDYWxsYmFjayIsIndpdGhFeGl0Q2FsbGJhY2siLCJ3aXRoRW50ZXJMb2dpYyIsIndpdGhFeGl0TG9naWMiLCJ3aXRoVGljayIsImNyZWF0ZSIsIndhaXQiLCJlbmFibGVDb21tYW5kSW5wdXQiLCJJdGVtIiwidXNhYmxlIiwidGFrZWFibGUiLCJ1c2VDYWxsYmFjayIsInRha2VDYWxsYmFjayIsIndpdGhOYW1lIiwiaXNVc2FibGUiLCJpc1Rha2VhYmxlIiwid2l0aFVzZUNhbGxiYWNrIiwid2l0aFRha2VDYWxsYmFjayIsInN0YXRlIiwicm9vbXMiLCJpbnB1dCIsInZpc2l0ZWRSb29tcyIsImRhdGEiLCJjb25zb2xlIiwibG9nIiwiZXhhbWluZUl0ZW1zIiwiZXhhbWluZUV4aXRzIiwiZXhpdERlc2NyaXB0aW9uIiwiZXhpdCIsImtleXMiLCJmaW5kIiwibXMiLCJQcm9taXNlIiwicmVzb2x2ZSIsInJlamVjdCIsIm5ld1Jvb20iLCJvbkV4aXQiLCJvbkVudGVyIl0sInNvdXJjZVJvb3QiOiIifQ== \ No newline at end of file diff --git a/src/engine/builders/item.js b/src/engine/builders/item.js index 7221606..ae0b0fc 100644 --- a/src/engine/builders/item.js +++ b/src/engine/builders/item.js @@ -31,12 +31,12 @@ export default class ItemBuilder { } withUseCallback(callback) { - this.item.useCallback = callback; + this.item.addUseCallback(callback); return this; } withTakeCallback(callback) { - this.item.takeCallback = callback; + this.item.addTakeCallback(callback); return this; } diff --git a/src/engine/item.js b/src/engine/item.js index 59ccc98..e0471a1 100644 --- a/src/engine/item.js +++ b/src/engine/item.js @@ -17,4 +17,12 @@ export default class Item { async onTake() { if (this.takeCallback) return this.takeCallback(); } + + addUseCallback(callback) { + this.useCallback = callback.bind(this); + } + + addTakeCallback(callback) { + this.takeCallback = callback.bind(this); + } } \ No newline at end of file diff --git a/src/engine/room.js b/src/engine/room.js index 100e0d2..a2f8cb6 100644 --- a/src/engine/room.js +++ b/src/engine/room.js @@ -50,23 +50,23 @@ export default class Room { } addEnterCallback(callback) { - this.enterCallback = callback; + this.enterCallback = callback.bind(this); } addExitCallback(callback) { - this.exitCallback = callback; + this.exitCallback = callback.bind(this); } addEnterLogic(func) { - this.canEnterLogic = func; + this.canEnterLogic = func.bind(this); } addExitLogic(func) { - this.canExitLogic = func; + this.canExitLogic = func.bind(this); } addTickCallback(callback) { - this.tickCallback = callback; + this.tickCallback = callback.bind(this); } getItems() { diff --git a/src/game/items/stone.js b/src/game/items/stone.js index 88bf067..855cf54 100644 --- a/src/game/items/stone.js +++ b/src/game/items/stone.js @@ -7,9 +7,9 @@ export default new ItemBuilder() .isTakeable(true) .isUsable(true) .withTakeCallback(async function(context) { - context.output.say("It feels heavy in your hands."); + context.print(`The ${this.id} feels heavy in your hands.`); }) .withUseCallback(async function(context) { - context.output.say("You can't really figure out what to do with this yet."); + context.print(`You can't really figure out what to do with ${this.name} yet`); }) .create(); \ No newline at end of file