chromatic-lattice/src/components/features/MainDisplay.vue

51 lines
1.2 KiB
Vue
Raw Normal View History

<template>
<div>
<span v-if="showPrefix">You have</span>
<resource :amount="amount" :color="color" />
{{ resource }}<!-- remove whitespace -->
<span v-if="effectDescription">, <component :is="effectDescription" /></span>
<br><br>
</div>
</template>
<script>
import { player } from '../../store/proxies';
import { layers } from '../../store/layers';
import { format, formatWhole } from '../../util/bignum';
import { coerceComponent } from '../../util/vue';
export default {
name: 'main-display',
2021-06-12 04:38:16 +00:00
inject: [ 'tab' ],
props: {
2021-06-12 04:38:16 +00:00
layer: String,
precision: Number
},
computed: {
style() {
2021-06-12 04:38:16 +00:00
return layers[this.layer || this.tab.layer].componentStyles?.['main-display'];
},
resource() {
2021-06-12 04:38:16 +00:00
return layers[this.layer || this.tab.layer].resource;
},
effectDescription() {
2021-06-12 04:38:16 +00:00
return coerceComponent(layers[this.layer || this.tab.layer].effectDescription);
},
showPrefix() {
2021-06-12 04:38:16 +00:00
return player[this.layer || this.tab.layer].points.lt('1e1000');
},
color() {
2021-06-12 04:38:16 +00:00
return layers[this.layer || this.tab.layer].color;
},
amount() {
return this.precision == undefined ?
2021-06-12 04:38:16 +00:00
formatWhole(player[this.layer || this.tab.layer].points) :
format(player[this.layer || this.tab.layer].points, this.precision);
}
}
};
</script>
<style scoped>
</style>