Skip to content

Commit

Permalink
Test for AI creating buildings in the Space biome.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 9127cdda47284a167cc504daef87da52918f39d4
  • Loading branch information
cpojer committed Mar 10, 2025
1 parent 5c08298 commit 23ca9d6
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/__tests__/AIBehavior.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
ShipyardConstructionSite,
} from '@deities/athena/info/Tile.tsx';
import {
APU,
Artillery,
Battleship,
Corvette,
Expand Down Expand Up @@ -1185,3 +1186,53 @@ test('activates skills where the unit ratio does not matter', async () => {
EndTurn { current: { funds: 300, player: 2 }, next: { funds: 0, player: 1 }, round: 2, rotatePlayers: null, supply: null, miss: null }"
`);
});

test('creates production buildings in the space biome despite not having access to funds buildings', async () => {
const initialMap = MapData.createMap({
config: {
biome: 4,
},
map: [
1, 1, 1, 29, 29, 1, 1, 1, 29, 29, 1, 1, 1, 29, 1, 1, 1, 1, 29, 29, 1, 1,
1, 1, 8,
],
size: {
height: 5,
width: 5,
},
teams: [
{
id: 1,
name: '',
players: [{ funds: 0, id: 1, userId: 'User-1' }],
},
{
id: 2,
name: '',
players: [{ funds: 1000, id: 2, name: 'AI' }],
},
],
});

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

const [, , gameStateA] = await executeGameAction(
map,
map.createVisionObject(player1),
new Map(),
EndTurnAction(),
AIRegistry,
);

expect(snapshotGameState(gameStateA)).toMatchInlineSnapshot(`
"Move (3,5 → 5,5) { fuel: 38, completed: null, path: [4,5 → 5,5] }
CreateBuilding (5,5) { building: Spawn Platform { id: 19, health: 100, player: 2, completed: true }, free: null }
CompleteUnit (5,3)
EndTurn { current: { funds: 850, player: 2 }, next: { funds: 0, player: 1 }, round: 2, rotatePlayers: null, supply: null, miss: null }"
`);
});

0 comments on commit 23ca9d6

Please sign in to comment.