Add special abilities to creature sheet

This commit is contained in:
Johannes Loher 2021-01-13 17:20:25 +01:00
parent 864a65fed2
commit e36f30a787
12 changed files with 107 additions and 15 deletions

View file

@ -11,6 +11,7 @@
"DS4.HeadingTalents": "Talente & Fähigkeiten", "DS4.HeadingTalents": "Talente & Fähigkeiten",
"DS4.HeadingSpells": "Zaubersprüche", "DS4.HeadingSpells": "Zaubersprüche",
"DS4.HeadingDescription": "Beschreibung", "DS4.HeadingDescription": "Beschreibung",
"DS4.HeadingSpecialCreatureAbilites": "Besondere Fähigkeiten",
"DS4.AttackType": "Angriffs Typ", "DS4.AttackType": "Angriffs Typ",
"DS4.AttackTypeAbbr": "AT", "DS4.AttackTypeAbbr": "AT",
"DS4.WeaponBonus": "Waffen Bonus", "DS4.WeaponBonus": "Waffen Bonus",

View file

@ -11,6 +11,7 @@
"DS4.HeadingTalents": "Talents & Abilities", "DS4.HeadingTalents": "Talents & Abilities",
"DS4.HeadingSpells": "Spells", "DS4.HeadingSpells": "Spells",
"DS4.HeadingDescription": "Description", "DS4.HeadingDescription": "Description",
"DS4.HeadingSpecialCreatureAbilites": "Special Abilites",
"DS4.AttackType": "Attack Type", "DS4.AttackType": "Attack Type",
"DS4.AttackTypeAbbr": "AT", "DS4.AttackTypeAbbr": "AT",
"DS4.WeaponBonus": "Weapon Bonus", "DS4.WeaponBonus": "Weapon Bonus",

View file

@ -33,16 +33,16 @@ export class DS4Actor extends Actor<DS4ActorDataType, DS4ItemDataType, DS4Item>
"weapon", "weapon",
"armor", "armor",
"shield", "shield",
"spell",
"trinket", "trinket",
"equipment", "equipment",
"spell",
"talent", "talent",
"racialAbility", "racialAbility",
"language", "language",
"alphabet", "alphabet",
]; ];
case "creature": case "creature":
return ["weapon", "armor", "spell", "specialCreatureAbility"]; return ["weapon", "armor", "shield", "trinket", "equipment", "spell", "specialCreatureAbility"];
default: default:
[]; [];
} }

View file

@ -1,7 +1,7 @@
import { DS4Item } from "../item/item"; import { DS4Item } from "../../item/item";
import { DS4ItemDataType, ItemType } from "../item/item-data"; import { DS4ItemDataType, ItemType } from "../../item/item-data";
import { DS4Actor } from "./actor"; import { DS4Actor } from "../actor";
import { DS4ActorDataType } from "./actor-data"; import { DS4ActorDataType } from "../actor-data";
/** /**
* Extend the basic ActorSheet with some very simple modifications * Extend the basic ActorSheet with some very simple modifications
@ -14,7 +14,6 @@ export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor, DS4Ite
classes: ["ds4", "sheet", "actor"], classes: ["ds4", "sheet", "actor"],
width: 745, width: 745,
height: 600, height: 600,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "inventory" }],
}); });
} }
@ -40,7 +39,6 @@ export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor, DS4Ite
// Add the items explicitly sorted by type to the data: // Add the items explicitly sorted by type to the data:
itemsByType: this.actor.itemTypes, itemsByType: this.actor.itemTypes,
}; };
console.log("Data:", data);
return data; return data;
} }

View file

@ -0,0 +1,11 @@
import { DS4ActorSheet } from "./actor-sheet";
export class DS4CharacterActorSheet extends DS4ActorSheet {
/** @override */
static get defaultOptions(): FormApplicationOptions {
return mergeObject(super.defaultOptions, {
classes: ["ds4", "sheet", "actor", "character"],
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "inventory" }],
});
}
}

View file

@ -0,0 +1,11 @@
import { DS4ActorSheet } from "./actor-sheet";
export class DS4CreatureActorSheet extends DS4ActorSheet {
/** @override */
static get defaultOptions(): FormApplicationOptions {
return mergeObject(super.defaultOptions, {
classes: ["ds4", "sheet", "actor", "creature"],
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "items" }],
});
}
}

