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(actors): Default token settings #1655

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* XP spending now consistently uses a dollar sign to trigger spending instead of the various methods it previously used ([#1629](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1629))
* Settings have been refactored to be more organized and easier to navigate ([#1639](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1639))
* Destiny point flipping is now themed ([#1658](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1658)
* Set default token settings when creating new actor ([#1652](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1652)))
* Fixes:
* Includes species characteristics bonus when calculating characteristic upgrade cost ([#1638](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1638))
* Specializations: Talents are now correctly looked up in compendium ([#1642](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1642)))
Expand Down
4 changes: 3 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -761,5 +761,7 @@
"SWFFG.DragDrop.Title": "Purchase item, or grant for 0 xp?",
"SWFFG.DragDrop.PurchaseItem": "Purchase",
"SWFFG.DragDrop.GrantItem": "Grant",
"SWFFG.DragDrop.XPLog": "drag-and-drop"
"SWFFG.DragDrop.XPLog": "drag-and-drop",
"SWFFG.Settings.actor.RivalTokenPrepend.Name": "Prepend Adjective to rival tokens",
"SWFFG.Settings.actor.RivalTokenPrepend.Hint": "Unlinked rival's token name will be prepended with an Adjective by default. Example: \"Angry\""
}
39 changes: 39 additions & 0 deletions modules/actors/actor-ffg.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,45 @@ import ModifierHelpers from "../helpers/modifiers.js";
* @extends {Actor}
*/
export class ActorFFG extends Actor {

static async create(data, options) {
const createData = data;

// Only apply defaults for newly created actors
if (!typeof data.system === "undefined") {
return super.create(createData, options);
}

switch (createData.type) {
case "minion":
createData.prototypeToken = {
actorLink: false,
disposition: CONST.TOKEN_DISPOSITIONS.HOSTILE,
};
break;
case "character":
createData.prototypeToken = {
actorLink: true,
disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY,
};
break;
case "rival":
createData.prototypeToken = {
actorLink: false,
disposition: CONST.TOKEN_DISPOSITIONS.HOSTILE,
prependAdjective: game.settings.get("starwarsffg", "RivalTokenPrepend"),
};
break;
case "nemesis":
createData.prototypeToken = {
actorLink: true,
disposition: CONST.TOKEN_DISPOSITIONS.HOSTILE,
};
break;
}
return super.create(createData, options);
}

/**
* Augment the basic actor data with additional dynamic data.
*/
Expand Down
6 changes: 4 additions & 2 deletions modules/settings/settings-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,10 @@ export default class SettingsHelpers {
onChange: this.debouncedReload,
});

// auto-configure the default values of tokens - once
game.settings.register("starwarsffg", "token_configured", {
// Auto-configure some tokens settings on creation
game.settings.register("starwarsffg", "RivalTokenPrepend", {
name: game.i18n.localize("SWFFG.Settings.actor.RivalTokenPrepend.Name"),
hint: game.i18n.localize("SWFFG.Settings.actor.RivalTokenPrepend.Hint"),
scope: "world",
config: false,
default: false,
Expand Down
1 change: 1 addition & 0 deletions modules/settings/ui-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export class actorSettings extends ffgSettings {
"starwarsffg.maxSkill",
"starwarsffg.medItemName",
"starwarsffg.HealingItemAction",
"starwarsffg.RivalTokenPrepend",
];
return super.getData(includeSettingsNames);
}
Expand Down