-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkillCountHandler.js
More file actions
41 lines (37 loc) · 1.31 KB
/
killCountHandler.js
File metadata and controls
41 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { grumblerCheck, killCountMsgConstructor } from './helperFunctions';
import { bossMap, specialKills, KILL_COUNT, BRUTUS } from '../constants';
/**
* Check if the current killCount is divisible by 100.
* If it's not but it is in specialKills then allow the notification.
* @param {Map<{ ID: string, URL: string}, string>} msgMap - The message map to update
* @param {*} playerName - The player's name
* @param {*} extra - Additional information
* @param {*} URL - The associated URL
* @returns {Map<{ ID: string, URL: string }, string>} The updated message map
*/
function killCountHandler(msgMap, playerName, extra, URL) {
const { boss, count: killCount, gameMessage } = extra || {};
const validatedBossName = grumblerCheck(boss);
const bossInterval = bossMap.get(validatedBossName?.toUpperCase());
// if KC is notable
if (
killCount % bossInterval === 0 ||
killCount % 100 === 0 ||
(killCount === 1 &&
validatedBossName === BRUTUS &&
playerName === "THEMILDEST1") ||
(killCount === 1 && specialKills.includes(validatedBossName.toUpperCase()))
) {
msgMap.set(
{ ID: KILL_COUNT, URL },
killCountMsgConstructor(
playerName,
gameMessage,
validatedBossName,
killCount
)
);
}
return msgMap;
}
export default killCountHandler;