Skip to content

Commit

Permalink
feat: add psionics (#23)
Browse files Browse the repository at this point in the history
* feat: add spionics

* fix: label

* fix: add plural for psi abilities label

* fix: stop process if roll aborted

* Update fvtt-token-action-hud-twodsix.min.js

* refactor: take advantage of item methods

don't duplicate code

* fix: update twodsix version
  • Loading branch information
marvin9257 authored Nov 8, 2024
1 parent bd31216 commit 73b03b7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"compatibility": [
{
"minimum": "4.20.0",
"verified": "5.10.0"
"verified": "5.11.0"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/action-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {

for (const [itemId, itemData] of this.items) {
let type = itemData.type
const equipped = (itemData.system.equipped === 'equipped' || ['skills', 'trait', 'spell'].includes(itemData.type))
const equipped = (itemData.system.equipped === 'equipped' || ['skills', 'trait', 'spell', 'psiAbility'].includes(itemData.type))

if (equipped || this.displayUnequipped) {
if (!equipped && !this.sortByType) {
Expand Down
2 changes: 2 additions & 0 deletions scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const GROUP = {
vehicle: { id: 'vehicle', name: 'TWODSIX.Actor.Items.LocationState.vehicle', type: 'system' },
skills: { id: 'skills', name: 'TYPES.Item.skillPl', type: 'system' },
spell: { id: 'spell', name: 'TYPES.Item.spellPl', type: 'system' },
psiAbility: { id: 'psiAbility', name: 'TYPES.Item.psiAbilityPl', type: 'system' },
weapons: { id: 'weapons', name: 'TYPES.Item.weaponPl', type: 'system' },
combat: { id: 'combat', name: 'tokenActionHud.combat', type: 'system' },
token: { id: 'token', name: 'tokenActionHud.token', type: 'system' },
Expand All @@ -67,6 +68,7 @@ export const ITEM_TYPE = {
base: { groupId: 'base' },
skills: { groupId: 'skills' },
spell: { groupId: 'spell' },
psiAbility: { groupId: 'psiAbility' },
treasure: { groupId: 'treasure' },
trait: { groupId: 'trait' },
tool: { groupId: 'equipment' },
Expand Down
8 changes: 8 additions & 0 deletions scripts/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
{ ...groups.trait, nestId: 'trait_trait' }
]
},
{
nestId: 'psiAbility',
id: 'psiAbility',
name: coreModule.api.Utils.i18n('TYPES.Item.psiAbilityPl'),
groups: [
{ ...groups.psiAbility, nestId: 'psiAbility_psiAbility' }
]
},
{
nestId: 'spell',
id: 'spell',
Expand Down
2 changes: 1 addition & 1 deletion scripts/fvtt-token-action-hud-twodsix.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions scripts/fvtt-token-action-hud-twodsix.min.js.map

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions scripts/roll-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,14 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {object} actor The actor
* @param {string} actionId The action id
*/
#handleItemAction (_event, actor, actionId) {
async #handleItemAction (_event, actor, actionId) {
const item = actor.items.get(actionId)
if (item.type === 'trait' || item.type === 'spell') {
const picture = item.img
const capType = item.type.capitalize()
const msg = `<div style="display: inline-flex;"><img src="${picture}" alt="" class="chat-image"></img><span style="align-self: center; text-align: center; padding-left: 1ch;"><strong>${capType}: ${item.name}</strong></span></div><br>${item.system.description}`
ChatMessage.create({ content: msg, speaker: ChatMessage.getSpeaker({ actor: this.actor }) })
if (item.type === 'trait') {
await item.sendDescriptionToChat(false)
} else if (item.type === 'weapon') {
item.resolveUnknownAutoMode()
} else {
item.skillRoll(true)
await item.doSkillTalentRoll(true)
}
}

Expand Down

0 comments on commit 73b03b7

Please sign in to comment.