summaryrefslogtreecommitdiff
path: root/src/HeroTalentTable.vue
blob: 77d868ca414ba146f7794e00118d4de13fcae61f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<template>
  <div class="box">
    <div class="columns is-mobile">
      <div class="column is-one-quarter">
        <hero-image :actor="selectedActor" class="is-64x64"></hero-image>
      </div>
      <div class="column has-text-centered">{{ (100 * totalHeroReport.TotalWinner / totalHeroReport.TotalPicks).toFixed(0) }}% Win&nbsp;Rate</div>
      <div class="column has-text-centered">{{ (100 * totalHeroReport.TotalPicks / totalPicks * playersPerMatch).toFixed(0) }}% Pick&nbsp;Rate</div>
    </div>

    <b-table v-show="hasTalents"
             :data="heroReport"
             :mobile-cards="false">
      <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="Talent" label="Talent">
          <talent-image :entry="props.row" :size="48"></talent-image>
        </b-table-column>

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

        <b-table-column field="TalentWinrateMax" label="Max Level Win Rate" meta="Estimated." sortable numeric>
          <template v-if="!isNaN(props.row.TalentWinrateMax)">
            {{ (100 * props.row.TalentWinrateMax).toFixed(0) }}%
            <small v-if="props.row.SampleTooSmall || props.row.VarianceTooLarge"><br />uncertain</small>
          </template>
        </b-table-column>
      </template>
    </b-table>
  </div>
</template>

<script>
import Vue from 'vue';
import TalentImage from './TalentImage.vue';
import HeroImage from './HeroImage.vue';
import RouterParamMixin from './RouterParamMixin';
import ReportService from './ReportService';
import * as maps from './maps/maps';

export default Vue.component('hero-talent-table', {
  mixins: [ RouterParamMixin ],
  data: function() {
    return {
      getTalentName: maps.getTalentName,
      getLevelBuckets: ReportService.getLevelBuckets,
      getLevelsPerBucket: (entry) => maps.getMaxLevel(entry) / this.getLevelBuckets(),
    };
  },
  computed: {
    hasTalents: function() {
      return maps.hasTalents(this.selectedMode);
    },
    totalPicks: function() {
      return ReportService.getTotalPicks(this.selectedMode);
    },
    heroReport: function() {
      return ReportService.getReport(this.selectedMode)
          .filter((entry) => entry.Actor == this.selectedActor)
          .sort((entry1, entry2) => maps.getTalentRarityIndex(entry1.Talent) - maps.getTalentRarityIndex(entry2.Talent));
    },
    totalHeroReport: function() {
      return this.heroReport
        .map((entry) => ({ 'TotalWinner': entry.TotalPicks * entry.TotalWinner, 'TotalPicks': entry.TotalPicks }))
        .reduce((agg, cur) =>
          ({ 'TotalWinner': agg.TotalWinner + cur.TotalWinner, 'TotalPicks': agg.TotalPicks + cur.TotalPicks }),
          { 'TotalWinner': 0, 'TotalPicks': 0 });
    },
    playersPerMatch: function() {
      return maps.playersPerMatch(this.selectedMode);
    },
  },
  components: {
    TalentImage,
    HeroImage,
  },
});
</script>