Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Latest commit

 

History

History
391 lines (266 loc) · 19.6 KB

api.md

File metadata and controls

391 lines (266 loc) · 19.6 KB

API

Many function of this api are redundant they can be easily replaced with other macros or modules, is advisable to use other module like CUB or Dfred convenient effects for manage the active effects anyway this module cna mange the active effects too.

Setting members

SENSESarray

The senses used in this system

CONDITIONSarray

The conditions used in this system

Work in progress...

Setting Functions

Work in progress...

Conditional Visibility Functions

game.modules.get('conditional-visibility').api.setCondition(tokenNameOrId: string, effectId: string, distance: number) ⇒ Promise.<void>

Add a active effect for work with the module, the effectId parameter must be present on the table associated to the system.

Returns: Promise.<void> - A empty promise

Param Type Description Default
tokenNameOrId string The name or the id of the token undefined
effectNameOrId string The effect name or id used from this module, must be present on the table of this system undefined
disabled boolean The effect must be applied, but disabled false
distance number OPTIONAL: explicit distance in units not grid to add to the Active Effects 0
visionLevelValue number OPTIONAL: explicit distance in units not grid to add to the Active Effects 0

Example: game.modules.get('conditional-visibility').api.setCondition('Zruggig Widebrain','darkvision', false, 60, 4)

game.modules.get('conditional-visibility').api.setCondition('Zruggig Widebrain','darkvision' false, 60, 4)

game.modules.get('conditional-visibility').api.setCondition('Zruggig Widebrain','darkvision', false,)

game.modules.get('conditional-visibility').api.setCondition('Zruggig Widebrain','darkvision' false)

game.modules.get('conditional-visibility').api.addEffectConditionalVisibilityOnToken(tokenNameOrId: string, effectId: string, distance: number) ⇒ Promise.<void>

NOTE: is the same of the game.modules.get('conditional-visibility').api.setCondition

Add a active effect for work with the module, the effectId parameter must be present on the table associated to the system.

Returns: Promise.<void> - A empty promise

Param Type Description Default
tokenNameOrId string The name or the id of the token undefined
effectNameOrId string The effect name or id used from this module, must be present on the table of this system undefined
disabled boolean The effect must be applied, but disabled false
distance number OPTIONAL: explicit distance in units not grid to add to the Active Effects 0
visionLevelValue number OPTIONAL: explicit distance in units not grid to add to the Active Effects 0

Example: game.modules.get('conditional-visibility').api.addEffectConditionalVisibilityOnToken('Zruggig Widebrain','darkvision', false, 60, 4)

game.modules.get('conditional-visibility').api.addEffectConditionalVisibilityOnToken('Zruggig Widebrain','darkvision' false, 60, 4)

game.modules.get('conditional-visibility').api.addEffectConditionalVisibilityOnToken('Zruggig Widebrain','darkvision', false,)

game.modules.get('conditional-visibility').api.addEffectConditionalVisibilityOnToken('Zruggig Widebrain','darkvision' false)

game.modules.get('conditional-visibility').api.getAllDefaultSensesAndConditions(token:Token) ⇒ Promise.<SenseData[]>

Return all senses and conditions register form the module by default hte ones present on the table associated to the system.

Returns: Promise.<SenseData[]> - A array of SenseData promise

Param Type Description Default
token Token The token object undefined

Example: game.modules.get('conditional-visibility').api.getAllDefaultSensesAndConditions()

game.modules.get('conditional-visibility').api.getAllDefaultSensesAndConditions()

game.modules.get('conditional-visibility').api.registerSense(senseData: SenseData) ⇒ Promise.<void>

A method to register a customize sense to add to the world

Returns: Promise.<void> - A empty promise

Param Type Description Default
senseData SenseData The sense data object undefined

Example:

