Persistent config data, between routes and components.

This commit is contained in:
Bart van der Braak 2020-02-04 00:12:03 +01:00
parent 251c85677a
commit 7e8ab1c381
2 changed files with 56 additions and 63 deletions

View file

@ -93,62 +93,12 @@ import master_json from '../data/masters'
export default { export default {
name: "ConfigSection", name: "ConfigSection",
props: { props: {
config: Object, configData: Object,
}, },
data() { data() {
return { return {
monsterData: monster_json, monsterData: monster_json,
mastersData: master_json, mastersData: master_json,
configData: {
pointUnlocks: [
{id: 0, name: 'Seeing red', monster_ids: [83, 3], unlock: false, masters: [5,6,7]},
{id: 1, name: 'I hope you mith me', monster_ids: [72], unlock: false, masters: [5,6,7]},
{id: 2, name: 'Watch the birdie', monster_ids: [4], unlock: false, masters: [4,5,6,7]},
{id: 3, name: 'Hot stuff', monster_ids: [102], unlock: false, masters: [4,6,7]},
{id: 4, name: 'Reptile got ripped', monster_ids: [66], unlock: false, masters: [4,5,6,7]},
{id: 5, name: 'Like a boss', monster_ids: [15], unlock: false, masters: [5,6,7]},
{id: 6, name: 'Stop the Wyvern', monster_ids: [42], unlock: false, block: true},
{id: 7, name: 'Basilocked', monster_ids: [7], unlock: false, masters: [5,6,7]},
],
blockList: [
{id: 0, name: 'Block task (50 quest points)', monster_ids: null, block: true},
{id: 1, name: 'Block task (100 quest points)', monster_ids: null, block: true},
{id: 2, name: 'Block task (150 quest points)', monster_ids: null, block: true},
{id: 3, name: 'Block task (200 quest points)', monster_ids: null, block: true},
{id: 4, name: 'Block task (250 quest points)', monster_ids: null, block: true},
{id: 5, name: 'Block task (300 quest points)', monster_ids: null, block: true},
],
questUnlocks: [
{id: 0, name: 'Bone Voyage', monster_ids: [42], unlock: false},
{id: 1, name: 'Cabin Fever', monster_ids: [60, 21], unlock: false},
{id: 2, name: 'Contact!', monster_ids: [70], unlock: false},
{id: 3, name: 'Death Plateau', monster_ids: [96], unlock: false},
{id: 4, name: 'Death to the Dorgeshuun', monster_ids: [74], unlock: false},
{id: 5, name: 'Desert Treasure (started)', monster_ids: [34, 94], unlock: false},
{id: 6, name: 'Dragon Slayer', monster_ids: [48, 14, 83, 12, 17, 58, 97, 72, 2, 87], alternative_text: "Dragons", unlock: false},
{id: 7, name: 'Dragon Slayer II', monster_ids: [2, 87], unlock: false},
{id: 8, name: 'Elemental Workshop I', monster_ids: [92], unlock: false},
{id: 9, name: 'Ernest the Chicken', monster_ids: [62], unlock: false},
{id: 10, name: 'Fairytale II (without Priest in Peril)', monster_ids: [1], unlock: false},
{id: 11, name: 'Horror from the Deep', monster_ids: [29], unlock: false},
{id: 12, name: 'Legends\' Quest', monster_ids: [91], unlock: false},
{id: 13, name: 'Lost City', monster_ids: [77, 80], unlock: false},
{id: 14, name: 'Lunar Diplomacy (partial)', monster_ids: [98], unlock: false},
{id: 15, name: 'Mourning\'s End Part II (started)', monster_ids: [30], unlock: false},
{id: 16, name: 'Olaf\'s Quest (partial)', monster_ids: [16], unlock: false},
{id: 17, name: 'Priest in Peril', monster_ids: [6, 27, 103, 45, 90, 106, 13, 0, 57, 78, 43, 1], alternative_text: "Morytania monsters", unlock: false},
{id: 18, name: 'Regicide (started)', monster_ids: [37], unlock: false},
{id: 19, name: 'Royal Trouble', monster_ids: [89], unlock: false},
{id: 20, name: 'Rum Deal (started)', monster_ids: [39], unlock: false},
{id: 21, name: 'Skippy and the Mogres (miniquest)', monster_ids: [73], unlock: false},
{id: 22, name: 'Waterfall Quest', monster_ids: [40], unlock: false},
],
statUnlocks: [
{id: 0, name: 'Slayer level', value: {min: 1, current: 99, max: 99}, image: 'Slayer_icon.png', unlock: false},
{id: 1, name: 'Combat level', value: {min: 3, current: 126, max: 126}, image: 'Combat_icon.png', unlock: false},
{id: 2, name: 'Defence level', value: {min: 1, current: 99, max: 99}, image: 'Defence_icon.png', unlock: false},
]
}
} }
}, },
methods: { methods: {
@ -178,11 +128,11 @@ export default {
return 'Added to ' + masterList.join(', ').replace(/,(?!.*,)/gmi, ' and'); return 'Added to ' + masterList.join(', ').replace(/,(?!.*,)/gmi, ' and');
}, },
}, },
watch: { beforeRouteLeave (to, from, next) {
$route(to, from) { this.$emit('update',this.configData);
console.log(JSON.stringify(this.configData, 0, 2)) next()
}
} }
} }
</script> </script>

