Skip to content

Commit

Permalink
Merge pull request #8 from diabeatz96/sin-sheet-icons-and-rolling
Browse files Browse the repository at this point in the history
Sin sheet icons and rolling
  • Loading branch information
diabeatz96 authored Aug 24, 2024
2 parents 4e8fec7 + e0e7688 commit a8a9a83
Show file tree
Hide file tree
Showing 23 changed files with 115 additions and 84 deletions.
72 changes: 43 additions & 29 deletions module/sheets/actor-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ export class CainActorSheet extends ActorSheet {
html.find('#editable-agenda-abilities').on('click', '.remove-ability-button', this._removeAbilityButton.bind(this));
html.find('#editable-agenda-items').on('change', '.editable-item-input', this._updateAgendaItem.bind(this));
html.find('#editable-agenda-abilities').on('change', '.editable-ability-input', this._updateAgendaAbility.bind(this));
html.find('.bold-item-button').click(this._boldItem.bind(this));
html.find('.agenda-to-chat').click(this._agendaToChat.bind(this));
/* NPC sheet specific listeners */
html.find('.attack-button').click(this._onNpcAttack.bind(this));
html.find('.severe-attack-button').click(this._onNpcSevereAttack.bind(this));
Expand All @@ -221,6 +223,27 @@ export class CainActorSheet extends ActorSheet {

}

_boldItem(event) {
event.preventDefault();
const index = event.currentTarget.getAttribute('data-index');
const textarea = document.querySelector(`.editable-item-input[data-index="${index}"]`);
textarea.style.fontWeight = textarea.style.fontWeight === 'bold' ? 'normal' : 'bold';
}

_agendaToChat(event) {
event.preventDefault();
const index = event.currentTarget.getAttribute('data-index');
const itemText = document.querySelector(`.editable-item-input[data-index="${index}"]`).value;
const message = `<p>${itemText}</p>`;
ChatMessage.create({
content: message,
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
});

}



_addAgendaItemButton(event) {
event.preventDefault();
const agendaItems = this.actor.system.currentAgendaItems || [];
Expand All @@ -241,7 +264,7 @@ _addAgendaAbilityButton(event) {

_removeItemButton(event) {
event.preventDefault();
const index = event.target.dataset.index;
const index = event.currentTarget.dataset.index;
const agendaItems = this.actor.system.currentAgendaItems || [];
agendaItems.splice(index, 1);
this.actor.update({ 'system.currentAgendaItems': agendaItems }).then(() => {
Expand All @@ -251,7 +274,7 @@ _removeItemButton(event) {

_removeAbilityButton(event) {
event.preventDefault();
const index = event.target.dataset.index;
const index = event.currentTarget.dataset.index;
const agendaAbilities = this.actor.system.currentAgendaAbilities || [];
agendaAbilities.splice(index, 1);
this.actor.update({ 'system.currentAgendaAbilities': agendaAbilities }).then(() => {
Expand Down Expand Up @@ -316,16 +339,16 @@ _updateAgendaAbility(event) {

_onRollButtonClick(event) {
const skill = document.querySelector('select[name="system.skill"]').value;

// Get the checkbox values
const useDivineAgony = document.querySelector('input[name="use-divine-agony"]').checked;
const teamwork = document.querySelector('input[name="teamwork"]').checked;
const setup = document.querySelector('input[name="setup"]').checked;
const hard = document.querySelector('input[name="hard"]').checked;

// Get the extra dice value
const extraDice = parseInt(document.querySelector('input[name="extra-dice"]').value) || 0;

// Perform the roll
this._performRoll(skill, useDivineAgony, teamwork, setup, hard, extraDice);
}
Expand All @@ -342,30 +365,19 @@ _updateAgendaAbility(event) {

let roll;
if (totalDice > 0) {
roll = new Roll(`${totalDice}d6`);
// Custom roll formula to count successes
roll = new Roll(`${totalDice}d6cs>=${hard ? 6 : 4}`);
} else {
roll = new Roll(`2d6`);
roll = new Roll(`2d6cs>=${hard ? 6 : 4}kl`);
}
await roll.evaluate({ async: true });

let rollResult;
if (totalDice > 0) {
rollResult = roll.dice[0].results.reduce((acc, r) => acc + r.result, 0);
} else {
rollResult = Math.min(...roll.dice[0].results.map(r => r.result));
}

let successes;
if (totalDice > 0) {
successes = roll.dice[0].results.filter(r => hard ? r.result === 6 : r.result >= 4).length;
} else {
successes = rollResult >= 4 ? 1 : 0;
}

// Calculate successes
let successes = roll.total;

if(successes === 0 && this.actor.system.divineAgony.value < 3) {
this.actor.update({'system.divineAgony.value' : this.actor.system.divineAgony.value + 1});
}


let message = `<h2>${skill.charAt(0).toUpperCase() + skill.slice(1)} Roll</h2>`;
message += `<p>Successes: <span style="color:${successes > 0 ? 'green' : 'red'}">${successes}</span></p>`;
Expand All @@ -377,8 +389,9 @@ _updateAgendaAbility(event) {

console.log(`Successes: ${successes}`);

ChatMessage.create({
content: message,
// Create the chat message using roll.toMessage() to ensure the roll noise is played
roll.toMessage({
flavor: message,
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
});
}
Expand Down Expand Up @@ -464,15 +477,15 @@ _updateAgendaAbility(event) {

let roll;
if (totalDice > 0) {
roll = new Roll(`${totalDice}d6`);
roll = new Roll(`${totalDice}d6cs>=${hardRoll ? 6 : 4}`);
} else {
roll = new Roll(`2d6`);
roll = new Roll(`2d6cs>=${hardRoll ? 6 : 4}`);
}
await roll.evaluate({ async: true });

console.log(roll.dice[0].results);

let successes = roll.dice[0].results.filter(r => hardRoll ? r.result === 6 : r.result >= 4).length;
let successes = roll.total;

let message = `<h2>Psyche Roll</h2>`;
message += `<p>Successes: <span style="color:${successes > 0 ? 'green' : 'red'}">${successes}</span></p>`;
Expand All @@ -484,8 +497,9 @@ _updateAgendaAbility(event) {

console.log(`Successes: ${successes}`);

ChatMessage.create({
content: message,
// Create the chat message using roll.toMessage() to ensure the roll noise is played
roll.toMessage({
flavor: message,
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
});
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/agenda/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000044
MANIFEST-000048
6 changes: 3 additions & 3 deletions packs/agenda/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/08/22-14:23:00.261627 ffff8efdf120 Recovering log #42
2024/08/22-14:23:00.294353 ffff8efdf120 Delete type=3 #40
2024/08/22-14:23:00.294705 ffff8efdf120 Delete type=0 #42
2024/08/24-08:51:07.214048 ffff8dfbf120 Recovering log #46
2024/08/24-08:51:07.243260 ffff8dfbf120 Delete type=3 #44
2024/08/24-08:51:07.243610 ffff8dfbf120 Delete type=0 #46
16 changes: 8 additions & 8 deletions packs/agenda/LOG.old
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
2024/08/22-13:55:21.885699 ffff8e7cf120 Recovering log #40
2024/08/22-13:55:21.922007 ffff8e7cf120 Delete type=3 #38
2024/08/22-13:55:21.922408 ffff8e7cf120 Delete type=0 #40
2024/08/22-14:22:05.610389 ffff8d7af120 Level-0 table #43: started
2024/08/22-14:22:05.611175 ffff8d7af120 Level-0 table #43: 0 bytes OK
2024/08/22-14:22:05.619647 ffff8d7af120 Delete type=0 #41
2024/08/22-14:22:05.620021 ffff8d7af120 Manual compaction at level-0 from '!items!1PnBSz1PZVcYKaWa' @ 72057594037927935 : 1 .. '!items!umnOFhEQgDzG2eaF' @ 0 : 0; will stop at (end)
2024/08/22-14:22:05.620219 ffff8d7af120 Manual compaction at level-1 from '!items!1PnBSz1PZVcYKaWa' @ 72057594037927935 : 1 .. '!items!umnOFhEQgDzG2eaF' @ 0 : 0; will stop at (end)
2024/08/22-14:23:00.261627 ffff8efdf120 Recovering log #42
2024/08/22-14:23:00.294353 ffff8efdf120 Delete type=3 #40
2024/08/22-14:23:00.294705 ffff8efdf120 Delete type=0 #42
2024/08/24-08:49:59.103616 ffff8d7af120 Level-0 table #47: started
2024/08/24-08:49:59.103749 ffff8d7af120 Level-0 table #47: 0 bytes OK
2024/08/24-08:49:59.114205 ffff8d7af120 Delete type=0 #45
2024/08/24-08:49:59.141347 ffff8d7af120 Manual compaction at level-0 from '!items!1PnBSz1PZVcYKaWa' @ 72057594037927935 : 1 .. '!items!umnOFhEQgDzG2eaF' @ 0 : 0; will stop at (end)
2024/08/24-08:49:59.141675 ffff8d7af120 Manual compaction at level-1 from '!items!1PnBSz1PZVcYKaWa' @ 72057594037927935 : 1 .. '!items!umnOFhEQgDzG2eaF' @ 0 : 0; will stop at (end)
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/blasphemy/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000044
MANIFEST-000048
6 changes: 3 additions & 3 deletions packs/blasphemy/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/08/22-14:23:00.310408 ffff8dfbf120 Recovering log #42
2024/08/22-14:23:00.340930 ffff8dfbf120 Delete type=3 #40
2024/08/22-14:23:00.341276 ffff8dfbf120 Delete type=0 #42
2024/08/24-08:51:07.256959 ffff8e7cf120 Recovering log #46
2024/08/24-08:51:07.291362 ffff8e7cf120 Delete type=3 #44
2024/08/24-08:51:07.291701 ffff8e7cf120 Delete type=0 #46
16 changes: 8 additions & 8 deletions packs/blasphemy/LOG.old
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
2024/08/22-13:55:21.935408 ffff8f7ef120 Recovering log #40
2024/08/22-13:55:21.966001 ffff8f7ef120 Delete type=3 #38
2024/08/22-13:55:21.966379 ffff8f7ef120 Delete type=0 #40
2024/08/22-14:22:05.592274 ffff8d7af120 Level-0 table #43: started
2024/08/22-14:22:05.592978 ffff8d7af120 Level-0 table #43: 0 bytes OK
2024/08/22-14:22:05.600987 ffff8d7af120 Delete type=0 #41
2024/08/22-14:22:05.619944 ffff8d7af120 Manual compaction at level-0 from '!folders!FWZZgy9tnHSHa9tk' @ 72057594037927935 : 1 .. '!items!yotw9uAVluGmTHO4' @ 0 : 0; will stop at (end)
2024/08/22-14:22:05.620152 ffff8d7af120 Manual compaction at level-1 from '!folders!FWZZgy9tnHSHa9tk' @ 72057594037927935 : 1 .. '!items!yotw9uAVluGmTHO4' @ 0 : 0; will stop at (end)
2024/08/22-14:23:00.310408 ffff8dfbf120 Recovering log #42
2024/08/22-14:23:00.340930 ffff8dfbf120 Delete type=3 #40
2024/08/22-14:23:00.341276 ffff8dfbf120 Delete type=0 #42
2024/08/24-08:49:59.133212 ffff8d7af120 Level-0 table #47: started
2024/08/24-08:49:59.133408 ffff8d7af120 Level-0 table #47: 0 bytes OK
2024/08/24-08:49:59.141017 ffff8d7af120 Delete type=0 #45
2024/08/24-08:49:59.141601 ffff8d7af120 Manual compaction at level-0 from '!folders!FWZZgy9tnHSHa9tk' @ 72057594037927935 : 1 .. '!items!yotw9uAVluGmTHO4' @ 0 : 0; will stop at (end)
2024/08/24-08:49:59.142358 ffff8d7af120 Manual compaction at level-1 from '!folders!FWZZgy9tnHSHa9tk' @ 72057594037927935 : 1 .. '!items!yotw9uAVluGmTHO4' @ 0 : 0; will stop at (end)
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/items/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000045
MANIFEST-000049
6 changes: 3 additions & 3 deletions packs/items/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/08/22-14:23:00.215323 ffff8e7cf120 Recovering log #43
2024/08/22-14:23:00.246432 ffff8e7cf120 Delete type=0 #43
2024/08/22-14:23:00.246745 ffff8e7cf120 Delete type=3 #41
2024/08/24-08:51:07.171446 ffff8efdf120 Recovering log #47
2024/08/24-08:51:07.201005 ffff8efdf120 Delete type=3 #45
2024/08/24-08:51:07.201373 ffff8efdf120 Delete type=0 #47
16 changes: 8 additions & 8 deletions packs/items/LOG.old
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
2024/08/22-13:55:21.824330 ffff8efdf120 Recovering log #41
2024/08/22-13:55:21.871578 ffff8efdf120 Delete type=3 #39
2024/08/22-13:55:21.871913 ffff8efdf120 Delete type=0 #41
2024/08/22-14:22:05.568802 ffff8d7af120 Level-0 table #44: started
2024/08/22-14:22:05.581881 ffff8d7af120 Level-0 table #44: 0 bytes OK
2024/08/22-14:22:05.591150 ffff8d7af120 Delete type=0 #42
2024/08/22-14:22:05.619884 ffff8d7af120 Manual compaction at level-0 from '!folders!DYa1yCl9CNfOahIN' @ 72057594037927935 : 1 .. '!items!zUOSvdFDFvXZqROE' @ 0 : 0; will stop at (end)
2024/08/22-14:22:05.620111 ffff8d7af120 Manual compaction at level-1 from '!folders!DYa1yCl9CNfOahIN' @ 72057594037927935 : 1 .. '!items!zUOSvdFDFvXZqROE' @ 0 : 0; will stop at (end)
2024/08/22-14:23:00.215323 ffff8e7cf120 Recovering log #43
2024/08/22-14:23:00.246432 ffff8e7cf120 Delete type=0 #43
2024/08/22-14:23:00.246745 ffff8e7cf120 Delete type=3 #41
2024/08/24-08:49:59.114466 ffff8d7af120 Level-0 table #48: started
2024/08/24-08:49:59.114595 ffff8d7af120 Level-0 table #48: 0 bytes OK
2024/08/24-08:49:59.123410 ffff8d7af120 Delete type=0 #46
2024/08/24-08:49:59.141442 ffff8d7af120 Manual compaction at level-0 from '!folders!DYa1yCl9CNfOahIN' @ 72057594037927935 : 1 .. '!items!zUOSvdFDFvXZqROE' @ 0 : 0; will stop at (end)
2024/08/24-08:49:59.141738 ffff8d7af120 Manual compaction at level-1 from '!folders!DYa1yCl9CNfOahIN' @ 72057594037927935 : 1 .. '!items!zUOSvdFDFvXZqROE' @ 0 : 0; will stop at (end)
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/tables/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-000044
MANIFEST-000048
6 changes: 3 additions & 3 deletions packs/tables/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/08/22-14:23:00.355214 ffff8f7ef120 Recovering log #42
2024/08/22-14:23:00.391396 ffff8f7ef120 Delete type=3 #40
2024/08/22-14:23:00.391736 ffff8f7ef120 Delete type=0 #42
2024/08/24-08:51:07.306606 ffff8f7ef120 Recovering log #46
2024/08/24-08:51:07.335868 ffff8f7ef120 Delete type=3 #44
2024/08/24-08:51:07.336239 ffff8f7ef120 Delete type=0 #46
16 changes: 8 additions & 8 deletions packs/tables/LOG.old
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
2024/08/22-13:55:21.982035 ffff8dfbf120 Recovering log #40
2024/08/22-13:55:22.016261 ffff8dfbf120 Delete type=3 #38
2024/08/22-13:55:22.016754 ffff8dfbf120 Delete type=0 #40
2024/08/22-14:22:05.621297 ffff8d7af120 Level-0 table #43: started
2024/08/22-14:22:05.622083 ffff8d7af120 Level-0 table #43: 0 bytes OK
2024/08/22-14:22:05.635545 ffff8d7af120 Delete type=0 #41
2024/08/22-14:22:05.670457 ffff8d7af120 Manual compaction at level-0 from '!tables!XY3o3oqawjUe6Wba' @ 72057594037927935 : 1 .. '!tables.results!z9VPZiT6MhJzjO6v.vwR7xQw1HrRWhrQn' @ 0 : 0; will stop at (end)
2024/08/22-14:22:05.671941 ffff8d7af120 Manual compaction at level-1 from '!tables!XY3o3oqawjUe6Wba' @ 72057594037927935 : 1 .. '!tables.results!z9VPZiT6MhJzjO6v.vwR7xQw1HrRWhrQn' @ 0 : 0; will stop at (end)
2024/08/22-14:23:00.355214 ffff8f7ef120 Recovering log #42
2024/08/22-14:23:00.391396 ffff8f7ef120 Delete type=3 #40
2024/08/22-14:23:00.391736 ffff8f7ef120 Delete type=0 #42
2024/08/24-08:49:59.123767 ffff8d7af120 Level-0 table #47: started
2024/08/24-08:49:59.123992 ffff8d7af120 Level-0 table #47: 0 bytes OK
2024/08/24-08:49:59.132811 ffff8d7af120 Delete type=0 #45
2024/08/24-08:49:59.141525 ffff8d7af120 Manual compaction at level-0 from '!tables!XY3o3oqawjUe6Wba' @ 72057594037927935 : 1 .. '!tables.results!z9VPZiT6MhJzjO6v.vwR7xQw1HrRWhrQn' @ 0 : 0; will stop at (end)
2024/08/24-08:49:59.141821 ffff8d7af120 Manual compaction at level-1 from '!tables!XY3o3oqawjUe6Wba' @ 72057594037927935 : 1 .. '!tables.results!z9VPZiT6MhJzjO6v.vwR7xQw1HrRWhrQn' @ 0 : 0; will stop at (end)
Binary file not shown.
2 changes: 1 addition & 1 deletion system.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"thumbnail": "systems/cain/assets/cain.png"
}
],
"version": "1.0.13",
"version": "1.0.15",
"compatibility": {
"minimum": 11,
"verified": "12"
Expand Down
29 changes: 23 additions & 6 deletions templates/actor/parts/actor-abilities.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@
{{#each actor.system.currentAgendaItems as |item index|}}
<li class='item flexrow'>
<textarea class="editable-item-input" data-index="{{index}}">{{item}}</textarea>
<button type="button" class="remove-item-button" data-index="{{index}}">Remove</button>
<div class="item-controls">
<a class="item-control agenda-to-chat" data-index="{{index}}" title="Send to Chat">
<i class="fas fa-comment"></i>
</a>
<a class="item-control bold-item-button" data-index="{{index}}" title="Bold Text">
<i class="fas fa-bold"></i>
</a>
<a class="item-control remove-item-button " data-index="{{index}}" title="Remove">
<i class="fas fa-trash"></i>
</a>
</div>
</li>
{{/each}}
</ul>
Expand All @@ -56,7 +66,17 @@
{{#each actor.system.currentAgendaAbilities as |ability index|}}
<li class='item flexrow'>
<textarea class="editable-ability-input" data-index="{{index}}">{{ability}}</textarea>
<button type="button" class="remove-ability-button" data-index="{{index}}">Remove</button>
<div class="item-controls">
<a class="item-control agenda-to-chat" data-index="{{index}}" title="Send to Chat">
<i class="fas fa-comment"></i>
</a>
<a class="item-control bold-item-button" data-index="{{index}}" title="Bold Text">
<i class="fas fa-bold"></i>
</a>
<a class="item-control remove-ability-button " data-index="{{index}}" title="Remove">
<i class="fas fa-trash"></i>
</a>
</div>
</li>
{{/each}}
</ul>
Expand Down Expand Up @@ -336,6 +356,7 @@
background-color: #333;
color: #e0e0e0;
border-radius: 4px;
margin-bottom: 5px;
font-size: 12px; /* Smaller font size */
width: 100%; /* Make the text areas wider */
resize: vertical; /* Allow vertical resizing */
Expand All @@ -355,10 +376,6 @@
background-color: #444;
}
.abilities-page .remove-item-button {
width: 50%;
}
.abilities-page .create-agenda-button {
background-color: #1a1a1a;
color: #e0e0e0;
Expand Down

0 comments on commit a8a9a83

Please sign in to comment.