Skip to content

Commit

Permalink
Minor changes to quest.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePix committed Dec 6, 2024
1 parent f9680fb commit eb674c5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 12 deletions.
45 changes: 36 additions & 9 deletions game-banks/npcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/); },
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion game-banks/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ s += '</select></td></tr></table>'


settings.startingDialogEnabled = settings.playMode !== 'dev'
//settings.startingDialogEnabled = true
settings.startingDialogEnabled = true
settings.startingDialogTitle = "To start with..."
settings.startingDialogWidth = 500
settings.startingDialogHeight = 550
Expand Down
12 changes: 10 additions & 2 deletions rpg/quest.js
Original file line number Diff line number Diff line change
@@ -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'});
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit eb674c5

Please sign in to comment.