forked from foundryvtt/dnd5e
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request foundryvtt#3935 from foundryvtt/activity/enchant
[foundryvtt#3914] Add `EnchantActivity` data and sheet
- Loading branch information
Showing
26 changed files
with
431 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import ActivitySheet from "./activity-sheet.mjs"; | ||
|
||
/** | ||
* Sheet for the enchant activity. | ||
*/ | ||
export default class EnchantSheet extends ActivitySheet { | ||
|
||
/** @inheritDoc */ | ||
static DEFAULT_OPTIONS = { | ||
classes: ["enchant-activity"] | ||
}; | ||
|
||
/* -------------------------------------------- */ | ||
|
||
/** @inheritDoc */ | ||
static PARTS = { | ||
...super.PARTS, | ||
effect: { | ||
template: "systems/dnd5e/templates/activity/enchant-effect.hbs", | ||
templates: [ | ||
"systems/dnd5e/templates/activity/parts/enchant-enchantments.hbs", | ||
"systems/dnd5e/templates/activity/parts/enchant-restrictions.hbs" | ||
] | ||
} | ||
}; | ||
|
||
/* -------------------------------------------- */ | ||
|
||
/** @override */ | ||
tabGroups = { | ||
sheet: "identity", | ||
activation: "time", | ||
effect: "enchantments" | ||
}; | ||
|
||
/* -------------------------------------------- */ | ||
/* Rendering */ | ||
/* -------------------------------------------- */ | ||
|
||
/** @override */ | ||
_prepareAppliedEffectContext(context, effect) { | ||
effect.effectOptions = context.allEffects.map(e => ({ | ||
...e, selected: effect.data.riders.effect.has(e.value) | ||
})); | ||
return effect; | ||
} | ||
|
||
/* -------------------------------------------- */ | ||
|
||
/** @inheritDoc */ | ||
async _prepareEffectContext(context) { | ||
context = await super._prepareEffectContext(context); | ||
|
||
const appliedEnchantments = new Set(context.activity.effects?.map(e => e._id) ?? []); | ||
context.allEnchantments = this.item.effects | ||
.filter(e => e.type === "enchantment") | ||
.map(effect => ({ | ||
value: effect.id, label: effect.name, selected: appliedEnchantments.has(effect.id) | ||
})); | ||
const enchantableTypes = this.activity.enchantableTypes; | ||
context.typeOptions = [ | ||
{ value: "", label: game.i18n.localize("DND5E.ENCHANT.FIELDS.restrictions.type.Any") }, | ||
...Object.keys(CONFIG.Item.dataModels) | ||
.filter(t => enchantableTypes.has(t)) | ||
.map(value => ({ value, label: game.i18n.localize(CONFIG.Item.typeLabels[value]) })) | ||
]; | ||
|
||
return context; | ||
} | ||
|
||
/* -------------------------------------------- */ | ||
|
||
/** @inheritDoc */ | ||
_getTabs() { | ||
const tabs = super._getTabs(); | ||
tabs.effect.label = "DND5E.ENCHANT.SECTIONS.Enchanting"; | ||
tabs.effect.icon = "fa-solid fa-wand-sparkles"; | ||
tabs.effect.tabs = this._markTabs({ | ||
enchantments: { | ||
id: "enchantments", group: "effect", icon: "fa-solid fa-star", | ||
label: "DND5E.ENCHANT.SECTIONS.Enchantments" | ||
}, | ||
restrictions: { | ||
id: "restrictions", group: "effect", icon: "fa-solid fa-ban", | ||
label: "DND5E.ENCHANT.SECTIONS.Restrictions" | ||
} | ||
}); | ||
return tabs; | ||
} | ||
|
||
/* -------------------------------------------- */ | ||
/* Event Listeners and Handlers */ | ||
/* -------------------------------------------- */ | ||
|
||
/** @override */ | ||
_addEffectData() { | ||
return { | ||
type: "enchantment", | ||
name: this.item.name, | ||
img: this.item.img, | ||
disabled: true | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.