Add sending overflow resources

This commit is contained in:
2020-06-06 20:38:40 +03:00
parent 74cfeb6075
commit d29e95f511
9 changed files with 142 additions and 106 deletions

View File

@ -4,7 +4,7 @@
<script>
export default {
props: ['value', 'max', 'speed'],
props: ['value', 'warning', 'critical', 'full'],
data() {
return {};
},
@ -13,31 +13,18 @@ export default {
return this.value;
},
percent() {
return Math.floor((this.value / this.max) * 100);
return Math.floor((this.value / this.full) * 100);
},
title() {
if (this.speed < 0) {
const time = this.fractionalHourToTime(this.value / this.speed);
return `${this.value}, ${this.percent}%, опустеет через ${time}`;
} else {
const time = this.fractionalHourToTime((this.max - this.value) / this.speed);
return `${this.value}, ${this.percent}%, заполнится через ${time}`;
}
return `${this.value}/${this.full}, ${this.percent}%`;
},
classes() {
return {
warning: this.percent >= 70 && this.percent < 95,
bad: this.percent >= 95,
warning: this.value >= this.warning && this.value < this.critical,
bad: this.value >= this.critical,
};
},
},
methods: {
fractionalHourToTime(value) {
const hours = Math.floor(value);
const minutes = Math.round((value - hours) * 60);
return `${hours}:${String(minutes).padStart(2, '0')}`;
},
},
};
</script>

View File

@ -30,52 +30,40 @@
<td class="right">
<filling
:value="villageState.resources.lumber"
:max="villageState.storage.capacity.lumber"
:speed="villageState.performance.lumber"
:warning="villageState.storageOptimumFullness.lumber"
:critical="villageState.upperCriticalLevel.lumber"
:full="villageState.storage.capacity.lumber"
></filling>
</td>
<td class="right">
<filling
:value="villageState.resources.clay"
:max="villageState.storage.capacity.clay"
:speed="villageState.performance.clay"
:warning="villageState.storageOptimumFullness.clay"
:critical="villageState.upperCriticalLevel.clay"
:full="villageState.storage.capacity.clay"
></filling>
</td>
<td class="right">
<filling
:value="villageState.resources.iron"
:max="villageState.storage.capacity.iron"
:speed="villageState.performance.iron"
:warning="villageState.storageOptimumFullness.iron"
:critical="villageState.upperCriticalLevel.iron"
:full="villageState.storage.capacity.iron"
></filling>
</td>
<td class="right">
<filling
:value="villageState.resources.crop"
:max="villageState.storage.capacity.crop"
:speed="villageState.performance.crop"
:warning="villageState.storageOptimumFullness.crop"
:critical="villageState.upperCriticalLevel.crop"
:full="villageState.storage.capacity.crop"
></filling>
</td>
<td class="right" v-text="storageTime(villageState)"></td>
<td></td>
</tr>
<tr class="performance-line">
<td class="right">Прирост:</td>
<td class="right">
<resource :value="villageState.performance.lumber"></resource>
</td>
<td class="right">
<resource :value="villageState.performance.clay"></resource>
</td>
<td class="right">
<resource :value="villageState.performance.iron"></resource>
</td>
<td class="right">
<resource :value="villageState.performance.crop"></resource>
</td>
<td></td>
<td></td>
</tr>
<resource-line :title="'Прирост:'" :resources="villageState.performance" />
<resource-line
v-if="isExtended(villageState.id)"
@ -84,43 +72,11 @@
:resources="villageState.upperCriticalLevel"
/>
<tr class="required-line" v-if="villageState.required.active">
<td class="right">След. задача:</td>
<td class="right">
<resource
:value="villageState.required.resources.lumber"
:hide-zero="true"
:color="false"
:sign="false"
></resource>
</td>
<td class="right">
<resource
:value="villageState.required.resources.clay"
:hide-zero="true"
:color="false"
:sign="false"
></resource>
</td>
<td class="right">
<resource
:value="villageState.required.resources.iron"
:hide-zero="true"
:color="false"
:sign="false"
></resource>
</td>
<td class="right">
<resource
:value="villageState.required.resources.crop"
:hide-zero="true"
:color="false"
:sign="false"
></resource>
</td>
<td></td>
<td></td>
</tr>
<resource-line
v-if="villageState.required.active"
:title="'След. задача:'"
:resources="villageState.required.resources"
/>
<resource-line
v-if="villageState.required.active"
@ -169,6 +125,8 @@
:title="'Крит. уровень:'"
:hint="'Критический уровень'"
:hide-zero="true"
:color="false"
:sign="false"
:resources="villageState.upperCriticalLevel"
/>
@ -177,6 +135,8 @@
:title="'Опт. уровень:'"
:hint="'Оптимальный уровень'"
:hide-zero="true"
:color="false"
:sign="false"
:resources="villageState.storageOptimumFullness"
/>
@ -192,6 +152,11 @@
"
>$->{{ s.village.name }}</a
>
</td>
</tr>
<tr class="normal-line">
<td class="right" colspan="7">
<a class="village-quick-link" :href="quartersPath(villageState.village)">Казармы</a>
<a class="village-quick-link" :href="horseStablePath(villageState.village)"
>Конюшни</a

View File

@ -2,16 +2,16 @@
<tr class="resource-line">
<td class="title" v-text="title" :title="hint"></td>
<td class="lumber">
<resource :value="resources.lumber" :hide-zero="hideZero" />
<resource :value="resources.lumber" :hide-zero="hideZero" :color="color" :sign="sign" />
</td>
<td class="clay">
<resource :value="resources.clay" :hide-zero="hideZero" />
<resource :value="resources.clay" :hide-zero="hideZero" :color="color" :sign="sign" />
</td>
<td class="iron">
<resource :value="resources.iron" :hide-zero="hideZero" />
<resource :value="resources.iron" :hide-zero="hideZero" :color="color" :sign="sign" />
</td>
<td class="crop">
<resource :value="resources.crop" :hide-zero="hideZero" />
<resource :value="resources.crop" :hide-zero="hideZero" :color="color" :sign="sign" />
</td>
<td class="time1" v-text="time1"></td>
<td class="time2" v-text="time2"></td>
@ -48,6 +48,14 @@ export default {
type: Boolean,
default: false,
},
color: {
type: Boolean,
default: true,
},
sign: {
type: Boolean,
default: true,
},
},
};
</script>