From 14f2c8246e3c4f90e9a45b704e83318b73105e2a Mon Sep 17 00:00:00 2001 From: cpojer Date: Thu, 30 May 2024 14:28:02 +0900 Subject: [PATCH] Add a test for research lab status effect behavior in fog. GitOrigin-RevId: 23f15ecb515e5d8284b24319e85839b4d3e048a2 --- tests/__tests__/Building.test.tsx | 45 ++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/__tests__/Building.test.tsx b/tests/__tests__/Building.test.tsx index b9457889..3bbefdd8 100644 --- a/tests/__tests__/Building.test.tsx +++ b/tests/__tests__/Building.test.tsx @@ -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); @@ -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), + ); +});