From fa7d3ecfcadc7ea78412a5da7008e33615115fc4 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Wed, 8 Jan 2025 12:46:36 +0100 Subject: [PATCH] Add resources management --- css/fvtt-cthulhu-eternal.css | 100 +++++++++++++++------------- lang/en.json | 16 +++++ module/config/system.mjs | 25 +++++++ module/models/protagonist.mjs | 28 +++++++- packs/skills/000030.log | 0 packs/skills/CURRENT | 2 +- packs/skills/LOG | 2 +- packs/skills/LOG.old | 2 +- packs/skills/MANIFEST-000028 | 3 + styles/mixins.less | 10 +-- styles/protagonist.less | 9 +++ templates/protagonist-biography.hbs | 19 +++++- templates/skill.hbs | 5 +- 13 files changed, 162 insertions(+), 59 deletions(-) create mode 100644 packs/skills/000030.log create mode 100644 packs/skills/MANIFEST-000028 diff --git a/css/fvtt-cthulhu-eternal.css b/css/fvtt-cthulhu-eternal.css index 44a1468..11226d6 100644 --- a/css/fvtt-cthulhu-eternal.css +++ b/css/fvtt-cthulhu-eternal.css @@ -176,10 +176,10 @@ i.fvtt-cthulhu-eternal { } .fvtt-cthulhu-eternal .protagonist-sheet-common label { font-family: var(--font-secondary); - font-size: calc(var(--font-size-standard) * 1.2); + font-size: calc(var(--font-size-standard) * 1); } .fvtt-cthulhu-eternal .item-sheet-common .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .item-sheet-common label { font-family: var(--font-secondary); @@ -220,7 +220,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .protagonist-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -228,8 +228,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .protagonist-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .protagonist-content .form-fields input, .fvtt-cthulhu-eternal .protagonist-content .form-fields select { @@ -248,7 +248,7 @@ i.fvtt-cthulhu-eternal { } .fvtt-cthulhu-eternal .protagonist-content label { font-family: var(--font-secondary); - font-size: calc(var(--font-size-standard) * 1.2); + font-size: calc(var(--font-size-standard) * 1); } .fvtt-cthulhu-eternal .sheet-tabs { background-color: var(--color-light-1); @@ -477,6 +477,14 @@ i.fvtt-cthulhu-eternal { .fvtt-cthulhu-eternal .protagonist-biography .adapted label { min-width: 20rem; } +.fvtt-cthulhu-eternal .protagonist-biography .resources { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 8px; +} +.fvtt-cthulhu-eternal .protagonist-biography .resources label { + min-width: 12rem; +} .fvtt-cthulhu-eternal .protagonist-biography .features, .fvtt-cthulhu-eternal .protagonist-biography .biodata { display: grid; @@ -789,7 +797,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .skill-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -797,8 +805,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .skill-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .skill-content .form-fields input, .fvtt-cthulhu-eternal .skill-content .form-fields select { @@ -816,7 +824,7 @@ i.fvtt-cthulhu-eternal { letter-spacing: 1px; } .fvtt-cthulhu-eternal .skill-content .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .skill-content label { font-family: var(--font-secondary); @@ -879,7 +887,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .injury-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -887,8 +895,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .injury-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .injury-content .form-fields input, .fvtt-cthulhu-eternal .injury-content .form-fields select { @@ -906,7 +914,7 @@ i.fvtt-cthulhu-eternal { letter-spacing: 1px; } .fvtt-cthulhu-eternal .injury-content .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .injury-content label { font-family: var(--font-secondary); @@ -969,7 +977,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .weapon-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -977,8 +985,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .weapon-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .weapon-content .form-fields input, .fvtt-cthulhu-eternal .weapon-content .form-fields select { @@ -996,7 +1004,7 @@ i.fvtt-cthulhu-eternal { letter-spacing: 1px; } .fvtt-cthulhu-eternal .weapon-content .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .weapon-content label { font-family: var(--font-secondary); @@ -1051,7 +1059,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .armor-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -1059,8 +1067,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .armor-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .armor-content .form-fields input, .fvtt-cthulhu-eternal .armor-content .form-fields select { @@ -1078,7 +1086,7 @@ i.fvtt-cthulhu-eternal { letter-spacing: 1px; } .fvtt-cthulhu-eternal .armor-content .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .armor-content label { font-family: var(--font-secondary); @@ -1133,7 +1141,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .motivation-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -1141,8 +1149,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .motivation-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .motivation-content .form-fields input, .fvtt-cthulhu-eternal .motivation-content .form-fields select { @@ -1160,7 +1168,7 @@ i.fvtt-cthulhu-eternal { letter-spacing: 1px; } .fvtt-cthulhu-eternal .motivation-content .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .motivation-content label { font-family: var(--font-secondary); @@ -1215,7 +1223,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .mentaldisorder-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -1223,8 +1231,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .mentaldisorder-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .mentaldisorder-content .form-fields input, .fvtt-cthulhu-eternal .mentaldisorder-content .form-fields select { @@ -1242,7 +1250,7 @@ i.fvtt-cthulhu-eternal { letter-spacing: 1px; } .fvtt-cthulhu-eternal .mentaldisorder-content .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .mentaldisorder-content label { font-family: var(--font-secondary); @@ -1297,7 +1305,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .bond-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -1305,8 +1313,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .bond-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .bond-content .form-fields input, .fvtt-cthulhu-eternal .bond-content .form-fields select { @@ -1324,7 +1332,7 @@ i.fvtt-cthulhu-eternal { letter-spacing: 1px; } .fvtt-cthulhu-eternal .bond-content .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .bond-content label { font-family: var(--font-secondary); @@ -1395,7 +1403,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .gear-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -1403,8 +1411,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .gear-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .gear-content .form-fields input, .fvtt-cthulhu-eternal .gear-content .form-fields select { @@ -1422,7 +1430,7 @@ i.fvtt-cthulhu-eternal { letter-spacing: 1px; } .fvtt-cthulhu-eternal .gear-content .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .gear-content label { font-family: var(--font-secondary); @@ -1477,7 +1485,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .arcane-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -1485,8 +1493,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .arcane-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .arcane-content .form-fields input, .fvtt-cthulhu-eternal .arcane-content .form-fields select { @@ -1504,7 +1512,7 @@ i.fvtt-cthulhu-eternal { letter-spacing: 1px; } .fvtt-cthulhu-eternal .arcane-content .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .arcane-content label { font-family: var(--font-secondary); @@ -1559,7 +1567,7 @@ i.fvtt-cthulhu-eternal { color: var(--color-dark-2); } .fvtt-cthulhu-eternal .archetype-content input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -1567,8 +1575,8 @@ i.fvtt-cthulhu-eternal { border: none; } .fvtt-cthulhu-eternal .archetype-content fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .fvtt-cthulhu-eternal .archetype-content .form-fields input, .fvtt-cthulhu-eternal .archetype-content .form-fields select { @@ -1586,7 +1594,7 @@ i.fvtt-cthulhu-eternal { letter-spacing: 1px; } .fvtt-cthulhu-eternal .archetype-content .form-fields { - padding-top: 5px; + padding-top: 4px; } .fvtt-cthulhu-eternal .archetype-content label { font-family: var(--font-secondary); diff --git a/lang/en.json b/lang/en.json index 496f9f1..f8b9610 100644 --- a/lang/en.json +++ b/lang/en.json @@ -34,6 +34,20 @@ }, "Protagonist": { "FIELDS": { + "resources": { + "permanentRating": { + "label": "Permanent Rating" + }, + "hand": { + "label": "Hand" + }, + "stowed": { + "label": "Stowed" + }, + "storage": { + "label": "Storage" + } + }, "biodata": { "feature": { "label": "Feature" @@ -274,6 +288,8 @@ "veryHarsh": "Very Harsh" }, "Label": { + "resources": "Resources", + "resourceChecks": "Resource Checks", "sanBPShort": "BP", "tempInsanity": "Temp. Insanity", "distinguishingFeatures": "Distinguishing Features", diff --git a/module/config/system.mjs b/module/config/system.mjs index 939c1d9..9d47c41 100644 --- a/module/config/system.mjs +++ b/module/config/system.mjs @@ -89,6 +89,30 @@ export const RESOURCE_RATING = { } } +export const RESOURCE_BREAKDOWN = [ + { value: 0, hand: 0, stowed: 0, storage: 0, checks: 0}, + { value: 1, hand: 1, stowed: 0, storage: 0, checks: 1}, + { value: 2, hand: 2, stowed: 0, storage: 0, checks: 1}, + { value: 3, hand: 3, stowed: 0, storage: 0, checks: 1}, + { value: 4, hand: 4, stowed: 0, storage: 0, checks: 1}, + { value: 5, hand: 5, stowed: 0, storage: 0, checks: 1}, + { value: 6, hand: 6, stowed: 0, storage: 0, checks: 1}, + { value: 7, hand: 6, stowed: 1, storage: 0, checks: 2}, + { value: 8, hand: 6, stowed: 2, storage: 0, checks: 2}, + { value: 9, hand: 6, stowed: 3, storage: 0, checks: 2}, + { value: 10, hand: 6, stowed: 4, storage: 0, checks: 2}, + { value: 11, hand: 6, stowed: 5, storage: 0, checks: 2}, + { value: 12, hand: 6, stowed: 6, storage: 0, checks: 2}, + { value: 13, hand: 6, stowed: 6, storage: 1, checks: 3}, + { value: 14, hand: 6, stowed: 6, storage: 2, checks: 3}, + { value: 15, hand: 6, stowed: 6, storage: 3, checks: 3}, + { value: 16, hand: 6, stowed: 6, storage: 4, checks: 3}, + { value: 17, hand: 6, stowed: 6, storage: 5, checks: 3}, + { value: 18, hand: 6, stowed: 6, storage: 6, checks: 3}, + { value: 19, hand: 6, stowed: 6, storage: 7, checks: 3}, + { value: 20, hand: 6, stowed: 6, storage: 8, checks: 3} +] + export const MENTAL_ILLNESS_CURE_SKILL = { jazz: "CTHULHUETERNAL.Skill.Psychoanalyze", modern: "CTHULHUETERNAL.Skill.Psychoanalyze", @@ -189,5 +213,6 @@ export const SYSTEM = { MENTAL_ILLNESS_CURE_SKILL, ERA_CSS, INSANITY, + RESOURCE_BREAKDOWN, ASCII } diff --git a/module/models/protagonist.mjs b/module/models/protagonist.mjs index ab7542f..eef6282 100644 --- a/module/models/protagonist.mjs +++ b/module/models/protagonist.mjs @@ -51,10 +51,16 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData schema.damageBonus = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }) schema.resources = new fields.SchemaField({ - value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), + value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), // Unused but kept for compatibility + permanentRating: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), hand: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), + currentHand: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), stowed: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), - storage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }) + currentStowed: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), + storage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), + currentStorage: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }), + checks: new fields.ArrayField(new fields.BooleanField(), { required: true, initial: [false, false, false], min:3, max:3 }), + nbValidChecks: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }) }) schema.biodata = new fields.SchemaField({ @@ -140,6 +146,22 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData updates[`system.hp.value`] = this.hp.max } + if ( this.resources.permanentRating <= 20) { + let breakdown = SYSTEM.RESOURCE_BREAKDOWN[this.resources.permanentRating] + if (this.resources.hand !== breakdown.hand) { + updates[`system.resources.hand`] = breakdown.hand + } + if (this.resources.stowed !== breakdown.stowed) { + updates[`system.resources.stowed`] = breakdown.stowed + } + if (this.resources.storage !== breakdown.storage) { + updates[`system.resources.storage`] = breakdown.storage + } + if (this.resources.nbValidChecks !== breakdown.checks) { + updates[`system.resources.nbValidChecks`] = breakdown.checks + } + } + if (Object.keys(updates).length > 0) { this.parent.update(updates) } @@ -157,7 +179,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData isExhausted() { return this.wp.exhausted } - + /** */ /** * Rolls a dice for a character. diff --git a/packs/skills/000030.log b/packs/skills/000030.log new file mode 100644 index 0000000..e69de29 diff --git a/packs/skills/CURRENT b/packs/skills/CURRENT index 6e219f2..cc9df1d 100644 --- a/packs/skills/CURRENT +++ b/packs/skills/CURRENT @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:01bd196d6a114691ec642082ebf6591765c0168d4098a0cd834869bd11c8b87d +oid sha256:444c150ee4bcfced9404f47e0cfe6f49b0e753a8c7ab597107844f156cf104fe size 16 diff --git a/packs/skills/LOG b/packs/skills/LOG index a974022..77c62ef 100644 --- a/packs/skills/LOG +++ b/packs/skills/LOG @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d59c6d2254ffe202163060c24e513c31e94816c54ab14f8a8334094c9404871 +oid sha256:3fedef4174124848cc6168a83b21f68e266071db074121fc05d824d38ac6ad73 size 736 diff --git a/packs/skills/LOG.old b/packs/skills/LOG.old index d7fc279..3e91d39 100644 --- a/packs/skills/LOG.old +++ b/packs/skills/LOG.old @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d63e51e65f5851187a85a7a837b184ae57f8243b1037b04d01bf737da77d0fad +oid sha256:c6a199bd76b41a49f7f30d06e92188a355e3e664b71ba45bde1a088e866622a7 size 736 diff --git a/packs/skills/MANIFEST-000028 b/packs/skills/MANIFEST-000028 new file mode 100644 index 0000000..bbc19aa --- /dev/null +++ b/packs/skills/MANIFEST-000028 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2d31e6d9405a5b62c8746a8fb5ce9acc56f39c96dddcf24d3e976e4beb3aa9a +size 139 diff --git a/styles/mixins.less b/styles/mixins.less index 00758e9..f60653b 100644 --- a/styles/mixins.less +++ b/styles/mixins.less @@ -21,7 +21,7 @@ } input[name="name"] { - height: 50px; + height: 40px; margin-right: 10px; font-family: var(--font-secondary); font-size: calc(var(--font-size-standard) * 1); @@ -30,8 +30,8 @@ } fieldset { - margin-bottom: 5px; - border-radius: 5px; + margin-bottom: 4px; + border-radius: 4px; } .form-fields { @@ -57,13 +57,13 @@ .protagonist-sheet-common { label { font-family: var(--font-secondary); - font-size: calc(var(--font-size-standard) * 1.2); + font-size: calc(var(--font-size-standard) * 1.0); } } .item-sheet-common { .form-fields { - padding-top: 5px; + padding-top: 4px; } label { diff --git a/styles/protagonist.less b/styles/protagonist.less index 92d9a5d..5185d45 100644 --- a/styles/protagonist.less +++ b/styles/protagonist.less @@ -256,6 +256,15 @@ min-width: 20rem; } } + + .resources { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 8px; + label { + min-width: 12rem; + } + } .features, .biodata { diff --git a/templates/protagonist-biography.hbs b/templates/protagonist-biography.hbs index 13901ed..7e6ec5e 100644 --- a/templates/protagonist-biography.hbs +++ b/templates/protagonist-biography.hbs @@ -1,5 +1,22 @@
- + +
+ {{localize "CTHULHUETERNAL.Label.resources"}} +
+ {{formField systemFields.resources.fields.permanentRating value=system.resources.permanentRating name="system.resources.permanentRating" localize=true}} + {{formField systemFields.resources.fields.hand value=system.resources.hand name="system.resources.hand" localize=true disabled=true}} + {{formField systemFields.resources.fields.stowed value=system.resources.stowed name="system.resources.stowed" localize=true disabled=true}} + {{formField systemFields.resources.fields.storage value=system.resources.storage name="system.resources.storage" localize=true disabled=true}} +
+ {{localize "CTHULHUETERNAL.Label.resourceChecks"}} + {{#each system.resources.checks as |check idx|}} + + {{/each}} +
+
+
+
{{localize "CTHULHUETERNAL.Label.biodata"}}
diff --git a/templates/skill.hbs b/templates/skill.hbs index 659037e..2a6766b 100644 --- a/templates/skill.hbs +++ b/templates/skill.hbs @@ -15,9 +15,12 @@
{{formField systemFields.isAdversary value=system.isAdversary}} {{formField systemFields.diceEvolved value=system.diceEvolved}} - {{#if system.diceEvolved}} + + +