diff --git a/src/app/helpers/cooldowns.ts b/src/app/helpers/cooldowns.ts index 054e7030..19b1d8b1 100644 --- a/src/app/helpers/cooldowns.ts +++ b/src/app/helpers/cooldowns.ts @@ -1,6 +1,7 @@ import { StateContext } from '@ngxs/store'; import { patch } from '@ngxs/store/operators'; import { IGameGatherLocation, IGameGathering } from '../../interfaces'; +import { NotifyInfo } from '../../stores/game/game.actions'; export function lowerGatheringCooldowns(ctx: StateContext, ticks = 1) { const state = ctx.getState(); @@ -14,6 +15,7 @@ export function lowerGatheringCooldowns(ctx: StateContext, ticks if(cooldowns[locationKey] <= 0) { delete cooldowns[locationKey]; + ctx.dispatch(new NotifyInfo(`${locationKey} can be gathered from again!`)); } }); @@ -43,10 +45,12 @@ export function putLocationOnCooldown( const locationCooldownReduction = location.cooldownTime * cdrPercent; + const newCooldownTime = Math.max(0, location.cooldownTime - (locationCooldownReduction || 0) - (cdrValue || 0)); + ctx.setState(patch({ cooldowns: { ...state.cooldowns, - [location.name]: Math.max(0, location.cooldownTime - (locationCooldownReduction || 0) - (cdrValue || 0)) + [location.name]: newCooldownTime } })); }