From 7e4046bc7ac76c9c91a903767f69af385a50f83b Mon Sep 17 00:00:00 2001 From: agaringer Date: Sat, 30 Oct 2021 12:19:42 -0400 Subject: [PATCH] v1.14.0 release --- CHANGELOG.txt | 2 ++ module/sav-helpers.js | 27 ++++++++++++++++++++++++++- module/sav-ship-sheet.js | 26 ++++++++++++++++++++++++++ styles/sav.css | 18 ++++++++++++++++++ system.json | 4 ++-- 5 files changed, 74 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 689e8bd..07e8968 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -137,3 +137,5 @@ v1.9.4 Fix Trauma tooltip z-indexing 1.13.1 Clean up Universe sheet 1.13.2 Updates for V9d1, simplified NPC sheet, remove item logic fields and functions + +1.14.0 Adds chat notifications for changes to Ship resources diff --git a/module/sav-helpers.js b/module/sav-helpers.js index 07707ee..a764699 100644 --- a/module/sav-helpers.js +++ b/module/sav-helpers.js @@ -34,7 +34,7 @@ export class SaVHelpers { static async addDefaultAbilities(item_data, actor) { let def_abilities = item_data.data.def_abilities || {}; - + let abil_list = def_abilities.split(', '); let item_type = ""; let items_to_add = []; @@ -226,5 +226,30 @@ export class SaVHelpers { } + /* -------------------------------------------- */ + + /** + * Creates a chat notification on a resource change + * + * @param {string} actor + * actor on which change occurred + * @param {string} resource + * localized resource name + * @param {int} oldValue + * original resource value + * @param {int} newValue + * new resource value + */ + static chatNotify( actor, resource, oldValue, newValue ) { + let change; + if ( newValue > oldValue ) { + change = '+' + String (newValue - oldValue); + } else { + change = String (newValue - oldValue); + } + let color = newValue >= oldValue ? 'green' : 'red' + let message = `
${actor}
${resource}${oldValue}${newValue}(${change})
`; + ChatMessage.create({content: message}); + } } diff --git a/module/sav-ship-sheet.js b/module/sav-ship-sheet.js index 4219473..9102dde 100644 --- a/module/sav-ship-sheet.js +++ b/module/sav-ship-sheet.js @@ -88,6 +88,32 @@ export class SaVShipSheet extends SaVSheet { item?.sheet.render(true, {"renderContext": "xp"}); }); + html.find('.coins').click(ev => { + let actor = this.actor.name; + let newValue = ev.target.value; + let oldValue, resource; + switch( ev.target.name ) { + case "data.coins": { + resource = game.i18n.localize("BITD.Coin"); + oldValue = this.actor.data.data.coins; + break; + } + case "data.debt": { + resource = game.i18n.localize("BITD.Debt"); + oldValue = this.actor.data.data.debt; + break; + } + case "data.gambits.value": { + resource = game.i18n.localize("BITD.Gambits"); + oldValue = this.actor.data.data.gambits.value; + break; + } + } + if ( resource !== undefined ) { + SaVHelpers.chatNotify(actor, resource, oldValue, newValue); + } + }) + // manage active effects html.find(".effect-control").click(ev => onManageActiveEffect(ev, this.actor)); } diff --git a/styles/sav.css b/styles/sav.css index d7cb7b8..3b80e18 100644 --- a/styles/sav.css +++ b/styles/sav.css @@ -83,6 +83,24 @@ color: var(--almost_white); background-size: 24px 24px; } +.resource-chat-notification table tr td.value { + font-weight: bold; + width: 25px; + text-align: center; +} +.resource-chat-notification table tr td.arrow { + width: 20px; + text-align: center; +} +.resource-chat-notification table tr td .small { + font-size: 10px; +} +.resource-chat-notification table tr td .green { + color: green; +} +.resource-chat-notification table tr td .red { + color: red; +} * .dialog-buttons { margin-top: 5px; } diff --git a/system.json b/system.json index 7a509b9..1d599a3 100644 --- a/system.json +++ b/system.json @@ -5,14 +5,14 @@ "authors": ["megastruktur", "Andrew Garinger [agaringer#6498]"], "url": "https://github.com/drewg13/foundryvtt-scum-and-villainy/", "flags": {}, - "version": "1.13.2", + "version": "1.14.0", "minimumCoreVersion": "0.7.9", "compatibleCoreVersion": "9.226", "system": [], "dependencies": [], "socket": false, "manifest": "https://raw.githubusercontent.com/drewg13/foundryvtt-scum-and-villainy/master/system.json", - "download": "https://github.com/drewg13/foundryvtt-scum-and-villainy/archive/v1.13.2.zip", + "download": "https://github.com/drewg13/foundryvtt-scum-and-villainy/archive/v1.14.0.zip", "protected": false, "scripts": [], "esmodules": [