diff --git a/commands/weapon-stats.js b/commands/weapon-stats.js index 96b387d..f6e603b 100644 --- a/commands/weapon-stats.js +++ b/commands/weapon-stats.js @@ -109,6 +109,8 @@ module.exports = { .setDescription(`${tag} stats for the **${weapon}**`) .setThumbnail(weapons[weaponClass][weapon]) .addFields( + { name: `Kills`, value: `${player.weaponStats[weapon].kills}`, inline: true }, + { name: `Deaths`, value: `${player.weaponStats[weapon].deaths}`, inline: true }, { name: `Shots Landed`, value: `${player.weaponStats[weapon].shotsLanded}`, inline: true }, { name: `Times Shot`, value: `${player.weaponStats[weapon].timesShot}`, inline: true }, ); diff --git a/database/player.js b/database/player.js index d6e67d3..1532c75 100644 --- a/database/player.js +++ b/database/player.js @@ -61,6 +61,8 @@ module.exports = { shotsLandedPerBodyPart: copy(BodyParts), timesShotPerBodyPart: copy(BodyParts), weaponStats: createWeaponsObject({ + kills: 0, + deaths: 0, shotsLanded: 0, timesShot: 0, shotsLandedPerBodyPart: copy(BodyParts), @@ -101,6 +103,8 @@ module.exports = { player.shotsLandedPerBodyPart = copy(BodyParts); player.timesShotPerBodyPart = copy(BodyParts); player.weaponStats = createWeaponsObject({ + kills: 0, + deaths: 0, shotsLanded: 0, timesShot: 0, shotsLandedPerBodyPart: copy(BodyParts), @@ -112,6 +116,8 @@ module.exports = { // If a new weapon is not in the existing weaponStats, this will add it. createWeaponStats(player, weapon) { player.weaponStats[weapon] = { + kills: 0, + deaths: 0, shotsLanded: 0, timesShot: 0, shotsLandedPerBodyPart: copy(BodyParts), diff --git a/database/weapons.js b/database/weapons.js index bab090a..d744770 100644 --- a/database/weapons.js +++ b/database/weapons.js @@ -70,5 +70,5 @@ module.exports = { }, }, - weaponClassOf: (weapon) => Object.keys(module.exports.weapons).filter(v => module.exports.weapons[v].hasOwnProperty(weapon))[0], + weaponClassOf: (weapon) => Object.keys(module.exports.weapons).filter(c => weapon in module.exports.weapons[c])[0], } diff --git a/package.json b/package.json index 3588e68..8fc5e34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayzr-bot", - "version": "12.5.3", + "version": "12.5.4", "description": "A General Purpose Discord Bot for DayZ Nitrado Servers.", "main": "index.js", "nodemonConfig": { diff --git a/util/KillfeedHandler.js b/util/KillfeedHandler.js index b59fdb7..77c467b 100644 --- a/util/KillfeedHandler.js +++ b/util/KillfeedHandler.js @@ -184,6 +184,8 @@ module.exports = { killerStat.KDR = killerStat.kills / (killerStat.deaths == 0 ? 1 : killerStat.deaths); // prevent division by 0 killerStat.longestKill = info.distance > killerStat.longestKill ? info.distance : killerStat.longestKill; killerStat.deathStreak = 0; + if (!client.exists(killerStat.weaponStats[weapon].kills)) killerStat.weaponStats[weapon].kills = 0; + killerStat.weaponStats[weapon].kills++; // Update victim stats victimStat.deaths++; @@ -192,6 +194,8 @@ module.exports = { victimStat.KDR = victimStat.kills / (victimStat.deaths == 0 ? 1 : victimStat.deaths); // prevent division by 0 victimStat.killStreak = 0; victimStat.lastDeathDate = newDt; + if (!client.exists(victimStat.weaponStats[weapon].deaths)) victimStat.weaponStats[weapon].death = 0; + victimStat.weaponStats[weapon].deaths++; // Create defaults for non-existing ratings if (!client.exists(killerStat.combatRating)) killerStat.combatRating = 800; @@ -233,7 +237,7 @@ module.exports = { } banking = banking.user; - if (!client.exists(banking.guilds[ guild.serverID])) { + if (!client.exists(banking.guilds[guild.serverID])) { const success = addUser(banking.guilds, guild.serverID, interaction.member.user.id, client, guild.startingBalance); if (!success) return client.sendInternalError(interaction, 'Failed to add bank'); }