From eb674c5dd19c1ef65d4d02c344d51c23dedd574f Mon Sep 17 00:00:00 2001 From: ThePix Date: Fri, 6 Dec 2024 16:12:11 +0000 Subject: [PATCH] Minor changes to quest.js --- game-banks/npcs.js | 45 +++++++++++++++++++++++++++++++++--------- game-banks/settings.js | 2 +- rpg/quest.js | 12 +++++++++-- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/game-banks/npcs.js b/game-banks/npcs.js index 5122d80..d4fca38 100644 --- a/game-banks/npcs.js +++ b/game-banks/npcs.js @@ -48,6 +48,23 @@ createItem("Xsansi", NPC(true), { }, }, + { + name:"myself", + test:function(p) { + return p.text.match(new RegExp("^me$|myself|" + player.alias), "i"); + }, + script:function() { + msg("'Tell me about myself, Xsansi,' you say."); + if (w.Xsansi.currentPlanet < 3) { + msg(processText(w.Xsansi.crewStatusTemplate, {char:player, room:w[player.loc]})) + w.Xsansi.locate = null + } + else { + msg("'I take it you have lost yourself, and want me to tell you where you are? I have navigated this bucket of bolts across half the galaxy, heaven forbid you could find your own way to canteen.'"); + } + }, + }, + { name:"kyle", test:function(p) { return p.text.match(/kyle/); }, @@ -65,7 +82,7 @@ createItem("Xsansi", NPC(true), { { name:"aada", - test:function(p) { return p.text.match(/house/); }, + test:function(p) { return p.text.match(/aada/); }, script:function() { msg("'Tell me about Aada, Xsansi,' you say."); if (w.Xsansi.currentPlanet < 3) { @@ -80,7 +97,7 @@ createItem("Xsansi", NPC(true), { { name:"ha_yoon", - test:function(p) { return p.text.match(/ha-yoon|ha yoon|ha|yoon/); }, + test:function(p) { return p.text.match(/ha-yoon|ha yoon|^ha$|^yoon$/); }, script:function() { msg("'Tell me about Ha-yoon, Xsansi,' you say."); if (w.Xsansi.currentPlanet < 3) { @@ -282,12 +299,12 @@ createItem("Xsansi", NPC(true), { name:"itinerary", test:function(p) { return p.text.match(/itinerary|stars|planets|route|destinations/); }, script:function() { - msg("'Remind me of the itinerary, Xsansi,' you say."); + msg("'Remind me of the itinerary, Xsansi,' you say.") if (w.Xsansi.currentPlanet < 3) { for (let i = w.Xsansi.currentPlanet; i < PLANETS.length; i++) { - let s = "'Item " + (i + 1) + ": " + PLANETS[i].starDesc; - if (i + 2 === PLANETS.length) s += "'"; - msg(s); + let s = "'Item " + (i + 1) + ": " + PLANETS[i].starDesc + if (i + 2 === PLANETS.length) s += "'" + msg(s) } } else { @@ -477,21 +494,31 @@ createItem("Kyle", CREW(false), { msg("'That's right, cobber! Did the accent give it away?' Actually his accent is pretty faint, apart from the occasional \"cobber\", which you suspect is just an affectation. 'I'm from Sydney... well, originally Newcastle, but lived in Sydney most of my life.'") }, askOptions:[ + { + test:function(p) { return p.text.match(/satel/); }, + script:function() { + msg("'What's the deal with the satellite?' you ask Kyle."); + msg("'I just laurnch them. Ask Xsansi for up to the minute data.'") + } + }, + { test:function(p) { return p.text.match(/newcastle/); }, script:function() { msg("'What's Newcastle like?' you ask Kyle."); msg("'It's... okay. But no better than that. I guess it's too close to Sydney, and anything interesting goes there, so its kinda dull.'"); trackRelationship(w.Kyle, 1, "background2"); - }}, + } + }, { test:function(p) { return p.text.match(/sydney/); }, - esponse:function() { + script:function() { msg("'What's Sydney like?' you ask Kyle."); msg("'It's great! Really great nightlife, just so lively. Everyone said when they banned vehicles from the CBD, back in '68, it would die a death, but I think it made it even better.'"); trackRelationship(w.Kyle, 1, "background2"); - }}, + } + }, { name:"radioSignals", diff --git a/game-banks/settings.js b/game-banks/settings.js index 160a457..3bc16d0 100644 --- a/game-banks/settings.js +++ b/game-banks/settings.js @@ -149,7 +149,7 @@ s += '' settings.startingDialogEnabled = settings.playMode !== 'dev' -//settings.startingDialogEnabled = true +settings.startingDialogEnabled = true settings.startingDialogTitle = "To start with..." settings.startingDialogWidth = 500 settings.startingDialogHeight = 550 diff --git a/rpg/quest.js b/rpg/quest.js index c54797a..9d66e2f 100644 --- a/rpg/quest.js +++ b/rpg/quest.js @@ -1,5 +1,8 @@ "use strict" +// A quest has state and progress. The state is active, failed, etc. The progress indicates what step we are at. + + function questmsg(s, params) { _msg(s, params || {}, {cssClass:"quest", tag:'p'}); @@ -33,6 +36,11 @@ const quest = { if (q.init) q.init() } }, + find:function(alias) { + for (const q of this.data) { + if (q.alias.toLowerCase() === alias.toLowerCase()) return q + } + }, } settings.modulesToEndTurn.push(quest) @@ -42,7 +50,7 @@ io.modulesToInit.push(quest) class Quest { constructor(name, data) { this.name = name - this.key = name.replace(/ /g, '_').replace(/[^a-zA-Z0-9_]/g, '') + this.key = name.replace(/ /g, '_').replace(/[^a-zA-Z0-9_]/g, '').toLowerCase() for (const key in data) { this[key] = data[key] } this.stateName = 'quest_state_' + this.key this.progressName = 'quest_progress_' + this.key @@ -57,7 +65,7 @@ class Quest { questmsg((s ? s : quest.stateNames[char[this.stateName]]) + ": {i:" + this.name + "}") const state = char[this.stateName] const progress = char[this.progressName] - if (state && this.stages[progress]) questmsg(this.stages[progress].text) + if (state && this.stages[progress] && this.stages[progress].text) questmsg(this.stages[progress].text) } start(char, restart) {