fchat-rising/site/character_page/match-report.vue

82 lines
2.4 KiB
Vue
Raw Normal View History

2019-06-29 20:59:29 +00:00
<template>
<div id="match-report" :class="{'match-report': true, minimized: minimized}" v-if="(haveScores(characterMatch.you) || haveScores(characterMatch.them))">
2019-06-29 21:28:47 +00:00
<a class="minimize-btn" @click="toggleMinimize()"><i :class="{fa: true, 'fa-plus': minimized, 'fa-minus': !minimized}"></i></a>
2019-06-29 20:59:29 +00:00
2019-06-29 21:28:47 +00:00
<div class="scores you">
<h3>
<img :src="avatarUrl(characterMatch.you.you.name)" class="thumbnail"/>
{{characterMatch.you.you.name}}
</h3>
2019-06-29 20:59:29 +00:00
<ul>
<li v-for="score in getScores(characterMatch.you)" v-if="shouldShowScore(score)" :class="getScoreClass(score)" v-html="score.description"></li>
</ul>
</div>
<div class="vs">
vs.
</div>
2019-06-29 21:28:47 +00:00
<div class="scores them">
<h3>
<img :src="avatarUrl(characterMatch.them.you.name)" class="thumbnail" />
{{characterMatch.them.you.name}}
</h3>
2019-06-29 20:59:29 +00:00
<ul>
<li v-for="score in getScores(characterMatch.them)" v-if="shouldShowScore(score)" :class="getScoreClass(score)" v-html="score.description"></li>
</ul>
</div>
</div>
</template>
<script lang="ts">
import { Component, Prop } from '@f-list/vue-ts';
import Vue from 'vue';
import { MatchReport, MatchResult, Score, Scoring } from './matcher';
import * as _ from 'lodash';
2019-06-29 21:28:47 +00:00
import * as Utils from '../utils';
2019-06-29 20:59:29 +00:00
@Component
export default class MatchReportView extends Vue {
@Prop({required: true})
readonly characterMatch!: MatchReport;
2019-06-29 21:28:47 +00:00
readonly avatarUrl = Utils.avatarURL;
2019-06-29 20:59:29 +00:00
minimized = false;
getScoreClass(score: Score) {
const classes: any = {};
classes[score.getRecommendedClass()] = true;
classes['match-score'] = true;
return classes;
}
haveScores(result: MatchResult): boolean {
return !_.every(
result.scores,
(s: Score) => (s.score === Scoring.NEUTRAL)
);
}
shouldShowScore(score: Score) {
return (score.score !== Scoring.NEUTRAL);
}
getScores(result: MatchResult): Score[] {
return _.map(result.scores, (s: Score) => (s));
}
toggleMinimize() {
this.minimized = !this.minimized;
}
}
</script>