Files
OpenFrontIO/tests/util/utils.ts
T
ilan schemoul 94dcb67a40 nukes now reduce attacking troops and transport ships (same as rest of pop)
Also made NukeExecution build in two separate steps (build then execute)
as for other execution. Otherwise it would instantly explode if I set
high speeds. high speeds in necessary for some tests.
It implied changing a bit some tests. This includes removing the test
that nukes.length == 0 in missile silo which had nothing to do there as
we are just checking cooldown. One test should test only one thing. Here
it was breaking because I changed the NukeExecution which made no sense.
2025-03-31 12:29:27 -07:00

31 lines
1.1 KiB
TypeScript

// Either someone can straight up call player.buildUnit. It's simpler and immediate (no tick required)
// Either someone can straight up call player.buildUnit. It's simpler and immediate (no tick required)
// However buildUnit do not create executions (e.g.: WarshipExecution)
// If you also need execution use function below. Does not work with things not
import { ConstructionExecution } from "../../src/core/execution/ConstructionExecution";
import { Game, PlayerID, UnitType } from "../../src/core/game/Game";
// built via UI (e.g.: trade ships)
export function constructionExecution(
game: Game,
playerID: PlayerID,
x: number,
y: number,
unit: UnitType,
ticks = 4,
) {
game.addExecution(new ConstructionExecution(playerID, game.ref(x, y), unit));
// 4 ticks by default as it usually goes like this
// Init of construction execution
// Exec construction execution
// Tick of construction execution which adds the execution related to the building/unit
// First tick of the execution of the constructed building/unit
// (sometimes step 3 and 4 are merged in one)
for (let i = 0; i < ticks; i++) {
game.executeNextTick();
}
}