mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Cleanup of 'pc' references
This commit is contained in:
parent
1f50e9533a
commit
1445baa556
14 changed files with 38 additions and 117 deletions
|
|
@ -40,7 +40,7 @@ Hooks.once('init', () => {
|
|||
CONFIG.Item.dataModels = models.items.config;
|
||||
|
||||
const { Items, Actors } = foundry.documents.collections;
|
||||
Items.unregisterSheet('core', foundry.appv1.sheets.ItemSheet);
|
||||
Items.unregisterSheet('core', foundry.applications.sheets.ItemSheetV2);
|
||||
Items.registerSheet(SYSTEM.id, applications.DhpAncestry, { types: ['ancestry'], makeDefault: true });
|
||||
Items.registerSheet(SYSTEM.id, applications.DhpCommunity, { types: ['community'], makeDefault: true });
|
||||
Items.registerSheet(SYSTEM.id, applications.DhpClassSheet, { types: ['class'], makeDefault: true });
|
||||
|
|
@ -54,12 +54,12 @@ Hooks.once('init', () => {
|
|||
|
||||
CONFIG.Actor.documentClass = documents.DhpActor;
|
||||
CONFIG.Actor.dataModels = {
|
||||
pc: models.DhCharacter,
|
||||
character: models.DhCharacter,
|
||||
adversary: models.DhpAdversary,
|
||||
environment: models.DhpEnvironment
|
||||
};
|
||||
Actors.unregisterSheet('core', foundry.appv1.sheets.ActorSheet);
|
||||
Actors.registerSheet(SYSTEM.id, applications.DhCharacterSheet, { types: ['pc'], makeDefault: true });
|
||||
Actors.unregisterSheet('core', foundry.applications.sheets.ActorSheetV2);
|
||||
Actors.registerSheet(SYSTEM.id, applications.DhCharacterSheet, { types: ['character'], makeDefault: true });
|
||||
Actors.registerSheet(SYSTEM.id, applications.DhpAdversarySheet, { types: ['adversary'], makeDefault: true });
|
||||
Actors.registerSheet(SYSTEM.id, applications.DhpEnvironment, { types: ['environment'], makeDefault: true });
|
||||
|
||||
|
|
@ -275,10 +275,10 @@ const preloadHandlebarsTemplates = async function () {
|
|||
'systems/daggerheart/templates/sheets/parts/heritage.hbs',
|
||||
'systems/daggerheart/templates/sheets/parts/subclassFeature.hbs',
|
||||
'systems/daggerheart/templates/sheets/parts/effects.hbs',
|
||||
'systems/daggerheart/templates/sheets/pc/sections/inventory.hbs',
|
||||
'systems/daggerheart/templates/sheets/pc/sections/loadout.hbs',
|
||||
'systems/daggerheart/templates/sheets/pc/parts/heritageCard.hbs',
|
||||
'systems/daggerheart/templates/sheets/pc/parts/advancementCard.hbs',
|
||||
'systems/daggerheart/templates/sheets/character/sections/inventory.hbs',
|
||||
'systems/daggerheart/templates/sheets/character/sections/loadout.hbs',
|
||||
'systems/daggerheart/templates/sheets/character/parts/heritageCard.hbs',
|
||||
'systems/daggerheart/templates/sheets/character/parts/advancementCard.hbs',
|
||||
'systems/daggerheart/templates/components/card-preview.hbs',
|
||||
'systems/daggerheart/templates/views/levelup/parts/selectable-card-preview.hbs',
|
||||
'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs',
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
"armor": "Armor"
|
||||
},
|
||||
"Actor": {
|
||||
"pc": "PC",
|
||||
"character": "Character",
|
||||
"npc": "NPC",
|
||||
"adversary": "Adversary",
|
||||
"environment": "Environment"
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
|
||||
static PARTS = {
|
||||
form: {
|
||||
id: 'pc',
|
||||
template: 'systems/daggerheart/templates/sheets/pc/pc.hbs'
|
||||
id: 'character',
|
||||
template: 'systems/daggerheart/templates/sheets/character/character.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -675,26 +675,6 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
}
|
||||
|
||||
async _onDragStart(_, event) {
|
||||
if (event.currentTarget.classList.contains('inventory-item')) {
|
||||
if (!['weapon', 'armor'].includes(event.currentTarget.dataset.type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const targets = {
|
||||
weapon: ['weapon-section', 'inventory-weapon-section'],
|
||||
armor: ['armor-section', 'inventory-armor-section']
|
||||
};
|
||||
|
||||
event.dataTransfer.setData(
|
||||
'text/plain',
|
||||
JSON.stringify({
|
||||
uuid: event.currentTarget.dataset.item,
|
||||
internal: true,
|
||||
targets: targets[event.currentTarget.dataset.type]
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
super._onDragStart(event);
|
||||
}
|
||||
|
||||
|
|
@ -704,76 +684,17 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
}
|
||||
|
||||
async _onDropItem(event, data) {
|
||||
const element = event.currentTarget;
|
||||
const item = await Item.implementation.fromDropData(data);
|
||||
const itemData = item.toObject();
|
||||
|
||||
const createdItems = [];
|
||||
|
||||
if (item.type === 'domainCard') {
|
||||
if (this.document.system.domainCards.loadout.length >= 5) {
|
||||
itemData.system.inVault = true;
|
||||
}
|
||||
|
||||
if (this.document.uuid === item.parent?.uuid) return this._onSortItem(event, itemData);
|
||||
const createdItem = await this._onDropItemCreate(itemData);
|
||||
|
||||
return createdItem;
|
||||
} else {
|
||||
if (item.type === 'ancestry') {
|
||||
for (var feature of this.document.items.filter(
|
||||
x => x.type === 'feature' && x.system.type === SYSTEM.ITEM.featureTypes.ancestry.id
|
||||
)) {
|
||||
await feature.delete();
|
||||
}
|
||||
|
||||
for (var feature of item.system.abilities) {
|
||||
const data = (await fromUuid(feature.uuid)).toObject();
|
||||
const itemData = await this._onDropItemCreate(data);
|
||||
createdItems.push(itemData);
|
||||
}
|
||||
} else if (item.type === 'community') {
|
||||
for (var feature of this.document.items.filter(
|
||||
x => x.type === 'feature' && x.system.type === SYSTEM.ITEM.featureTypes.community.id
|
||||
)) {
|
||||
await feature.delete();
|
||||
}
|
||||
|
||||
for (var feature of item.system.abilities) {
|
||||
const data = (await fromUuid(feature.uuid)).toObject();
|
||||
const itemData = await this._onDropItemCreate(data);
|
||||
createdItems.push(itemData);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.document.uuid === item.parent?.uuid) return this._onSortItem(event, item);
|
||||
|
||||
if (item.type === 'weapon') {
|
||||
if (!element) return;
|
||||
|
||||
if (element.classList.contains('weapon-section')) {
|
||||
await this.document.system.constructor.unequipBeforeEquip.bind(this.document.system)(itemData);
|
||||
itemData.system.equipped = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.type === 'armor') {
|
||||
if (!element) return;
|
||||
|
||||
if (element.classList.contains('armor-section')) {
|
||||
const existing = this.document.system.armor
|
||||
? await fromUuid(this.document.system.armor.uuid)
|
||||
: null;
|
||||
await existing?.update({ 'system.equipped': false });
|
||||
itemData.system.equipped = true;
|
||||
}
|
||||
}
|
||||
|
||||
const createdItem = await this._onDropItemCreate(itemData);
|
||||
createdItems.push(createdItem);
|
||||
|
||||
return createdItems;
|
||||
if (item.type === 'domainCard' && this.document.system.domainCards.loadout.length >= 5) {
|
||||
itemData.system.inVault = true;
|
||||
}
|
||||
|
||||
if (this.document.uuid === item.parent?.uuid) return this._onSortItem(event, itemData);
|
||||
const createdItem = await this._onDropItemCreate(itemData);
|
||||
|
||||
return createdItem;
|
||||
}
|
||||
|
||||
async _onDropItemCreate(itemData, event) {
|
||||
|
|
|
|||
|
|
@ -198,8 +198,8 @@ export const tiers = {
|
|||
};
|
||||
|
||||
export const objectTypes = {
|
||||
pc: {
|
||||
name: 'TYPES.Actor.pc'
|
||||
character: {
|
||||
name: 'TYPES.Actor.character'
|
||||
},
|
||||
npc: {
|
||||
name: 'TYPES.Actor.npc'
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export default class DHClass extends BaseDataItem {
|
|||
const allowed = await super._preCreate(data, options, user);
|
||||
if (allowed === false) return;
|
||||
|
||||
if (this.actor?.type === 'pc') {
|
||||
if (this.actor?.type === 'character') {
|
||||
const path = data.system.isMulticlass ? 'system.multiclass.value' : 'system.class.value';
|
||||
if (foundry.utils.getProperty(this.actor, path)) {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.Item.Errors.ClassAlreadySelected'));
|
||||
|
|
@ -67,7 +67,7 @@ export default class DHClass extends BaseDataItem {
|
|||
|
||||
_onCreate(data, options, userId) {
|
||||
super._onCreate(data, options, userId);
|
||||
if (options.parent?.type === 'pc') {
|
||||
if (options.parent?.type === 'character') {
|
||||
const path = `system.${data.system.isMulticlass ? 'multiclass.value' : 'class.value'}`;
|
||||
options.parent.update({ [path]: `${options.parent.uuid}.Item.${data._id}` });
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ export default class DHClass extends BaseDataItem {
|
|||
_onDelete(options, userId) {
|
||||
super._onDelete(options, userId);
|
||||
|
||||
if (options.parent?.type === 'pc') {
|
||||
if (options.parent?.type === 'character') {
|
||||
const path = `system.${this.isMulticlass ? 'multiclass' : 'class'}`;
|
||||
options.parent.update({
|
||||
[`${path}.value`]: null
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export default class DHDomainCard extends BaseDataItem {
|
|||
const allowed = await super._preCreate(data, options, user);
|
||||
if (allowed === false) return;
|
||||
|
||||
if (this.actor?.type === 'pc') {
|
||||
if (this.actor?.type === 'character') {
|
||||
if (!this.actor.system.class.value) {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.Item.Errors.NoClassSelected'));
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export default class DHSubclass extends BaseDataItem {
|
|||
const allowed = await super._preCreate(data, options, user);
|
||||
if (allowed === false) return;
|
||||
|
||||
if (this.actor?.type === 'pc') {
|
||||
if (this.actor?.type === 'character') {
|
||||
const path = data.system.isMulticlass ? 'system.multiclass' : 'system.class';
|
||||
const classData = foundry.utils.getProperty(this.actor, path);
|
||||
if (!classData.value) {
|
||||
|
|
@ -52,7 +52,7 @@ export default class DHSubclass extends BaseDataItem {
|
|||
_onCreate(data, options, userId) {
|
||||
super._onCreate(data, options, userId);
|
||||
|
||||
if (options.parent?.type === 'pc') {
|
||||
if (options.parent?.type === 'character') {
|
||||
const path = `system.${data.system.isMulticlass ? 'multiclass.subclass' : 'class.subclass'}`;
|
||||
options.parent.update({ [path]: `${options.parent.uuid}.Item.${data._id}` });
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ export default class DHSubclass extends BaseDataItem {
|
|||
_onDelete(options, userId) {
|
||||
super._onDelete(options, userId);
|
||||
|
||||
if (options.parent?.type === 'pc') {
|
||||
if (options.parent?.type === 'character') {
|
||||
const path = `system.${this.isMulticlass ? 'multiclass.subclass' : 'class.subclass'}`;
|
||||
options.parent.update({ [path]: null });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export default class DhpActor extends Actor {
|
|||
|
||||
// Configure prototype token settings
|
||||
const prototypeToken = {};
|
||||
if (this.type === 'pc')
|
||||
if (this.type === 'character')
|
||||
Object.assign(prototypeToken, {
|
||||
sight: { enabled: true },
|
||||
actorLink: true,
|
||||
|
|
@ -28,7 +28,7 @@ export default class DhpActor extends Actor {
|
|||
}
|
||||
|
||||
async updateLevel(newLevel) {
|
||||
if (this.type !== 'pc' || newLevel === this.system.levelData.level.changed) return;
|
||||
if (this.type !== 'character' || newLevel === this.system.levelData.level.changed) return;
|
||||
|
||||
if (newLevel > this.system.levelData.level.current) {
|
||||
await this.update({ 'system.levelData.level.changed': newLevel });
|
||||
|
|
@ -124,7 +124,7 @@ export default class DhpActor extends Actor {
|
|||
}
|
||||
|
||||
async diceRoll(modifier, shiftKey) {
|
||||
if (this.type === 'pc') {
|
||||
if (this.type === 'character') {
|
||||
return await this.dualityRoll(modifier, shiftKey);
|
||||
} else {
|
||||
return await this.npcRoll(modifier, shiftKey);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ export const getCommandTarget = () => {
|
|||
ui.notifications.error(game.i18n.localize('DAGGERHEART.Notification.Error.NoSelectedToken'));
|
||||
return null;
|
||||
}
|
||||
if (target.type !== 'pc') {
|
||||
if (target.type !== 'character') {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.Notification.Error.OnlyUseableByPC'));
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,10 +95,10 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="tab domain-card-tab {{this.tabs.primary.loadout.cssClass}}" data-group="primary" data-tab="loadout">
|
||||
{{> "systems/daggerheart/templates/sheets/pc/sections/loadout.hbs" abilities=this.abilities actor=this.document config=this.config }}
|
||||
{{> "systems/daggerheart/templates/sheets/character/sections/loadout.hbs" abilities=this.abilities actor=this.document config=this.config }}
|
||||
</div>
|
||||
<div class="tab {{this.tabs.primary.inventory.cssClass}}" data-group="primary" data-tab="inventory">
|
||||
{{> "systems/daggerheart/templates/sheets/pc/sections/inventory.hbs" inventory=this.inventory }}
|
||||
{{> "systems/daggerheart/templates/sheets/character/sections/inventory.hbs" inventory=this.inventory }}
|
||||
</div>
|
||||
<div class="tab {{this.tabs.primary.story.cssClass}}" data-group="primary" data-tab="story">
|
||||
<div class="flexcol" style="height: 100%;">
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
<div class="card-row">
|
||||
<div class="heritage-card {{#if (not abilities.foundation.ancestry)}}outlined{{/if}}">
|
||||
{{#if abilities.foundation.ancestry}}
|
||||
{{> "systems/daggerheart/templates/sheets/pc/parts/heritageCard.hbs" card=abilities.foundation.ancestry }}
|
||||
{{> "systems/daggerheart/templates/sheets/character/parts/heritageCard.hbs" card=abilities.foundation.ancestry }}
|
||||
{{else}}
|
||||
<div class="empty-ability-container">
|
||||
<div class="empty-ability-inner-container">
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
<div class="heritage-card {{#if (not abilities.foundation.community)}}outlined{{/if}}">
|
||||
{{#if abilities.foundation.community}}
|
||||
{{> "systems/daggerheart/templates/sheets/pc/parts/heritageCard.hbs" card=abilities.foundation.community }}
|
||||
{{> "systems/daggerheart/templates/sheets/character/parts/heritageCard.hbs" card=abilities.foundation.community }}
|
||||
{{else}}
|
||||
<div class="empty-ability-container">
|
||||
<div class="empty-ability-inner-container">
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
<div class="card-row">
|
||||
<div class="heritage-card {{#if (not abilities.foundation.advancement.foundation)}}outlined{{/if}}">
|
||||
{{#if abilities.foundation.advancement.foundation}}
|
||||
{{> "systems/daggerheart/templates/sheets/pc/parts/advancementCard.hbs" card=abilities.foundation.advancement.foundation }}
|
||||
{{> "systems/daggerheart/templates/sheets/character/parts/advancementCard.hbs" card=abilities.foundation.advancement.foundation }}
|
||||
{{else}}
|
||||
<div class="empty-ability-container">
|
||||
<div class="empty-ability-inner-container">
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
</div>
|
||||
<div class="heritage-card {{#if (not abilities.foundation.advancement.first)}}outlined{{/if}}">
|
||||
{{#if abilities.foundation.advancement.first}}
|
||||
{{> "systems/daggerheart/templates/sheets/pc/parts/advancementCard.hbs" card=abilities.foundation.advancement.first }}
|
||||
{{> "systems/daggerheart/templates/sheets/character/parts/advancementCard.hbs" card=abilities.foundation.advancement.first }}
|
||||
{{else}}
|
||||
<div class="empty-ability-container">
|
||||
<div class="empty-ability-inner-container">
|
||||
|
|
@ -68,7 +68,7 @@
|
|||
</div>
|
||||
<div class="heritage-card {{#if (not abilities.foundation.advancement.second)}}outlined{{/if}}">
|
||||
{{#if abilities.foundation.advancement.second}}
|
||||
{{> "systems/daggerheart/templates/sheets/pc/parts/advancementCard.hbs" card=abilities.foundation.advancement.second}}
|
||||
{{> "systems/daggerheart/templates/sheets/character/parts/advancementCard.hbs" card=abilities.foundation.advancement.second}}
|
||||
{{else}}
|
||||
<div class="empty-ability-container">
|
||||
<div class="empty-ability-inner-container">
|
||||
Loading…
Add table
Add a link
Reference in a new issue