ValidTargetsFinder Class
Gets a list of valid targets filtered by provided criteria.
Constructor
ValidTargetsFinder
-
game
-
settings
Parameters:
-
game
Game -
settings
Object-
x
Number- The x map tile coord to use as the origin of the attack.
-
y
Number- The y map tile coord to use as the origin of the attack.
-
[limitToFov=false]
FovROT optional- If set only targets within the given
FovROT
will be valid.
- If set only targets within the given
-
[limitToNonDiagonalAdjacent=false]
Bool optional- If true diagonally adjacent targets are not valid (only used if
range = 1
).
- If true diagonally adjacent targets are not valid (only used if
-
[range=1]
Number optional- Max distance in tiles target can be from origin.
-
[validTypes=[]]
Array optional- Array of valid target object types. Checked using
target instanceof type
.
- Array of valid target object types. Checked using
-
[includeTiles=false]
Bool optional- If true tile objects are can be valid targets.
-
[exclude=false]
Object | Array optional- Object or Array of objects to exclude from results.
-
[prepareValidTargets=true]
Bool optional- If true valid targets are wraped in an object with x, y, range, value properties.
-
[filter=false]
Function optional- Function to filter objects when checking if they are valid.
function(obj){ return true }
. Targets must still be a valid type.
- Function to filter objects when checking if they are valid.
-
Item Index
Methods
Methods
checkValidTarget
-
target
Checks if an object is a valid target for this action.
Parameters:
-
target
Object- The target to be checked.
Returns:
true
if valid.
checkValidType
-
target
Checks if a target object is an instance of a type in this.validTypes
.
Parameters:
-
target
Object- The target to be checked.
Returns:
true
if valid.
getValidTargets
()
Array
Gets all valid targets.
Returns:
getValidTargetsAtPosition
-
x
-
y
Get valid target objects on a tile coord.
Parameters:
-
x
Number- Map tile coord to get valid target objects from.
-
y
Number- Map tile coord to get valid target objects from.
Returns:
mixed objects
getValidTargetTiles
()
Array
Get tile coords a valid target may be on. Only checking range and fov, not objects on the tile.
Returns:
of Tile objects
prepareTargetObject
-
target
-
[x=target.x]
-
[y=target.y]
-
[range]
Wraps a target object in a container object with x, y, range
Parameters:
-
target
Object -
[x=target.x]
Number optional -
[y=target.y]
Number optional -
[range]
Number optionalrange from
this.x
,this.y
to x,y
Returns:
result.value target object
Properties
exclude
Object | Array
Object or Array of objects to exclude from results.
filter
Function
Function to filter objects when checking if they are valid. function(obj){ return true }
.
Targets must still be an instance of this.validTypes.
includeTiles
Boolean
If true tile objects are can be valid targets.
limitToNonDiagonalAdjacent
Boolean
Limit results to non-diagonal adjacent tiles
prepareValidTargets
Boolean
If true valid targets are wraped in an object with x, y, range, value properties.
range
Number
Max distance in tiles target can be from origin.
validTypes
Array
Array of valid target object types. Checked using target instanceof type
.
If set to an empty array or a value evaluating to false, all types are considered valid.
x
Number
The x map tile coord to use as the origin of this target finder.
y
Number
The y map tile coord to use as the origin of this target finder.