Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix languages, dungeon skills, and rollable items (abilities, weapons, spells) in V10 #224

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/module/actor/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ export class OseActorSheet extends ActorSheet {

_toggleItemSummary(event) {
event.preventDefault();
const itemSummary = event.currentTarget.closest(".item-entry.item").querySelector('.item-summary');
const itemSummary = event.currentTarget
.closest(".item-entry.item")
.querySelector(".item-summary");
if (itemSummary.style.display === "") {
itemSummary.style.display = 'block';
itemSummary.style.display = "block";
} else {
itemSummary.style.display = '';
itemSummary.style.display = "";
}
}

Expand Down Expand Up @@ -158,7 +160,7 @@ export class OseActorSheet extends ActorSheet {

async _rollAbility(event) {
const item = this._getItemFromActor(event);
const itemData = itemData?.system || item?.data?.data; //v9-compatibility
const itemData = item?.system || item?.data?.data; //v9-compatibility
if (item.type == "weapon") {
if (this.actor.data.type === "monster") {
item.update({
Expand Down
2 changes: 1 addition & 1 deletion src/module/actor/character-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class OseActorSheetCharacter extends OseActorSheet {

_pushLang(table) {
const data = this.actor.data.data;
let update = data.toObject()[table]; //V10 compatibility
let update = data[table]; //V10 compatibility
this._chooseLang().then((dialogInput) => {
const name = CONFIG.OSE.languages[dialogInput.choice];
if (update.value) {
Expand Down
4 changes: 3 additions & 1 deletion src/module/dice.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ export class OseDice {
};
result.target = data.roll.thac0;
let targetActorData =
data.roll.target.actor?.system || data.roll.target.actor?.data?.data; //v9-compatibility
data.roll.target?.actor?.system ||
data.roll.target?.actor?.data?.data ||
null; //v9-compatibility

const targetAc = data.roll.target ? targetActorData.ac.value : 9;
const targetAac = data.roll.target ? targetActorData.aac.value : 0;
Expand Down
6 changes: 3 additions & 3 deletions src/module/item/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class OseItem extends Item {
},
};

if (data.missile && data.melee && !isNPC) {
if (itemData.missile && itemData.melee && !isNPC) {
// Dialog
new Dialog({
title: "Choose Attack Range",
Expand All @@ -106,7 +106,7 @@ export class OseItem extends Item {
default: "melee",
}).render(true);
return true;
} else if (data.missile && !isNPC) {
} else if (itemData.missile && !isNPC) {
type = "missile";
}
this.actor.targetAttack(rollData, type, options);
Expand Down Expand Up @@ -322,7 +322,7 @@ export class OseItem extends Item {
const templateData = {
actor: this.actor,
tokenId: token ? `${token.parent.id}.${token.id}` : null,
item: this.data.toObject(), //V10 compatibility
item: this.data,
data: this.getChatData(),
labels: this.labels,
isHealing: this.isHealing,
Expand Down
18 changes: 9 additions & 9 deletions src/templates/actors/partials/character-abilities-tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</h4>
<div class="attribute-value">
<input
name="data.exploration.ld"
name="system.exploration.ld"
type="text"
value="{{data.exploration.ld}}"
value="{{system.exploration.ld}}"
data-dtype="Number"
placeholder="0"
/>
Expand All @@ -25,9 +25,9 @@
</h4>
<div class="attribute-value">
<input
name="data.exploration.od"
name="system.exploration.od"
type="text"
value="{{data.exploration.od}}"
value="{{system.exploration.od}}"
placeholder="0"
data-dtype="String"
/>
Expand All @@ -42,9 +42,9 @@
</h4>
<div class="attribute-value">
<input
name="data.exploration.sd"
name="system.exploration.sd"
type="text"
value="{{data.exploration.sd}}"
value="{{system.exploration.sd}}"
placeholder="0"
data-dtype="String"
/>
Expand All @@ -59,9 +59,9 @@
</h4>
<div class="attribute-value">
<input
name="data.exploration.ft"
name="system.exploration.ft"
type="text"
value="{{data.exploration.ft}}"
value="{{system.exploration.ft}}"
placeholder="0"
data-dtype="String"
/>
Expand All @@ -86,7 +86,7 @@
{{#each abilities as |item|}}
<li class="item-entry item" data-item-id="{{item.id}}">
<div
class="item-header flexrow {{#if item.data.data.roll}}item-rollable{{/if}}"
class="item-header flexrow {{#if item.system.roll}}item-rollable{{/if}}"
>
<div
class="item-image"
Expand Down
70 changes: 35 additions & 35 deletions src/templates/actors/partials/character-inventory-tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
></div>
<h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
<div class="tag-row icon-row">
{{#each item.data.data.manualTags as |tag|}} {{#if (getTagIcon
{{#each item.system.manualTags as |tag|}} {{#if (getTagIcon
tag.value)}}
<img
title="{{tag.title}}"
src="{{getTagIcon tag.value}}"
width="24"
height="24"
/>
{{/if}} {{/each}} {{#each item.data.data.manualTags as |tag|}}
{{#unless (getTagIcon tag.value)}}
{{/if}} {{/each}} {{#each item.system.manualTags as |tag|}} {{#unless
(getTagIcon tag.value)}}
<span title="{{tag.title}}"
>{{tag.value}}{{#unless @last}},{{/unless}}</span
>
Expand All @@ -41,12 +41,12 @@ <h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
</div>
<div class="field-short">
{{#if (eq @root.config.encumbrance
"basic")}}_{{else}}{{item.data.data.weight}}{{/if}}
"basic")}}_{{else}}{{item.system.weight}}{{/if}}
</div>
<div class="item-controls">
{{#if @root.owner }} {{#if (eq @root.type "character")}}
<a
class="item-control item-toggle {{#unless item.data.data.equipped}}item-unequipped{{/unless}}"
class="item-control item-toggle {{#unless item.system.equipped}}item-unequipped{{/unless}}"
title='{{localize "OSE.items.Equip"}}'
>
<i class="fas fa-tshirt"></i>
Expand Down Expand Up @@ -96,17 +96,17 @@ <h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
></div>
<h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
<div class="field-short">
{{#if @root.config.ascendingAC}} {{item.data.data.aac.value}} {{else}}
{{item.data.data.ac.value}} {{/if}}
{{#if @root.config.ascendingAC}} {{item.system.aac.value}} {{else}}
{{item.system.ac.value}} {{/if}}
</div>
<div class="field-short">
{{#if (eq @root.config.encumbrance
"basic")}}_{{else}}{{item.data.data.weight}}{{/if}}
"basic")}}_{{else}}{{item.system.weight}}{{/if}}
</div>
<div class="item-controls">
{{#if @root.owner }} {{#if (eq @root.type "character")}}
<a
class="item-control item-toggle {{#unless item.data.data.equipped}}item-unequipped{{/unless}}"
class="item-control item-toggle {{#unless item.system.equipped}}item-unequipped{{/unless}}"
title='{{localize "OSE.items.Equip"}}'
>
<i class="fas fa-tshirt"></i>
Expand Down Expand Up @@ -156,12 +156,12 @@ <h4 class="item-name" title="{{bag.name}}">{{bag.name~}}</h4>
<div class="field-short container-total-weight">
{{#if (eq @root.config.encumbrance "basic")}}_{{else if (eq
@root.config.encumbrance
"detailed")}}_{{else}}{{bag.data.data.totalWeight}}{{/if}}
"detailed")}}_{{else}}{{bag.system.totalWeight}}{{/if}}
</div>
<div class="field-short container-item-weight">
{{#if (eq @root.config.encumbrance "basic")}}_{{else if (eq
@root.config.encumbrance
"detailed")}}_{{else}}{{bag.data.data.weight}}{{/if}}
"detailed")}}_{{else}}{{bag.system.weight}}{{/if}}
</div>
<div class="item-controls">
{{#if @root.owner}}
Expand All @@ -179,7 +179,7 @@ <h4 class="item-name" title="{{bag.name}}">{{bag.name~}}</h4>
item=bag}}
</div>
<ol class="item-list contained-items">
{{#each bag.data.data.itemIds as |item|}}
{{#each bag.system.itemIds as |item|}}
<li class="item-entry item" data-item-id="{{item.id}}">
<div
class="item-header flexrow {{#if (eq item.type 'weapon') }}item-rollable{{/if}}"
Expand All @@ -191,17 +191,17 @@ <h4 class="item-name" title="{{bag.name}}">{{bag.name~}}</h4>
<h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
<div class="field-short quantity">
<input
value="{{item.data.data.quantity.value}}"
value="{{item.system.quantity.value}}"
type="text"
placeholder="0"
data-field="value"
/>{{#if
item.data.data.quantity.max}}<span>/{{item.data.data.quantity.max}}</span>{{/if}}
item.system.quantity.max}}<span>/{{item.system.quantity.max}}</span>{{/if}}
</div>
<div class="field-short">
{{#if (eq @root.config.encumbrance "basic")}}_{{else if (eq
@root.config.encumbrance
"detailed")}}_{{else}}{{item.data.data.weight}}{{/if}}
"detailed")}}_{{else}}{{item.system.weight}}{{/if}}
</div>
<div class="item-controls">
{{#if @root.owner}}
Expand All @@ -216,14 +216,14 @@ <h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
{{/if}}
</div>
</div>
{{#if item.data.data.quantity.max }} {{#if (lte
item.data.data.quantity.max 38)}}
{{#if item.system.quantity.max }} {{#if (lte item.system.quantity.max
38)}}
<div class="consumable-counter">
<label>{{localize "OSE.items.uses"}}</label>
{{#times item.data.data.quantity.value}}
{{#times item.system.quantity.value}}
<div class="full-mark"></div>
{{/times}} {{#times (subtract item.data.data.quantity.max
item.data.data.quantity.value)}}
{{/times}} {{#times (subtract item.system.quantity.max
item.system.quantity.value)}}
<div class="empty-mark"></div>
{{/times}}
</div>
Expand Down Expand Up @@ -264,17 +264,17 @@ <h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
<h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
<div class="field-short quantity">
<input
value="{{item.data.data.quantity.value}}"
value="{{item.system.quantity.value}}"
type="text"
placeholder="0"
data-field="value"
/>{{#if
item.data.data.quantity.max}}<span>/{{item.data.data.quantity.max}}</span>{{/if}}
item.system.quantity.max}}<span>/{{item.system.quantity.max}}</span>{{/if}}
</div>
<div class="field-short">
{{#if (eq @root.config.encumbrance "basic")}}_{{else if (eq
@root.config.encumbrance
"detailed")}}_{{else}}{{item.data.data.weight}}{{/if}}
"detailed")}}_{{else}}{{item.system.weight}}{{/if}}
</div>
<div class="item-controls">
{{#if @root.owner}}
Expand All @@ -287,14 +287,14 @@ <h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
{{/if}}
</div>
</div>
{{#if item.data.data.quantity.max }} {{#if (lte
item.data.data.quantity.max 38)}}
{{#if item.system.quantity.max }} {{#if (lte item.system.quantity.max
38)}}
<div class="consumable-counter">
<label>{{localize "OSE.items.uses"}}</label>
{{#times item.data.data.quantity.value}}
{{#times item.system.quantity.value}}
<div class="full-mark"></div>
{{/times}} {{#times (subtract item.data.data.quantity.max
item.data.data.quantity.value)}}
{{/times}} {{#times (subtract item.system.quantity.max
item.system.quantity.value)}}
<div class="empty-mark"></div>
{{/times}}
</div>
Expand All @@ -311,7 +311,7 @@ <h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
<div class="category-caret"><i class="fas fa-caret-down"></i></div>
<div class="category-name">{{localize "OSE.items.Treasure"}}</div>
<div class="field-long">
{{data.treasure}} <i class="fas fa-circle"></i>
{{system.treasure}} <i class="fas fa-circle"></i>
</div>
<div class="field-short"><i class="fas fa-hashtag"></i></div>
<div class="field-short"><i class="fas fa-weight-hanging"></i></div>
Expand All @@ -335,21 +335,21 @@ <h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
></div>
<h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
<div class="field-long">
{{mult item.data.data.quantity.value item.data.data.cost}}
{{mult item.system.quantity.value item.system.cost}}
</div>
<div class="field-short quantity">
<input
value="{{item.data.data.quantity.value}}"
value="{{item.system.quantity.value}}"
type="text"
placeholder="0"
data-field="value"
/>
{{#if item.data.data.quantity.max}}
<span>/{{item.data.data.quantity.max}}</span>
{{#if item.system.quantity.max}}
<span>/{{item.system.quantity.max}}</span>
{{/if}}
</div>
<div class="field-short">
{{mult item.data.data.quantity.value item.data.data.weight}}
{{mult item.system.quantity.value item.system.weight}}
</div>
<div class="item-controls">
{{#if @root.owner}}
Expand All @@ -371,7 +371,7 @@ <h4 class="item-name" title="{{item.name}}">{{item.name~}}</h4>
</ol>
</section>
<section>
{{#with data.encumbrance}}
{{#with system.encumbrance}}
<div class="encumbrance {{#if encumbered}}encumbered{{/if}}">
<span class="encumbrance-bar" style="width:{{pct}}%"></span>
<span class="encumbrance-label">{{value}} / {{max}}</span>
Expand Down