Skip to content

Commit

Permalink
feat(actors): Default token settings
Browse files Browse the repository at this point in the history
  • Loading branch information
obrenckle committed Aug 10, 2024
1 parent b0017d4 commit 2f2e3d1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
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
8 changes: 5 additions & 3 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 Expand Up @@ -377,7 +379,7 @@ export default class SettingsHelpers {
config: false,
type: String,
choices: stimpackChoices,
});
});
}

static debouncedReload = foundry.utils.debounce(() => window.location.reload(), 100);
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

0 comments on commit 2f2e3d1

Please sign in to comment.