Skip to content

Commit

Permalink
fix(ui): round timers better in general
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Mar 27, 2023
1 parent c88be7d commit a8cb999
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ export class AppComponent implements OnInit, OnDestroy {
{ title: 'Fishing', url: 'fishing', icon: 'fishing',
requirements: 'Discover Plant Fiber',
unlocked: this.store.select(state => state.fishing.unlocked),
timer: this.store.select(state => state.fishing.currentLocationDuration),
timer: this.store.select(state => Math.floor(state.fishing.currentLocationDuration)),
level: this.store.select(state => state.fishing.level) },

{ title: 'Foraging', url: 'foraging', icon: 'foraging',
requirements: 'None',
unlocked: this.store.select(state => state.foraging.unlocked),
timer: this.store.select(state => state.foraging.currentLocationDuration),
timer: this.store.select(state => Math.floor(state.foraging.currentLocationDuration)),
level: this.store.select(state => state.foraging.level) },

{ title: 'Hunting', url: 'hunting', icon: 'hunting',
requirements: 'Discover Stone',
unlocked: this.store.select(state => state.hunting.unlocked),
timer: this.store.select(state => state.hunting.currentLocationDuration),
timer: this.store.select(state => Math.floor(state.hunting.currentLocationDuration)),
level: this.store.select(state => state.hunting.level) },

{ title: 'Logging', url: 'logging', icon: 'logging',
requirements: 'None',
unlocked: this.store.select(state => state.logging.unlocked),
timer: this.store.select(state => state.logging.currentLocationDuration),
timer: this.store.select(state => Math.floor(state.logging.currentLocationDuration)),
level: this.store.select(state => state.logging.level) },

{ title: 'Mining', url: 'mining', icon: 'mining',
requirements: 'Discover Pine Log',
unlocked: this.store.select(state => state.mining.unlocked),
timer: this.store.select(state => state.mining.currentLocationDuration),
timer: this.store.select(state => Math.floor(state.mining.currentLocationDuration)),
level: this.store.select(state => state.mining.level) },
];

Expand All @@ -69,7 +69,7 @@ export class AppComponent implements OnInit, OnDestroy {
unlocked: this.store.select(state => state.alchemy.unlocked),
timer: this.store.select(state => sum(
state.alchemy.recipeQueue
.map((r: IGameRefiningRecipe) => r.currentDuration
.map((r: IGameRefiningRecipe) => Math.floor(r.currentDuration)
+ (r.durationPer * (r.totalLeft - 1)))
)),
level: this.store.select(state => state.alchemy.level) },
Expand All @@ -79,7 +79,7 @@ export class AppComponent implements OnInit, OnDestroy {
unlocked: this.store.select(state => state.blacksmithing.unlocked),
timer: this.store.select(state => sum(
state.blacksmithing.recipeQueue
.map((r: IGameRefiningRecipe) => r.currentDuration
.map((r: IGameRefiningRecipe) => Math.floor(r.currentDuration)
+ (r.durationPer * (r.totalLeft - 1)))
)),
level: this.store.select(state => state.blacksmithing.level) },
Expand All @@ -89,7 +89,7 @@ export class AppComponent implements OnInit, OnDestroy {
unlocked: this.store.select(state => state.cooking.unlocked),
timer: this.store.select(state => sum(
state.cooking.recipeQueue
.map((r: IGameRefiningRecipe) => r.currentDuration
.map((r: IGameRefiningRecipe) => Math.floor(r.currentDuration)
+ (r.durationPer * (r.totalLeft - 1)))
)),
level: this.store.select(state => state.cooking.level) },
Expand All @@ -99,7 +99,7 @@ export class AppComponent implements OnInit, OnDestroy {
unlocked: this.store.select(state => state.jewelcrafting.unlocked),
timer: this.store.select(state => sum(
state.jewelcrafting.recipeQueue
.map((r: IGameRefiningRecipe) => r.currentDuration
.map((r: IGameRefiningRecipe) => Math.floor(r.currentDuration)
+ (r.durationPer * (r.totalLeft - 1)))
)),
level: this.store.select(state => state.jewelcrafting.level) },
Expand All @@ -109,7 +109,7 @@ export class AppComponent implements OnInit, OnDestroy {
unlocked: this.store.select(state => state.weaving.unlocked),
timer: this.store.select(state => sum(
state.weaving.recipeQueue
.map((r: IGameRefiningRecipe) => r.currentDuration
.map((r: IGameRefiningRecipe) => Math.floor(r.currentDuration)
+ (r.durationPer * (r.totalLeft - 1)))
)),
level: this.store.select(state => state.weaving.level) }
Expand Down
2 changes: 1 addition & 1 deletion src/app/helpers/cooldowns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function lowerGatheringCooldowns(ctx: StateContext<IGameGathering>, ticks
Object.keys(cooldowns || {}).forEach(locationKey => {
const location = cooldowns[locationKey];
if(location > 0) {
cooldowns[locationKey] = location - ticks;
cooldowns[locationKey] = Math.floor(location - ticks);
}

if(cooldowns[locationKey] <= 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/helpers/gathering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function decreaseGatherTimer(
return;
}

const newTicks = state.currentLocationDuration - ticks;
const newTicks = Math.floor(state.currentLocationDuration - ticks);

ctx.setState(patch<IGameGathering>({
currentLocationDuration: newTicks
Expand Down
4 changes: 2 additions & 2 deletions src/app/helpers/refined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function decreaseRefineTimer(ctx: StateContext<IGameRefining>, ticks: num
}

// lower ticks on the current recipe
const newTicks = job.currentDuration - ticks;
const newTicks = Math.floor(job.currentDuration - ticks);
ctx.setState(patch<IGameRefining>({
recipeQueue: updateItem<IGameRefiningRecipe>(0, { ...job, currentDuration: newTicks })
}));
Expand Down Expand Up @@ -45,7 +45,7 @@ export function decreaseRefineTimer(ctx: StateContext<IGameRefining>, ticks: num

// otherwise, just lower the total left and start it again
const newJob = cloneDeep(job);
newJob.currentDuration = newJob.durationPer;
newJob.currentDuration = Math.floor(newJob.durationPer);
newJob.totalLeft -= 1;

if(newJob.refundItems.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/stores/farming/farming.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function resetFarming(ctx: StateContext<IGameFarming>) {
export function decreaseDuration(ctx: StateContext<IGameFarming>, { ticks }: TickTimer) {
const state = ctx.getState();

const plots = state.plots.map(plot => ({ ...plot, currentDuration: Math.max(0, plot.currentDuration - ticks) }));
const plots = state.plots.map(plot => ({ ...plot, currentDuration: Math.max(0, Math.floor(plot.currentDuration - ticks)) }));

ctx.setState(patch<IGameFarming>({
plots
Expand Down

0 comments on commit a8cb999

Please sign in to comment.