Skip to content

Commit

Permalink
send item descriptions to chat, fix toggle buttons, update packs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-Talman committed Mar 8, 2024
1 parent cfaa131 commit d458668
Show file tree
Hide file tree
Showing 31 changed files with 110 additions and 53 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
- All attacks roll their description (not just relics)
- Monster sheets display AP and can roll reverse AP
- New PCs and recruits have "Link Actor Data" selected by default
- Armor can be unequipped for AP calculations without being removed from inventory
- Clicking item names or icons in inventory sends their descriptions to chat (only when items have descriptions)
- Fix labels for toggleable buttons on items in actor inventory

## 0.2.1
- Added support for reverse AP rolls for PCs/recruits
Expand Down
9 changes: 5 additions & 4 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@

"KNAVE2E.QuantityPerSlot": "# per Slot",

"KNAVE2E.BreakWeaponDetail": "Toggle Broken Weapon",
"KNAVE2E.CastSpellbookDetail": "Toggle Cast Spellbook",
"KNAVE2E.ActiveBlessingDetail": "Toggle Active Blessing",
"KNAVE2E.ActivateLightSourceDetail": "Toggle Light Source",
"KNAVE2E.BreakWeaponDetail": "Break",
"KNAVE2E.CastSpellbookDetail": "Cast",
"KNAVE2E.ActiveBlessingDetail": "Bless",
"KNAVE2E.ActivateLightSourceDetail": "Light",
"KNAVE2E.EquipArmorDetail": "Equip",

"KNAVE2E.AttackRoll": "Attack Roll",
"KNAVE2E.PowerAttackRoll": "Power Attack Roll",
Expand Down
1 change: 1 addition & 0 deletions module/data/armor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class Knave2eArmor extends Knave2eItemType {
const schema = super.defineSchema();

schema.armorPoints = new fields.NumberField({ ...requiredInteger, initial: 1, min: 1});
schema.equipped = new fields.BooleanField({ initial: true });

return schema;
}
Expand Down
26 changes: 24 additions & 2 deletions module/sheets/actor-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default class Knave2eActorSheet extends ActorSheet {
}

