diff --git a/src/lang/en.json b/src/lang/en.json index e40564a..4224303 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -23,6 +23,7 @@ "OSE.Level": "Level", "OSE.Experience": "Experience", "OSE.ExperienceBonus": "Bonus Experience", + "OSE.ExperienceNextLevel": "Next level", "OSE.ExperienceAward": "XP Award", "OSE.Treasure": "Treasure type", "OSE.TreasureTable": "Table", @@ -58,15 +59,15 @@ "OSE.SavingThrow": "Save", "OSE.SavingThrowDetails": "Roll 1d20 >= {save} for success", "OSE.saves.death.short": "D", - "OSE.saves.death.long": "Death, Poison", + "OSE.saves.death.long": "Death Poison", "OSE.saves.wand.short": "W", - "OSE.saves.wand.long": "Wand", + "OSE.saves.wand.long": "Wands", "OSE.saves.paralysis.short": "P", - "OSE.saves.paralysis.long": "Paralysis, Petrify", + "OSE.saves.paralysis.long": "Paralysis Petrify", "OSE.saves.breath.short": "B", - "OSE.saves.breath.long": "Dragon Breath", + "OSE.saves.breath.long": "Breath Attacks", "OSE.saves.spell.short": "S", - "OSE.saves.spell.long": "Rod, Staff, Spell", + "OSE.saves.spell.long": "Spells Rods Staves", "OSE.saves.magic.long": "Bonus vs Magic", "OSE.Health": "Hit Points", diff --git a/src/module/actor/character-sheet.js b/src/module/actor/character-sheet.js index 7baa01d..5bf496c 100644 --- a/src/module/actor/character-sheet.js +++ b/src/module/actor/character-sheet.js @@ -1,5 +1,6 @@ import { OseActor } from "./entity.js"; import { OseActorSheet } from "./actor-sheet.js"; +import { OseCharacterModifiers } from "../dialog/character-modifiers.js"; /** * Extend the basic ActorSheet with some very simple modifications @@ -103,14 +104,15 @@ export class OseActorSheetCharacter extends OseActorSheet { } _calculateMovement(data, weight) { + let delta = data.encumbrance.max - 1600; if (data.config.encumbrance == "detailed") { if (weight > data.encumbrance.max) { data.data.movement.base = 0; - } else if (weight > 800) { + } else if (weight > (800 + delta)) { data.data.movement.base = 30; - } else if (weight > 600) { + } else if (weight > (600 + delta)) { data.data.movement.base = 60; - } else if (weight > 400) { + } else if (weight > (400 + delta)) { data.data.movement.base = 90; } else { data.data.movement.base = 120; @@ -152,6 +154,14 @@ export class OseActorSheetCharacter extends OseActorSheet { return item.update({ "data.quantity.value": parseInt(event.target.value) }); } + _onShowModifiers(event) { + event.preventDefault(); + new OseCharacterModifiers(this.actor, { + top: this.position.top + 40, + left: this.position.left + (this.position.width - 400) / 2, + }).render(true); + } + /** * Activate event listeners using the prepared sheet HTML * @param html {HTML} The prepared HTML object ready to be rendered into the DOM @@ -246,6 +256,10 @@ export class OseActorSheetCharacter extends OseActorSheet { } }); + html.find("button[data-action='modifiers']").click(ev => { + this._onShowModifiers(ev); + }); + // Handle default listeners last so system listeners are triggered first super.activateListeners(html); } diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js index ea7968d..7c7f519 100644 --- a/src/module/actor/entity.js +++ b/src/module/actor/entity.js @@ -357,44 +357,14 @@ export class OseActor extends Actor { }); } - static _valueToMod(val) { - switch (val) { - case 3: - return -3; - case 4: - case 5: - return -2; - case 6: - case 7: - case 8: - return -1; - case 9: - case 10: - case 11: - case 12: - return 0; - case 13: - case 14: - case 15: - return 1; - case 16: - case 17: - return 2; - case 18: - return 3; - default: - return 0; + static _valueFromTable(table, val) { + let output; + for (let i = 0; i <= val; i++) { + if (table[i]) { + output = table[i]; + } } - } - - static _cappedMod(val) { - let mod = OseActor._valueToMod(val); - if (mod > 1) { - mod -= 1; - } else if (mod < -1) { - mod += 1; - } - return mod; + return output; } _isSlow() { @@ -415,14 +385,59 @@ export class OseActor extends Actor { return; } const data = this.data.data; - data.scores.str.mod = OseActor._valueToMod(this.data.data.scores.str.value); - data.scores.int.mod = OseActor._valueToMod(this.data.data.scores.int.value); - data.scores.dex.mod = OseActor._valueToMod(this.data.data.scores.dex.value); - data.scores.cha.mod = OseActor._valueToMod(this.data.data.scores.cha.value); - data.scores.wis.mod = OseActor._valueToMod(this.data.data.scores.wis.value); - data.scores.con.mod = OseActor._valueToMod(this.data.data.scores.con.value); - data.scores.dex.init = OseActor._cappedMod(this.data.data.scores.dex.value); - data.scores.cha.npc = OseActor._cappedMod(this.data.data.scores.cha.value); + const standard = { + 3: -3, + 4: -2, + 6: -1, + 9: 0, + 13: 1, + 16: 2, + 18: 3 + } + data.scores.str.mod = OseActor._valueFromTable(standard, data.scores.str.value); + data.scores.int.mod = OseActor._valueFromTable(standard, data.scores.int.value); + data.scores.dex.mod = OseActor._valueFromTable(standard, data.scores.dex.value); + data.scores.cha.mod = OseActor._valueFromTable(standard, data.scores.cha.value); + data.scores.wis.mod = OseActor._valueFromTable(standard, data.scores.wis.value); + data.scores.con.mod = OseActor._valueFromTable(standard, data.scores.con.value); + + const capped = { + 3: -2, + 4: -1, + 6: -1, + 9: 0, + 13: 1, + 16: 1, + 18: 2 + } + data.scores.dex.init = OseActor._valueFromTable(capped, data.scores.dex.value); + data.scores.cha.npc = OseActor._valueFromTable(capped, data.scores.cha.value); + data.scores.cha.retain = data.scores.cha.mod + 4; + data.scores.cha.loyalty = data.scores.cha.mod + 7; + + const od = { + 3: 1, + 9: 2, + 13: 3, + 16: 4, + 18: 5 + } + data.exploration.odMod = OseActor._valueFromTable(od, data.scores.str.value); + + const literacy = { + 3: "OSE.Illiterate", + 6: "OSE.LiteracyBasic", + 9: "OSE.Literate" + } + data.languages.literacy = OseActor._valueFromTable(literacy, data.scores.int.value) + + const spoken = { + 3: 0, + 13: 2, + 16: 3, + 18: 4 + } + data.languages.count = OseActor._valueFromTable(spoken, data.scores.int.value) } } diff --git a/src/module/dialog/character-modifiers.js b/src/module/dialog/character-modifiers.js new file mode 100644 index 0000000..4cf24bd --- /dev/null +++ b/src/module/dialog/character-modifiers.js @@ -0,0 +1,43 @@ +// eslint-disable-next-line no-unused-vars +import { OseActor } from '../actor/entity.js'; + +export class OseCharacterModifiers extends FormApplication { + static get defaultOptions() { + const options = super.defaultOptions; + options.classes = ["ose", "dialog", "modifiers"], + options.id = 'sheet-modifiers'; + options.template = + 'systems/ose/templates/actors/dialogs/modifiers-dialog.html'; + options.width = 380; + return options; + } + + /* -------------------------------------------- */ + + /** + * Add the Entity name into the window title + * @type {String} + */ + get title() { + return `${this.object.name}: Modifiers`; + } + + /* -------------------------------------------- */ + + /** + * Construct and return the data object used to render the HTML template for this form application. + * @return {Object} + */ + getData() { + let data = this.object.data; + data.user = game.user; + return data; + } + + /* -------------------------------------------- */ + + /** @override */ + activateListeners(html) { + super.activateListeners(html); + } +} diff --git a/src/module/helpers.js b/src/module/helpers.js index a2fabf5..01041df 100644 --- a/src/module/helpers.js +++ b/src/module/helpers.js @@ -4,6 +4,20 @@ export const registerHelpers = async function () { return a == b; }); + Handlebars.registerHelper("gt", function (a, b) { + return a >= b; + }); + + Handlebars.registerHelper("mod", function (val) { + if (val == 0) { + return "0"; + } else if (val > 0) { + return `+${val}`; + } else if (val < 0) { + return `${val}`; + } + }); + Handlebars.registerHelper("add", function (lh, rh) { return parseInt(lh) + parseInt(rh); }); @@ -21,6 +35,8 @@ export const registerHelpers = async function () { }); Handlebars.registerHelper("counter", function (status, value, max) { - return status ? Math.clamped((100.0 * value) / max, 0, 100) : Math.clamped(100 - (100.0 * value) / max, 0, 100); + return status + ? Math.clamped((100.0 * value) / max, 0, 100) + : Math.clamped(100 - (100.0 * value) / max, 0, 100); }); }; diff --git a/src/scss/actor-base.scss b/src/scss/actor-base.scss index c1263bc..0ca06f8 100644 --- a/src/scss/actor-base.scss +++ b/src/scss/actor-base.scss @@ -66,6 +66,20 @@ bottom: 0; left: 12px; } + @keyframes notify { + from { + text-shadow: none; + } + to { + text-shadow: -1px -1px 4px $colorOlive, 1px -1px 4px $colorOlive, -1px 1px 4px $colorOlive, 1px 1px 4px $colorOlive; + } + } + &.notify { + input { + font-weight: bold; + animation: 0.8s ease-in 1s infinite alternate notify; + } + } } } .sheet-tabs { diff --git a/src/scss/apps.scss b/src/scss/apps.scss index 15033bc..5596558 100644 --- a/src/scss/apps.scss +++ b/src/scss/apps.scss @@ -5,6 +5,17 @@ } } +.ose.dialog.modifiers { + .attribute-bonuses { + label { + font-weight: bold; + } + ol { + list-style: outside; + } + } +} + #settings .ose.game-license { font-size: 12px; .button { diff --git a/src/template.json b/src/template.json index 2ab3816..775dfec 100644 --- a/src/template.json +++ b/src/template.json @@ -131,7 +131,11 @@ "encumbrance": { "max": 1600 }, - "languages": [] + "languages": { + "values": [], + "literacy": "literate", + "count": 1 + } }, "monster": { "templates": ["common", "spellcaster"], diff --git a/src/templates/actors/dialogs/modifiers-dialog.html b/src/templates/actors/dialogs/modifiers-dialog.html new file mode 100644 index 0000000..03148c0 --- /dev/null +++ b/src/templates/actors/dialogs/modifiers-dialog.html @@ -0,0 +1,68 @@ +
\ No newline at end of file diff --git a/src/templates/actors/dialogs/tweaks-dialog.html b/src/templates/actors/dialogs/tweaks-dialog.html index 41a5d30..762a9c6 100644 --- a/src/templates/actors/dialogs/tweaks-dialog.html +++ b/src/templates/actors/dialogs/tweaks-dialog.html @@ -21,6 +21,12 @@ {{#if (eq this.type 'character')}} +