game.modules.get('conditional-visibility').api.registerSense({
  id: 'bloodsight',
  name: 'Bloodsight',
  path: '',
  img: 'systems/dnd5e/icons/spells/haste-fire-3.jpg',
  conditionElevation: true,
  conditionTargets: ['invisible','hidden'],
  conditionSources: [],
})
game.modules.get('conditional-visibility').api.registerSense({
  id: 'bloodsight',
  name: 'Bloodsight',
  path: '',
  img: 'systems/dnd5e/icons/spells/haste-fire-3.jpg',
  conditionElevation: true,
  conditionTargets: ['invisible','hidden'],
  conditionSources: [],
})

game.modules.get('conditional-visibility').api.registerCondition(senseData: SenseData) ⇒ Promise.<void>

A method to register a customize condition to add to the world. Remember for make this work you need to add the active effect with the same name with the custom handler from Dfred convenient effects is a forced thing i know, but that a module alreay have all the import/export and ui stuff... if no active effect is founded a deafult one is build with minimal data

Returns: Promise.<void> - A empty promise

Param Type Description Default
senseData SenseData The sense data object undefined
game.modules.get('conditional-visibility').api.registerCondition({
  id: 'bloodsight',
  name: 'Bloodsight',
  path: '',
  img: 'systems/dnd5e/icons/spells/haste-fire-3.jpg',
  conditionElevation: true,
  conditionTargets: [],
  conditionSources: ['darkvision'],
})
game.modules.get('conditional-visibility').api.registerCondition({
  id: 'bloodsight',
  name: 'Bloodsight',
  path: '',
  img: 'systems/dnd5e/icons/spells/haste-fire-3.jpg',
  conditionElevation: true,
  conditionTargets: [],
  conditionSources: ['darkvision'],
})

game.modules.get('conditional-visibility').api.unRegisterSense(senseDataIdOrName: string) ⇒ Promise.<void>

A method to un-register a customize sense from the world.

Returns: Promise.<void> - A empty promise

Param Type Description Default
senseDataIdOrName string The sense id or name to remove (if founded) undefined

Example:

game.modules.get('conditional-visibility').api.unRegisterSense('bloodsight')

game.modules.get('conditional-visibility').api.unRegisterSense('bloodsight')

game.modules.get('conditional-visibility').api.unRegisterCondition(senseDataIdOrName: string) ⇒ Promise.<void>

A method to un-register a customize condition from the world

Returns: Promise.<void> - A empty promise

Param Type Description Default
senseDataIdOrName string The condition id or name to remove (if founded) undefined

Example:

game.modules.get('conditional-visibility').api.unRegisterCondition('bloodsight')

game.modules.get('conditional-visibility').api.unRegisterCondition('bloodsight')

async game.modules.get('conditional-visibility').api.unHide(tokens: Token[]) ⇒ Promise.<void>

A method to force a array of tokens to be visible to everyone with a specific flag "Force to be visible". This flag can be managed on the token configuration panel of every token.

Returns: Promise.<void> - A empty promise

Param Type Description Default
tokens Token[] The array of tokens to make visible to everyone undefined

async game.modules.get('conditional-visibility').api.forceToBeVisible(token: Token) ⇒ Promise.<void>

A method to force a token to be visibile for the CV checker

Returns: Promise.<void>

Param Type Description Default
token string The token to show undefined

async game.modules.get('conditional-visibility').api.unforceToBeVisible(token:Token) ⇒ Promise.<void>

A method to unforce a token to be visibile for the CV checker, the cheker will work on effects anyway.

Returns: Promise.<void>

Param Type Description Default
token string The token to hide undefined

