From 55e9f9b390e4ed7ed76b2a6ed7893d34a0ef8b99 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 13 Sep 2020 23:54:37 -0400 Subject: [PATCH] Factor in new subscoring model --- src/commands/score.ts | 19 ++++++++++++------- src/intervals/score.ts | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/commands/score.ts b/src/commands/score.ts index 60111cb..bf84bb7 100644 --- a/src/commands/score.ts +++ b/src/commands/score.ts @@ -56,6 +56,7 @@ export default class Score extends Command { let moderationScore = '0'; let roleScore = '0'; let cloudServicesScore = '0'; + let otherScore = '0'; let miscScore = '0'; if (score) { @@ -73,13 +74,16 @@ export default class Score extends Command { moderationScore = `${score.moderation}`; + if (score.other === 0) otherScore = '---'; + else otherScore = `${score.other}`; + if (score.staff <= 0) miscScore = '---'; else miscScore = `${score.staff}`; if (score.cloudServices === 0) cloudServicesScore = '---'; - else if (score.cloudServices > 50) cloudServicesScore = '50'; + else if (score.cloudServices > 10) cloudServicesScore = '10'; else cloudServicesScore = `${score.cloudServices}`; - } else return this.error(message.channel, 'Community Score has not been calculated yet.'); + } // else return this.error(message.channel, 'Community Score has not been calculated yet.'); const embed = new RichEmbed(); embed.setTitle('Community Score'); @@ -105,11 +109,12 @@ export default class Score extends Command { if (score.total >= 500) { color = '🟡'; embed.setColor('FFFF00'); } if (score.total >= 700) { color = '🟢'; embed.setColor('66FF66'); } embed.addField('Total | 200 to 800', `${color} ${totalScore}`, true); - embed.addField(`Activity | 10 to ${Math.floor(Math.log1p(5000 + 300 + 200 + 100) * 12)}`, activityScore, true); - embed.addField('Roles | 1 to N/A', roleScore, true); - embed.addField('Moderation | N/A to 2', moderationScore, true); - embed.addField('Cloud Services | N/A to 10', cloudServicesScore, true); - embed.addField('Misc', miscScore, true); + embed.addField(`Activity | 10 to ${Math.floor(Math.log1p(5000 + 300 + 200 + 100) * 12)}`, activityScore || 'N/C', true); + embed.addField('Roles | 1 to N/A', roleScore || 'N/C', true); + embed.addField('Moderation | N/A to 2' || 'N/C', moderationScore, true); + embed.addField('Cloud Services | N/A to 10', cloudServicesScore || 'N/C', true); + embed.addField('Other', otherScore || 'N/C', true); + embed.addField('Misc', miscScore || 'N/C', true); if (score.lastUpdate) { embed.setFooter('Report last updated', this.client.user.avatarURL); embed.setTimestamp(score.lastUpdate); diff --git a/src/intervals/score.ts b/src/intervals/score.ts index 38f2f2e..4915f4a 100644 --- a/src/intervals/score.ts +++ b/src/intervals/score.ts @@ -36,6 +36,7 @@ export default async function calculateScore(client: Client): Promise 0) { + for (const inq of score.inquiries) { + const testDate = (new Date(new Date(inq.date).setHours(2190))); + if (testDate > new Date()) other -= 1.5; + } + other = Math.floor(other * 1.15); + } - await score.updateOne({ $set: { total, activity, roles, moderation, cloudServices, staff, lastUpdate: new Date() } }); + total = Math.floor(((total + activity + roles + moderation + cloudServices + staff + other) * 5.13) * 1.87); + + await score.updateOne({ $set: { total, activity, roles, moderation, cloudServices, other, staff, lastUpdate: new Date() } }); // client.util.signale.debug(`SCORE SET - ${member.username}\nTotal: ${total}\nActivity: ${activity}\nRoles: ${roles}\nModeration: ${moderation}\nCloud Services: ${cloudServices}\nStaff: ${staff}`); } };