From eb24970fe3316e679e29887620732bfb0e465791 Mon Sep 17 00:00:00 2001 From: thewilley <89783791+TheWilley@users.noreply.github.com> Date: Fri, 11 Aug 2023 10:32:55 +0200 Subject: [PATCH] added ability to add images to characters --- game-disks/demo-disk.js | 19 +++++++++++++++++++ index.js | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/game-disks/demo-disk.js b/game-disks/demo-disk.js index e724067..260e3df 100644 --- a/game-disks/demo-disk.js +++ b/game-disks/demo-disk.js @@ -181,6 +181,25 @@ const demoDisk = () => ({ name: ['Benji', 'Benj', 'receptionist'], roomId: 'reception', desc: 'He looks... helpful!', // printed when the player looks at the character + img: ` + .------\\ /------. + | - | + | | + | | + | | + _______________________ + ===========.=========== + / ~~~~~ ~~~~~ \\ + /| | |\\ + W --- / \\ --- W + \\. |o o| ./ + | | + \\ ######### / + \\ ## ----- ## / + \\## ##/ + \\_____v_____/ + + `, // optional callback, run when the player talks to this character onTalk: () => println(`"Hi," he says, "How can I help you?"`), // things the player can discuss with the character diff --git a/index.js b/index.js index a7cd1fc..9dfa7a9 100644 --- a/index.js +++ b/index.js @@ -243,6 +243,11 @@ let lookAt = (args) => { } else { const character = getCharacter(name, getCharactersInRoom(disk.roomId)); if (character) { + // show character image if available + if(character.img) { + println(character.img, 'img'); + } + // Look at a character. if (character.desc) { println(character.desc); @@ -250,6 +255,7 @@ let lookAt = (args) => { println(`You don't notice anything remarkable about them.`); } + if (typeof(character.onLook) === 'function') { character.onLook({disk, println, getRoom, enterRoom, item}); }