_updateArmor(context) {
const armorPieces = context.items.filter(i => i.type === "armor" && i.system.dropped === false);
const armorPieces = context.items.filter(i => i.type === "armor" && i.system.dropped === false && i.system.equipped === true);
const uniqueCategories = [];
let armorPoints = 0;

Expand Down Expand Up @@ -318,11 +318,13 @@ export default class Knave2eActorSheet extends ActorSheet {
// Rollable elements (e.g. Abilities)
html.on('click', '.rollable', this._onRollable.bind(this));

// Item Description to chat
html.on('click', '.item-name', this._onItemName.bind(this));

// Toggle Item Icons
html.on('click', '.item-toggle', this._onItemToggle.bind(this));



/* -------------------------------------------- */
/* Item Rolls */
/* -------------------------------------------- */
Expand Down Expand Up @@ -356,6 +358,24 @@ export default class Knave2eActorSheet extends ActorSheet {
html.on('click', '.actor-button.numberAppearing', this._onNumberAppearing.bind(this));
}

async _onItemName(event) {
event.preventDefault();
const a = event.currentTarget;
const systemData = this.actor.system;

const li = a.closest("li");
const item = li.dataset.itemId ? this.actor.items.get(li.dataset.itemId) : null;

if (item.system.description !== ""){
ChatMessage.create({
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
flavor: `${item.name}`,
content:`${item.system.description}`,
rollMode: game.settings.get('core', 'rollMode')
});
}
}

async _onItemToggle(event) {
event.preventDefault();
const a = event.currentTarget;
Expand All @@ -370,6 +390,8 @@ export default class Knave2eActorSheet extends ActorSheet {
return item.update({ "system.broken": !item.system.broken })
case "cast":
return item.update({ "system.cast": !item.system.cast })
case "equip":
return item.update({"system.equipped": !item.system.equipped})
case "blessing":
if (item.system.relic.isActive) {
this.actor.update({
Expand Down
Binary file removed packs/actors/000019.ldb
Binary file not shown.
Binary file added packs/actors/000070.ldb
Binary file not shown.
2 changes: 1 addition & 1 deletion packs/actors/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000064
MANIFEST-000071
4 changes: 1 addition & 3 deletions packs/actors/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
2024/03/08-14:02:24.827 676c Recovering log #63
2024/03/08-14:02:24.830 676c Delete type=0 #63
2024/03/08-14:02:24.830 676c Delete type=3 #62
2024/03/08-16:02:40.580 bf0c Recovering log #68
17 changes: 14 additions & 3 deletions packs/actors/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2024/03/08-13:32:41.661 5198 Recovering log #61
2024/03/08-13:32:41.664 5198 Delete type=0 #61
2024/03/08-13:32:41.664 5198 Delete type=3 #60
2024/03/08-15:06:29.615 3708 Recovering log #65
2024/03/08-15:06:29.618 3708 Delete type=0 #65
2024/03/08-15:06:29.618 3708 Delete type=3 #64
2024/03/08-16:00:25.524 cb84 Level-0 table #69: started
2024/03/08-16:00:25.526 cb84 Level-0 table #69: 2717 bytes OK
2024/03/08-16:00:25.526 cb84 Delete type=0 #67
2024/03/08-16:00:25.526 cb84 Manual compaction at level-0 from '!actors!trjwBEQQMtRgNF55' @ 72057594037927935 : 1 .. '!actors.items!trjwBEQQMtRgNF55.ruMHE8dQmioMrKyQ' @ 0 : 0; will stop at '!actors.items!trjwBEQQMtRgNF55.ruMHE8dQmioMrKyQ' @ 17 : 1
2024/03/08-16:00:25.526 cb84 Compacting 1@0 + 1@1 files
2024/03/08-16:00:25.529 cb84 Generated table #70@0: 6 keys, 2626 bytes
2024/03/08-16:00:25.529 cb84 Compacted 1@0 + 1@1 files => 2626 bytes
2024/03/08-16:00:25.530 cb84 compacted to: files[ 0 1 0 0 0 0 0 ]
2024/03/08-16:00:25.530 cb84 Delete type=2 #19
2024/03/08-16:00:25.530 cb84 Delete type=2 #69
2024/03/08-16:00:25.531 cb84 Manual compaction at level-0 from '!actors.items!trjwBEQQMtRgNF55.ruMHE8dQmioMrKyQ' @ 17 : 1 .. '!actors.items!trjwBEQQMtRgNF55.ruMHE8dQmioMrKyQ' @ 0 : 0; will stop at (end)
Binary file removed packs/actors/MANIFEST-000064
Binary file not shown.
Binary file added packs/actors/MANIFEST-000071
Binary file not shown.
2 changes: 1 addition & 1 deletion packs/items/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000064
MANIFEST-000070
4 changes: 1 addition & 3 deletions packs/items/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
2024/03/08-14:02:24.820 6194 Recovering log #63
2024/03/08-14:02:24.823 6194 Delete type=0 #63
2024/03/08-14:02:24.823 6194 Delete type=3 #62
2024/03/08-16:02:40.573 a7e8 Recovering log #68
10 changes: 7 additions & 3 deletions packs/items/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2024/03/08-13:32:41.653 60e4 Recovering log #61
2024/03/08-13:32:41.657 60e4 Delete type=0 #61
2024/03/08-13:32:41.657 60e4 Delete type=3 #60
2024/03/08-15:06:29.609 a7e8 Recovering log #65
2024/03/08-15:06:29.611 a7e8 Delete type=0 #65
2024/03/08-15:06:29.612 a7e8 Delete type=3 #64
2024/03/08-16:00:25.521 cb84 Level-0 table #69: started
2024/03/08-16:00:25.521 cb84 Level-0 table #69: 0 bytes OK
2024/03/08-16:00:25.522 cb84 Delete type=0 #67
2024/03/08-16:00:25.522 cb84 Manual compaction at level-0 from '!items!sV2GWqGVqxfb3PD2' @ 72057594037927935 : 1 .. '!items!sV2GWqGVqxfb3PD2' @ 0 : 0; will stop at (end)
Binary file not shown.
Binary file removed packs/monsters/000019.ldb
Binary file not shown.
Binary file added packs/monsters/000070.ldb
Binary file not shown.
2 changes: 1 addition & 1 deletion packs/monsters/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000064
MANIFEST-000071
4 changes: 1 addition & 3 deletions packs/monsters/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
2024/03/08-14:02:24.815 676c Recovering log #63
2024/03/08-14:02:24.817 676c Delete type=0 #63
2024/03/08-14:02:24.817 676c Delete type=3 #62
2024/03/08-16:02:40.564 bf0c Recovering log #68
17 changes: 14 additions & 3 deletions packs/monsters/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2024/03/08-13:32:41.647 5198 Recovering log #61
2024/03/08-13:32:41.650 5198 Delete type=0 #61
2024/03/08-13:32:41.650 5198 Delete type=3 #60
2024/03/08-15:06:29.603 3708 Recovering log #65
2024/03/08-15:06:29.605 3708 Delete type=0 #65
2024/03/08-15:06:29.605 3708 Delete type=3 #64
2024/03/08-16:00:25.513 cb84 Level-0 table #69: started
2024/03/08-16:00:25.514 cb84 Level-0 table #69: 1821 bytes OK
2024/03/08-16:00:25.515 cb84 Delete type=0 #67
2024/03/08-16:00:25.518 cb84 Manual compaction at level-0 from '!actors!GuNBsOpZWgJF8PEZ' @ 72057594037927935 : 1 .. '!actors.items!GuNBsOpZWgJF8PEZ.rcEop0TaEm8qlpXt' @ 0 : 0; will stop at '!actors.items!H9MttKr2aT05fSVJ.rcEop0TaEm8qlpXt' @ 4 : 0
2024/03/08-16:00:25.518 cb84 Compacting 1@0 + 1@1 files
2024/03/08-16:00:25.519 cb84 Generated table #70@0: 3 keys, 1766 bytes
2024/03/08-16:00:25.519 cb84 Compacted 1@0 + 1@1 files => 1766 bytes
2024/03/08-16:00:25.520 cb84 compacted to: files[ 0 1 0 0 0 0 0 ]
2024/03/08-16:00:25.520 cb84 Delete type=2 #19
2024/03/08-16:00:25.520 cb84 Delete type=2 #69
2024/03/08-16:00:25.522 cb84 Manual compaction at level-0 from '!actors.items!H9MttKr2aT05fSVJ.rcEop0TaEm8qlpXt' @ 4 : 0 .. '!actors.items!GuNBsOpZWgJF8PEZ.rcEop0TaEm8qlpXt' @ 0 : 0; will stop at (end)
Binary file removed packs/monsters/MANIFEST-000064
Binary file not shown.
Binary file added packs/monsters/MANIFEST-000071
Binary file not shown.
2 changes: 1 addition & 1 deletion packs/spells/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000052
MANIFEST-000058
3 changes: 0 additions & 3 deletions packs/spells/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
2024/03/08-14:02:24.834 6194 Recovering log #51
2024/03/08-14:02:24.837 6194 Delete type=0 #51
2024/03/08-14:02:24.837 6194 Delete type=3 #50
10 changes: 7 additions & 3 deletions packs/spells/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2024/03/08-13:32:41.669 60e4 Recovering log #49
2024/03/08-13:32:41.672 60e4 Delete type=0 #49
2024/03/08-13:32:41.672 60e4 Delete type=3 #48
2024/03/08-15:06:29.622 a7e8 Recovering log #53
2024/03/08-15:06:29.625 a7e8 Delete type=0 #53
2024/03/08-15:06:29.625 a7e8 Delete type=3 #52
2024/03/08-16:00:25.523 cb84 Level-0 table #57: started
2024/03/08-16:00:25.523 cb84 Level-0 table #57: 0 bytes OK
2024/03/08-16:00:25.524 cb84 Delete type=0 #55
2024/03/08-16:00:25.526 cb84 Manual compaction at level-0 from 'undefined' @ 72057594037927935 : 1 .. 'undefined' @ 0 : 0; will stop at (end)
Binary file removed packs/spells/MANIFEST-000052
Binary file not shown.
Binary file added packs/spells/MANIFEST-000058
Binary file not shown.
2 changes: 1 addition & 1 deletion templates/actor/actor-monster-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</li>
{{#each items as |item id|}}
<li class="item grid grid-12col" data-item-id="{{item._id}}">
<div class="item-name detail grid-span-6" style="margin-left:2px;">{{item.name}}</div>
<a class="item-name detail grid-span-6" style="margin-left:2px;">{{item.name}}</a>
<div class="item-buttons grid-span-2 flexrow flex-group-center">
<button class="item-button attack sheet" data-action="attack" type="button"
title={{localize "KNAVE2E.AttackRoll" }}>{{localize "KNAVE2E.AttackAbbr"}}</button>
Expand Down
23 changes: 15 additions & 8 deletions templates/actor/actor-recruit-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
<div class="resource-label">{{localize "KNAVE2E.HitPoints"}}</div>
<div class="progress-container horizontal hitPoints">
<div class="progress-bar">
<div class="progress-fill hitPoints" style="width:{{system.hitPoints.progress}}%"></div>
<div class="progress-fill hitPoints" style="width:{{system.hitPoints.progress}}%">
</div>
<input class="progress-input resource-label content" name="system.hitPoints.value"
value="{{system.hitPoints.value}}" />
</div>
Expand Down Expand Up @@ -147,13 +148,13 @@
<li class="item grid grid-12col {{#if system.dropped}}dropped{{/if}}"
data-item-id="{{item._id}}">

<div class="item-image rollable"><a class="item-image rollable grid-span-1"><img
<div class="item-image"><a class="item-image item-name grid-span-1"><img
src="{{item.img}}" title="{{item.name}}" width="36" height="36" /></a></div>

{{#if (eq item.type "weapon")}}
<div class="item-name detail grid-span-5">{{#if item.system.dropped}}({{localize
<a class="item-name detail grid-span-5">{{#if item.system.dropped}}({{localize
"KNAVE2E.Dropped"}})
{{/if}}{{item.name}}</div>
{{/if}}{{item.name}}</a>
<div class="item-buttons grid-span-3 flexrow flex-group-center">
<button class="item-button attack sheet" data-action="attack" type="button"
title={{localize "KNAVE2E.AttackRoll" }}>{{localize "KNAVE2E.AttackAbbr"}}</button>
Expand All @@ -165,18 +166,18 @@

{{else}}
{{#if (eq item.type "spellbook")}}
<div class="item-name detail grid-span-7">{{#if item.system.dropped}}({{localize
<a class="item-name detail grid-span-7">{{#if item.system.dropped}}({{localize
"KNAVE2E.Dropped"}})
{{/if}}{{item.name}}</div>
{{/if}}{{item.name}}</a>
<div class="item-buttons grid-span-1 flexrow flex-group-center">
<button class="item-button cast" data-action="cast" type="button">{{localize
"KNAVE2E.CastAbbr"}}</button>
</div>

{{else}}
<div class="item-name detail grid-span-8">{{#if item.system.dropped}}({{localize
<a class="item-name detail grid-span-8">{{#if item.system.dropped}}({{localize
"KNAVE2E.Dropped"}})
{{/if}}{{item.name}}</div>
{{/if}}{{item.name}}</a>
{{/if}}
{{/if}}

Expand All @@ -193,6 +194,12 @@
}}>
<i class="fas {{#if item.system.cast}}fa-book-open{{else}}fa-book{{/if}}"></i></a>
{{/if}}
{{#if (eq item.type "armor")}}
<a class="item-toggle" data-action="equip" title={{localize "KNAVE2E.EquipArmorDetail"
}}>
<i
class="{{#if item.system.equipped}}fas fa-shirt{{else}}far fa-shirt{{/if}}"></i></a>
{{/if}}
{{#if (eq item.type "lightSource")}}
<a class="item-toggle" data-action="light"
title={{localize "KNAVE2E.ActivateLightSourceDetail" }}>
Expand Down
18 changes: 11 additions & 7 deletions templates/actor/parts/actor-character-items.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
{{#each items as |item id|}}
<li class="item grid grid-12col {{#if system.dropped}}dropped{{/if}}" data-item-id="{{item._id}}">

<div class="item-image rollable"><a class="item-image rollable grid-span-1"><img src="{{item.img}}"
<div class="item-image"><a class="item-image item-name grid-span-1"><img src="{{item.img}}"
title="{{item.name}}" width="36" height="36" /></a></div>

{{#if (eq item.type "weapon")}}
<div class="item-name detail grid-span-5">{{#if item.system.dropped}}({{localize "KNAVE2E.Dropped"}})
{{/if}}{{item.name}}</div>
<a class="item-name detail grid-span-5">{{#if item.system.dropped}}({{localize "KNAVE2E.Dropped"}})
{{/if}}{{item.name}}</a>
<div class="item-buttons grid-span-3 flexrow flex-group-center">
<button class="item-button attack sheet" data-action="attack" type="button"
title={{localize "KNAVE2E.AttackRoll" }}>{{localize "KNAVE2E.AttackAbbr"}}</button>
Expand All @@ -61,16 +61,16 @@

{{else}}
{{#if (eq item.type "spellbook")}}
<div class="item-name detail grid-span-7">{{#if item.system.dropped}}({{localize "KNAVE2E.Dropped"}})
{{/if}}{{item.name}}</div>
<a class="item-name detail grid-span-7">{{#if item.system.dropped}}({{localize "KNAVE2E.Dropped"}})
{{/if}}{{item.name}}</a>
<div class="item-buttons grid-span-1 flexrow flex-group-center">
<button class="item-button cast" data-action="cast" type="button">{{localize
"KNAVE2E.CastAbbr"}}</button>
</div>

{{else}}
<div class="item-name detail grid-span-8">{{#if item.system.dropped}}({{localize "KNAVE2E.Dropped"}})
{{/if}}{{item.name}}</div>
<a class="item-name detail grid-span-8">{{#if item.system.dropped}}({{localize "KNAVE2E.Dropped"}})
{{/if}}{{item.name}}</a>
{{/if}}
{{/if}}

Expand All @@ -88,6 +88,10 @@
<a class="item-toggle" data-action="light" title={{localize "KNAVE2E.ActivateLightSourceDetail" }}>
<i class="{{#if item.system.lit}}fas fa-lightbulb{{else}}far fa-lightbulb{{/if}}"></i></a>
{{/if}}
{{#if (eq item.type "armor")}}
<a class="item-toggle" data-action="equip" title={{localize "KNAVE2E.EquipArmorDetail" }}>
<i class="{{#if item.system.equipped}}fas fa-shirt{{else}}far fa-shirt{{/if}}"></i></a>
{{/if}}
{{#if (eq item.system.relic.isRelic true)}}
<a class="item-toggle" data-action="blessing" title={{localize "KNAVE2E.ActiveBlessingDetail" }}>
<i class="{{#if item.system.relic.isActive}}fas fa-sun{{else}}fa-regular fa-sun{{/if}}"></i></a>
Expand Down
4 changes: 1 addition & 3 deletions templates/item/item-chat-message.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@
<h4 class="dice-total">{{rolls.[0].total}}</h4>
</div>
</div>
{{/if}}

{{log data}}
{{/if}}

0 comments on commit d458668

Please sign in to comment.