fix/handle new weapons in weaponStats
This commit is contained in:
3 files changed
+15
-2
No files matched your search
@@ -107,5 +107,16 @@ module.exports = {
|
||||
timesShotPerBodyPart: copy(BodyParts),
|
||||
});
|
||||
return player;
|
||||
},
|
||||
|
||||
// If a new weapon is not in the existing weaponStats, this will add it.
|
||||
createWeaponStats(player, weapon) {
|
||||
player.weaponStats[weapon] = {
|
||||
shotsLanded: 0,
|
||||
timesShot: 0,
|
||||
shotsLandedPerBodyPart: copy(BodyParts),
|
||||
timesShotPerBodyPart: copy(BodyParts),
|
||||
}
|
||||
return player;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dayzr-bot",
|
||||
"version": "12.3.15",
|
||||
"version": "12.3.16",
|
||||
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
||||
"main": "index.js",
|
||||
"nodemonConfig": {
|
||||
|
||||
+3
-1
@@ -3,7 +3,7 @@ const { HandleAlarmsAndUAVs } = require('./AlarmsHandler');
|
||||
const { SendConnectionLogs, DetectCombatLog } = require('./AdminLogsHandler');
|
||||
const { getDefaultPlayer } = require('../database/player');
|
||||
const { FetchServerSettings } = require('../util/NitradoAPI');
|
||||
const { UpdatePlayer, insertPVPstats } = require('../database/player')
|
||||
const { UpdatePlayer, insertPVPstats, createWeaponStats } = require('../database/player')
|
||||
|
||||
let lastSendMessage;
|
||||
|
||||
@@ -184,11 +184,13 @@ module.exports = {
|
||||
if (info.weapon in playerStat.weaponStats) {
|
||||
playerStat.timesShot++;
|
||||
playerStat.timesShotPerBodyPart[info.bodyPart]++;
|
||||
if (!client.exists(playerStat.weaponStats[info.weapon])) playerStat = createWeaponStats(playerStat, info.weapon);
|
||||
playerStat.weaponStats[info.weapon].timesShot++;
|
||||
playerStat.weaponStats[info.weapon].timesShotPerBodyPart[info.bodyPart]++;
|
||||
|
||||
attackerStat.shotsLanded++;
|
||||
attackerStat.shotsLandedPerBodyPart[info.bodyPart]++;
|
||||
if (!client.exists(attackerStat.weaponStats[info.weapon])) attackerStat = createWeaponStats(attackerStat, info.weapon);
|
||||
attackerStat.weaponStats[info.weapon].shotsLanded++;
|
||||
attackerStat.weaponStats[info.weapon].shotsLandedPerBodyPart[info.bodyPart]++;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user