Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for powers (e.g. surges) and path skills #124

Merged
merged 17 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
c5bd73e
feat: add Goal & Power item documents and add support for linked skil…
stanavdb Oct 28, 2024
b3e3f84
feat(talents): add grant rules to be executed upon obtaining the talent
stanavdb Oct 30, 2024
3ab2699
chore: make grant rules deletable
stanavdb Oct 30, 2024
3da0398
feat(talents): add functionality to execute grant rules for talents
stanavdb Oct 30, 2024
a2bc021
chore(goal): refactor goal onCompletion.grants to rewards
stanavdb Oct 30, 2024
3f4166d
feat(goals): implement automatic reward granting upon goal completion
stanavdb Oct 30, 2024
414669a
feat(actor): add unlocked field to non-core skills
stanavdb Oct 30, 2024
91dd0fc
feat(character sheet): Show path linked skills beside the path
stanavdb Oct 30, 2024
3998df1
feat(character sheet): add power type sections to actions list
stanavdb Oct 30, 2024
11061d5
fix(multi value select component): fix issue causing selected values …
stanavdb Oct 30, 2024
edd85a3
fix(item rewards): fix issue causing item goal rewards to grant id-ed…
stanavdb Oct 31, 2024
41c0ed6
fix(talents & goals): fix issue causing a duplicate goal to be added …
stanavdb Oct 31, 2024
ae2fb18
feat(powers): make it so by default powers use the skill matching the…
stanavdb Oct 31, 2024
54dba85
feat(actor): add check to block adding a power whose id matches a pow…
stanavdb Oct 31, 2024
789fb03
Merge branch 'release-0.1.2' into feat/path-skills-88
stanavdb Oct 31, 2024
d092b32
feat(powers): change none power type label and make untyped powers sh…
stanavdb Oct 31, 2024
32b728f
Merge branch 'release-0.1.2' into feat/path-skills-88
stanavdb Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default tseslint.config(
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-unexpected-multiline': 'off',
},
languageOptions: {
parserOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ declare function _ClientDocumentMixin<
>(base: BaseClass): Mixin<BaseClass, typeof ClientDocument>;

declare class ClientDocument {
readonly uuid: string;

/**
* A collection of Application instances which should be re-rendered whenever this document is updated.
* The keys of this object are the application ids and the values are Application instances. Each
Expand Down
18 changes: 9 additions & 9 deletions src/declarations/foundry/client/data/documents/actor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ declare class Actor<
/**
* Handle how changes to a Token attribute bar are applied to the Actor.
* This allows for game systems to override this behavior and deploy special logic.
* @param {string} attribute The attribute path
* @param {number} value The target attribute value
* @param {boolean} isDelta Whether the number represents a relative change (true) or an absolute change (false)
* @param {boolean} isBar Whether the new value is part of an attribute bar, or just a direct value
* @returns {Promise<documents.Actor>} The updated Actor document
* @param attribute The attribute path
* @param value The target attribute value
* @param isDelta Whether the number represents a relative change (true) or an absolute change (false)
* @param isBar Whether the new value is part of an attribute bar, or just a direct value
* @returns The updated Actor document
*/
public async modifyTokenAttribute(
attribute,
value,
isDelta,
isBar,
attribute: string,
value: number,
isDelta: boolean,
isBar: boolean,
): Promise<Actor | undefined>;
}
33 changes: 31 additions & 2 deletions src/declarations/foundry/common/abstract/data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,35 @@ namespace foundry {
operation: DatabaseCreateOperation,
user: documents.BaseUser,
): Promise<void>;

/* --- Database Update Operations --- */

/**
* Pre-process an update operation for a single Document instance. Pre-operation events only occur for the client
* which requested the operation.
*
* @param changes The candidate changes to the Document
* @param options Additional options which modify the update request
* @param user The User requesting the document update
* @returns A return value of false indicates the update operation should be cancelled.
* @internal
*/
async _preUpdate(
changes: object,
options: object,
user: documents.BaseUser,
): Promise<boolean | void>;

/**
* Post-process an update operation for a single Document instance. Post-operation events occur for all connected
* clients.
*
* @param changed The differential data that was changed relative to the documents prior values
* @param options Additional options which modify the update request
* @param userId The id of the User requesting the document update
* @internal
*/
_onUpdate(changed: object, options: object, userId: string);
}

