Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/engine/components/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Component } from '../ecs/Component';
export type ResourceType = 'minerals' | 'vespene';

// Optimal worker counts per resource
// Minerals: 1 worker per patch is optimal for display, 3 is max (diminishing returns)
// Minerals: 2 workers per patch is optimal, 3 is max (diminishing returns)
// Vespene: 3 workers per geyser is optimal and max
export const OPTIMAL_WORKERS_PER_MINERAL = 1;
export const OPTIMAL_WORKERS_PER_MINERAL = 2;
export const MAX_WORKERS_PER_MINERAL = 3;
export const OPTIMAL_WORKERS_PER_VESPENE = 3;
export const MAX_WORKERS_PER_VESPENE = 3;
Expand Down
9 changes: 5 additions & 4 deletions tests/engine/components/resource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe('Resource Component', () => {
const resource = new Resource('minerals', 1500);

expect(resource.getOptimalWorkers()).toBe(OPTIMAL_WORKERS_PER_MINERAL);
expect(resource.getOptimalWorkers()).toBe(1);
expect(resource.getOptimalWorkers()).toBe(2);
});

it('returns optimal for vespene', () => {
Expand Down Expand Up @@ -284,15 +284,16 @@ describe('Resource Component', () => {
describe('isOptimallySaturated', () => {
it('returns false when under optimal', () => {
const resource = new Resource('minerals', 1500, 5);
// With optimal = 1, having 0 gatherers is under optimal
// With optimal = 2, having 0 or 1 gatherers is under optimal

expect(resource.isOptimallySaturated()).toBe(false);
});

it('returns true when at optimal', () => {
const resource = new Resource('minerals', 1500, 5);
resource.addGatherer(1);
// With optimal = 1, having 1 gatherer is at optimal
resource.addGatherer(2);
// With optimal = 2, having 2 gatherers is at optimal

expect(resource.isOptimallySaturated()).toBe(true);
});
Expand Down Expand Up @@ -331,7 +332,7 @@ describe('Resource Component', () => {

describe('constants', () => {
it('exports correct worker constants', () => {
expect(OPTIMAL_WORKERS_PER_MINERAL).toBe(1);
expect(OPTIMAL_WORKERS_PER_MINERAL).toBe(2);
expect(MAX_WORKERS_PER_MINERAL).toBe(3);
expect(OPTIMAL_WORKERS_PER_VESPENE).toBe(3);
expect(MAX_WORKERS_PER_VESPENE).toBe(3);
Expand Down