Moved the help and lore dialog to the faction leaders

This commit is contained in:
2018-10-27 17:22:06 +11:00
parent c65488154f
commit 90cb007e4d
10 changed files with 103 additions and 18 deletions

View File

@@ -14,7 +14,7 @@ let shared = require("../Shared/shared");
//dialog system //dialog system
let dialog = shared.GenerateDialogFunction(require("./dialog.json")); let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
//ADAM dialog decorator //dialog decorator
dialog = function(baseDialog) { dialog = function(baseDialog) {
return function(key, ...data) { return function(key, ...data) {
if ( (key === "help" || key === "lore") && typeof(data[0]) !== "undefined") { if ( (key === "help" || key === "lore") && typeof(data[0]) !== "undefined") {
@@ -27,7 +27,7 @@ dialog = function(baseDialog) {
let result = baseDialog(key, ...data); let result = baseDialog(key, ...data);
if (result === "") { if (result === "") {
return "No result for \"" + key + "\""; return dialog("noResult", key);
} }
return result; return result;
} }
@@ -152,16 +152,6 @@ function processBasicCommands(client, message) {
message.delete(1000); message.delete(1000);
} }
return true; return true;
case "help":
case "lore":
shared.SendPublicMessage(client, message.author, message.channel, dialog(command, args[0]));
return true;
//DEBUGGING
case "debugxp":
shared.AddXP(client, message.author, args[0]);
return true;
} }
return false; return false;

View File

@@ -92,5 +92,7 @@
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.", "loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
"loreLibrarian": "WARNING: DATA CORRUPTED", "loreLibrarian": "WARNING: DATA CORRUPTED",
"loreCodex": "WARNING: DATA CORRUPTED", "loreCodex": "WARNING: DATA CORRUPTED",
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon." "loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
"noResult": "No result for \"{1}\""
} }

View File

@@ -13,6 +13,25 @@ let shared = require("../Shared/shared");
//dialog system //dialog system
let dialog = shared.GenerateDialogFunction(require("./dialog.json")); let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
//dialog decorator
dialog = function(baseDialog) {
return function(key, ...data) {
if ( (key === "help" || key === "lore") && typeof(data[0]) !== "undefined") {
//force the arg into camelCase
arg = data[0].toLowerCase();
arg = arg.charAt(0).toUpperCase() + arg.substr(1);
key += arg;
}
let result = baseDialog(key, ...data);
if (result === "") {
return dialog("noResult", key);
}
return result;
}
}(dialog);
//handle errors //handle errors
client.on('error', console.error); client.on('error', console.error);
@@ -98,6 +117,16 @@ function processBasicCommands(client, message) {
message.delete(1000); message.delete(1000);
} }
return true; return true;
case "help":
case "lore":
//skip the gate channel
if (message.channel.id === process.env.GATE_CHANNEL_ID) {
return true;
}
shared.SendPublicMessage(client, message.author, message.channel, dialog(command, args[0]));
return true;
} }
return false; return false;

View File

@@ -92,5 +92,7 @@
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.", "loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
"loreLibrarian": "WARNING: DATA CORRUPTED", "loreLibrarian": "WARNING: DATA CORRUPTED",
"loreCodex": "WARNING: DATA CORRUPTED", "loreCodex": "WARNING: DATA CORRUPTED",
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon." "loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
"noResult": "No result for \"{1}\""
} }

View File

@@ -13,6 +13,25 @@ let shared = require("../Shared/shared");
//dialog system //dialog system
let dialog = shared.GenerateDialogFunction(require("./dialog.json")); let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
//dialog decorator
dialog = function(baseDialog) {
return function(key, ...data) {
if ( (key === "help" || key === "lore") && typeof(data[0]) !== "undefined") {
//force the arg into camelCase
arg = data[0].toLowerCase();
arg = arg.charAt(0).toUpperCase() + arg.substr(1);
key += arg;
}
let result = baseDialog(key, ...data);
if (result === "") {
return dialog("noResult", key);
}
return result;
}
}(dialog);
//handle errors //handle errors
client.on('error', console.error); client.on('error', console.error);
@@ -98,6 +117,16 @@ function processBasicCommands(client, message) {
message.delete(1000); message.delete(1000);
} }
return true; return true;
case "help":
case "lore":
//skip the gate channel
if (message.channel.id === process.env.GATE_CHANNEL_ID) {
return true;
}
shared.SendPublicMessage(client, message.author, message.channel, dialog(command, args[0]));
return true;
} }
return false; return false;

View File

@@ -92,5 +92,7 @@
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.", "loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
"loreLibrarian": "WARNING: DATA CORRUPTED", "loreLibrarian": "WARNING: DATA CORRUPTED",
"loreCodex": "WARNING: DATA CORRUPTED", "loreCodex": "WARNING: DATA CORRUPTED",
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon." "loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
"noResult": "No result for \"{1}\""
} }

View File

@@ -13,6 +13,25 @@ let shared = require("../Shared/shared");
//dialog system //dialog system
let dialog = shared.GenerateDialogFunction(require("./dialog.json")); let dialog = shared.GenerateDialogFunction(require("./dialog.json"));
//dialog decorator
dialog = function(baseDialog) {
return function(key, ...data) {
if ( (key === "help" || key === "lore") && typeof(data[0]) !== "undefined") {
//force the arg into camelCase
arg = data[0].toLowerCase();
arg = arg.charAt(0).toUpperCase() + arg.substr(1);
key += arg;
}
let result = baseDialog(key, ...data);
if (result === "") {
return dialog("noResult", key);
}
return result;
}
}(dialog);
//handle errors //handle errors
client.on('error', console.error); client.on('error', console.error);
@@ -98,6 +117,16 @@ function processBasicCommands(client, message) {
message.delete(1000); message.delete(1000);
} }
return true; return true;
case "help":
case "lore":
//skip the gate channel
if (message.channel.id === process.env.GATE_CHANNEL_ID) {
return true;
}
shared.SendPublicMessage(client, message.author, message.channel, dialog(command, args[0]));
return true;
} }
return false; return false;

View File

@@ -92,5 +92,7 @@
"loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.", "loreSanctum": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
"loreLibrarian": "WARNING: DATA CORRUPTED", "loreLibrarian": "WARNING: DATA CORRUPTED",
"loreCodex": "WARNING: DATA CORRUPTED", "loreCodex": "WARNING: DATA CORRUPTED",
"loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon." "loreFactions": "TODO: Sorry. I recognize the term but am unable to process the request. There is a corruption in my cognitive core. Try again soon.",
"noResult": "No result for \"{1}\""
} }

View File

@@ -51,5 +51,5 @@
"heal": "THIS IS A LIBRARY. NOT A PLACE FOR HEALING.", "heal": "THIS IS A LIBRARY. NOT A PLACE FOR HEALING.",
"read": "PLEASE CHOOSE A BOOK: !book [name].", "read": "PLEASE CHOOSE A BOOK: !book [name].",
"unknown": "UNKNOWN" "noResult": "UNKNOWN"
} }

View File

@@ -27,7 +27,7 @@ dialog = function(baseDialog) {
let result = baseDialog(key, ...data); let result = baseDialog(key, ...data);
if (result === "") { if (result === "") {
return baseDialog("unknown"); return baseDialog("noResult");
} }
return result; return result;
} }