View file

@ -1,10 +1,11 @@
// Import Modules // Import Modules
import { DS4Actor } from "./actor/actor"; import { DS4Actor } from "./actor/actor";
import { DS4ActorSheet } from "./actor/actor-sheet";
import { DS4Item } from "./item/item"; import { DS4Item } from "./item/item";
import { DS4ItemSheet } from "./item/item-sheet"; import { DS4ItemSheet } from "./item/item-sheet";
import { DS4 } from "./config"; import { DS4 } from "./config";
import { DS4Check } from "./rolls/check"; import { DS4Check } from "./rolls/check";
import { DS4CharacterActorSheet } from "./actor/sheets/character-sheet";
import { DS4CreatureActorSheet } from "./actor/sheets/creature-sheet";
Hooks.once("init", async function () { Hooks.once("init", async function () {
console.log(`DS4 | Initializing the DS4 Game System\n${DS4.ASCII}`); console.log(`DS4 | Initializing the DS4 Game System\n${DS4.ASCII}`);
@ -36,7 +37,8 @@ Hooks.once("init", async function () {
// Register sheet application classes // Register sheet application classes
Actors.unregisterSheet("core", ActorSheet); Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("ds4", DS4ActorSheet, { makeDefault: true }); Actors.registerSheet("ds4", DS4CharacterActorSheet, { types: ["character"], makeDefault: true });
Actors.registerSheet("ds4", DS4CreatureActorSheet, { types: ["creature"], makeDefault: true });
Items.unregisterSheet("core", ItemSheet); Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("ds4", DS4ItemSheet, { makeDefault: true }); Items.registerSheet("ds4", DS4ItemSheet, { makeDefault: true });
@ -59,6 +61,7 @@ async function registerHandlebarsPartials() {
"systems/ds4/templates/actor/partials/combat-values.hbs", "systems/ds4/templates/actor/partials/combat-values.hbs",
"systems/ds4/templates/actor/partials/profile.hbs", "systems/ds4/templates/actor/partials/profile.hbs",
"systems/ds4/templates/actor/partials/character-progression.hbs", "systems/ds4/templates/actor/partials/character-progression.hbs",
"systems/ds4/templates/actor/partials/special-creature-abilites-overview.hbs",
]; ];
return loadTemplates(templatePaths); return loadTemplates(templatePaths);
} }
@ -100,7 +103,7 @@ Hooks.once("setup", function () {
]; ];
// Exclude some from sorting where the default order matters // Exclude some from sorting where the default order matters
const noSort = ["attributes", "traits", "combatValues"]; const noSort = ["attributes", "traits", "combatValues", "creatureSizeCategories"];
// Localize and sort CONFIG objects // Localize and sort CONFIG objects
for (const o of toLocalize) { for (const o of toLocalize) {

View file

@ -53,8 +53,9 @@
{{!-- Sheet Tab Navigation --}} {{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary"> <nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="inventory">{{localize 'DS4.HeadingInventory'}}</a> <a class="item" data-tab="inventory">{{localize 'DS4.HeadingInventory'}}</a>
<a class="item" data-tab="description">{{localize 'DS4.HeadingDescription'}}</a> <a class="item" data-tab="special-creature-abilites">{{localize 'DS4.HeadingSpecialCreatureAbilites'}}</a>
<a class="item" data-tab="spells">{{localize 'DS4.HeadingSpells'}}</a> <a class="item" data-tab="spells">{{localize 'DS4.HeadingSpells'}}</a>
<a class="item" data-tab="description">{{localize 'DS4.HeadingDescription'}}</a>
</nav> </nav>
{{!-- Sheet Body --}} {{!-- Sheet Body --}}
@ -62,6 +63,9 @@
{{!-- Items Tab --}} {{!-- Items Tab --}}
{{> systems/ds4/templates/actor/partials/items-overview.hbs}} {{> systems/ds4/templates/actor/partials/items-overview.hbs}}
{{!-- Special Creature Abilities Tab --}}
{{> systems/ds4/templates/actor/partials/special-creature-abilites-overview.hbs}}
{{!-- Spells Tab --}} {{!-- Spells Tab --}}
{{> systems/ds4/templates/actor/partials/spells-overview.hbs}} {{> systems/ds4/templates/actor/partials/spells-overview.hbs}}

View file

@ -1,5 +1,5 @@
{{!-- TODO: For items list: only show header, if list is not empty --}} {{!-- TODO: For items list: only show header, if list is not empty --}}
{{!-- TODO: Refactor to avoid code duplication with special-creature-abilites-overview and talents-overview --}}
{{!-- ======================================================================== --}} {{!-- ======================================================================== --}}
{{!-- INLINE PARTIAL DEFINITIONS --}} {{!-- INLINE PARTIAL DEFINITIONS --}}

View file

@ -0,0 +1,61 @@
{{!-- TODO: Refactor to avoid code duplication with items-overview and talents-overview --}}
{{!-- ======================================================================== --}}
{{!-- INLINE PARTIAL DEFINITIONS --}}
{{!-- ======================================================================== --}}
{{!--
!-- Render a list row for a base item from a given item.
!-- Base item means it just has an image, a description, and a name (and effects).
!-- It is a flexbox with a child for each item value of interest.
!-- The partial assumes a variable item to be given in the context.
!--
!-- @param item: hand over the item to the partial as hash parameter
--}}
{{#*inline "baseItemListEntry"}}
<li class="item flexrow" data-item-id="{{item._id}}">
{{!-- image --}}
<div class="flex05 item-image">
<img src="{{item.img}}" title="{{item.name}}" width="24" height="24" />
</div>
{{!-- name --}}
<input class="flex1 item-name item-change" type="text" value="{{item.name}}" data-dtype="String"
data-property="name" title="{{localize 'DS4.ItemName'}}">
{{!-- description --}}
<div class="flex3 item-description">{{{item.data.data.description}}}</div>
{{!-- control buttons --}}
{{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }}
</li>
{{/inline}}
{{!--
!-- Render a list header for a base item list entries from a given item.
!-- The partial assumes a variable dataType to be given in the context.
!--
!-- @param dataType: the string item type for the list
--}}
{{#*inline "baseItemListHeader"}}
<li class="item flexrow item-header">
{{!-- image --}}
<div class="flex05 item-image"></div>
{{!-- name --}}
<div class="flex1 item-name">{{localize 'DS4.ItemName'}}</div>
{{!-- description --}}
<div class="flex3">{{localize 'DS4.Description'}}</div>
{{!-- add button --}}
{{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }}
</li>
{{/inline}}
{{!-- ======================================================================== --}}
<div class="tab special-creature-abilites" data-group="primary" data-tab="special-creature-abilites">
<ol class="items-list">
{{> baseItemListHeader dataType='specialCreatureAbility' }}
{{#each itemsByType.specialCreatureAbility as |item id|}}
{{> baseItemListEntry item=item}}
{{/each}}
</ol>
</div>

View file

@ -27,7 +27,7 @@
{{!-- ======================================================================== --}} {{!-- ======================================================================== --}}
<div class="tab items" data-group="primary" data-tab="spells"> <div class="tab spells" data-group="primary" data-tab="spells">
<ol class="items-list"> <ol class="items-list">
<li class="item flexrow item-header"> <li class="item flexrow item-header">
{{!-- equipped --}} {{!-- equipped --}}

View file

@ -1,3 +1,5 @@
{{!-- TODO: Refactor to avoid code duplication with creature-special-abilities-overview and talents-overview --}}
{{!-- ======================================================================== --}} {{!-- ======================================================================== --}}
{{!-- INLINE PARTIAL DEFINITIONS --}} {{!-- INLINE PARTIAL DEFINITIONS --}}
{{!-- ======================================================================== --}} {{!-- ======================================================================== --}}
@ -118,7 +120,7 @@
{{!-- ======================================================================== --}} {{!-- ======================================================================== --}}
<div class="tab items" data-group="primary" data-tab="talents"> <div class="tab talents" data-group="primary" data-tab="talents">
<h4 class="items-list-title">{{localize 'DS4.ItemTypeTalentPlural'}}</h4> <h4 class="items-list-title">{{localize 'DS4.ItemTypeTalentPlural'}}</h4>
{{#> ifHasItemOfType itemsArray=itemsByType.talent dataType='talent' }} {{#> ifHasItemOfType itemsArray=itemsByType.talent dataType='talent' }}
<ol class="items-list"> <ol class="items-list">