mirror of
https://github.com/Ratstail91/SANCTUM.git
synced 2025-11-28 18:14:28 +11:00
Graze prints upgrade details, fixed dialog bug
This commit is contained in:
@@ -37,6 +37,9 @@ client.on('ready', async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log("Logged in as: " + client.user.username + " - " + client.user.id);
|
console.log("Logged in as: " + client.user.username + " - " + client.user.id);
|
||||||
|
|
||||||
|
//connect to the server
|
||||||
|
shared.ConnectToServer(client.user.username, process.env.SERVER_ADDRESS, process.env.SERVER_PORT, process.env.SERVER_PASS_KEY);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create an event listener for messages
|
// Create an event listener for messages
|
||||||
@@ -82,6 +85,16 @@ function processBasicCommands(client, message) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
//TODO: avoid help command collisions
|
||||||
|
|
||||||
|
case "upgrade":
|
||||||
|
if (!args[0]) {
|
||||||
|
printUpgrades(message.author, message.channel);
|
||||||
|
} else {
|
||||||
|
processUpgradeCommand(message.author, message.channel, args);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
shared.SendPublicMessage(client, message.author, message.channel, dialog(command));
|
shared.SendPublicMessage(client, message.author, message.channel, dialog(command));
|
||||||
return true;
|
return true;
|
||||||
@@ -89,3 +102,24 @@ function processBasicCommands(client, message) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function printUpgrades(user, channel) {
|
||||||
|
let handleResponse = function(stats) {
|
||||||
|
//create the embed
|
||||||
|
let embed = new discord.RichEmbed()
|
||||||
|
.setAuthor(client.user.username, client.user.avatarURL)
|
||||||
|
.setColor(client.guilds.get(process.env.SANCTUM_ID).roles.find(role => role.name === "NPC").color) //NOTE: probably a better way to do this
|
||||||
|
.setTitle("Nanotech Upgrades")
|
||||||
|
.setDescription(dialog("upgradeText"))
|
||||||
|
.setFooter(`${user.username}, you have ${stats.wallet} crystals. Use !upgrade [OPTION] to buy.`); //TODO: move this to dialog?
|
||||||
|
|
||||||
|
shared.SendPublicMessage(client, user, channel, dialog("upgradeHeading"));
|
||||||
|
channel.send({ embed });
|
||||||
|
}
|
||||||
|
|
||||||
|
shared.OnServerData("userStats", handleResponse, user.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function processUpgradeCommand(uset, channel, args) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"upgradeHeading": "Hey buddy! Here's what we can upgrade ASAP!",
|
||||||
|
|
||||||
|
"upgradeText": "STR - :cannister: **1**\n```Permanently upgrades your Strength by 1, so you can hit them Ravagers harder.```\nSPD - :cannister: **1**\n```Permanently upgrades your Speed by 1, so you can get hit less in battle.```\nSTAM - :cannister: **1**\n```Permanently upgrades your Max Stamina by 1, so you can hit more Ravagers.```\nHP - :cannister: **1**\n```Permanently upgrades your Max HP by 10, so you can can take those beatings like a champ.```",
|
||||||
|
|
||||||
"noResult": "I have no idea what you just said."
|
"noResult": "I have no idea what you just said."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,17 @@ exports.GenerateDialogFunction = function(dialogJson) {
|
|||||||
result = dialogJson[key];
|
result = dialogJson[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//handle no result
|
||||||
if (typeof(result) === "undefined") {
|
if (typeof(result) === "undefined") {
|
||||||
return dialogJson["noResult"];
|
const noResult = dialogJson["noResult"];
|
||||||
|
if (typeof(noResult) === "undefined") {
|
||||||
|
return ""; //nothing at all to show
|
||||||
|
}
|
||||||
|
if (Array.isArray(noResult)) {
|
||||||
|
result = noResult[Math.floor(Math.random() * noResult.length)];
|
||||||
|
} else {
|
||||||
|
result = noResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user