Changeset View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_UnitAI.js
Engine.LoadHelperScript("FSM.js"); | Engine.LoadHelperScript("FSM.js"); | ||||
Engine.LoadHelperScript("Entity.js"); | Engine.LoadHelperScript("Entity.js"); | ||||
Engine.LoadHelperScript("Player.js"); | Engine.LoadHelperScript("Player.js"); | ||||
Engine.LoadHelperScript("Sound.js"); | Engine.LoadHelperScript("Sound.js"); | ||||
Engine.LoadComponentScript("interfaces/Attack.js"); | |||||
Engine.LoadComponentScript("interfaces/Auras.js"); | Engine.LoadComponentScript("interfaces/Auras.js"); | ||||
Engine.LoadComponentScript("interfaces/Builder.js"); | Engine.LoadComponentScript("interfaces/Builder.js"); | ||||
Engine.LoadComponentScript("interfaces/BuildingAI.js"); | Engine.LoadComponentScript("interfaces/BuildingAI.js"); | ||||
Engine.LoadComponentScript("interfaces/Capturable.js"); | Engine.LoadComponentScript("interfaces/Capturable.js"); | ||||
Engine.LoadComponentScript("interfaces/Resistance.js"); | Engine.LoadComponentScript("interfaces/Resistance.js"); | ||||
Engine.LoadComponentScript("interfaces/Formation.js"); | Engine.LoadComponentScript("interfaces/Formation.js"); | ||||
Engine.LoadComponentScript("interfaces/Heal.js"); | Engine.LoadComponentScript("interfaces/Heal.js"); | ||||
Engine.LoadComponentScript("interfaces/Health.js"); | Engine.LoadComponentScript("interfaces/Health.js"); | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | function TestFormationExiting(mode) | ||||
var playerEntity = 5; | var playerEntity = 5; | ||||
var unit = 10; | var unit = 10; | ||||
var enemy = 20; | var enemy = 20; | ||||
var controller = 30; | var controller = 30; | ||||
AddMock(SYSTEM_ENTITY, IID_Timer, { | AddMock(SYSTEM_ENTITY, IID_Timer, { | ||||
SetInterval: function() { }, | SetInterval: function() { }, | ||||
Lint: ESLintBear (quote-props): `Unquoted property 'SetInterval' found.` | |||||
SetTimeout: function() { }, | SetTimeout: function() { }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'SetTimeout' found. Lint: ESLintBear (quote-props): `Unquoted property 'SetTimeout' found.` | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_RangeManager, { | AddMock(SYSTEM_ENTITY, IID_RangeManager, { | ||||
CreateActiveQuery: function(ent, minRange, maxRange, players, iid, flags) { | CreateActiveQuery: function(ent, minRange, maxRange, players, iid, flags) { | ||||
Lint: ESLintBear (quote-props) Unquoted property 'CreateActiveQuery' found. Lint: ESLintBear (quote-props): `Unquoted property 'CreateActiveQuery' found.` | |||||
return 1; | return 1; | ||||
}, | }, | ||||
EnableActiveQuery: function(id) { }, | EnableActiveQuery: function(id) { }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'EnableActiveQuery' found. Lint: ESLintBear (quote-props): `Unquoted property 'EnableActiveQuery' found.` | |||||
ResetActiveQuery: function(id) { if (mode == 0) return []; else return [enemy]; }, | ResetActiveQuery: function(id) { if (mode == 0) return []; else return [enemy]; }, | ||||
Lint: ESLintBear (no-else-return) Unnecessary 'else' after 'return'. Lint: ESLintBear (no-else-return): `Unnecessary 'else' after 'return'.` | |||||
Lint: ESLintBear (brace-rules/brace-on-same-line) Closing curly brace appears on the same line as the subsequent block. Lint: ESLintBear (brace-rules/brace-on-same-line): `Closing curly brace appears on the same line as the subsequent block.` | |||||
Lint: ESLintBear (quote-props) Unquoted property 'ResetActiveQuery' found. Lint: ESLintBear (quote-props): `Unquoted property 'ResetActiveQuery' found.` | |||||
DisableActiveQuery: function(id) { }, | DisableActiveQuery: function(id) { }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'DisableActiveQuery' found. Lint: ESLintBear (quote-props): `Unquoted property 'DisableActiveQuery' found.` | |||||
GetEntityFlagMask: function(identifier) { }, | GetEntityFlagMask: function(identifier) { }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetEntityFlagMask' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetEntityFlagMask' found.` | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_TemplateManager, { | AddMock(SYSTEM_ENTITY, IID_TemplateManager, { | ||||
GetCurrentTemplateName: function(ent) { return "special/formations/line_closed"; }, | GetCurrentTemplateName: function(ent) { return "special/formations/line_closed"; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetCurrentTemplateName' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetCurrentTemplateName' found.` | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
GetPlayerByID: function(id) { return playerEntity; }, | GetPlayerByID: function(id) { return playerEntity; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetPlayerByID' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetPlayerByID' found.` | |||||
GetNumPlayers: function() { return 2; }, | GetNumPlayers: function() { return 2; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetNumPlayers' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetNumPlayers' found.` | |||||
}); | }); | ||||
AddMock(playerEntity, IID_Player, { | AddMock(playerEntity, IID_Player, { | ||||
IsAlly: function() { return false; }, | IsAlly: function() { return false; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'IsAlly' found. Lint: ESLintBear (quote-props): `Unquoted property 'IsAlly' found.` | |||||
IsEnemy: function() { return true; }, | IsEnemy: function() { return true; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'IsEnemy' found. Lint: ESLintBear (quote-props): `Unquoted property 'IsEnemy' found.` | |||||
GetEnemies: function() { return [2]; }, | GetEnemies: function() { return [2]; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetEnemies' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetEnemies' found.` | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { | AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { | ||||
"IsInTargetRange": () => true, | "IsInTargetRange": () => true, | ||||
"IsInPointRange": () => true | "IsInPointRange": () => true | ||||
}); | }); | ||||
var unitAI = ConstructComponent(unit, "UnitAI", { "FormationController": "false", "DefaultStance": "aggressive" }); | var unitAI = ConstructComponent(unit, "UnitAI", { "FormationController": "false", "DefaultStance": "aggressive" }); | ||||
AddMock(unit, IID_Identity, { | AddMock(unit, IID_Identity, { | ||||
GetClassesList: function() { return []; }, | GetClassesList: function() { return []; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetClassesList' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetClassesList' found.` | |||||
}); | }); | ||||
AddMock(unit, IID_Ownership, { | AddMock(unit, IID_Ownership, { | ||||
GetOwner: function() { return 1; }, | GetOwner: function() { return 1; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetOwner' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetOwner' found.` | |||||
}); | }); | ||||
AddMock(unit, IID_Position, { | AddMock(unit, IID_Position, { | ||||
GetTurretParent: function() { return INVALID_ENTITY; }, | GetTurretParent: function() { return INVALID_ENTITY; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetTurretParent' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetTurretParent' found.` | |||||
GetPosition: function() { return new Vector3D(); }, | GetPosition: function() { return new Vector3D(); }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetPosition' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetPosition' found.` | |||||
GetPosition2D: function() { return new Vector2D(); }, | GetPosition2D: function() { return new Vector2D(); }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetPosition2D' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetPosition2D' found.` | |||||
GetRotation: function() { return { "y": 0 }; }, | GetRotation: function() { return { "y": 0 }; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetRotation' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetRotation' found.` | |||||
IsInWorld: function() { return true; }, | IsInWorld: function() { return true; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'IsInWorld' found. Lint: ESLintBear (quote-props): `Unquoted property 'IsInWorld' found.` | |||||
}); | }); | ||||
AddMock(unit, IID_UnitMotion, { | AddMock(unit, IID_UnitMotion, { | ||||
"GetWalkSpeed": () => 1, | "GetWalkSpeed": () => 1, | ||||
"MoveToFormationOffset": (target, x, z) => {}, | "MoveToFormationOffset": (target, x, z) => {}, | ||||
"MoveToTargetRange": (target, min, max) => true, | "MoveToTargetRange": (target, min, max) => true, | ||||
"StopMoving": () => {}, | "StopMoving": () => {}, | ||||
"SetFacePointAfterMove": () => {}, | "SetFacePointAfterMove": () => {}, | ||||
"GetFacePointAfterMove": () => true, | "GetFacePointAfterMove": () => true, | ||||
"GetPassabilityClassName": () => "default" | "GetPassabilityClassName": () => "default" | ||||
}); | }); | ||||
AddMock(unit, IID_Vision, { | AddMock(unit, IID_Vision, { | ||||
GetRange: function() { return 10; }, | GetRange: function() { return 10; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetRange' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetRange' found.` | |||||
}); | }); | ||||
AddMock(unit, IID_Attack, { | AddMock(unit, IID_Attack, { | ||||
GetRange: function() { return { "max": 10, "min": 0}; }, | GetRange: function() { return { "max": 10, "min": 0}; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetRange' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetRange' found.` | |||||
Lint: ESLintBear (object-curly-spacing) A space is required before '}'. Lint: ESLintBear (object-curly-spacing): `A space is required before '}'.` | |||||
GetFullAttackRange: function() { return { "max": 40, "min": 0}; }, | GetFullAttackRange: function() { return { "max": 40, "min": 0}; }, | ||||
Lint: ESLintBear (object-curly-spacing) A space is required before '}'. Lint: ESLintBear (object-curly-spacing): `A space is required before '}'.` | |||||
Lint: ESLintBear (quote-props) Unquoted property 'GetFullAttackRange' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetFullAttackRange' found.` | |||||
GetBestAttackAgainst: function(t) { return "melee"; }, | GetBestAttackAgainst: function(t) { return "melee"; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetBestAttackAgainst' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetBestAttackAgainst' found.` | |||||
GetPreference: function(t) { return 0; }, | GetPreference: function(t) { return 0; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetPreference' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetPreference' found.` | |||||
GetTimers: function() { return { "prepare": 500, "repeat": 1000 }; }, | GetTimers: function() { return { "prepare": 500, "repeat": 1000 }; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetTimers' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetTimers' found.` | |||||
CanAttack: function(v) { return true; }, | CanAttack: function(v) { return true; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'CanAttack' found. Lint: ESLintBear (quote-props): `Unquoted property 'CanAttack' found.` | |||||
CompareEntitiesByPreference: function(a, b) { return 0; }, | CompareEntitiesByPreference: function(a, b) { return 0; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'CompareEntitiesByPreference' found. Lint: ESLintBear (quote-props): `Unquoted property 'CompareEntitiesByPreference' found.` | |||||
}); | }); | ||||
unitAI.OnCreate(); | unitAI.OnCreate(); | ||||
unitAI.SetupAttackRangeQuery(1); | unitAI.SetupAttackRangeQuery(1); | ||||
if (mode == 1) | if (mode == 1) | ||||
{ | { | ||||
AddMock(enemy, IID_Health, { | AddMock(enemy, IID_Health, { | ||||
GetHitpoints: function() { return 10; }, | GetHitpoints: function() { return 10; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetHitpoints' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetHitpoints' found.` | |||||
}); | }); | ||||
AddMock(enemy, IID_UnitAI, { | AddMock(enemy, IID_UnitAI, { | ||||
IsAnimal: function() { return false; } | IsAnimal: function() { return false; } | ||||
Lint: ESLintBear (quote-props) Unquoted property 'IsAnimal' found. Lint: ESLintBear (quote-props): `Unquoted property 'IsAnimal' found.` | |||||
}); | }); | ||||
} | } | ||||
else if (mode == 2) | else if (mode == 2) | ||||
AddMock(enemy, IID_Health, { | AddMock(enemy, IID_Health, { | ||||
GetHitpoints: function() { return 0; }, | GetHitpoints: function() { return 0; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetHitpoints' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetHitpoints' found.` | |||||
}); | }); | ||||
var controllerFormation = ConstructComponent(controller, "Formation", {"FormationName": "Line Closed", "FormationShape": "square", "ShiftRows": "false", "SortingClasses": "", "WidthDepthRatio": 1, "UnitSeparationWidthMultiplier": 1, "UnitSeparationDepthMultiplier": 1, "SpeedMultiplier": 1, "Sloppyness": 0}); | var controllerFormation = ConstructComponent(controller, "Formation", {"FormationName": "Line Closed", "FormationShape": "square", "ShiftRows": "false", "SortingClasses": "", "WidthDepthRatio": 1, "UnitSeparationWidthMultiplier": 1, "UnitSeparationDepthMultiplier": 1, "SpeedMultiplier": 1, "Sloppyness": 0}); | ||||
Lint: ESLintBear (object-curly-spacing) A space is required before '}'. Lint: ESLintBear (object-curly-spacing): `A space is required before '}'.` | |||||
Lint: ESLintBear (object-curly-spacing) A space is required after '{'. Lint: ESLintBear (object-curly-spacing): `A space is required after '{'.` | |||||
var controllerAI = ConstructComponent(controller, "UnitAI", { "FormationController": "true", "DefaultStance": "aggressive" }); | var controllerAI = ConstructComponent(controller, "UnitAI", { "FormationController": "true", "DefaultStance": "aggressive" }); | ||||
AddMock(controller, IID_Position, { | AddMock(controller, IID_Position, { | ||||
JumpTo: function(x, z) { this.x = x; this.z = z; }, | JumpTo: function(x, z) { this.x = x; this.z = z; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'JumpTo' found. Lint: ESLintBear (quote-props): `Unquoted property 'JumpTo' found.` | |||||
GetTurretParent: function() { return INVALID_ENTITY; }, | GetTurretParent: function() { return INVALID_ENTITY; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetTurretParent' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetTurretParent' found.` | |||||
GetPosition: function() { return new Vector3D(this.x, 0, this.z); }, | GetPosition: function() { return new Vector3D(this.x, 0, this.z); }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetPosition' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetPosition' found.` | |||||
GetPosition2D: function() { return new Vector2D(this.x, this.z); }, | GetPosition2D: function() { return new Vector2D(this.x, this.z); }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetPosition2D' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetPosition2D' found.` | |||||
GetRotation: function() { return { "y": 0 }; }, | GetRotation: function() { return { "y": 0 }; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetRotation' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetRotation' found.` | |||||
IsInWorld: function() { return true; }, | IsInWorld: function() { return true; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'IsInWorld' found. Lint: ESLintBear (quote-props): `Unquoted property 'IsInWorld' found.` | |||||
MoveOutOfWorld: () => {} | MoveOutOfWorld: () => {} | ||||
Lint: ESLintBear (quote-props) Unquoted property 'MoveOutOfWorld' found. Lint: ESLintBear (quote-props): `Unquoted property 'MoveOutOfWorld' found.` | |||||
}); | }); | ||||
AddMock(controller, IID_UnitMotion, { | AddMock(controller, IID_UnitMotion, { | ||||
"GetWalkSpeed": () => 1, | "GetWalkSpeed": () => 1, | ||||
"StopMoving": () => {}, | "StopMoving": () => {}, | ||||
"SetSpeedMultiplier": () => {}, | "SetSpeedMultiplier": () => {}, | ||||
"MoveToPointRange": () => true, | "MoveToPointRange": () => true, | ||||
"SetFacePointAfterMove": () => {}, | "SetFacePointAfterMove": () => {}, | ||||
Show All 35 Lines | function TestMoveIntoFormationWhileAttacking() | ||||
var controller = 10; | var controller = 10; | ||||
var enemy = 20; | var enemy = 20; | ||||
var unit = 30; | var unit = 30; | ||||
var units = []; | var units = []; | ||||
var unitCount = 8; | var unitCount = 8; | ||||
var unitAIs = []; | var unitAIs = []; | ||||
AddMock(SYSTEM_ENTITY, IID_Timer, { | AddMock(SYSTEM_ENTITY, IID_Timer, { | ||||
SetInterval: function() { }, | SetInterval: function() { }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'SetInterval' found. Lint: ESLintBear (quote-props): `Unquoted property 'SetInterval' found.` | |||||
SetTimeout: function() { }, | SetTimeout: function() { }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'SetTimeout' found. Lint: ESLintBear (quote-props): `Unquoted property 'SetTimeout' found.` | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_RangeManager, { | AddMock(SYSTEM_ENTITY, IID_RangeManager, { | ||||
CreateActiveQuery: function(ent, minRange, maxRange, players, iid, flags) { | CreateActiveQuery: function(ent, minRange, maxRange, players, iid, flags) { | ||||
Lint: ESLintBear (quote-props) Unquoted property 'CreateActiveQuery' found. Lint: ESLintBear (quote-props): `Unquoted property 'CreateActiveQuery' found.` | |||||
return 1; | return 1; | ||||
}, | }, | ||||
EnableActiveQuery: function(id) { }, | EnableActiveQuery: function(id) { }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'EnableActiveQuery' found. Lint: ESLintBear (quote-props): `Unquoted property 'EnableActiveQuery' found.` | |||||
ResetActiveQuery: function(id) { return [enemy]; }, | ResetActiveQuery: function(id) { return [enemy]; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'ResetActiveQuery' found. Lint: ESLintBear (quote-props): `Unquoted property 'ResetActiveQuery' found.` | |||||
DisableActiveQuery: function(id) { }, | DisableActiveQuery: function(id) { }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'DisableActiveQuery' found. Lint: ESLintBear (quote-props): `Unquoted property 'DisableActiveQuery' found.` | |||||
GetEntityFlagMask: function(identifier) { }, | GetEntityFlagMask: function(identifier) { }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetEntityFlagMask' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetEntityFlagMask' found.` | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_TemplateManager, { | AddMock(SYSTEM_ENTITY, IID_TemplateManager, { | ||||
GetCurrentTemplateName: function(ent) { return "special/formations/line_closed"; }, | GetCurrentTemplateName: function(ent) { return "special/formations/line_closed"; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetCurrentTemplateName' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetCurrentTemplateName' found.` | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
GetPlayerByID: function(id) { return playerEntity; }, | GetPlayerByID: function(id) { return playerEntity; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetPlayerByID' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetPlayerByID' found.` | |||||
GetNumPlayers: function() { return 2; }, | GetNumPlayers: function() { return 2; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetNumPlayers' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetNumPlayers' found.` | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { | AddMock(SYSTEM_ENTITY, IID_ObstructionManager, { | ||||
"IsInTargetRange": (ent, target, min, max) => true | "IsInTargetRange": (ent, target, min, max) => true | ||||
}); | }); | ||||
AddMock(playerEntity, IID_Player, { | AddMock(playerEntity, IID_Player, { | ||||
IsAlly: function() { return false; }, | IsAlly: function() { return false; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'IsAlly' found. Lint: ESLintBear (quote-props): `Unquoted property 'IsAlly' found.` | |||||
IsEnemy: function() { return true; }, | IsEnemy: function() { return true; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'IsEnemy' found. Lint: ESLintBear (quote-props): `Unquoted property 'IsEnemy' found.` | |||||
GetEnemies: function() { return [2]; }, | GetEnemies: function() { return [2]; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetEnemies' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetEnemies' found.` | |||||
}); | }); | ||||
// create units | // create units | ||||
for (var i = 0; i < unitCount; i++) { | for (var i = 0; i < unitCount; i++) { | ||||
Lint: ESLintBear (brace-rules/brace-on-same-line) Opening curly brace appears on the same line as controlling statement. Lint: ESLintBear (brace-rules/brace-on-same-line): `Opening curly brace appears on the same line as controlling statement.` | |||||
units.push(unit + i); | units.push(unit + i); | ||||
var unitAI = ConstructComponent(unit + i, "UnitAI", { "FormationController": "false", "DefaultStance": "aggressive" }); | var unitAI = ConstructComponent(unit + i, "UnitAI", { "FormationController": "false", "DefaultStance": "aggressive" }); | ||||
AddMock(unit + i, IID_Identity, { | AddMock(unit + i, IID_Identity, { | ||||
GetClassesList: function() { return []; }, | GetClassesList: function() { return []; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetClassesList' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetClassesList' found.` | |||||
}); | }); | ||||
AddMock(unit + i, IID_Ownership, { | AddMock(unit + i, IID_Ownership, { | ||||
GetOwner: function() { return 1; }, | GetOwner: function() { return 1; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetOwner' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetOwner' found.` | |||||
}); | }); | ||||
AddMock(unit + i, IID_Position, { | AddMock(unit + i, IID_Position, { | ||||
GetTurretParent: function() { return INVALID_ENTITY; }, | GetTurretParent: function() { return INVALID_ENTITY; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetTurretParent' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetTurretParent' found.` | |||||
GetPosition: function() { return new Vector3D(); }, | GetPosition: function() { return new Vector3D(); }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetPosition' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetPosition' found.` | |||||
GetPosition2D: function() { return new Vector2D(); }, | GetPosition2D: function() { return new Vector2D(); }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetPosition2D' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetPosition2D' found.` | |||||
GetRotation: function() { return { "y": 0 }; }, | GetRotation: function() { return { "y": 0 }; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetRotation' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetRotation' found.` | |||||
IsInWorld: function() { return true; }, | IsInWorld: function() { return true; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'IsInWorld' found. Lint: ESLintBear (quote-props): `Unquoted property 'IsInWorld' found.` | |||||
}); | }); | ||||
AddMock(unit + i, IID_UnitMotion, { | AddMock(unit + i, IID_UnitMotion, { | ||||
"GetWalkSpeed": () => 1, | "GetWalkSpeed": () => 1, | ||||
"MoveToFormationOffset": (target, x, z) => {}, | "MoveToFormationOffset": (target, x, z) => {}, | ||||
"MoveToTargetRange": (target, min, max) => true, | "MoveToTargetRange": (target, min, max) => true, | ||||
"StopMoving": () => {}, | "StopMoving": () => {}, | ||||
"SetFacePointAfterMove": () => {}, | "SetFacePointAfterMove": () => {}, | ||||
"GetFacePointAfterMove": () => true, | "GetFacePointAfterMove": () => true, | ||||
"GetPassabilityClassName": () => "default" | "GetPassabilityClassName": () => "default" | ||||
}); | }); | ||||
AddMock(unit + i, IID_Vision, { | AddMock(unit + i, IID_Vision, { | ||||
GetRange: function() { return 10; }, | GetRange: function() { return 10; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetRange' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetRange' found.` | |||||
}); | }); | ||||
AddMock(unit + i, IID_Attack, { | AddMock(unit + i, IID_Attack, { | ||||
GetRange: function() { return {"max":10, "min": 0}; }, | GetRange: function() { return {"max":10, "min": 0}; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetRange' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetRange' found.` | |||||
Lint: ESLintBear (object-curly-spacing) A space is required after '{'. Lint: ESLintBear (object-curly-spacing): `A space is required after '{'.` | |||||
Lint: ESLintBear (key-spacing) Missing space before value for key 'max'. Lint: ESLintBear (key-spacing): `Missing space before value for key 'max'.` | |||||
Lint: ESLintBear (object-curly-spacing) A space is required before '}'. Lint: ESLintBear (object-curly-spacing): `A space is required before '}'.` | |||||
GetFullAttackRange: function() { return { "max": 40, "min": 0}; }, | GetFullAttackRange: function() { return { "max": 40, "min": 0}; }, | ||||
Lint: ESLintBear (object-curly-spacing) A space is required before '}'. Lint: ESLintBear (object-curly-spacing): `A space is required before '}'.` | |||||
Lint: ESLintBear (quote-props) Unquoted property 'GetFullAttackRange' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetFullAttackRange' found.` | |||||
GetBestAttackAgainst: function(t) { return "melee"; }, | GetBestAttackAgainst: function(t) { return "melee"; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetBestAttackAgainst' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetBestAttackAgainst' found.` | |||||
GetTimers: function() { return { "prepare": 500, "repeat": 1000 }; }, | GetTimers: function() { return { "prepare": 500, "repeat": 1000 }; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetTimers' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetTimers' found.` | |||||
CanAttack: function(v) { return true; }, | CanAttack: function(v) { return true; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'CanAttack' found. Lint: ESLintBear (quote-props): `Unquoted property 'CanAttack' found.` | |||||
CompareEntitiesByPreference: function(a, b) { return 0; }, | CompareEntitiesByPreference: function(a, b) { return 0; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'CompareEntitiesByPreference' found. Lint: ESLintBear (quote-props): `Unquoted property 'CompareEntitiesByPreference' found.` | |||||
}); | }); | ||||
unitAI.OnCreate(); | unitAI.OnCreate(); | ||||
unitAI.SetupAttackRangeQuery(1); | unitAI.SetupAttackRangeQuery(1); | ||||
unitAIs.push(unitAI); | unitAIs.push(unitAI); | ||||
} | } | ||||
// create enemy | // create enemy | ||||
AddMock(enemy, IID_Health, { | AddMock(enemy, IID_Health, { | ||||
GetHitpoints: function() { return 40; }, | GetHitpoints: function() { return 40; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'GetHitpoints' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetHitpoints' found.` | |||||
}); | }); | ||||
var controllerFormation = ConstructComponent(controller, "Formation", {"FormationName": "Line Closed", "FormationShape": "square", "ShiftRows": "false", "SortingClasses": "", "WidthDepthRatio": 1, "UnitSeparationWidthMultiplier": 1, "UnitSeparationDepthMultiplier": 1, "SpeedMultiplier": 1, "Sloppyness": 0}); | var controllerFormation = ConstructComponent(controller, "Formation", {"FormationName": "Line Closed", "FormationShape": "square", "ShiftRows": "false", "SortingClasses": "", "WidthDepthRatio": 1, "UnitSeparationWidthMultiplier": 1, "UnitSeparationDepthMultiplier": 1, "SpeedMultiplier": 1, "Sloppyness": 0}); | ||||
Lint: ESLintBear (object-curly-spacing) A space is required before '}'. Lint: ESLintBear (object-curly-spacing): `A space is required before '}'.` | |||||
Lint: ESLintBear (object-curly-spacing) A space is required after '{'. Lint: ESLintBear (object-curly-spacing): `A space is required after '{'.` | |||||
var controllerAI = ConstructComponent(controller, "UnitAI", { "FormationController": "true", "DefaultStance": "aggressive" }); | var controllerAI = ConstructComponent(controller, "UnitAI", { "FormationController": "true", "DefaultStance": "aggressive" }); | ||||
AddMock(controller, IID_Position, { | AddMock(controller, IID_Position, { | ||||
"GetTurretParent": () => INVALID_ENTITY, | "GetTurretParent": () => INVALID_ENTITY, | ||||
"JumpTo": function(x, z) { this.x = x; this.z = z; }, | "JumpTo": function(x, z) { this.x = x; this.z = z; }, | ||||
"GetPosition": function(){ return new Vector3D(this.x, 0, this.z); }, | "GetPosition": function(){ return new Vector3D(this.x, 0, this.z); }, | ||||
"GetPosition2D": function(){ return new Vector2D(this.x, this.z); }, | "GetPosition2D": function(){ return new Vector2D(this.x, this.z); }, | ||||
"GetRotation": () => ({ "y": 0 }), | "GetRotation": () => ({ "y": 0 }), | ||||
"IsInWorld": () => true, | "IsInWorld": () => true, | ||||
"MoveOutOfWorld": () => {}, | "MoveOutOfWorld": () => {}, | ||||
}); | }); | ||||
AddMock(controller, IID_UnitMotion, { | AddMock(controller, IID_UnitMotion, { | ||||
"GetWalkSpeed": () => 1, | "GetWalkSpeed": () => 1, | ||||
"SetSpeedMultiplier": (speed) => {}, | "SetSpeedMultiplier": (speed) => {}, | ||||
"MoveToPointRange": (x, z, minRange, maxRange) => {}, | "MoveToPointRange": (x, z, minRange, maxRange) => {}, | ||||
"StopMoving": () => {}, | "StopMoving": () => {}, | ||||
"SetFacePointAfterMove": () => {}, | "SetFacePointAfterMove": () => {}, | ||||
"GetFacePointAfterMove": () => true, | "GetFacePointAfterMove": () => true, | ||||
"GetPassabilityClassName": () => "default" | "GetPassabilityClassName": () => "default" | ||||
}); | }); | ||||
AddMock(controller, IID_Attack, { | AddMock(controller, IID_Attack, { | ||||
GetRange: function() { return {"max":10, "min": 0}; }, | GetRange: function() { return {"max":10, "min": 0}; }, | ||||
Lint: ESLintBear (object-curly-spacing) A space is required before '}'. Lint: ESLintBear (object-curly-spacing): `A space is required before '}'.` | |||||
Lint: ESLintBear (key-spacing) Missing space before value for key 'max'. Lint: ESLintBear (key-spacing): `Missing space before value for key 'max'.` | |||||
Lint: ESLintBear (object-curly-spacing) A space is required after '{'. Lint: ESLintBear (object-curly-spacing): `A space is required after '{'.` | |||||
Lint: ESLintBear (quote-props) Unquoted property 'GetRange' found. Lint: ESLintBear (quote-props): `Unquoted property 'GetRange' found.` | |||||
CanAttackAsFormation: function() { return false; }, | CanAttackAsFormation: function() { return false; }, | ||||
Lint: ESLintBear (quote-props) Unquoted property 'CanAttackAsFormation' found. Lint: ESLintBear (quote-props): `Unquoted property 'CanAttackAsFormation' found.` | |||||
}); | }); | ||||
controllerAI.OnCreate(); | controllerAI.OnCreate(); | ||||
controllerFormation.SetMembers(units); | controllerFormation.SetMembers(units); | ||||
controllerAI.Attack(enemy, []); | controllerAI.Attack(enemy, []); | ||||
for (let ent of unitAIs) | for (let ent of unitAIs) | ||||
TS_ASSERT_EQUALS(unitAI.fsmStateName, "INDIVIDUAL.COMBAT.ATTACKING"); | TS_ASSERT_EQUALS(unitAI.fsmStateName, "INDIVIDUAL.COMBAT.ATTACKING"); | ||||
Lint: JSHintBear 'unitAI' used out of scope. Lint: JSHintBear: `'unitAI' used out of scope.` | |||||
controllerAI.MoveIntoFormation({"name": "Circle"}); | controllerAI.MoveIntoFormation({"name": "Circle"}); | ||||
Lint: ESLintBear (object-curly-spacing) A space is required before '}'. Lint: ESLintBear (object-curly-spacing): `A space is required before '}'.` | |||||
Lint: ESLintBear (object-curly-spacing) A space is required after '{'. Lint: ESLintBear (object-curly-spacing): `A space is required after '{'.` | |||||
// let all units be in position | // let all units be in position | ||||
for (let ent of unitAIs) | for (let ent of unitAIs) | ||||
controllerFormation.SetWaitingOnController(ent); | controllerFormation.SetWaitingOnController(ent); | ||||
for (let ent of unitAIs) | for (let ent of unitAIs) | ||||
TS_ASSERT_EQUALS(unitAI.fsmStateName, "INDIVIDUAL.COMBAT.ATTACKING"); | TS_ASSERT_EQUALS(unitAI.fsmStateName, "INDIVIDUAL.COMBAT.ATTACKING"); | ||||
Lint: JSHintBear 'unitAI' used out of scope. Lint: JSHintBear: `'unitAI' used out of scope.` | |||||
controllerFormation.Disband(); | controllerFormation.Disband(); | ||||
} | } | ||||
TestFormationExiting(0); | TestFormationExiting(0); | ||||
TestFormationExiting(1); | TestFormationExiting(1); | ||||
TestFormationExiting(2); | TestFormationExiting(2); | ||||
TestMoveIntoFormationWhileAttacking(); | TestMoveIntoFormationWhileAttacking(); |
Unquoted property 'SetInterval' found.