Skip to content

Commit

Permalink
fix: issue with consumables?
Browse files Browse the repository at this point in the history
  • Loading branch information
Mees committed Oct 24, 2024
1 parent 2295dc5 commit f89f9d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/stores/adventureStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,24 @@ export const useAdventureStore = defineStore('adventureStore', {
this.battleStatus = 'idle'
},
applyBuffs(deltaTime) {
this.activeBuffs.forEach((buff) => {
if (buff.active) {
this.activeBuffs.map((buff) => {
if (buff.active && buff.duration > 0) {
buff.duration -= deltaTime
return buff
}

if (buff.duration > 0 && !buff.active) {
buff.effect()
buff.active = true
return buff
}

if (buff.duration <= 0 && buff.active && buff.onRemove) {
if (buff.duration <= 0 && buff.onRemove) {
buff.onRemove()
this.activeBuffs = this.activeBuffs.filter((activeBuff) => activeBuff.id !== buff.id)
}

return buff
})
},

Expand Down Expand Up @@ -774,13 +778,20 @@ export const useAdventureStore = defineStore('adventureStore', {
const inventoryStore = useInventoryStore()
this.activeBuffs = adventureState.activeBuffs?.map((buff) => {
const itemFromName = inventoryStore.getItemById(buff.name)
return {
if (itemFromName) {
return {
...buff,
active: false,
effect: itemFromName?.effect,
onRemove: itemFromName?.onRemove,
}
}

return {
...buff,
active: false,
}
}) ?? []


this.battleStatus = adventureState.battleStatus ?? 'idle'
this.lastSavedTime = adventureState.lastSavedTime ?? Date.now()
Expand Down Expand Up @@ -1103,17 +1114,10 @@ export const useAdventureStore = defineStore('adventureStore', {
maxHealth: baseHealth,
regen: baseRegen,

damageMultiplier: this.armyAttackModifier,
defenseMultiplier: this.armyDefenseModifier,
damageMultiplier: this.armyAttackModifier * trainingStore.modifiers.army.attack,
defenseMultiplier: this.armyDefenseModifier * useTrainingStore().farmingModifiers.defense * trainingStore.modifiers.army.defense,
healthMultiplier: this.armyMaxHealthModifier * trainingStore.modifiers.army.health,
regenMultiplier: this.armyRegenModifier,
})

this.activeBuffs = this.activeBuffs?.map((buff) => {
return {
...buff,
active: false,
}
regenMultiplier: this.armyRegenModifier * trainingStore.modifiers.army.regen,
})

inventoryStore.reApplyPassiveEffects()
Expand Down
1 change: 1 addition & 0 deletions src/stores/trainingStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ export const useTrainingStore = defineStore({

applyCombatMilestones() {
this.resetArmyModifiers()

this.combatMilestones.forEach(milestone => {
if (this.training[milestone.type].level >= milestone.levelRequired) {
this.applyCombatMilestone(milestone)
Expand Down

0 comments on commit f89f9d8

Please sign in to comment.