game.modules.get('conditional-visibility').api.hasConditionFromId(tokenNameOrId:string, conditionId:string):boolean{

A method to check if a source token can has a specific condition

Returns: boolean

Param Type Description Default
tokenNameOrId string The reference to the token undefined
conditionId string The id of the condition undefined

game.modules.get('conditional-visibility').api.hasCondition(token:Token, conditionId:string):boolean ⇒ boolean

A method to check if a source token can has a specific condition

Returns: boolean

Param Type Description Default
token string The source token undefined
conditionId string The id of the condition undefined

game.modules.get('conditional-visibility').api.hasAnyCondition(token:Token):boolean ⇒ boolean

A method to check if a source token can has a any condition

Returns: boolean

Param Type Description Default
token string The source token undefined

game.modules.get('conditional-visibility').api.canSee(sourceToken: Token, targetToken: Token) ⇒ boolean

A method to check if a source token can see a target token

Returns: boolean

Param Type Description Default
sourceToken string The source token undefined
targetToken string The target token undefined

game.modules.get('conditional-visibility').api.canSeeFromTokenIds(sourceTokenIdOrName: string, targetTokenIdOrName: string) ⇒ boolean

A method to check if a source token can see a target token

Returns: boolean

Param Type Description Default
sourceTokenIdOrName string The source token id or name (if founded) undefined
targetTokenIdOrName string The target token id or name (if founded) undefined

game.modules.get('conditional-visibility').api.canSeeWithData(sourceTokenIdOrName: string, targetTokenIdOrName: string) ⇒ CVResultData

A method to check if a source token can see a target token, with info

Returns: CVResultData

Param Type Description Default
sourceTokenIdOrName string The source token id or name (if founded) undefined
targetTokenIdOrName string The target token id or name (if founded) undefined

async game.modules.get('conditional-visibility').api.cleanUpTokenSelected() ⇒ Promise.<void>

Macro to clean up flags on token and actor

Examples:

game.modules.get('automated-polymorpher').api.cleanUpTokenSelected()

async game.modules.get('conditional-visibility').api.cleanUpToken(tokenId: string) ⇒ Promise.<void>

Macro to clean up flags on token and actor for specific

Examples:

game.modules.get('automated-polymorpher').api.cleanUpToken('asedtd')

[DEPRECATED] async game.modules.get('conditional-visibility').api.cleanUpTokenSelectedOnlyCVData() ⇒ Promise.<void>

Macro to clean up flags on token and actor, but limited only to CVDATA

Examples:

game.modules.get('automated-polymorpher').api.cleanUpTokenSelectedOnlyCVData()

Work in progress for add the others function, not sure if i'll find the time for this, but you can read directly the API class if you want API...

Models

Sense Data

This is the model used for register a custom sense or condition to the module

{
  id: string; // This is the unique id used for sync all the senses and conditions (please no strange character, no whitespace and all in lowercase...)
  name: string; // This is the unique name used for sync all the senses and conditions (here you cna put any dirty character you want)
  path: string; // [OPTIONAL] This is the path to the property you want to associate with this sense e.g. data.skills.prc.passive
  img: string; // [OPTIONAL] Image to associate to this sense
  conditionType:string // indicate the type of CV usually they are or 'sense' or 'condition' not both, **THIS IS ESSENTIAL  FOR USE SENSE AND CONDITION NOT REGISTERED ON THE MODULE IF NOT FOUNDED BY DEFAULT IS CONSIDERED A SENSE**, so now you can just modify the AE and you are not forced to call the registered macro of the module CV, this is very useful for integration with other modules.
  conditionElevation:boolean; // [OPTIONAL] if true will force to check the elevation between tokens source and target, VERY USEFUL IF YOU USE LEVELS
  conditionTargets: Array of string; // [OPTIONAL] This is used for explicitly tell to the checker what AE Condition can be see from this AE Sense based on the custom id used from this module (you can set this but is used only from a sense effect), check out the [TABLES](./tables.md) for details, **this is basically a override of the point 6. checker based on the indexes given to the sense
  conditionSources: Array of string: // [OPTIONAL] This is used for explicitly tell to the checker what AE Sense can be see from this AE Condition based on the custom id used from this module (you can set this but is used only from a condition effect), check out the [TABLES](./tables.md) for details, **this is basically a override of the point 6. checker based on the indexes given to the condition
  conditionDistance:number; // [OPTIONAL] set a maximum distance for check the sight/vision with this effect
  conditionBlinded:boolean; // [OPTIONAL] If true this effect / condition is applied on the token / actor it will be evaluated for the blinded check and only another effect with `ATCV.conditionBlindedOverride = true` will be able to avoid this check.
  conditionBlindedOverride:boolean; // [OPTIONAL] If true it indicates that this effect is able to work even with the "Blinded" condition applied to the token
  conditionTargetImage:string  // [OPTIONAL] string path to the image applied on target token and used from the source token (the one you click on) for replace the image token only for that player with a special sight, only if the CV check is true
  conditionSourceImage:string; // [OPTIONAL] string path to the image applied on target token and used from the target token (the one you try to see) for replace the image token only for that player with a special sight, only if the CV check is true
}

Effect

The effect object inspired from the Dfred convenient effects This is a example

{
    customId: string;
    name: string;
    description: string;
    icon: string;
    tint: string;
    seconds: number;
    rounds: number;
    turns: number;
    flags: {};
    changes: {};
    atlChanges: {};
    tokenMagicChanges: {};
    atcvChanges: {}; // THESE ARE THE NEW CONDITIONAL VISIBILITY CHANGES
}

Active Token Effect Conditiona Visibility Model or ATCV

{ visionId: string, // This is the unique id used for sync all the senses and conditions (please no strange character, no whitespace and all in lowercase...) visionName: string, // This is the unique name used for sync all the senses and conditions (here you cna put any dirty character you want) visionPath: string, // [OPTIONAL] This is the path to the property you want to associate with this sense e.g. data.skills.prc.passive visionIcon: string, // [OPTIONAL] Image to associate to this sense visionLevelValue:number // The numeric value of the sense/condition to check with others visionIsDisabled: boolean, // Boolean value for tell if the effect is disabled or not visionType:string, // indicate the type of CV usually they are or 'sense' or 'condition' not both, THIS IS ESSENTIAL FOR USE SENSE AND CONDITION NOT REGISTERED ON THE MODULE IF NOT FOUNDED BY DEFAULT IS CONSIDERED A SENSE, so now you can just modify the AE and you are not forced to call the registered macro of the module CV, this is very useful for integration with other modules. visionElevation:boolean, // [OPTIONAL] if true will force to check the elevation between tokens source and target, VERY USEFUL IF YOU USE LEVELS visionTargets: Array of string, // [OPTIONAL] This is used for explicitly tell to the checker what AE Condition can be see from this AE Sense based on the custom id used from this module (you can set this but is used only from a sense effect), check out the TABLES for details, **this is basically a override of the point 6. checker based on the indexes given to the sense visionSources: Array of string, // [OPTIONAL] This is used for explicitly tell to the checker what AE Sense can be see from this AE Condition based on the custom id used from this module (you can set this but is used only from a condition effect), check out the TABLES for details, **this is basically a override of the point 6. checker based on the indexes given to the condition visionDistance:number, // [OPTIONAL] set a maximum distance for check the sight/vision with this effect visionBlinded:boolean, // [OPTIONAL] If true this effect / condition is applied on the token / actor it will be evaluated for the blinded check and only another effect with ATCV.conditionBlindedOverride = true will be able to avoid this check. visionBlindedOverride:boolean, // [OPTIONAL] If true it indicates that this effect is able to work even with the "Blinded" condition applied to the token visionTargetImage:string, // [OPTIONAL] string path to the image applied on target token and used from the source token (the one you click on) for replace the image token only for that player with a special sight, only if the CV check is true visionSourceImage:string, // [OPTIONAL] string path to the image applied on target token and used from the target token (the one you try to see) for replace the image token only for that player with a special sight, only if the CV check is true }

CVResultData

{ sourceTokenId:string; targetTokenId:string; sourceVisionsLevels: AtcvEffect[]; targetVisionsLevels: AtcvEffect[]; canSee: boolean; }