forked from GitHub-Mirrors/foundry-sw5e
Spot the link / entityClass error!
This commit is contained in:
parent
441342b7e9
commit
de52576408
53 changed files with 6102 additions and 223 deletions
|
@ -82,7 +82,11 @@ export class ActorSheet5eCharacter extends ActorSheet5e {
|
|||
|
||||
|
||||
// Partition items by category
|
||||
<<<<<<< Updated upstream
|
||||
let [items, powers, feats, classes, species] = data.items.reduce((arr, item) => {
|
||||
=======
|
||||
let [items, powers, feats, classes, species, archetypes, classfeatures, backgrounds] = data.items.reduce((arr, item) => {
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
// Item details
|
||||
item.img = item.img || DEFAULT_TOKEN;
|
||||
|
@ -102,9 +106,18 @@ export class ActorSheet5eCharacter extends ActorSheet5e {
|
|||
else if ( item.type === "feat" ) arr[2].push(item);
|
||||
else if ( item.type === "class" ) arr[3].push(item);
|
||||
else if ( item.type === "species" ) arr[4].push(item);
|
||||
<<<<<<< Updated upstream
|
||||
else if ( Object.keys(inventory).includes(item.type ) ) arr[0].push(item);
|
||||
return arr;
|
||||
}, [[], [], [], [], []]);
|
||||
=======
|
||||
else if ( item.type === "archetype" ) arr[5].push(item);
|
||||
else if ( item.type === "classfeature" ) arr[6].push(item);
|
||||
else if ( item.type === "background" ) arr[7].push(item);
|
||||
else if ( Object.keys(inventory).includes(item.type ) ) arr[0].push(item);
|
||||
return arr;
|
||||
}, [[], [], [], [], [], [], [], []]);
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
// Apply active item filters
|
||||
items = this._filterItems(items, this._filters.inventory);
|
||||
|
@ -131,7 +144,14 @@ export class ActorSheet5eCharacter extends ActorSheet5e {
|
|||
// Organize Features
|
||||
const features = {
|
||||
classes: { label: "SW5E.ItemTypeClassPl", items: [], hasActions: false, dataset: {type: "class"}, isClass: true },
|
||||
<<<<<<< Updated upstream
|
||||
species: { label: "SW5E.ItemTypeSpecies", items: [], hasActions: false, dataset: {type: "species"}, isSpecies: true},
|
||||
=======
|
||||
classfeatures: { label: "SW5E.ItemTypeClassFeats", items: [], hasActions: false, dataset: {type: "classfeature"}, isClassfeature: true},
|
||||
archetype: { label: "SW5E.ItemTypeArchetype", items: [], hasActions: false, dataset: {type: "archetype"}, isArchetype: true },
|
||||
species: { label: "SW5E.ItemTypeSpecies", items: [], hasActions: false, dataset: {type: "species"}, isSpecies: true},
|
||||
background: { label: "SW5E.ItemTypeBackground", items: [], hasActions: false, dataset: {type: "background"}, isBackground: true},
|
||||
>>>>>>> Stashed changes
|
||||
active: { label: "SW5E.FeatureActive", items: [], hasActions: true, dataset: {type: "feat", "activation.type": "action"} },
|
||||
passive: { label: "SW5E.FeaturePassive", items: [], hasActions: false, dataset: {type: "feat"} }
|
||||
};
|
||||
|
@ -141,7 +161,14 @@ export class ActorSheet5eCharacter extends ActorSheet5e {
|
|||
}
|
||||
classes.sort((a, b) => b.levels - a.levels);
|
||||
features.classes.items = classes;
|
||||
<<<<<<< Updated upstream
|
||||
features.species.items = species;
|
||||
=======
|
||||
features.classfeatures.items = classfeatures;
|
||||
features.archetype.items = archetypes;
|
||||
features.species.items = species;
|
||||
features.background.items = backgrounds;
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
// Assign and return
|
||||
data.inventory = Object.values(inventory);
|
||||
|
|
102
module/apps/cast-dialog.js
Normal file
102
module/apps/cast-dialog.js
Normal file
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* A specialized Dialog subclass for casting a cast item at a certain level
|
||||
* @type {Dialog}
|
||||
*/
|
||||
export class CastDialog extends Dialog {
|
||||
constructor(actor, item, dialogData={}, options={}) {
|
||||
super(dialogData, options);
|
||||
this.options.classes = ["sw5e", "dialog"];
|
||||
|
||||
/**
|
||||
* Store a reference to the Actor entity which is casting the cast
|
||||
* @type {Actor5e}
|
||||
*/
|
||||
this.actor = actor;
|
||||
|
||||
/**
|
||||
* Store a reference to the Item entity which is the cast being cast
|
||||
* @type {Item5e}
|
||||
*/
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Rendering */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* A constructor function which displays the Cast Cast Dialog app for a given Actor and Item.
|
||||
* Returns a Promise which resolves to the dialog FormData once the workflow has been completed.
|
||||
* @param {Actor5e} actor
|
||||
* @param {Item5e} item
|
||||
* @return {Promise}
|
||||
*/
|
||||
static async create(actor, item) {
|
||||
const ad = actor.data.data;
|
||||
const id = item.data.data;
|
||||
|
||||
// Determine whether the cast may be upcast
|
||||
const lvl = id.level;
|
||||
const canUpcast = (lvl > 0) && CONFIG.SW5E.castUpcastModes.includes(id.preparation.mode);
|
||||
|
||||
// Determine the levels which are feasible
|
||||
let lmax = 0;
|
||||
const castLevels = Array.fromRange(10).reduce((arr, i) => {
|
||||
if ( i < lvl ) return arr;
|
||||
const l = ad.casts["cast"+i] || {max: 0, override: null};
|
||||
let max = parseInt(l.override || l.max || 0);
|
||||
let slots = Math.clamped(parseInt(l.value || 0), 0, max);
|
||||
if ( max > 0 ) lmax = i;
|
||||
arr.push({
|
||||
level: i,
|
||||
label: i > 0 ? `${CONFIG.SW5E.castLevels[i]} (${slots} Slots)` : CONFIG.SW5E.castLevels[i],
|
||||
canCast: canUpcast && (max > 0),
|
||||
hasSlots: slots > 0
|
||||
});
|
||||
return arr;
|
||||
}, []).filter(sl => sl.level <= lmax);
|
||||
|
||||
const pact = ad.casts.pact;
|
||||
if (pact.level >= lvl) {
|
||||
// If this character has pact slots, present them as an option for
|
||||
// casting the cast.
|
||||
castLevels.push({
|
||||
level: 'pact',
|
||||
label: game.i18n.localize('SW5E.CastLevelPact')
|
||||
+ ` (${game.i18n.localize('SW5E.Level')} ${pact.level}) `
|
||||
+ `(${pact.value} ${game.i18n.localize('SW5E.Slots')})`,
|
||||
canCast: canUpcast,
|
||||
hasSlots: pact.value > 0
|
||||
});
|
||||
}
|
||||
|
||||
const canCast = castLevels.some(l => l.hasSlots);
|
||||
|
||||
// Render the Cast casting template
|
||||
const html = await renderTemplate("systems/sw5e/templates/apps/cast-cast.html", {
|
||||
item: item.data,
|
||||
canCast: canCast,
|
||||
canUpcast: canUpcast,
|
||||
castLevels,
|
||||
hasPlaceableTemplate: game.user.can("TEMPLATE_CREATE") && item.hasAreaTarget
|
||||
});
|
||||
|
||||
// Create the Dialog and return as a Promise
|
||||
return new Promise((resolve, reject) => {
|
||||
const dlg = new this(actor, item, {
|
||||
title: `${item.name}: Cast Configuration`,
|
||||
content: html,
|
||||
buttons: {
|
||||
cast: {
|
||||
icon: '<i class="fas fa-magic"></i>',
|
||||
label: "Cast",
|
||||
callback: html => resolve(new FormData(html[0].querySelector("#cast-config-form")))
|
||||
}
|
||||
},
|
||||
default: "cast",
|
||||
close: reject
|
||||
});
|
||||
dlg.render(true);
|
||||
});
|
||||
}
|
||||
}
|
102
module/apps/spell-cast-dialog.js
Normal file
102
module/apps/spell-cast-dialog.js
Normal file
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* A specialized Dialog subclass for casting a spell item at a certain level
|
||||
* @type {Dialog}
|
||||
*/
|
||||
export class SpellCastDialog extends Dialog {
|
||||
constructor(actor, item, dialogData={}, options={}) {
|
||||
super(dialogData, options);
|
||||
this.options.classes = ["dnd5e", "dialog"];
|
||||
|
||||
/**
|
||||
* Store a reference to the Actor entity which is casting the spell
|
||||
* @type {Actor5e}
|
||||
*/
|
||||
this.actor = actor;
|
||||
|
||||
/**
|
||||
* Store a reference to the Item entity which is the spell being cast
|
||||
* @type {Item5e}
|
||||
*/
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Rendering */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* A constructor function which displays the Spell Cast Dialog app for a given Actor and Item.
|
||||
* Returns a Promise which resolves to the dialog FormData once the workflow has been completed.
|
||||
* @param {Actor5e} actor
|
||||
* @param {Item5e} item
|
||||
* @return {Promise}
|
||||
*/
|
||||
static async create(actor, item) {
|
||||
const ad = actor.data.data;
|
||||
const id = item.data.data;
|
||||
|
||||
// Determine whether the spell may be upcast
|
||||
const lvl = id.level;
|
||||
const canUpcast = (lvl > 0) && CONFIG.DND5E.spellUpcastModes.includes(id.preparation.mode);
|
||||
|
||||
// Determine the levels which are feasible
|
||||
let lmax = 0;
|
||||
const spellLevels = Array.fromRange(10).reduce((arr, i) => {
|
||||
if ( i < lvl ) return arr;
|
||||
const l = ad.spells["spell"+i] || {max: 0, override: null};
|
||||
let max = parseInt(l.override || l.max || 0);
|
||||
let slots = Math.clamped(parseInt(l.value || 0), 0, max);
|
||||
if ( max > 0 ) lmax = i;
|
||||
arr.push({
|
||||
level: i,
|
||||
label: i > 0 ? `${CONFIG.DND5E.spellLevels[i]} (${slots} Slots)` : CONFIG.DND5E.spellLevels[i],
|
||||
canCast: canUpcast && (max > 0),
|
||||
hasSlots: slots > 0
|
||||
});
|
||||
return arr;
|
||||
}, []).filter(sl => sl.level <= lmax);
|
||||
|
||||
const pact = ad.spells.pact;
|
||||
if (pact.level >= lvl) {
|
||||
// If this character has pact slots, present them as an option for
|
||||
// casting the spell.
|
||||
spellLevels.push({
|
||||
level: 'pact',
|
||||
label: game.i18n.localize('DND5E.SpellLevelPact')
|
||||
+ ` (${game.i18n.localize('DND5E.Level')} ${pact.level}) `
|
||||
+ `(${pact.value} ${game.i18n.localize('DND5E.Slots')})`,
|
||||
canCast: canUpcast,
|
||||
hasSlots: pact.value > 0
|
||||
});
|
||||
}
|
||||
|
||||
const canCast = spellLevels.some(l => l.hasSlots);
|
||||
|
||||
// Render the Spell casting template
|
||||
const html = await renderTemplate("systems/dnd5e/templates/apps/spell-cast.html", {
|
||||
item: item.data,
|
||||
canCast: canCast,
|
||||
canUpcast: canUpcast,
|
||||
spellLevels,
|
||||
hasPlaceableTemplate: game.user.can("TEMPLATE_CREATE") && item.hasAreaTarget
|
||||
});
|
||||
|
||||
// Create the Dialog and return as a Promise
|
||||
return new Promise((resolve, reject) => {
|
||||
const dlg = new this(actor, item, {
|
||||
title: `${item.name}: Spell Configuration`,
|
||||
content: html,
|
||||
buttons: {
|
||||
cast: {
|
||||
icon: '<i class="fas fa-magic"></i>',
|
||||
label: "Cast",
|
||||
callback: html => resolve(new FormData(html[0].querySelector("#spell-config-form")))
|
||||
}
|
||||
},
|
||||
default: "cast",
|
||||
close: reject
|
||||
});
|
||||
dlg.render(true);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -630,11 +630,17 @@ SW5E.languages = {
|
|||
"antarian": "SW5E.LanguagesAntarian",
|
||||
"anzellan": "SW5E.LanguagesAnzellan",
|
||||
"aqualish": "SW5E.LanguagesAqualish",
|
||||
"arconese": "SW5E.LanguagesArconese",
|
||||
"ardennian": "SW5E.LanguagesArdennian",
|
||||
"arkanian": "SW5E.LanguagesArkanian",
|
||||
"balosur": "SW5E.LanguagesBalosur",
|
||||
"barabel": "SW5E.LanguagesBarabel",
|
||||
"basic": "SW5E.LanguagesBasic",
|
||||
<<<<<<< Updated upstream
|
||||
"besalisk": "SW5E.LanguagesBesalisk",
|
||||
=======
|
||||
"besalisk": "SW5E.LanguagesBesalisk",
|
||||
>>>>>>> Stashed changes
|
||||
"binary": "SW5E.LanguagesBinary",
|
||||
"bith": "SW5E.LanguagesBith",
|
||||
"bocce": "SW5E.LanguagesBocce",
|
||||
|
@ -686,6 +692,7 @@ SW5E.languages = {
|
|||
"lannik": "SW5E.LanguagesLannik",
|
||||
"lasat": "SW5E.LanguagesLasat",
|
||||
"lowickese": "SW5E.LanguagesLowickese",
|
||||
"lurmese": "SW5E.LanguagesLurmese",
|
||||
"mandoa": "SW5E.LanguagesMandoa",
|
||||
"miralukese": "SW5E.LanguagesMiralukese",
|
||||
"mirialan": "SW5E.LanguagesMirialan",
|
||||
|
@ -701,6 +708,7 @@ SW5E.languages = {
|
|||
"rattataki": "SW5E.LanguagesRattataki",
|
||||
"rishii": "SW5E.LanguagesRishii",
|
||||
"rodese": "SW5E.LanguagesRodese",
|
||||
"ryn": "SW5E.LanguagesRyn",
|
||||
"selkatha": "SW5E.LanguagesSelkatha",
|
||||
"semblan": "SW5E.LanguagesSemblan",
|
||||
"shistavanen": "SW5E.LanguagesShistavanen",
|
||||
|
@ -711,6 +719,7 @@ SW5E.languages = {
|
|||
"ssi-ruuvi": "SW5E.LanguagesSsi-ruuvi",
|
||||
"sullustese": "SW5E.LanguagesSullustese",
|
||||
"talzzi": "SW5E.LanguagesTalzzi",
|
||||
"tarasinese": "SW5E.LanguagesTarasinese",
|
||||
"thisspiasian": "SW5E.LanguagesThisspiasian",
|
||||
"togorese": "SW5E.LanguagesTogorese",
|
||||
"togruti": "SW5E.LanguagesTogruti",
|
||||
|
|
|
@ -162,7 +162,23 @@ export class Item5e extends Item {
|
|||
|
||||
// Species Items
|
||||
else if ( itemData.type === "species" ) {
|
||||
<<<<<<< Updated upstream
|
||||
labels.species = C.species[data.species];
|
||||
=======
|
||||
// labels.species = C.species[data.species];
|
||||
}
|
||||
// Archetype Items
|
||||
else if ( itemData.type === "archetype" ) {
|
||||
// labels.archetype = C.archetype[data.archetype];
|
||||
}
|
||||
// Background Items
|
||||
else if ( itemData.type === "background" ) {
|
||||
|
||||
}
|
||||
// Class Feature Items
|
||||
else if ( itemData.type === "classfeature" ) {
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
// Equipment Items
|
||||
|
|
|
@ -106,9 +106,24 @@ export class ItemSheet5e extends ItemSheet {
|
|||
}
|
||||
|
||||
else if ( item.type === "species" ) {
|
||||
|
||||
|
||||
}
|
||||
<<<<<<< Updated upstream
|
||||
|
||||
=======
|
||||
else if ( item.type === "archetype" ) {
|
||||
|
||||
}
|
||||
|
||||
else if ( item.type === "background" ) {
|
||||
|
||||
}
|
||||
|
||||
else if ( item.type === "classfeature" ) {
|
||||
|
||||
}
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
// Action type
|
||||
if ( item.data.actionType ) {
|
||||
props.push(CONFIG.SW5E.itemActionTypes[item.data.actionType]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue