[HQ, Config] Auto split enhancements + more hq config

This commit is contained in:
vilP1L
2019-06-10 22:43:19 -04:00
parent 6209234a1f
commit 14296fb3a8
3 changed files with 15 additions and 4 deletions

View File

@@ -21,7 +21,7 @@ Wilder Emu Bot + Trivia Emulator
- [X] Checkpoint Support (HQ) - [X] Checkpoint Support (HQ)
- [X] Auto Checkpoint Claiming - [X] Auto Checkpoint Claiming
- [X] Auto Splitting - [X] Auto Splitting
- [ ] Auto Split Enhancements (split on last q, prize qs, etc) - [X] Auto Split Enhancements (split on last q, prize qs, etc)
### Discord Bot Commands ### Discord Bot Commands

View File

@@ -80,10 +80,10 @@
] ]
}, },
"mongo": { "mongo": {
"dbName": "weights",
"user": "mongoadmin", "user": "mongoadmin",
"pass": "torchard#", "pass": "torchard#",
"host": "skysilk.vilp1l.dev" "host": "skysilk.vilp1l.dev",
"dbName": "weights"
}, },
"proxy": { "proxy": {
"user": "grbyzyjh", "user": "grbyzyjh",
@@ -98,6 +98,8 @@
}, },
"hq": { "hq": {
"autoSplit": true, "autoSplit": true,
"autoSplitOnPrizeQuestions": true,
"autoSplitOnLastQuestion": true,
"splitThreshold": 0.65, "splitThreshold": 0.65,
"autoCheckpoints": true, "autoCheckpoints": true,
"checkpointThreshold": 1 "checkpointThreshold": 1

View File

@@ -78,7 +78,16 @@ export default async (client, prize) => {
const bestAnswerPercentage = client.weights.hq[bestAnswer] / total; const bestAnswerPercentage = client.weights.hq[bestAnswer] / total;
const canAnswer = client.hqClients.filter(c => c.inTheGame); const canAnswer = client.hqClients.filter(c => c.inTheGame);
const splitArr = [...canAnswer]; const splitArr = [...canAnswer];
if ((bestAnswerPercentage < hq.splitThreshold) && hq.autoSplit) { // eslint-disable-next-line max-len
const splitLastQ = hq.autoSplitOnLastQuestion && json.questionNumber === json.questionCount;
const splitOnPrizeQ = hq.autoSplitOnPrizeQuestions && !json.nextCheckpointIn;
if (splitOnPrizeQ || splitLastQ) {
for (let i = 0; i < 3; i += 1) {
const num = Math.round(canAnswer / 3);
const clients = splitArr.slice(0, num <= splitArr.length ? num : splitArr.length);
clients.forEach(c => c.submitAnswer(i));
}
} else if ((bestAnswerPercentage < hq.splitThreshold) && hq.autoSplit) {
client.weights.hq.forEach((w, i) => { client.weights.hq.forEach((w, i) => {
const percentage = w / total; const percentage = w / total;
const num = Math.round(canAnswer.length * percentage); const num = Math.round(canAnswer.length * percentage);