-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
326 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/engine/core/utils/job/__test__/job_create_stalker.surge.ignore.ltx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[logic@test_smart_surge_1_walk] | ||
active = walker@test_smart_surge_1_walk | ||
[walker@test_smart_surge_1_walk] | ||
sound_idle = state | ||
use_camp = true | ||
meet = meet@generic_lager | ||
path_walk = surge_1_walk | ||
def_state_standing = guard | ||
def_state_moving = patrol | ||
path_look = surge_1_look | ||
out_restr = def_restrictor_test | ||
combat_ignore_cond = {=npc_in_zone(smart.base_on_actor_control.ignore_zone)} true | ||
combat_ignore_keep_when_attacked = true | ||
[logic@test_smart_surge_2_walk] | ||
active = walker@test_smart_surge_2_walk | ||
[walker@test_smart_surge_2_walk] | ||
sound_idle = state | ||
use_camp = true | ||
meet = meet@generic_lager | ||
path_walk = surge_2_walk | ||
def_state_standing = guard | ||
def_state_moving = patrol | ||
path_look = surge_2_look | ||
out_restr = def_restrictor_test | ||
combat_ignore_cond = {=npc_in_zone(smart.base_on_actor_control.ignore_zone)} true | ||
combat_ignore_keep_when_attacked = true | ||
[logic@test_smart_surge_3_walk] | ||
active = walker@test_smart_surge_3_walk | ||
[walker@test_smart_surge_3_walk] | ||
sound_idle = state | ||
use_camp = true | ||
meet = meet@generic_lager | ||
path_walk = surge_3_walk | ||
def_state_standing = guard | ||
def_state_moving = patrol | ||
out_restr = def_restrictor_test | ||
combat_ignore_cond = {=npc_in_zone(smart.base_on_actor_control.ignore_zone)} true | ||
combat_ignore_keep_when_attacked = true |
29 changes: 29 additions & 0 deletions
29
src/engine/core/utils/job/__test__/job_create_stalker.surge.ltx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[logic@test_smart_surge_1_walk] | ||
active = walker@test_smart_surge_1_walk | ||
[walker@test_smart_surge_1_walk] | ||
sound_idle = state | ||
use_camp = true | ||
meet = meet@generic_lager | ||
path_walk = surge_1_walk | ||
def_state_standing = guard | ||
def_state_moving = patrol | ||
path_look = surge_1_look | ||
[logic@test_smart_surge_2_walk] | ||
active = walker@test_smart_surge_2_walk | ||
[walker@test_smart_surge_2_walk] | ||
sound_idle = state | ||
use_camp = true | ||
meet = meet@generic_lager | ||
path_walk = surge_2_walk | ||
def_state_standing = guard | ||
def_state_moving = patrol | ||
path_look = surge_2_look | ||
[logic@test_smart_surge_3_walk] | ||
active = walker@test_smart_surge_3_walk | ||
[walker@test_smart_surge_3_walk] | ||
sound_idle = state | ||
use_camp = true | ||
meet = meet@generic_lager | ||
path_walk = surge_3_walk | ||
def_state_standing = guard | ||
def_state_moving = patrol |
32 changes: 32 additions & 0 deletions
32
src/engine/core/utils/job/__test__/job_create_stalker.surge.restrictors.ltx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[logic@test_smart_surge_1_walk] | ||
active = walker@test_smart_surge_1_walk | ||
[walker@test_smart_surge_1_walk] | ||
sound_idle = state | ||
use_camp = true | ||
meet = meet@generic_lager | ||
path_walk = surge_1_walk | ||
def_state_standing = guard | ||
def_state_moving = patrol | ||
path_look = surge_1_look | ||
out_restr = def_restrictor_test | ||
[logic@test_smart_surge_2_walk] | ||
active = walker@test_smart_surge_2_walk | ||
[walker@test_smart_surge_2_walk] | ||
sound_idle = state | ||
use_camp = true | ||
meet = meet@generic_lager | ||
path_walk = surge_2_walk | ||
def_state_standing = guard | ||
def_state_moving = patrol | ||
path_look = surge_2_look | ||
out_restr = def_restrictor_test | ||
[logic@test_smart_surge_3_walk] | ||
active = walker@test_smart_surge_3_walk | ||
[walker@test_smart_surge_3_walk] | ||
sound_idle = state | ||
use_camp = true | ||
meet = meet@generic_lager | ||
path_walk = surge_3_walk | ||
def_state_standing = guard | ||
def_state_moving = patrol | ||
out_restr = def_restrictor_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
src/engine/core/utils/job/job_create_stalker.surge.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import * as path from "path"; | ||
|
||
import { describe, expect, it, jest } from "@jest/globals"; | ||
|
||
import { IRegistryObjectState, registerZone } from "@/engine/core/database"; | ||
import { SmartTerrain, SmartTerrainControl } from "@/engine/core/objects"; | ||
import { createStalkerSurgeJobs } from "@/engine/core/utils/job/job_create_stalker"; | ||
import { range } from "@/engine/core/utils/number"; | ||
import { readInGameTestLtx } from "@/fixtures/engine"; | ||
import { mockClientGameObject } from "@/fixtures/xray"; | ||
|
||
describe("jobs_general should correctly generate stalkers surge jobs", () => { | ||
it("should correctly generate surge jobs for stalkers when no patrols exist", async () => { | ||
const smartTerrain: SmartTerrain = new SmartTerrain("test_smart"); | ||
|
||
smartTerrain.ini = smartTerrain.spawn_ini(); | ||
|
||
jest.spyOn(smartTerrain, "name").mockImplementation(() => "test_surge_paths_smart"); | ||
|
||
const [jobsList, ltx, count] = createStalkerSurgeJobs(smartTerrain); | ||
|
||
expect(count).toBe(1); | ||
expect(ltx).toBe(""); | ||
expect(jobsList).toEqualLuaTables({ | ||
jobs: {}, | ||
priority: 50, | ||
}); | ||
}); | ||
|
||
it("should correctly generate surge jobs for stalkers when patrols exist", async () => { | ||
const surgeJobsLtx: string = await readInGameTestLtx( | ||
path.resolve(__dirname, "__test__", "job_create_stalker.surge.ltx") | ||
); | ||
|
||
const smartTerrain: SmartTerrain = new SmartTerrain("test_smart"); | ||
|
||
smartTerrain.ini = smartTerrain.spawn_ini(); | ||
smartTerrain.defendRestrictor = null; | ||
|
||
jest.spyOn(smartTerrain, "name").mockImplementation(() => "test_smart"); | ||
|
||
const [jobsList, ltx, count] = createStalkerSurgeJobs(smartTerrain); | ||
|
||
expect(count).toBe(4); | ||
expect(ltx).toBe(surgeJobsLtx); | ||
expect(jobsList).toEqualLuaTables({ | ||
jobs: $fromArray( | ||
range(3, 1).map((it) => ({ | ||
_precondition_function: expect.any(Function), | ||
_precondition_params: {}, | ||
job_id: { | ||
job_type: "path_job", | ||
section: `logic@test_smart_surge_${it}_walk`, | ||
}, | ||
priority: 50, | ||
})) | ||
), | ||
priority: 50, | ||
}); | ||
}); | ||
|
||
it("should correctly generate surge jobs for stalkers when patrols exist with restrictors", async () => { | ||
const surgeJobsLtx: string = await readInGameTestLtx( | ||
path.resolve(__dirname, "__test__", "job_create_stalker.surge.restrictors.ltx") | ||
); | ||
|
||
const smartTerrain: SmartTerrain = new SmartTerrain("test_smart"); | ||
|
||
smartTerrain.ini = smartTerrain.spawn_ini(); | ||
|
||
jest.spyOn(smartTerrain, "name").mockImplementation(() => "test_smart"); | ||
|
||
smartTerrain.defendRestrictor = "def_restrictor_test"; | ||
smartTerrain.smartTerrainActorControl = { ignoreZone: "test_ignore_zone" } as SmartTerrainControl; | ||
|
||
const [jobsList, ltx, count] = createStalkerSurgeJobs(smartTerrain); | ||
|
||
expect(count).toBe(4); | ||
expect(ltx).toBe(surgeJobsLtx); | ||
expect(jobsList).toEqualLuaTables({ | ||
jobs: $fromArray( | ||
range(3, 1).map((it) => ({ | ||
_precondition_function: expect.any(Function), | ||
_precondition_params: {}, | ||
job_id: { | ||
job_type: "path_job", | ||
section: `logic@test_smart_surge_${it}_walk`, | ||
}, | ||
priority: 50, | ||
})) | ||
), | ||
priority: 50, | ||
}); | ||
}); | ||
|
||
it("should correctly generate surge jobs for stalkers when patrols exist, when in restrictor", async () => { | ||
const surgeJobsLtx: string = await readInGameTestLtx( | ||
path.resolve(__dirname, "__test__", "job_create_stalker.surge.ignore.ltx") | ||
); | ||
|
||
const smartTerrain: SmartTerrain = new SmartTerrain("test_smart"); | ||
|
||
registerZone(mockClientGameObject({ name: () => "some_restrictor", inside: () => true })); | ||
|
||
smartTerrain.ini = smartTerrain.spawn_ini(); | ||
|
||
jest.spyOn(smartTerrain, "name").mockImplementation(() => "test_smart"); | ||
|
||
smartTerrain.defendRestrictor = "def_restrictor_test"; | ||
smartTerrain.smartTerrainActorControl = { ignoreZone: "some_restrictor" } as SmartTerrainControl; | ||
|
||
const [jobsList, ltx, count] = createStalkerSurgeJobs(smartTerrain); | ||
|
||
expect(count).toBe(4); | ||
expect(ltx).toBe(surgeJobsLtx); | ||
expect(jobsList).toEqualLuaTables({ | ||
jobs: $fromArray( | ||
range(3, 1).map((it) => ({ | ||
_precondition_function: expect.any(Function), | ||
_precondition_params: {}, | ||
job_id: { | ||
job_type: "path_job", | ||
section: `logic@test_smart_surge_${it}_walk`, | ||
}, | ||
priority: 50, | ||
})) | ||
), | ||
priority: 50, | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.