Skip to content

Commit

Permalink
Add a test for research lab status effect behavior in fog.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 23f15ecb515e5d8284b24319e85839b4d3e048a2
  • Loading branch information
cpojer committed May 30, 2024
1 parent f7530da commit 14f2c82
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion tests/__tests__/Building.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ import {
BuildingInfo,
Factory,
filterBuildings,
ResearchLab,
} from '@deities/athena/info/Building.tsx';
import { Skill } from '@deities/athena/info/Skill.tsx';
import { BazookaBear, Cannon } from '@deities/athena/info/Unit.tsx';
import { Plain } from '@deities/athena/info/Tile.tsx';
import {
BazookaBear,
Cannon,
Pioneer,
SmallTank,
} from '@deities/athena/info/Unit.tsx';
import getAttackStatusEffect from '@deities/athena/lib/getAttackStatusEffect.tsx';
import withModifiers from '@deities/athena/lib/withModifiers.tsx';
import Building from '@deities/athena/map/Building.tsx';
import { HumanPlayer } from '@deities/athena/map/Player.tsx';
import vec from '@deities/athena/map/vec.tsx';
import MapData from '@deities/athena/MapData.tsx';
import { expect, test } from 'vitest';

BuildingInfo.setConstructor(Building);
Expand Down Expand Up @@ -184,3 +195,35 @@ test('units can be added to the Bar via skills', () => {
Number.POSITIVE_INFINITY,
);
});

test('Research Lab status effects are available even in fog', () => {
const initialMap = withModifiers(
MapData.createMap({
config: {
fog: true,
},
map: [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1,
],
size: { height: 5, width: 5 },
teams: [
{ id: 1, name: '', players: [{ funds: 500, id: 1, userId: '1' }] },
{ id: 2, name: '', players: [{ funds: 500, id: 2, name: 'Bot' }] },
],
}),
);
const player1 = initialMap.getPlayer(1);
const vision = initialMap.createVisionObject(player1);

const map = initialMap.copy({
buildings: initialMap.buildings
.set(vec(1, 1), ResearchLab.create(2))
.set(vec(5, 5), ResearchLab.create(2)),
units: initialMap.units.set(vec(1, 1), Pioneer.create(1)),
});

expect(getAttackStatusEffect(map, SmallTank.create(2), Plain)).toEqual(
getAttackStatusEffect(vision.apply(map), SmallTank.create(2), Plain),
);
});

0 comments on commit 14f2c82

Please sign in to comment.