interface DataValidationOptions {
Expand Down Expand Up @@ -755,7 +784,7 @@ namespace foundry {
* @param options Options provided to the model constructor
* @returns Migrated and cleaned source data which will be stored to the model instance
*/
_initializeSource(
protected _initializeSource(
data: object | DataModel,
options?: object,
): object;
Expand All @@ -773,7 +802,7 @@ namespace foundry {
* This mirrors the workflow of SchemaField#initialize but with some added functionality.
* @param options Options provided to the model constructor
*/
_initialize(options?: object);
protected _initialize(options?: object);

/**
* Reset the state of this data instance back to mirror the contained source data, erasing any changes.
Expand Down
14 changes: 14 additions & 0 deletions src/declarations/foundry/common/abstract/fields.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,26 @@ declare namespace foundry {
*/
initialize(value: any, model: object, options?: object): any;

/**
* Export the current value of the field into a serializable object.
* @param value The initialized value of the field
* @returns An exported representation of the field
*/
toObject(value: any): any;

/**
* Recursively traverse a schema and retrieve a field specification by a given path
* @param path The field path as an array of strings
* @internal
*/
_getField(path: string[]): DataField;

/**
* Cast a non-default value to ensure it is the correct type for the field
* @param value The provided non-default value
* @returns The standardized value
*/
protected _cast(value: any): any;
}

class SchemaField extends DataField {
Expand Down
85 changes: 85 additions & 0 deletions src/declarations/foundry/common/abstract/validation.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,91 @@
declare namespace foundry {
namespace data {
namespace validation {
namespace DataModelValidationFailure {
interface Config {
/**
* The value that failed validation for this field.
*/
invalidValue?: any;

/**
* The value it was replaced by, if any.
*/
fallback?: any;

/**
* Whether the value was dropped from some parent collection.
* @default true
*/
dropped?: boolean;

/**
* The validation error message.
*/
message?: string;

/**
* Whether this failure was unresolved
* @default false
*/
unresolved?: boolean;
}

interface ElementValidationFailure {
/**
* Either the element's index or some other identifier for it.
*/
id: string | number;

/**
* Optionally a user-friendly name for the element.
*/
name?: string;

/**
* The element's validation failure.
*/
failure: DataModelValidationFailure;
}
}

class DataModelValidationFailure {
/**
* The value that failed validation for this field.
*/
public invalidValue?: any;

/**
* The value it was replaced by, if any.
*/
public fallback?: any;

/**
* Whether the value was dropped from some parent collection.
* @defaultValue true
*/
public dropped?: boolean;

/**
* The validation error message.
*/
public message?: string;

/**
* If this field contains other fields that are validated
* as part of its validation, their results are recorded here.
*/
public fields: Record<string, DataModelValidationFailure>;

/**
* If this field contains a list of elements that are validated
* as part of its validation, their results are recorded here.
*/
public elements: ElementValidationFailure[];

constructor(config?: DataModelValidationFailure.Config);
}

class DataModelValidationError extends Error {
constructor(errors: Record<string, any>);
}
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Hooks.once('init', async () => {
registerItemSheet(ItemType.Talent, applications.item.TalentItemSheet);
registerItemSheet(ItemType.Equipment, applications.item.EquipmentItemSheet);
registerItemSheet(ItemType.Weapon, applications.item.WeaponItemSheet);
registerItemSheet(ItemType.Goal, applications.item.GoalItemSheet);
registerItemSheet(ItemType.Power, applications.item.PowerItemSheet);

CONFIG.Dice.types.push(dice.PlotDie);
CONFIG.Dice.terms.p = dice.PlotDie;
Expand Down
Loading