View file

@ -1,6 +1,6 @@
<template> <template>
<main role="main" class="col-md-10 ml-sm-auto col-lg-10 px-4"> <main role="main" class="col-md-10 ml-sm-auto col-lg-10 px-4">
<router-view v-bind="currentConfig" v-on:config="setConfig"></router-view> <router-view :configData="mainConfig" @update="mainConfig = $event"></router-view>
</main> </main>
</template> </template>
@ -9,15 +9,58 @@ export default {
name: 'MainContent', name: 'MainContent',
data() { data() {
return { return {
currentConfig: {}, mainConfig: {
pointUnlocks: [
{id: 0, name: 'Seeing red', monster_ids: [83, 3], unlock: false, masters: [5,6,7]},
{id: 1, name: 'I hope you mith me', monster_ids: [72], unlock: false, masters: [5,6,7]},
{id: 2, name: 'Watch the birdie', monster_ids: [4], unlock: false, masters: [4,5,6,7]},
{id: 3, name: 'Hot stuff', monster_ids: [102], unlock: false, masters: [4,6,7]},
{id: 4, name: 'Reptile got ripped', monster_ids: [66], unlock: false, masters: [4,5,6,7]},
{id: 5, name: 'Like a boss', monster_ids: [15], unlock: false, masters: [5,6,7]},
{id: 6, name: 'Stop the Wyvern', monster_ids: [42], unlock: false, block: true},
{id: 7, name: 'Basilocked', monster_ids: [7], unlock: false, masters: [5,6,7]},
],
blockList: [
{id: 0, name: 'Block task (50 quest points)', monster_ids: null, block: true},
{id: 1, name: 'Block task (100 quest points)', monster_ids: null, block: true},
{id: 2, name: 'Block task (150 quest points)', monster_ids: null, block: true},
{id: 3, name: 'Block task (200 quest points)', monster_ids: null, block: true},
{id: 4, name: 'Block task (250 quest points)', monster_ids: null, block: true},
{id: 5, name: 'Block task (300 quest points)', monster_ids: null, block: true},
],
questUnlocks: [
{id: 0, name: 'Bone Voyage', monster_ids: [42], unlock: false},
{id: 1, name: 'Cabin Fever', monster_ids: [60, 21], unlock: false},
{id: 2, name: 'Contact!', monster_ids: [70], unlock: false},
{id: 3, name: 'Death Plateau', monster_ids: [96], unlock: false},
{id: 4, name: 'Death to the Dorgeshuun', monster_ids: [74], unlock: false},
{id: 5, name: 'Desert Treasure (started)', monster_ids: [34, 94], unlock: false},
{id: 6, name: 'Dragon Slayer', monster_ids: [48, 14, 83, 12, 17, 58, 97, 72, 2, 87], alternative_text: "Dragons", unlock: false},
{id: 7, name: 'Dragon Slayer II', monster_ids: [2, 87], unlock: false},
{id: 8, name: 'Elemental Workshop I', monster_ids: [92], unlock: false},
{id: 9, name: 'Ernest the Chicken', monster_ids: [62], unlock: false},
{id: 10, name: 'Fairytale II (without Priest in Peril)', monster_ids: [1], unlock: false},
{id: 11, name: 'Horror from the Deep', monster_ids: [29], unlock: false},
{id: 12, name: 'Legends\' Quest', monster_ids: [91], unlock: false},
{id: 13, name: 'Lost City', monster_ids: [77, 80], unlock: false},
{id: 14, name: 'Lunar Diplomacy (partial)', monster_ids: [98], unlock: false},
{id: 15, name: 'Mourning\'s End Part II (started)', monster_ids: [30], unlock: false},
{id: 16, name: 'Olaf\'s Quest (partial)', monster_ids: [16], unlock: false},
{id: 17, name: 'Priest in Peril', monster_ids: [6, 27, 103, 45, 90, 106, 13, 0, 57, 78, 43, 1], alternative_text: "Morytania monsters", unlock: false},
{id: 18, name: 'Regicide (started)', monster_ids: [37], unlock: false},
{id: 19, name: 'Royal Trouble', monster_ids: [89], unlock: false},
{id: 20, name: 'Rum Deal (started)', monster_ids: [39], unlock: false},
{id: 21, name: 'Skippy and the Mogres (miniquest)', monster_ids: [73], unlock: false},
{id: 22, name: 'Waterfall Quest', monster_ids: [40], unlock: false},
],
statUnlocks: [
{id: 0, name: 'Slayer level', value: {min: 1, current: 99, max: 99}, image: 'Slayer_icon.png', unlock: false},
{id: 1, name: 'Combat level', value: {min: 3, current: 126, max: 126}, image: 'Combat_icon.png', unlock: false},
{id: 2, name: 'Defence level', value: {min: 1, current: 99, max: 99}, image: 'Defence_icon.png', unlock: false},
]
}
} }
}, },
methods: {
setConfig(configObject) {
this.currentConfig = configObject;
console.log(this.currentConfig)
}
}
} }
</script> </script>