mirror of
https://github.com/kihashi/stardew_community_checklist.git
synced 2025-10-19 08:03:17 +00:00
Import V1 Data (#117)
* Add method to get open bundles * Add method to load V1 data * Convert v1 data on load
This commit is contained in:
parent
5195f5c2d3
commit
4df5eacd03
@ -17,6 +17,12 @@ export default {
|
||||
},
|
||||
created () {
|
||||
this.$store.commit('initState')
|
||||
var v1data = localStorage.getItem('user_data')
|
||||
if (v1data !== null && v1data !== '') {
|
||||
this.$store.dispatch('LoadV1State', JSON.parse(atob(v1data)))
|
||||
localStorage.removeItem('user_data')
|
||||
localStorage.setItem('v1data', v1data)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -73,6 +73,9 @@ export default new Vuex.Store({
|
||||
},
|
||||
IsRoomComplete: (state, getters) => (room) => {
|
||||
return getters.GetRoomItemsRedeemed(room) >= room.items_required
|
||||
},
|
||||
GetOpenBundleItems: (state, getters) => (bundleId, itemId) => {
|
||||
return (getters.GetBundleById(bundleId)).items.filter(bundleItem => bundleItem.item.id === itemId && !getters.IsBundleItemRedeemed(bundleItem))
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
@ -113,6 +116,30 @@ export default new Vuex.Store({
|
||||
resetData (state) {
|
||||
state.StoredItems = {}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
LoadV1State (context, v1state) {
|
||||
for (var i = 0; i < v1state.length; i++) {
|
||||
for (var j = 0; j < v1state[i].length; j++) {
|
||||
var itemId = v1state[i][j].item
|
||||
// Patch for duplicate oak
|
||||
if (itemId === 116) {
|
||||
itemId = 24
|
||||
}
|
||||
|
||||
// Patch for parsnip
|
||||
if (itemId === 26 && i === 6) {
|
||||
itemId = 27
|
||||
}
|
||||
var bundleItems = context.getters.GetOpenBundleItems(i, itemId)
|
||||
if (bundleItems.length > 0) {
|
||||
context.commit('RedeemItem', bundleItems[0])
|
||||
} else {
|
||||
console.log(`Tried to redeem bundle ${i} item ${itemId}, but no open bundle items were found`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user