Mezeman1 / idle-ant-farm

MIT License
1 stars 1 forks source link

Auto seed storage not working even when there are seeds #6

Closed steve2116 closed 1 week ago

steve2116 commented 1 week ago

When there are a lot of ants producing a lot of seeds, and an equally high amount of queens producing a lot of larva, because of the order of calculations the game can get "stuck" where queens aren't purchased and ants are bought in small quantities whereas the seed storage is not bought at all even though between "ticks" the seed amount is maxed out.

I think it can be fixed by adding an if in the handleAutoCreations method in gameStore.ts to check whether the seed storage is maxed out - and if so then upgrading the seed storage first.

~ Before ~

297        handleAutoCreations() {
298          const prestigeStore = usePrestigeStore()
299          // if (prestigeStore.autoLarvaeCreation) this.createMaxLarvae()
300          if (prestigeStore.autoAntCreation) this.createMaxAnts()
301          if (prestigeStore.autoQueenCreation) this.buyMaxQueens()
302          if (prestigeStore.autoSeedStorageUpgrade) this.upgradeSeedStorage()
303        },

~ After ~

297        handleAutoCreations() {
298          const prestigeStore = usePrestigeStore()
    299      // // let upgradedSeedStorage = false
    300      if (this.seeds >= this.maxSeeds) {
    301        this.upgradeSeedStorage()
    302        // // upgradedSeedStorage = true
    303      }
299 304      // if (prestigeStore.autoLarvaeCreation) this.createMaxLarvae()
300 305      if (prestigeStore.autoAntCreation) this.createMaxAnts()
301 306      if (prestigeStore.autoQueenCreation) this.buyMaxQueens()
    307      if (
    308        // // !upgradedSeedStorage &&
    309        prestigeStore.autoSeedStorageUpgrade
    310      ) this.upgradeSeedStorage()
303 311    },

(There's also a flag to prevent buying two seed storages commented out)

Obviously, this is just a suggestion. Depending on how you look at it, it could not be a bug but instead a decision to get the user to be more active 🤷‍♂️

Mezeman1 commented 1 week ago

This code was updated today already. To be more modular.

handleAutoCreations() {
      const prestigeStore = usePrestigeStore()

      const autoActions = [
        { enabled: prestigeStore.autoSeedStorageUpgrade, action: this.upgradeSeedStorage },
        { enabled: prestigeStore.autoAntCreation, action: this.createMaxAnts },
        { enabled: prestigeStore.autoQueenCreation, action: this.buyMaxQueens },
      ]

      autoActions.forEach(autoAction => {
        if (autoAction.enabled) {
          autoAction.action()
        }
      })
    },

I've changed the order of the array, this way, the upgrade is called before calling the ants and queens. Prioritizing upgrading the storage. Hope that's what you wanted. :)