From 0fd213742bbf840794183491c44f2d2119167e52 Mon Sep 17 00:00:00 2001 From: Adam Kostandy Date: Sun, 6 Oct 2024 13:42:36 -0400 Subject: [PATCH 1/2] Added in changes to sinoverflow to work correctly now. --- module/data/actor-character.mjs | 6 +-- module/sheets/actor-sheet.mjs | 31 +++++++++++++++- templates/actor/parts/actor-sin.hbs | 57 +++++++++++++++++++++++++++-- 3 files changed, 86 insertions(+), 8 deletions(-) diff --git a/module/data/actor-character.mjs b/module/data/actor-character.mjs index e61a464..8f7c647 100644 --- a/module/data/actor-character.mjs +++ b/module/data/actor-character.mjs @@ -81,9 +81,9 @@ export default class CainCharacter extends CainActorBase { schema.currentSinMarks = new fields.ArrayField(new fields.StringField({ required: true, initial: " " }), { required: true, initial: [] }); schema.sinOverflow = new fields.SchemaField({ - value: new fields.NumberField({ required: true, initial: 0, min: 0, max: 10 }), - max: new fields.NumberField({ required: true, initial: 10, min: 0, max: 10 }), - min : new fields.NumberField({ required: true, initial: 0, min: 0, max: 10 }), + value: new fields.NumberField({ required: true, initial: 0, min: 0, max: 20 }), + max: new fields.NumberField({ required: true, initial: 10, min: 0, max: 20 }), + min : new fields.NumberField({ required: true, initial: 0, min: 0, max: 20 }), }); schema.kitPoints = new fields.SchemaField({ diff --git a/module/sheets/actor-sheet.mjs b/module/sheets/actor-sheet.mjs index 548c7a4..0e62e6d 100644 --- a/module/sheets/actor-sheet.mjs +++ b/module/sheets/actor-sheet.mjs @@ -308,6 +308,29 @@ export class CainActorSheet extends ActorSheet { } }); + // Event listener for increasing sinOverflow max + html.find('.sin-overflow-increase').click(ev => { + ev.preventDefault(); + const actor = this.actor; + const newMax = Math.min(actor.system.sinOverflow.max + 1, 20); + actor.update({ 'system.sinOverflow.max': newMax }); + }); + + // Event listener for decreasing sinOverflow max + html.find('.sin-overflow-decrease').click(ev => { + ev.preventDefault(); + const actor = this.actor; + const newMax = actor.system.sinOverflow.max - 1; + if (newMax >= actor.system.sinOverflow.min) { + const updates = { 'system.sinOverflow.max': newMax }; + if (newMax < actor.system.sinOverflow.value) { + updates['system.sinOverflow.value'] = newMax; + } + actor.update(updates); + } + }); + + let scHtml = new HTMLShortcut(html); // Character sheet specific listeners @@ -475,7 +498,7 @@ export class CainActorSheet extends ActorSheet { // Event listener for selectedAgenda html.find('#selectedAgenda').change(this._onAbilitySelect.bind(this)); - html.find('.rollable[data-roll="1d3"]').click(async () => { + html.find('.roll-sin').click(async () => { const actor = this.actor; await this._rollSinOverflow(actor); }); @@ -487,6 +510,12 @@ export class CainActorSheet extends ActorSheet { const roll = await new Roll('1d3').roll(); const rolledValue = roll.total; + // Send roll result to chat + roll.toMessage({ + speaker: ChatMessage.getSpeaker({ actor: actor }), + flavor: "Sin Overflow Roll" + }); + // Get current sinOverflow value and max const currentSinOverflow = actor.system.sinOverflow.value; const maxSinOverflow = actor.system.sinOverflow.max; diff --git a/templates/actor/parts/actor-sin.hbs b/templates/actor/parts/actor-sin.hbs index 410cf32..11336fd 100644 --- a/templates/actor/parts/actor-sin.hbs +++ b/templates/actor/parts/actor-sin.hbs @@ -22,8 +22,7 @@

{{system.sinOverflow.value}} / {{system.sinOverflow.max}}

-
- - + +
+ +
+

Sin Marks

@@ -163,4 +165,51 @@ border-radius: 8px; padding: 15px; } + +.sin-overflow-controls { + display: flex; + flex-direction: column; + align-items: center; +} + +#sinOverflow-checkboxes { + display: flex; + flex-wrap: wrap; + justify-content: center; + margin-top: 10px; +} + +.sinOverflow-icon { + margin: 2px; +} + +.sin-overflow-decrease, +.sin-overflow-increase { + background-color: #cc33ff; + border: 2px solid #660066; + border-radius: 8px; + color: white; + font-size: 16px; + width: 30px; + height: 30px; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + margin: 0 5px; + transition: background-color 0.3s, transform 0.3s; +} + +.sin-overflow-decrease:hover, +.sin-overflow-increase:hover { + background-color: #a329cc; + transform: scale(1.1); +} + +.sin-overflow-decrease:active, +.sin-overflow-increase:active { + background-color: #801999; + transform: scale(0.9); +} + \ No newline at end of file From 7c2fdfda96a05fecf4695334184e3f0e177cc970 Mon Sep 17 00:00:00 2001 From: Adam Kostandy Date: Sun, 6 Oct 2024 13:44:23 -0400 Subject: [PATCH 2/2] updated system json --- system.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system.json b/system.json index e20af3b..c90fca9 100644 --- a/system.json +++ b/system.json @@ -20,7 +20,7 @@ "thumbnail": "systems/cain/assets/cain.png" } ], - "version": "1.1.6", + "version": "1.1.7", "compatibility": { "minimum": 11, "verified": "12"