Add optimum storage fill strategy
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import Vuex from 'vuex';
|
||||
import { LogStorage } from '../Storage/LogStorage';
|
||||
import { VillageSettings, VillageSettingsDefaults } from '../Core/Village';
|
||||
import { ReceiveResourcesMode, VillageSettings, VillageSettingsDefaults } from '../Core/Village';
|
||||
import { getNumber, notify } from '../utils';
|
||||
import { VillageStorage } from '../Storage/VillageStorage';
|
||||
import { VillageFactory } from '../VillageFactory';
|
||||
@ -13,13 +13,13 @@ export enum Mutations {
|
||||
ToggleVillageEditor = 'toggle_village_editor',
|
||||
SetVillageSettings = 'set_village_settings',
|
||||
UpdateVillageSendResourceThreshold = 'UpdateVillageSendResourceThreshold',
|
||||
UpdateVillageSendResourceTimeout = 'UpdateVillageSendResourceTimeout',
|
||||
UpdateVillageSendResourcesMultiplier = 'UpdateVillageSendResourcesMultiplier',
|
||||
}
|
||||
|
||||
export enum Actions {
|
||||
OpenVillageEditor = 'open_village_editor',
|
||||
SaveVillageSettings = 'save_village_settings',
|
||||
ToggleVillageReceiveMode = 'toggle_village_receive_mode',
|
||||
}
|
||||
|
||||
export function createStore(villageFactory: VillageFactory) {
|
||||
@ -83,8 +83,9 @@ export function createStore(villageFactory: VillageFactory) {
|
||||
commit(Mutations.ToggleVillageEditor, true);
|
||||
},
|
||||
[Actions.SaveVillageSettings]({ state }) {
|
||||
const villageId = state.villageSettings.villageId;
|
||||
const villageName = state.villageSettings.villageName;
|
||||
const villageId = state.villageSettings.villageId;
|
||||
const villageState = villageFactory.createState(villageId);
|
||||
const newSettings: VillageSettings = {
|
||||
sendResourcesThreshold:
|
||||
state.villageSettings.sendResourcesThreshold ||
|
||||
@ -92,11 +93,16 @@ export function createStore(villageFactory: VillageFactory) {
|
||||
sendResourcesMultiplier:
|
||||
state.villageSettings.sendResourcesMultiplier ||
|
||||
VillageSettingsDefaults.sendResourcesMultiplier,
|
||||
receiveResourcesMode: villageState.settings.receiveResourcesMode,
|
||||
};
|
||||
const storage = new VillageStorage(villageId);
|
||||
storage.storeSettings(newSettings);
|
||||
notify(`Настройки для ${villageName} сохранены`);
|
||||
},
|
||||
[Actions.ToggleVillageReceiveMode]({}, { villageId }) {
|
||||
const controller = villageFactory.createController(villageId);
|
||||
controller.toggleReceiveResourcesMode();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -143,9 +143,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="normal-line">
|
||||
<td class="right" colspan="7" v-text="villageStatus(villageState)"></td>
|
||||
</tr>
|
||||
<status-line :village-state="villageState" />
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -160,6 +158,7 @@ import { path } from '../Helpers/Path';
|
||||
import { Actions } from './Store';
|
||||
import { translateProductionQueue } from '../Core/ProductionQueue';
|
||||
import VillageStateResourceLine from './VillageStateResourceLine';
|
||||
import VillageStateStatusLine from './VillageStateStatusLine';
|
||||
|
||||
function secondsToTime(value) {
|
||||
if (value === 0) {
|
||||
@ -176,6 +175,7 @@ export default {
|
||||
'resource': ResourceBalance,
|
||||
'filling': VillageResource,
|
||||
'resource-line': VillageStateResourceLine,
|
||||
'status-line': VillageStateStatusLine,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -189,11 +189,6 @@ export default {
|
||||
const name = villageState.village.name;
|
||||
return `${name}, ${id}`;
|
||||
},
|
||||
villageStatus(villageState) {
|
||||
const threshold = villageState.settings.sendResourcesThreshold;
|
||||
const multiplier = villageState.settings.sendResourcesMultiplier;
|
||||
return `порог ${threshold}, множ. ${multiplier}`;
|
||||
},
|
||||
path(name, args) {
|
||||
return path(name, args);
|
||||
},
|
||||
|
51
src/DashboardView/VillageStateStatusLine.vue
Normal file
51
src/DashboardView/VillageStateStatusLine.vue
Normal file
@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<tr>
|
||||
<td class="status-line" colspan="7">
|
||||
режим
|
||||
<a href="#" v-text="settings.receiveResourcesMode" v-on:click.prevent="toggleMode()"></a>,
|
||||
<span v-text="status"></span>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Actions } from './Store';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
villageState: {
|
||||
type: Object,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
settings() {
|
||||
return this.villageState.settings;
|
||||
},
|
||||
status() {
|
||||
const settings = this.villageState.settings;
|
||||
const threshold = settings.sendResourcesThreshold;
|
||||
const multiplier = settings.sendResourcesMultiplier;
|
||||
return `порог ${threshold}, множ. ${multiplier}`;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
toggleMode() {
|
||||
const villageId = this.villageState.id;
|
||||
this.$store.dispatch(Actions.ToggleVillageReceiveMode, { villageId });
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
%right {
|
||||
text-align: right;
|
||||
}
|
||||
%small-cell {
|
||||
padding: 0 4px 4px;
|
||||
font-size: 90%;
|
||||
}
|
||||
.status-line {
|
||||
@extend %right;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user