Rewrote ADAM

This commit is contained in:
2018-10-21 19:07:41 +11:00
parent e7069db0d0
commit c18f189ab7
5 changed files with 338 additions and 1156 deletions

View File

@@ -79,11 +79,12 @@ exports.ChangeFaction = async function(client, factionRole, channel, member) {
if (member.roles.has(factionRole)) {
//can't change to this faction
return messaging.SendPublicMessage(client, member.user, channel, "You have already joined that faction.");
return "alreadyJoined";
}
if (dataRequest.loadServerData("hasConvertedToday", member.user.id) == 1) {
return messaging.SendPublicMessage(client, member.user, channel, "You have already converted today.");
//can't change too fast
return "hasConvertedToday";
}
//Creates a new user
@@ -98,12 +99,11 @@ exports.ChangeFaction = async function(client, factionRole, channel, member) {
//send the server the info (for logging)
dataRequest.sendServerData("conversion", "Converted to " + exports.GetFactionName(factionRole), member.user.id);
//send the public welcoming message
messaging.SendPublicMessage(client, member.user, channel, "Welcome to " + exports.GetFactionName(factionRole));
//send the private welcoming message
if (newUserResponse === "createdUser") {
//TODO: more dialog from adam & other faction leaders
messaging.SendPrivateMessage(client, member.user, "Welcome to SANCTUM.");
//send the private welcoming message
return newUserResponse;
} else {
//send the public welcoming message
return "joined";
}
}

View File

@@ -35,19 +35,16 @@ exports.LevelUp = function(client, member) { //NOTE: why is this called separate
let response = String(dataRequest.sendServerData("getLevelUp", 0, member.user.id)); //TODO: please change the order of sendServerData's arguments!
let responseArray = response.split(",");
//DEBUGGING
// console.log("response: " + response);
let responseMessage = responseArray[0];
let level = Math.floor(parseFloat(responseArray[1]));
let statPoints = parseFloat(responseArray[2]);
// let userStats = String(dataRequest.loadServerData("userStats", member.user.id));
let rankUp = exports.RankUp(client, member, level);
exports.RankUp(client, member, level);
if (responseMessage == "levelup") {
//TODO: proper dialog
if (rankUp == "rankUp") {
return rankUp;
} else if (responseMessage === "levelup") {
return "levelUp";
}
}
@@ -85,7 +82,7 @@ exports.RankUp = async function(client, member, level) {
}
if (member.roles.has(levelRole.id)) { //member has this role already
return;
return "";
}
//the ranks as roles
@@ -102,4 +99,7 @@ exports.RankUp = async function(client, member, level) {
//this will enable the new rooms
member.addRole(levelRole);
//return the result
return "rankUp";
}

View File

@@ -34,6 +34,10 @@ exports.GenerateDialogFunction = function(dialogJson) {
result = dialogJson[key];
}
if (typeof(result) === "undefined") {
return "";
}
let counter = 0;
data.map((dat) => {
counter++;
@@ -162,7 +166,7 @@ exports.CheckValidDisplay = function(client, member, channel, checkRole) { //See
return false;
}
default:
//default value
return false;
//default value: always show messages if not a faction leader
return true;
}
}