Skip to content

Commit

Permalink
Fixed errors and added missing stats (slothpixel#681)
Browse files Browse the repository at this point in the history
* Fixed 4v4 stats

* idk stole this from bedwars

* tbh I don't know what to call this but it's done

* Added my uuid to controbutors

* Made fixes for lintnofix

* Updated for better readability

* Removed unneeded replace statements

* Fixed errors and added missing stats

Fixed regex to remove labs from solo and teams

added heads stats

* Fixed errors

Removed duplicate code
Fixed incorrect naming
Added missing arrow hit miss ratio
  • Loading branch information
TheMysterys authored and ChristianDobbie committed Jan 10, 2022
1 parent 8a0b0f2 commit f858c23
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions processors/games/SkyWars.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,29 @@ module.exports = ({
soul_well = 0,
soul_well_rares = 0,
soul_well_legendaries = 0,
heads = 0,
heads_eww = 0,
heads_yucky = 0,
heads_meh = 0,
heads_decent = 0,
heads_salty = 0,
heads_tasty = 0,
heads_succulent = 0,
heads_sweet = 0,
heads_divine = 0,
heads_heavenly = 0,
...rest
}) => {
const getModeStats = (regexp) => pickKeys(rest, {
regexp,
keyMap: (key) => key.replace(regexp, '')
keyMap: (key) => key.replace(regexp, ''),
});
const gamemodes = {};
const betterModeNames = {
'solo(?!_insane|_normal)': 'solo',
'(?<!lab_)solo(?!_insane|_normal)': 'solo',
solo_insane: 'solo_insane',
solo_normal: 'solo_normal',
'team(?!_insane|_normal)': 'team',
'(?<!lab_)team(?!_insane|_normal)': 'team',
team_insane: 'team_insane',
team_normal: 'team_normal',
'lab(?!_solo|_team)': 'lab',
Expand All @@ -44,13 +55,12 @@ module.exports = ({
};
Object.keys(betterModeNames).forEach((name) => {
gamemodes[betterModeNames[name]] = getModeStats(new RegExp(`_${name}$`));
gamemodes[betterModeNames[name]].kill_death_ratio = getRatio(gamemodes[betterModeNames[name]].kills, gamemodes[betterModeNames[name]].deaths);
gamemodes[betterModeNames[name]].win_loss_ratio = getRatio(gamemodes[betterModeNames[name]].wins, gamemodes[betterModeNames[name]].losses);
});
Object.keys(gamemodes).forEach(function(name) {
Object.keys(gamemodes).forEach((name) => {
const mode = gamemodes[name];
mode.kill_death_ratio = getRatio(mode.kills,mode.deaths);
mode.kill_death_ratio = getRatio(mode.wins,mode.losses);
mode.kill_death_ratio = getRatio(mode.kills, mode.deaths);
mode.win_loss_ratio = getRatio(mode.wins, mode.losses);
mode.arrow_hit_miss_ratio = getRatio(mode.arrows_hit, mode.arrows_shot)
});
return ({
coins,
Expand All @@ -59,7 +69,7 @@ module.exports = ({
win_loss_ratio: getRatio(wins, losses),
experience: skywars_experience,
level: getLevelForExp(skywars_experience),
levelFormatted: `${levelFormatted.replace(/§[\da-f]/g, '$&[')}]`,
levelFormatted: `${levelFormatted.replace(/§[\da-f]/g, '$&[').replace(/§/, '&')}]`,
kills,
deaths,
assists,
Expand All @@ -76,6 +86,19 @@ module.exports = ({
soul_well_uses: soul_well,
soul_well_rares,
soul_well_legendaries,
heads: {
total_heads: heads,
heads_eww,
heads_yucky,
heads_meh,
heads_decent,
heads_salty,
heads_tasty,
heads_succulent,
heads_sweet,
heads_divine,
heads_heavenly,
},
gamemodes,
});
};

0 comments on commit f858c23

Please sign in to comment.