Skip to content
This repository has been archived by the owner on Jan 12, 2020. It is now read-only.

Commit

Permalink
ReportTable: Advantage per Level -> Max Win Rate, fix 5v5/3v3 table, …
Browse files Browse the repository at this point in the history
…add filters
  • Loading branch information
schneefux committed Jun 17, 2018
1 parent 445a79e commit 25e9376
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/ReportService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as maps from './maps/maps';
import * as metadata from '../data/2d73896c/metadata.json';

const POPULAR_THRESHOLD = 1.0; // percent
const PICKS_THRESHOLD = 200; // picks
const PICKS_THRESHOLD = 300; // picks

const report = require('../data/2d73896c/report.json')
.filter((entry) => entry.Actor != undefined); // bad data from API downtime
Expand Down Expand Up @@ -66,6 +66,7 @@ for(let mode of modes) {
return Object.assign({}, entry, {
TalentWinrateBase: intercept,
TalentWinrateScaling: slope, // to 1 = max level
TalentWinrateMax: intercept + slope,
TalentWinrateLevelScaling: slope / maps.getMaxLevel(entry),
TotalPicks: sum_weights || entry.Count, // NoTalent has no weights
TotalWinner: sum_y / sum_weights || entry.Winner,
Expand Down
59 changes: 49 additions & 10 deletions src/ReportTable.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
<template>
<section>
<b-field>
<p class="control">
<b-dropdown v-model="filterRarity">
<button class="button" slot="trigger">
<span>{{ filterRarity || 'All' }} Talents</span>
<b-icon icon="menu-down"></b-icon>
</button>

<b-dropdown-item value="">All Talents</b-dropdown-item>
<b-dropdown-item v-for="rarity in RARITIES" :key="rarity" :value="rarity">{{ rarity }} Talents</b-dropdown-item>
</b-dropdown>
</p>

<b-input placeholder="Search…" type="search" icon="magnify" v-model="filterName"></b-input>

</b-field>

<b-field>
<div class="control">
<b-switch v-model="filterLowPickrate">Include entries without enough data</b-switch>
</div>
</b-field>

<b-table :data="report"
:default-sort="['TotalPicks', 'desc']"
:default-sort-directon="'desc'"
:paginated="true">
<template slot-scope="props" slot="header">
<b-tooltip :active="!!props.column.meta" :label="props.column.meta || ''" position="is-bottom" dashed>
{{ props.column.label }}
</b-tooltip>
</template>

<template slot-scope="props">
<b-table-column field="Actor" label="Hero" sortable>
<!-- desktop, table view -->
Expand Down Expand Up @@ -39,24 +68,25 @@
</div>
</b-table-column>

<b-table-column field="Winner" label="Level 1 Win Rate" sortable numeric>
<template v-if="isNaN(props.row.TalentWinrateBase) || props.row.SampleTooSmall">
{{ (100 * props.row.Winner).toFixed(2) }}%
<b-table-column field="TalentWinrateBase" label="Level 1 Win Rate" meta="Estimated." :visible="hasTalents" sortable numeric>
<template v-if="isNaN(props.row.TalentWinrateBase)">
{{ (100 * props.row.Winner).toFixed(2) }}% <!-- No Talent -->
</template>
<template v-else>
{{ (100 * props.row.TalentWinrateBase).toFixed(2) }}%
</template>
</b-table-column>

<b-table-column field="TalentWinrateScaling" label="Win Rate Advantage" sortable numeric>
<template v-if="isNaN(props.row.TalentWinrateScaling) || props.row.SampleTooSmall">
<span class="mdi mdi-gauge-empty mdi-18px" title="Not enough data"></span>
</template>
<template v-else>
{{ (props.row.TalentWinrateScaling > 0? '+' : '') + (100 * props.row.TalentWinrateScaling / getLevelBuckets()).toFixed(2) }}% <small>for {{ getLevelsPerBucket(props.row) + (getLevelsPerBucket(props.row) > 1? ' Levels' : ' Level') }}</small>
<b-table-column field="TalentWinrateMax" label="Max Level Win Rate" meta="Estimated." :visible="hasTalents" sortable numeric>
<template v-if="!isNaN(props.row.TalentWinrateMax)">
{{ (100 * props.row.TalentWinrateMax).toFixed(2) }}%
</template>
</b-table-column>

<b-table-column field="Winner" label="Win Rate" :visible="!hasTalents" sortable numeric>
{{ (100 * props.row.Winner).toFixed(2) }}%
</b-table-column>

<b-table-column field="TotalPicks" label="Pick Rate" sortable numeric>
{{ (100 * playersPerMatch * props.row.TotalPicks / totalPicks).toFixed(2) }}%
</b-table-column>
Expand All @@ -76,6 +106,7 @@ export default Vue.component('report-table', {
mixins: [ RouterParamMixin ],
data: function() {
return {
RARITIES: maps.RARITIES,
getTalentName: maps.getTalentName,
getTalentRarityIndex: maps.getTalentRarityIndex,
getHero: maps.getHero,
Expand All @@ -85,7 +116,15 @@ export default Vue.component('report-table', {
},
computed: {
report: function() {
return ReportService.getReport(this.selectedMode);
const giveTrue = (x) => true;
const filters = [
this.filterRarity != ''? (entry) => maps.getTalentRarity(entry.Talent) == this.filterRarity : giveTrue,
this.filterName != ''? (entry) => maps.getHero(entry.Actor).includes(this.filterName) || maps.getTalentName(entry.Talent).includes(this.filterName) : giveTrue,
!this.filterLowPickrate? (entry) => !entry.SampleTooSmall : giveTrue,
];
const and = (a, b) => a && b;
return ReportService.getReport(this.selectedMode)
.filter((entry) => filters.map((filter) => filter(entry)).reduce(and, true));
},
totalPicks: function() {
return ReportService.getTotalPicks(this.selectedMode);
Expand Down
30 changes: 30 additions & 0 deletions src/RouterParamMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,35 @@ export default {
this.$router.push({ query });
},
},
filterRarity: {
get: function() {
return this.$route.query.rarity || '';
},
set: function(value) {
this.$ga.event('Rarity', 'update', value);
const query = Object.assign({}, this.$route.query, { rarity: value });
this.$router.push({ query });
},
},
filterName: {
get: function() {
return this.$route.query.search || '';
},
set: function(value) {
this.$ga.event('Search', 'update', value);
const query = Object.assign({}, this.$route.query, { search: value });
this.$router.push({ query });
},
},
filterLowPickrate: {
get: function() {
return this.$route.query.lowPickrate == true;
},
set: function(value) {
this.$ga.event('LowPickrate', 'update', value);
const query = Object.assign({}, this.$route.query, { lowPickrate: value });
this.$router.push({ query });
},
},
},
};
5 changes: 3 additions & 2 deletions src/WinPickScatter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ export default Vue.component('win-pick-scatter', {
selectedMode() {
this.refresh();
},
selectedActor() {
filterLowPickrate() {
this.refresh();
},
},
methods: {
refresh() {
const data = ReportService.getReport(this.selectedMode);
const data = ReportService.getReport(this.selectedMode)
.filter((entry) => !this.filterLowPickrate? !entry.SampleTooSmall : true);
const total = ReportService.getTotalPicks(this.selectedMode);
const dataWithRarity = (rarity) => data.filter((entry) => maps.getTalentRarity(entry.Talent) == rarity);
Expand Down
13 changes: 1 addition & 12 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,5 @@ module.exports = {
new MiniCssExtractPlugin({
}),
new OptimizeCssAssetsPlugin(),
].concat(process.env.NODE_ENV == 'production' ? [
new PurgecssPlugin({
paths: glob.sync([
'./src/*.html',
'./src/*.js',
'./src/*.vue',
'./src/**/*.vue',
'./node_modules/buefy/src/components/table/*',
'./node_modules/buefy/src/components/pagination/*',
])
}),
] : []),
],
};

0 comments on commit 25e9376

Please sign in to comment.