forked from slothpixel/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added more murder mystery stats (slothpixel#685)
* Added murder mystery stats * Fixed coding standad * Forgot to add infection stats * Removed murder from gamemode names
- Loading branch information
1 parent
bd5fc22
commit b10fdf0
Showing
1 changed file
with
83 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,99 @@ | ||
const { getRatio } = require('../../util/utility'); | ||
const { getRatio, pickKeys } = require('../../util/utility'); | ||
/* | ||
* Murder Mystery | ||
*/ | ||
module.exports = ({ | ||
detective_chance = 0, | ||
murderer_chance = 0, | ||
coins = 0, | ||
wins = 0, | ||
games = 0, | ||
kills = 0, | ||
bow_kills = 0, | ||
knife_kills = 0, | ||
thrown_knife_kills = 0, | ||
trap_kills = 0, | ||
deaths = 0, | ||
was_hero = 0, | ||
mm_chests = 0, | ||
detective_wins = 0, | ||
murderer_wins = 0, | ||
MurderMystery_openedChests = 0, | ||
MurderMystery_openedCommons = 0, | ||
MurderMystery_openedRares = 0, | ||
MurderMystery_openedEpics = 0, | ||
MurderMystery_openedLegendaries = 0, | ||
}) => ({ | ||
coins, | ||
wins, | ||
losses: games - wins, | ||
games_played: games, | ||
win_loss_ratio: getRatio(wins, games - wins), | ||
kills, | ||
deaths, | ||
kill_death_ratio: getRatio(kills, deaths), | ||
times_hero: was_hero, | ||
boxes: { | ||
current: mm_chests, | ||
opened: MurderMystery_openedChests, | ||
commons: MurderMystery_openedCommons, | ||
rares: MurderMystery_openedRares, | ||
epics: MurderMystery_openedEpics, | ||
legendaries: MurderMystery_openedLegendaries, | ||
}, | ||
}); | ||
...rest | ||
}) => { | ||
const getModeStats = (regexp) => pickKeys(rest, { | ||
regexp, | ||
keyMap: (key) => key.replace(regexp, ''), | ||
}); | ||
const gamemodes = {}; | ||
const mapNames = [ | ||
'headquarters', | ||
'library', | ||
'gold_rush', | ||
'hypixel_world', | ||
'archives', | ||
'transport', | ||
'ancient_tomb', | ||
'mountain', | ||
'cruise_ship', | ||
'towerfall', | ||
'hollywood', | ||
'aquarium', | ||
'san_peratico', | ||
'san_peratico_v2', | ||
'library', | ||
'darkfall', | ||
'widow\'s_den', | ||
'snowfall', | ||
'skyway_pier', | ||
'spooky_mansion', | ||
'snowglobe', | ||
'archives_top_floor', | ||
]; | ||
const betterModeNames = { | ||
MURDER_CLASSIC: 'classic', | ||
MURDER_DOUBLE_UP: 'double_up', | ||
MURDER_ASSASSINS: 'assassins', | ||
MURDER_INFECTION: 'infection' | ||
}; | ||
Object.keys(betterModeNames).forEach((name) => { | ||
gamemodes[betterModeNames[name]] = getModeStats(new RegExp(`(?<!${mapNames.join('|')})_${name}$`)); | ||
}); | ||
Object.keys(gamemodes).forEach((name) => { | ||
const mode = gamemodes[name]; | ||
mode.kill_death_ratio = getRatio(mode.kills, mode.deaths); | ||
mode.win_loss_ratio = getRatio(mode.wins, mode.games - mode.wins); | ||
}); | ||
return ({ | ||
detective_chance, | ||
murderer_chance, | ||
coins, | ||
wins, | ||
detective_wins, | ||
murderer_wins, | ||
losses: games - wins, | ||
games_played: games, | ||
win_loss_ratio: getRatio(wins, games - wins), | ||
kills, | ||
bow_kills, | ||
knife_kills, | ||
thrown_knife_kills, | ||
trap_kills, | ||
deaths, | ||
kill_death_ratio: getRatio(kills, deaths), | ||
times_hero: was_hero, | ||
boxes: { | ||
current: mm_chests, | ||
opened: MurderMystery_openedChests, | ||
commons: MurderMystery_openedCommons, | ||
rares: MurderMystery_openedRares, | ||
epics: MurderMystery_openedEpics, | ||
legendaries: MurderMystery_openedLegendaries, | ||
}, | ||
gamemodes, | ||
}); | ||
}; |