Add additional physical item types

This commit is contained in:
Johannes Loher 2020-10-29 22:01:13 +01:00
parent e51376dc02
commit abeb9d8b24
12 changed files with 248 additions and 29 deletions

View file

@ -26,6 +26,11 @@
padding: 0;
}
.grid-1col {
grid-column: span 1 / span 1;
grid-template-columns: repeat(1, minmax(0, 1fr));
}
.grid-3col {
grid-column: span 3 / span 3;
grid-template-columns: repeat(3, minmax(0, 1fr));

View file

@ -18,6 +18,22 @@
"DS4.ItemAvailabilityCity": "City",
"DS4.ItemAvailabilityElves": "Elves",
"DS4.ItemAvailabilityDwarves": "Dwarves",
"DS4.ItemAvailabilityNone": "None",
"DS4.ItemTypeWeapon": "Weapon",
"DS4.ItemTypeEquipment": "Equipment"
"DS4.ItemTypeArmor": "Armor",
"DS4.ItemTypeShield": "Shield",
"DS4.ItemTypeTrinket": "Trinket",
"DS4.ItemTypeEquipment": "Equipment",
"DS4.ArmorType": "Armor Type",
"DS4.ArmorMaterialType": "Material Type",
"DS4.ArmorValue": "Armor Value",
"DS4.ArmorTypeBody": "Body",
"DS4.ArmorTypeHelmet": "Helmet",
"DS4.ArmorTypeVambrace": "Vambrace",
"DS4.ArmorTypeGreaves": "Greaves",
"DS4.ArmorTypeVambraceGreaves": "Vambrace + Greaves",
"DS4.ArmorMaterialTypeCloth": "Cloth",
"DS4.ArmorMaterialTypeLeather": "Leather",
"DS4.ArmorMaterialTypeChain": "Chain",
"DS4.ArmorMaterialTypePlate": "Plate"
}

View file

@ -29,6 +29,7 @@ DS4.itemAvailabilities = {
city: "DS4.ItemAvailabilityCity",
elves: "DS4.ItemAvailabilityElves",
dwarves: "DS4.ItemAvailabilityDwarves",
none: "DS4.ItemAvailabilityNone",
};
/**
@ -37,5 +38,31 @@ DS4.itemAvailabilities = {
*/
DS4.itemTypes = {
weapon: "DS4.ItemTypeWeapon",
armor: "DS4.ItemTypeArmor",
shield: "DS4.ItemTypeShield",
trinket: "DS4.ItemTypeTrinket",
equipment: "DS4.ItemTypeEquipment",
};
/**
* * Define the set of armor types, a character may only wear one item of each at any given time
* @type {Object}
*/
DS4.armorTypes = {
body: "DS4.ArmorTypeBody",
helment: "DS4.ArmorTypeHelmet",
vambrace: "DS4.ArmorTypeVambrace",
greaves: "DS4.ArmorTypeGreaves",
vambraceGreaves: "DS4.ArmorTypeVambraceGreaves",
};
/**
* * Define the set of armor materials, used to determine if a characer may wear the armor without additional penalties
* @type {Object}
*/
DS4.armorMaterialTypes = {
cloth: "DS4.ArmorMaterialTypeCloth",
leather: "DS4.ArmorMaterialTypeLeather",
chain: "DS4.ArmorMaterialTypeChain",
plate: "DS4.ArmorMaterialTypePlate",
};

View file

