ENH: Modifiers and Next Level

master
U~man 2020-07-11 12:29:53 +02:00
parent 65eba9aea5
commit 1b11568593
12 changed files with 264 additions and 102 deletions

View File

@ -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",

View File

@ -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);
}

View File

@ -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)
}
}

View File

@ -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);
}
}

View File

@ -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);
});
};

View File

@ -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 {

View File

@ -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 {

View File

@ -131,7 +131,11 @@
"encumbrance": {
"max": 1600
},
"languages": []
"languages": {
"values": [],
"literacy": "literate",
"count": 1
}
},
"monster": {
"templates": ["common", "spellcaster"],

View File

@ -0,0 +1,68 @@
<form autocomplete="off">
<div class="attribute-bonuses">
<label>{{localize 'OSE.scores.str.long'}}</label>
<ol>
<li>
{{localize 'OSE.Melee'}} ({{mod data.scores.str.mod}})
</li>
<li>
{{localize 'OSE.exploration.od.long'}} ({{data.exploration.odMod}} in 6)
</li>
</ol>
</div>
<div class="attribute-bonuses">
<label>{{localize 'OSE.scores.int.long'}}</label>
<ol>
<li>
{{localize 'OSE.SpokenLanguages'}} ({{mod data.languages.count}})
</li>
<li>
{{localize 'OSE.Literacy'}} ({{localize data.languages.literacy}})
</li>
</ol>
</div>
<div class="attribute-bonuses">
<label>{{localize 'OSE.scores.wis.long'}}</label>
<ol>
<li>
{{localize 'OSE.saves.magic.long'}} ({{mod data.scores.wis.mod}})
</li>
</ol>
</div>
<div class="attribute-bonuses">
<label>{{localize 'OSE.scores.dex.long'}}</label>
<ol>
<li>
{{localize 'OSE.Missile'}} ({{mod data.scores.dex.mod}})
</li>
<li>
{{localize 'OSE.Initiative'}} ({{mod data.scores.dex.init}})
</li>
<li>
{{localize 'OSE.ArmorClass'}} ({{mod data.scores.dex.mod}})
</li>
</ol>
</div>
<div class="attribute-bonuses">
<label>{{localize 'OSE.scores.con.long'}}</label>
<ol>
<li>
{{localize 'OSE.Health'}} ({{mod data.scores.con.mod}})
</li>
</ol>
</div>
<div class="attribute-bonuses">
<label>{{localize 'OSE.scores.cha.long'}}</label>
<ol>
<li>
{{localize 'OSE.NPCReaction'}} ({{mod data.scores.cha.npc}})
</li>
<li>
{{localize 'OSE.RetainersMax'}} ({{add data.scores.cha.mod 4}})
</li>
<li>
{{localize 'OSE.Loyalty'}} ({{add data.scores.cha.mod 7}})
</li>
</ol>
</div>
</form>

View File

@ -21,6 +21,12 @@
</div>
</div>
{{#if (eq this.type 'character')}}
<div class="form-group">
<label>{{localize "OSE.ExperienceNextLevel"}}</label>
<div class="form-fields">
<input type="text" name="data.details.xp.next" id="experiencenext" value="{{data.details.xp.next}}" />
</div>
</div>
<div class="form-group">
<label>{{localize "OSE.ExperienceBonus"}} (%)</label>
<div class="form-fields">
@ -44,7 +50,7 @@
<label>{{localize "OSE.Encumbrance"}}</label>
<div class="form-fields">
<input type="text" name="data.encumbrance.max" id="encumbrance" value="{{data.encumbrance.max}}"
data-dtype="Number" />
data-dtype="Number" {{#unless user.isGM}}disabled{{/unless}} />
</div>
</div>
<div class="form-group">

View File

@ -8,12 +8,6 @@
<div class="attribute-value">
<input name="data.scores.str.value" type="text" value="{{data.scores.str.value}}" placeholder="0"
data-dtype="Number" />
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
<div class="attribute-bonuses">
{{localize 'OSE.Melee'}} ({{data.scores.str.mod}})<br/>
{{localize 'OSE.exploration.od.long'}}
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
</li>
<li class="attribute ability-score" data-score="int">
@ -22,12 +16,6 @@
<div class="attribute-value">
<input name="data.scores.int.value" type="text" value="{{data.scores.int.value}}" placeholder="0"
data-dtype="Number" />
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
<div class="attribute-bonuses">
{{localize 'OSE.SpokenLanguages'}}<br/>
{{localize 'OSE.Literacy'}}
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
</li>
<li class="attribute ability-score" data-score="wis">
@ -36,11 +24,6 @@
<div class="attribute-value">
<input name="data.scores.wis.value" type="text" value="{{data.scores.wis.value}}" placeholder="0"
data-dtype="Number" />
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
<div class="attribute-bonuses">
{{localize 'OSE.saves.magic.long'}}({{data.scores.wis.mod}})
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
</li>
<li class="attribute ability-score" data-score="dex">
@ -49,13 +32,6 @@
<div class="attribute-value">
<input name="data.scores.dex.value" type="text" value="{{data.scores.dex.value}}" placeholder="0"
data-dtype="Number" />
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
<div class="attribute-bonuses">
{{localize 'OSE.Missile'}} ({{data.scores.dex.mod}})<br/>
{{localize 'OSE.Initiative'}} ({{data.scores.dex.init}})<br/>
{{localize 'OSE.ArmorClass'}} ({{data.scores.dex.mod}})
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
</li>
<li class="attribute ability-score" data-score="con">
@ -64,11 +40,6 @@
<div class="attribute-value">
<input name="data.scores.con.value" type="text" value="{{data.scores.con.value}}" placeholder="0"
data-dtype="Number" />
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
<div class="attribute-bonuses">
{{localize 'OSE.Health'}} ({{data.scores.con.mod}})
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
</li>
<li class="attribute ability-score" data-score="cha">
@ -77,13 +48,6 @@
<div class="attribute-value">
<input name="data.scores.cha.value" type="text" value="{{data.scores.cha.value}}" placeholder="0"
data-dtype="Number" />
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
<div class="attribute-bonuses">
{{localize 'OSE.NPCReaction'}} ({{data.scores.cha.npc}})<br/>
{{localize 'OSE.RetainersMax'}} ({{add data.scores.cha.mod 4}})<br/>
{{localize 'OSE.Loyalty'}} ({{add data.scores.cha.mod 7}})
<span class="attribute-mod"><a><i class="fas fa-circle"></i></a></span>
</div>
</li>
{{#if data.retainer.enabled}}
@ -97,28 +61,34 @@
</div>
</li>
{{/if}}
<li>
<button type="button" data-action="modifiers" title="{{localize 'OSE.Modifiers'}}"><i class="fas fa-book"></i></button>
</li>
</ul>
</div>
{{!-- Resource Tracking --}}
<div class="flex2">
<div class="flexrow">
<div class="health">
<input class="health-value health-top" name="data.hp.value" type="text" value="{{data.hp.value}}" data-dtype="Number"
placeholder="0" title="{{localize 'OSE.Health'}}" />
<input class="health-value health-bottom" name="data.hp.max" type="text" value="{{data.hp.max}}" data-dtype="Number"
placeholder="0" title="{{localize 'OSE.HealthMax'}}" />
<input class="health-value health-top" name="data.hp.value" type="text" value="{{data.hp.value}}"
data-dtype="Number" placeholder="0" title="{{localize 'OSE.Health'}}" />
<input class="health-value health-bottom" name="data.hp.max" type="text" value="{{data.hp.max}}"
data-dtype="Number" placeholder="0" title="{{localize 'OSE.HealthMax'}}" />
<div class="health-empty" style="height:{{counter false data.hp.value data.hp.max}}%"></div>
<div class="health-full" style="height:{{counter true data.hp.value data.hp.max}}%"></div>
</div>
<div class="health armor-class">
{{#if config.ascendingAC}}
<div class="health-value health-top" title="{{localize 'OSE.ArmorClass'}}">{{data.aac.value}}</div>
<div class="health-value health-bottom" title="{{localize 'OSE.ArmorClassNaked'}}">{{add 10 data.scores.dex.mod}}</div>
<div class="health-value health-top" title="{{localize 'OSE.ArmorClass'}}">{{data.aac.value}}</div>
<div class="health-value health-bottom" title="{{localize 'OSE.ArmorClassNaked'}}">
{{add 10 data.scores.dex.mod}}</div>
{{else}}
<div class="health-value health-top" title="{{localize 'OSE.ArmorClass'}}">{{data.ac.value}}</div>
<div class="health-value health-bottom" title="{{localize 'OSE.ArmorClassNaked'}}">{{subtract data.scores.dex.mod 9}}</div>
<div class="health-value health-bottom" title="{{localize 'OSE.ArmorClassNaked'}}">
{{subtract data.scores.dex.mod 9}}</div>
{{/if}}
{{#if data.shield}}<div class="shield" title="{{localize 'OSE.items.hasShield'}} ({{data.shield}})"><i class="fas fa-shield-alt"></i></div>{{/if}}
{{#if data.shield}}<div class="shield" title="{{localize 'OSE.items.hasShield'}} ({{data.shield}})"><i
class="fas fa-shield-alt"></i></div>{{/if}}
</div>
</div>
<div class="flexrow">
@ -207,7 +177,7 @@
{{ localize "OSE.MovementExplorationShort" }}</h4>
<div class="attribute-value flexrow">
<input name="data.movement.base" type="text" value="{{data.movement.base}}" placeholder="0"
data-dtype="Number" {{#if data.config.movementAuto}}disabled{{/if}}/>
data-dtype="Number" {{#if data.config.movementAuto}}disabled{{/if}} />
</div>
</li>
<li class="attribute attribute-secondaries">

View File

@ -21,7 +21,7 @@
/>
<label>{{localize 'OSE.Class'}}</label>
</li>
<li>
<li class="{{#if (gt data.details.xp.value data.details.xp.next)}}notify{{/if}}">
<input type="text" name="data.details.level" value="{{data.details.level}}" data-dtype="Number"
/>
<label>{{localize 'OSE.Level'}}</label>