Skip to content

Commit

Permalink
default to refining bonus city
Browse files Browse the repository at this point in the history
  • Loading branch information
Nfinished committed Dec 30, 2023
1 parent 90efd27 commit 6bf953d
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions store/refining/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { MutationTree } from 'vuex'
import { Features, RefiningState } from './typeDefs'
import { ResponseModel, SettingsWithItem, ItemInfo, OneOfCitiesProp } from './typeDefs'
import { getRawResourceNameByMaterial } from '../utils';
import { getProductionBonusCityByItem, getRawResourceNameByMaterial } from '../utils';
import Vue from 'vue';

export const mutations: MutationTree<RefiningState> = {
/**
* Set json files data into state
*
*
* @param state - vuex state
*/
SET_STATE(state) {
Expand All @@ -34,20 +34,33 @@ export const mutations: MutationTree<RefiningState> = {

/**
* Set information about selected material
*
*
* @param state - vuex state
* @param itemInfo - material info
*/
SET_ITEM_INFO(state, itemInfo: ItemInfo) {
state.currentItemInfo = itemInfo;
const productionBonusCity = getProductionBonusCityByItem(itemInfo.name);

if (productionBonusCity) {
if (state.settings.useMultipleCities) {
state.settings.cities.refiningResources = productionBonusCity;
} else {
state.settings.cities = {
sellMaterials: productionBonusCity,
refiningResources: productionBonusCity,
buyMaterials: productionBonusCity,
buyRawResources: productionBonusCity
}}
}
},

/**
* Set raw resources prices to state
*
*
* @param state - vuex state
* @param data - api response
* @param settingsWithItem - сonvenient item data and settings
* @param settingsWithItem - сonvenient item data and settings
*/
SET_RAW_RESOURCES(state, { data, settingsWithItem }: { data: ResponseModel[], settingsWithItem: SettingsWithItem}) {
const itemName = getRawResourceNameByMaterial(settingsWithItem.currentItemInfo.name);
Expand All @@ -58,10 +71,10 @@ export const mutations: MutationTree<RefiningState> = {

/**
* Set material prices where we sell them
*
*
* @param state - vuex state
* @param data - api response
* @param settingsWithItem - сonvenient item data and settings
* @param settingsWithItem - сonvenient item data and settings
*/
SET_SELL_MATERIALS(state, { data, settingsWithItem }: { data: ResponseModel[], settingsWithItem: SettingsWithItem}) {
const itemName = settingsWithItem.currentItemInfo.name;
Expand All @@ -72,10 +85,10 @@ export const mutations: MutationTree<RefiningState> = {

/**
* Set material prices where we buy them
*
*
* @param state - vuex state
* @param data - api response
* @param settingsWithItem - сonvenient item data and settings
* @param settingsWithItem - сonvenient item data and settings
*/
SET_BUY_MATERIALS(state, { data, settingsWithItem }: { data: ResponseModel[], settingsWithItem: SettingsWithItem}) {
const itemName = settingsWithItem.currentItemInfo.name;
Expand All @@ -90,7 +103,7 @@ export const mutations: MutationTree<RefiningState> = {

/**
* Update use focus param
*
*
* @param state - vuex state
* @param useFocus - use focus points or not
*/
Expand All @@ -100,7 +113,7 @@ export const mutations: MutationTree<RefiningState> = {

/**
* Update craft fee
*
*
* @param state - vuex state
* @param fee - craft fee
*/
Expand All @@ -114,7 +127,7 @@ export const mutations: MutationTree<RefiningState> = {

/**
* Update use own return percentage param
*
*
* @param state - vuex state
* @param useOwnPercentage - use own return percentage or not
*/
Expand All @@ -124,7 +137,7 @@ export const mutations: MutationTree<RefiningState> = {

/**
* Update own return percentage
*
*
* @param state - vuex state
* @param returnPercentage - own return percentage
*/
Expand All @@ -134,21 +147,21 @@ export const mutations: MutationTree<RefiningState> = {

/**
* Set loading text
*
*
* @param state - vuex state
* @param loadingText - text of loading
*/
SET_LOADING_TEXT(state, loadingText: Features['loadingText']) {
state.features.loadingText = loadingText;
},

UPDATE_ITEM_BY_ITEM_NAME(state, {
itemName,
item,
UPDATE_ITEM_BY_ITEM_NAME(state, {
itemName,
item,
itemGroup,
}: {
itemName: string;
item: ResponseModel,
}: {
itemName: string;
item: ResponseModel,
itemGroup: 'sellMaterials' | 'buyMaterials' | 'buyRawResources',
}) {
const currentItemInfo = state.currentItemInfo;
Expand All @@ -165,4 +178,4 @@ export const mutations: MutationTree<RefiningState> = {
Vue.set(items, storeItemIndex, item);
}
}
}
}

0 comments on commit 6bf953d

Please sign in to comment.