@ -26,8 +26,15 @@ Hooks.once("init", async function () {
Actors.registerSheet("ds4", DS4ActorSheet, { makeDefault: true });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("ds4", DS4ItemSheet, { makeDefault: true });
registerHandlebarsPartials();
});
async function registerHandlebarsPartials() {
const templatePaths = ["systems/ds4/templates/item/partials/description.hbs"];
return loadTemplates(templatePaths);
}
/* -------------------------------------------- */
/* Foundry VTT Setup */
/* -------------------------------------------- */
@ -37,7 +44,7 @@ Hooks.once("init", async function () {
*/
Hooks.once("setup", function () {
// Localize CONFIG objects once up-front
const toLocalize = ["attackTypes", "itemAvailabilities", "itemTypes"];
const toLocalize = ["attackTypes", "itemAvailabilities", "itemTypes", "armorTypes", "armorMaterialTypes"];
// Exclude some from sorting where the default order matters
const noSort = [];

View file

@ -7,6 +7,11 @@
padding: 0;
}
.grid-1col {
grid-column: span 1 / span 1;
grid-template-columns: repeat(1, minmax(0, 1fr));
}
.grid-3col {
grid-column: span 3 / span 3;
grid-template-columns: repeat(3, minmax(0, 1fr));

View file

@ -46,7 +46,7 @@
}
},
"Item": {
"types": ["weapon", "equipment"],
"types": ["weapon", "armor", "shield", "trinket", "equipment"],
"templates": {
"base": {
"description": ""
@ -54,16 +54,32 @@
"physical": {
"quantity": 1,
"price": 0,
"availability": "Hamlet"
"availability": "none"
},
"equipable": {
"equipped": false
}
},
"weapon": {
"templates": ["base", "physical"],
"templates": ["base", "physical", "equipable"],
"attackType": "melee",
"weaponBonus": 0,
"opponentDefense": 0,
"properties": {}
},
"armor": {
"templates": ["base", "physical", "equipable"],
"armorMaterialType": "cloth",
"armorType": "body",
"armorValue": 0
},
"shield": {
"templates": ["base", "physical", "equipable"],
"armorValue": 0
},
"trinket": {
"templates": ["base", "physical", "equipable"]
},
"equipment": {
"templates": ["base", "physical"]
}

View file

@ -0,0 +1,54 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<div class="header-fields flexrow">
<h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>
<h2 class="item-type">{{localize (lookup config.itemTypes item.type)}}</h2>
<div class="grid grid-3col basic-properties">
<div class="basic-property">
<label class="basic-property-label">{{localize "DS4.ArmorType"}}</label>
<select class="basic-property-select" name="data.armorType" data-type="String">
{{#select data.armorType}}
{{#each config.armorTypes as |value key|}}
<option value="{{key}}">{{value}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div class="basic-property">
<label class="basic-property-label">{{localize "DS4.ArmorMaterialType"}}</label>
<select class="basic-property-select" name="data.armorMaterialType" data-type="String">
{{#select data.armorMaterialType}}
{{#each config.armorMaterialTypes as |value key|}}
<option value="{{key}}">{{value}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div class="basic-property">
<label class="basic-property-label">{{localize "DS4.ArmorValue"}}</label>
<input class="basic-property-input" type="text" name="data.armorValue" value="{{data.armorValue}}"
placeholder="0" data-dtype="Number" />
</div>
</div>
</div>
</header>
{{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="description">{{localize "DS4.Description"}}</a>
<a class="item" data-tab="details">{{localize "DS4.Details"}}</a>
</nav>
{{!-- Sheet Body --}}
<section class="sheet-body">
{{!-- Description Tab --}}
{{> systems/ds4/templates/item/partials/description.hbs}}
{{!-- Attributes Tab --}}
<div class="tab details" data-group="primary" data-tab="details">
{{!-- As you add new fields, add them in here! --}}
</div>
</section>
</form>

View file

@ -0,0 +1,27 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<div class="header-fields flexrow">
<h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>
<h2 class="item-type">{{localize (lookup config.itemTypes item.type)}}</h2>
</div>
</header>
{{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="description">{{localize "DS4.Description"}}</a>
<a class="item" data-tab="details">{{localize "DS4.Details"}}</a>
</nav>
{{!-- Sheet Body --}}
<section class="sheet-body">
{{!-- Description Tab --}}
{{> systems/ds4/templates/item/partials/description.hbs}}
{{!-- Attributes Tab --}}
<div class="tab details" data-group="primary" data-tab="details">
{{!-- As you add new fields, add them in here! --}}
</div>
</section>
</form>

View file

@ -0,0 +1,24 @@
<div class="tab flexrow" data-group="primary" data-tab="description">
<div class="side-properties">
<div class="side-property">
<label for="data.quantity">{{localize "DS4.Quantity"}}</label>
<input type="number" data-dtype="Number" name="data.quantity" value="{{data.quantity}}" />
</div>
<div class="side-property">
<label for="data.price">{{localize "DS4.PriceGold"}}</label>
<input type="number" data-dtype="Number" name="data.price" value="{{data.price}}" />
</div>
<div class="side-property">
<label for="data.price">{{localize "DS4.ItemAvailability"}}</label>
<select name="data.availability" data-type="String">
{{#select data.availability}}
{{#each config.itemAvailabilities as |value key|}}
<option value="{{key}}">{{value}}</option>
{{/each}}
{{/select}}
</select>
</div>
</div>
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
</div>

View file

@ -0,0 +1,34 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<div class="header-fields flexrow">
<h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>
<h2 class="item-type">{{localize (lookup config.itemTypes item.type)}}</h2>
<div class="grid grid-1col basic-properties">
<div class="basic-property">
<label class="basic-property-label">{{localize "DS4.ArmorValue"}}</label>
<input class="basic-property-input" type="text" name="data.armorValue" value="{{data.armorValue}}"
placeholder="0" data-dtype="Number" />
</div>
</div>
</div>
</header>
{{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="description">{{localize "DS4.Description"}}</a>
<a class="item" data-tab="details">{{localize "DS4.Details"}}</a>
</nav>
{{!-- Sheet Body --}}
<section class="sheet-body">
{{!-- Description Tab --}}
{{> systems/ds4/templates/item/partials/description.hbs}}
{{!-- Attributes Tab --}}
<div class="tab details" data-group="primary" data-tab="details">
{{!-- As you add new fields, add them in here! --}}
</div>
</section>
</form>

View file

@ -0,0 +1,27 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<div class="header-fields flexrow">
<h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>
<h2 class="item-type">{{localize (lookup config.itemTypes item.type)}}</h2>
</div>
</header>
{{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="description">{{localize "DS4.Description"}}</a>
<a class="item" data-tab="details">{{localize "DS4.Details"}}</a>
</nav>
{{!-- Sheet Body --}}
<section class="sheet-body">
{{!-- Description Tab --}}
{{> systems/ds4/templates/item/partials/description.hbs}}
{{!-- Attributes Tab --}}
<div class="tab details" data-group="primary" data-tab="details">
{{!-- As you add new fields, add them in here! --}}
</div>
</section>
</form>

View file

@ -39,30 +39,7 @@
<section class="sheet-body">
{{!-- Description Tab --}}
<div class="tab flexrow" data-group="primary" data-tab="description">
<div class="side-properties">
<div class="side-property">
<label for="data.quantity">{{localize "DS4.Quantity"}}</label>
<input type="number" data-dtype="Number" name="data.quantity" value="{{data.quantity}}" />
</div>
<div class="side-property">
<label for="data.price">{{localize "DS4.PriceGold"}}</label>
<input type="number" data-dtype="Number" name="data.price" value="{{data.price}}" />
</div>
<div class="side-property">
<label for="data.price">{{localize "DS4.ItemAvailability"}}</label>
<select name="data.availability" data-type="String">
{{#select data.availability}}
{{#each config.itemAvailabilities as |value key|}}
<option value="{{key}}">{{value}}</option>
{{/each}}
{{/select}}
</select>
</div>
</div>
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
</div>
{{> systems/ds4/templates/item/partials/description.hbs}}
{{!-- Attributes Tab --}}
<div class="tab details" data-group="primary" data-tab="details">