FIX: Monster rolls

master
U~man 2020-07-04 22:17:23 +02:00
parent 77e1da23b1
commit 573c9fe23c
14 changed files with 205 additions and 143 deletions

View File

@ -148,6 +148,7 @@
"OSE.spells.Class": "Class", "OSE.spells.Class": "Class",
"OSE.spells.Duration": "Duration", "OSE.spells.Duration": "Duration",
"OSE.spells.Level": "Level", "OSE.spells.Level": "Level",
"OSE.spells.Save": "Save",
"OSE.abilities.Requirements": "Requirements", "OSE.abilities.Requirements": "Requirements",

View File

@ -117,6 +117,14 @@ export class OseActorSheet extends ActorSheet {
item.roll(); item.roll();
}); });
html.find(".attack a").click(ev => {
let actorObject = this.actor;
let element = event.currentTarget;
let attack = element.parentElement.parentElement.dataset.attack;
actorObject.rollAttack(attack, { event: event });
});
super.activateListeners(html); super.activateListeners(html);
} }
@ -141,6 +149,9 @@ export class OseActorSheet extends ActorSheet {
super._onResize(event); super._onResize(event);
let html = $(event.path); let html = $(event.path);
let resizable = html.find(".resizable"); let resizable = html.find(".resizable");
if (resizable.length == 0) {
return;
}
resizable.each((_, el) => { resizable.each((_, el) => {
let heightDelta = this.position.height - this.options.height; let heightDelta = this.position.height - this.options.height;
el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`; el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`;

View File

@ -159,13 +159,6 @@ export class OseActorSheetCharacter extends OseActorSheet {
actorObject.rollExploration(expl, { event: event }); actorObject.rollExploration(expl, { event: event });
}); });
html.find(".attack a").click(ev => {
let actorObject = this.actor;
let element = event.currentTarget;
let attack = element.parentElement.parentElement.dataset.attack;
actorObject.rollAttack(attack, { event: event });
});
html.find(".ability-score .attribute-mod a").click(ev => { html.find(".ability-score .attribute-mod a").click(ev => {
let box = $(event.currentTarget.parentElement.parentElement.parentElement); let box = $(event.currentTarget.parentElement.parentElement.parentElement);
box.children('.attribute-bonuses').slideDown(200); box.children('.attribute-bonuses').slideDown(200);

View File

@ -1,4 +1,4 @@
import { OseDice } from '../dice.js'; import { OseDice } from "../dice.js";
export class OseActor extends Actor { export class OseActor extends Actor {
/** /**
@ -8,11 +8,11 @@ export class OseActor extends Actor {
prepareData() { prepareData() {
super.prepareData(); super.prepareData();
const data = this.data.data; const data = this.data.data;
// Determine Initiative // Determine Initiative
if (game.settings.get('ose', 'individualInit')) { if (game.settings.get("ose", "individualInit")) {
data.initiative.value = data.initiative.mod ; data.initiative.value = data.initiative.mod;
if (this.data.type == 'character') { if (this.data.type == "character") {
const mods = this.computeModifiers(); const mods = this.computeModifiers();
data.initiative.value += mods.dex; data.initiative.value += mods.dex;
} }
@ -20,7 +20,7 @@ export class OseActor extends Actor {
data.initiative.value = 0; data.initiative.value = 0;
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Socket Listeners and Handlers /* Socket Listeners and Handlers
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -29,14 +29,17 @@ export class OseActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
rollSave(save, options = {}) { rollSave(save, options = {}) {
const label = game.i18n.localize(`OSE.saves.${save}.long`); const label = game.i18n.localize(`OSE.saves.${save}.long`);
const rollParts = ['1d20']; const rollParts = ["1d20"];
const data = {...this.data, ...{ const data = {
rollData : { ...this.data,
type: 'Save', ...{
stat: save rollData: {
} type: "Save",
}}; stat: save,
},
},
};
// Roll and return // Roll and return
return OseDice.Roll({ return OseDice.Roll({
@ -44,21 +47,24 @@ export class OseActor extends Actor {
parts: rollParts, parts: rollParts,
data: data, data: data,
speaker: ChatMessage.getSpeaker({ actor: this }), speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${label} ${game.i18n.localize('OSE.SavingThrow')}`, flavor: `${label} ${game.i18n.localize("OSE.SavingThrow")}`,
title: `${label} ${game.i18n.localize('OSE.SavingThrow')}`, title: `${label} ${game.i18n.localize("OSE.SavingThrow")}`,
}); });
} }
rollCheck(score, options = {}) { rollCheck(score, options = {}) {
const label = game.i18n.localize(`OSE.scores.${score}.long`); const label = game.i18n.localize(`OSE.scores.${score}.long`);
const rollParts = ['1d20']; const rollParts = ["1d20"];
const data = {...this.data, ...{ const data = {
rollData : { ...this.data,
type: 'Check', ...{
stat: score rollData: {
} type: "Check",
}}; stat: score,
},
},
};
// Roll and return // Roll and return
return OseDice.Roll({ return OseDice.Roll({
@ -66,21 +72,24 @@ export class OseActor extends Actor {
parts: rollParts, parts: rollParts,
data: data, data: data,
speaker: ChatMessage.getSpeaker({ actor: this }), speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${label} ${game.i18n.localize('OSE.AbilityCheck')}`, flavor: `${label} ${game.i18n.localize("OSE.AbilityCheck")}`,
title: `${label} ${game.i18n.localize('OSE.AbilityCheck')}`, title: `${label} ${game.i18n.localize("OSE.AbilityCheck")}`,
}); });
} }
rollExploration(expl, options = {}) { rollExploration(expl, options = {}) {
const label = game.i18n.localize(`OSE.exploration.${expl}.long`); const label = game.i18n.localize(`OSE.exploration.${expl}.long`);
const rollParts = ['1d6']; const rollParts = ["1d6"];
const data = {...this.data, ...{ const data = {
rollData : { ...this.data,
type: 'Exploration', ...{
stat: expl rollData: {
} type: "Exploration",
}}; stat: expl,
},
},
};
// Roll and return // Roll and return
return OseDice.Roll({ return OseDice.Roll({
@ -88,42 +97,45 @@ export class OseActor extends Actor {
parts: rollParts, parts: rollParts,
data: data, data: data,
speaker: ChatMessage.getSpeaker({ actor: this }), speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${label} ${game.i18n.localize('OSE.ExplorationCheck')}`, flavor: `${label} ${game.i18n.localize("OSE.ExplorationCheck")}`,
title: `${label} ${game.i18n.localize('OSE.ExplorationCheck')}`, title: `${label} ${game.i18n.localize("OSE.ExplorationCheck")}`,
}); });
} }
rollAttack(attack, options={}) { rollAttack(attack, options = {}) {
const label = game.i18n.localize(`OSE.${attack}`); const label = game.i18n.localize(`OSE.${attack}`);
const rollParts = ['1d20',]; const rollParts = ["1d20"];
const mods = this.computeModifiers(); const mods = this.computeModifiers();
if (attack == 'Missile') { if (attack == "Missile") {
rollParts.push( rollParts.push(
'+', "+",
mods.dex.toString(), mods.dex.toString(),
'+', "+",
this.data.data.thac0.mod.missile.toString() this.data.data.thac0.mod.missile.toString()
); );
} else if (attack == 'Melee') { } else if (attack == "Melee") {
rollParts.push( rollParts.push(
'+', "+",
mods.str.toString(), mods.str.toString(),
'+', "+",
this.data.data.thac0.mod.melee.toString() this.data.data.thac0.mod.melee.toString()
); );
} }
if (game.settings.get('ose', 'ascendingAC')) { if (game.settings.get("ose", "ascendingAC")) {
rollParts.push('+', this.data.data.thac0.bba.toString()); rollParts.push("+", this.data.data.thac0.bba.toString());
} }
const data = {...this.data, ...{ const data = {
rollData : { ...this.data,
type: 'Attack', ...{
stat: attack, rollData: {
mods: mods type: "Attack",
} stat: attack,
}}; mods: mods,
},
},
};
// Roll and return // Roll and return
return OseDice.Roll({ return OseDice.Roll({
@ -131,12 +143,24 @@ export class OseActor extends Actor {
parts: rollParts, parts: rollParts,
data: data, data: data,
speaker: ChatMessage.getSpeaker({ actor: this }), speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${label} ${game.i18n.localize('OSE.Attack')}`, flavor: `${label} ${game.i18n.localize("OSE.Attack")}`,
title: `${label} ${game.i18n.localize('OSE.Attack')}`, title: `${label} ${game.i18n.localize("OSE.Attack")}`,
}); });
} }
computeModifiers() { computeModifiers() {
if (this.data.type != "character") {
return {
str: 0,
dex: 0,
int: 0,
con: 0,
wis: 0,
cha: 0,
npc: 0,
init: 0,
};
}
let _valueToMod = (val) => { let _valueToMod = (val) => {
switch (val) { switch (val) {
case 3: case 3:

View File

@ -1 +1,17 @@
export const OSE = {}; export const OSE = {
scores: {
str: "OSE.scores.str.long",
int: "OSE.scores.int.long",
dex: "OSE.scores.dex.long",
wis: "OSE.scores.wis.long",
con: "OSE.scores.con.long",
cha: "OSE.scores.cha.long"
},
saves: {
death: "OSE.saves.death.short",
wand: "OSE.saves.wand.short",
paralysis: "OSE.saves.paralysis.short",
breath: "OSE.saves.breath.short",
spell: "OSE.saves.spell.short"
}
};

View File

@ -3,11 +3,6 @@
.ose.sheet.actor { .ose.sheet.actor {
$detailsHeight: 44px; $detailsHeight: 44px;
ul li {
list-style: none;
padding: 0;
}
.panel { .panel {
border: 1px solid $colorDark; border: 1px solid $colorDark;
.panel-title { .panel-title {
@ -77,7 +72,8 @@
position: absolute; position: absolute;
transform: rotate(90deg); transform: rotate(90deg);
top: 365px; top: 365px;
right: -169px; right: -168px;
border-bottom: 1px solid black;
width: 320px; width: 320px;
z-index: -1; z-index: -1;
.item { .item {
@ -103,6 +99,7 @@
padding: 5px 0; padding: 5px 0;
height: calc(100% - 140px); height: calc(100% - 140px);
.attributes { .attributes {
list-style: none;
margin: 0; margin: 0;
padding: 0; padding: 0;
.attribute { .attribute {

View File

@ -1,37 +1,47 @@
.ose.sheet.item { .ose.sheet.item {
.profile-img { .profile-img {
border: none; border: none;
flex: 0 0 84px; flex: 0 0 84px;
height: 84px; height: 84px;
}
.sheet-body {
.stats {
flex: 0 0 90px;
border-right: 1px groove rgba(0, 0, 0, 0.2);
padding-right: 2px;
font-size: 13px;
.form-group {
margin: 2px;
border: 1px solid rgba(0, 0, 0, 0.15);
label {
background: rgba(0, 0, 0, 0.1);
padding: 0 4px;
}
input {
border-bottom: none;
margin: auto 0;
}
}
.block-input {
display: flex;
flex-direction: column;
text-align: center;
}
&.narrow {
.form-group {
label {
}
input {
height: 18px;
}
}
}
} }
.sheet-body { .editor {
.stats { height: 240px;
flex: 0 0 90px; }
border-right: 1px groove rgba(0, 0, 0, 0.2); .weapon-editor .editor {
padding-right: 2px; height: 215px;
.form-group { }
margin: 2px; }
border: 1px solid rgba(0, 0, 0, 0.15); }
label {
background: rgba(0, 0, 0, 0.1);
padding: 0 4px;
}
input {
border-bottom: none;
margin: auto 0;
}
}
.block-input {
display: flex;
flex-direction: column;
text-align: center;
}
}
.editor {
height: 240px;
}
.weapon-editor .editor {
height: 215px;
}
}
}

View File

@ -38,7 +38,7 @@
"movement": { "movement": {
"base": 120 "base": 120
}, },
"initative": { "initiative": {
"value": 0, "value": 0,
"mod": 0 "mod": 0
} }
@ -132,7 +132,6 @@
"alignment": "", "alignment": "",
"xp": 0, "xp": 0,
"treasure": "", "treasure": "",
"size": "",
"appearing": "", "appearing": "",
"morale": 0 "morale": 0
}, },
@ -178,7 +177,8 @@
"roll": "", "roll": "",
"description": "", "description": "",
"memorized": false, "memorized": false,
"cast": false "cast": false,
"save": ""
}, },
"ability": { "ability": {
"requirements": "", "requirements": "",

View File

@ -131,7 +131,7 @@
{{ localize "OSE.HitDiceShort" }} {{ localize "OSE.HitDiceShort" }}
</h4> </h4>
<div class="attribute-value"> <div class="attribute-value">
<input name="data.hp.hd" type="text" value="{{data.hp.hd}}" placeholder="0" <input name="data.hp.hd" type="text" value="{{data.hp.hd}}" placeholder=""
data-dtype="String" /> data-dtype="String" />
</div> </div>
</li> </li>

View File

@ -6,29 +6,29 @@
<ul class="summary flexrow"> <ul class="summary flexrow">
<li> <li>
<input type="text" name="data.details.title" value="{{data.details.title}}" <input type="text" name="data.details.title" value="{{data.details.title}}"
placeholder="{{ localize 'OSE.Title' }}" /> />
<label>{{localize 'OSE.Title'}}</label> <label>{{localize 'OSE.Title'}}</label>
</li> </li>
<li> <li>
<input type="text" name="data.details.alignment" value="{{data.details.alignment}}" <input type="text" name="data.details.alignment" value="{{data.details.alignment}}"
placeholder="{{ localize 'OSE.Alignment' }}" /> />
<label>{{localize 'OSE.Alignment'}}</label> <label>{{localize 'OSE.Alignment'}}</label>
</li> </li>
</ul> </ul>
<ul class="summary flexrow"> <ul class="summary flexrow">
<li class="flex3"> <li class="flex3">
<input type="text" name="data.details.class" value="{{data.details.class}}" <input type="text" name="data.details.class" value="{{data.details.class}}"
placeholder="{{ localize 'OSE.Class' }}" /> />
<label>{{localize 'OSE.Class'}}</label> <label>{{localize 'OSE.Class'}}</label>
</li> </li>
<li> <li>
<input type="text" name="data.details.level" value="{{data.details.level}}" <input type="text" name="data.details.level" value="{{data.details.level}}"
placeholder="{{ localize 'OSE.Level' }}" /> />
<label>{{localize 'OSE.Level'}}</label> <label>{{localize 'OSE.Level'}}</label>
</li> </li>
<li class="flex2"> <li class="flex2">
<input type="text" name="data.details.xp.value" value="{{data.details.xp.value}}" <input type="text" name="data.details.xp.value" value="{{data.details.xp.value}}"
placeholder="{{ localize 'OSE.Experience' }}" /> />
<label>{{localize 'OSE.Experience'}}</label> <label>{{localize 'OSE.Experience'}}</label>
{{#if data.details.xp.bonus}} {{#if data.details.xp.bonus}}
<span class="xp-bonus">+{{data.details.xp.bonus}}%</span> <span class="xp-bonus">+{{data.details.xp.bonus}}%</span>

View File

@ -3,17 +3,16 @@
<li class="attribute health"> <li class="attribute health">
<h4 class="attribute-name box-title" title="{{localize 'OSE.Health'}}">{{ localize "OSE.HealthShort" }}</h4> <h4 class="attribute-name box-title" title="{{localize 'OSE.Health'}}">{{ localize "OSE.HealthShort" }}</h4>
<div class="attribute-value flexrow"> <div class="attribute-value flexrow">
<input name="data.hp.value" type="text" value="{{data.hp.value}}" data-dtype="Number" <input name="data.hp.value" type="text" value="{{data.hp.value}}" data-dtype="Number" placeholder="0" />
placeholder="10" />
<span class="sep"> / </span> <span class="sep"> / </span>
<input name="data.hp.max" type="text" value="{{data.hp.max}}" data-dtype="Number" placeholder="10" /> <input name="data.hp.max" type="text" value="{{data.hp.max}}" data-dtype="Number" placeholder="0" />
</div> </div>
</li> </li>
<li class="attribute"> <li class="attribute">
<h4 class="attribute-name box-title" title="{{localize 'OSE.HitDice'}}">{{ localize "OSE.HitDiceShort" }} <h4 class="attribute-name box-title" title="{{localize 'OSE.HitDice'}}">{{ localize "OSE.HitDiceShort" }}
</h4> </h4>
<div class="attribute-value"> <div class="attribute-value">
<input name="data.hp.hd" type="text" value="{{data.hp.hd}}" placeholder="0" data-dtype="String" /> <input name="data.hp.hd" type="text" value="{{data.hp.hd}}" data-dtype="String" />
</div> </div>
</li> </li>
<li class="attribute"> <li class="attribute">
@ -33,12 +32,20 @@
</div> </div>
{{/if}} {{/if}}
</li> </li>
<li class="attribute"> <li class="attribute attack" data-attack="Melee">
<h4 class="attribute-name box-title" title="{{localize 'OSE.Thac0'}}">{{ localize "OSE.Thac0" }}</h4> {{#if config.ascendingAC}}
<h4 class="attribute-name box-title" title="{{localize 'OSE.AB'}}"><a>{{ localize "OSE.ABShort" }}</a></h4>
<div class="attribute-value">
<input name="data.thac0.bba" type="text" value="{{data.thac0.bba}}" placeholder="0"
data-dtype="Number" />
</div>
{{else}}
<h4 class="attribute-name box-title" title="{{localize 'OSE.Thac0'}}"><a>{{ localize "OSE.Thac0" }}</a></h4>
<div class="attribute-value"> <div class="attribute-value">
<input name="data.thac0.value" type="text" value="{{data.thac0.value}}" placeholder="0" <input name="data.thac0.value" type="text" value="{{data.thac0.value}}" placeholder="0"
data-dtype="Number" /> data-dtype="Number" />
</div> </div>
{{/if}}
</li> </li>
{{#if data.retainer.enabled}} {{#if data.retainer.enabled}}
<li class="attribute"> <li class="attribute">

View File

@ -5,38 +5,28 @@
</h1> </h1>
<ul class="summary flexrow"> <ul class="summary flexrow">
<li class="flex2"> <li class="flex2">
<input type="text" name="data.details.alignment" value="{{data.details.alignment}}" <input type="text" name="data.details.alignment" value="{{data.details.alignment}}" />
placeholder="{{ localize 'OSE.Alignment' }}" />
<label>{{localize 'OSE.Alignment'}}</label> <label>{{localize 'OSE.Alignment'}}</label>
</li> </li>
<li class="flex2">
<input type="text" name="data.details.treasure" value="{{data.details.treasure}}"
placeholder="{{ localize 'OSE.Treasure' }}" />
<label>{{localize 'OSE.Treasure'}}</label>
</li>
<li> <li>
<input type="text" name="data.details.appearing" value="{{data.details.appearing}}" <input type="text" name="data.details.appearing" value="{{data.details.appearing}}" />
placeholder="{{ localize 'OSE.Appearing' }}" />
<label>{{localize 'OSE.Appearing'}}</label> <label>{{localize 'OSE.Appearing'}}</label>
</li> </li>
</ul>
<ul class="summary flexrow">
<li class="flex2">
<input type="text" name="data.details.size" value="{{data.details.size}}"
placeholder="{{ localize 'OSE.Size' }}" />
<label>{{localize 'OSE.Size'}}</label>
</li>
<li class="flex2">
<input type="text" name="data.details.xp" value="{{data.details.xp}}"
placeholder="{{ localize 'OSE.Experience' }}" />
<label>{{localize 'OSE.Experience'}}</label>
</li>
{{#if config.morale}} {{#if config.morale}}
<li> <li>
<input type="text" name="data.details.morale" value="{{data.details.morale}}" <input type="text" name="data.details.morale" value="{{data.details.morale}}" />
placeholder="{{ localize 'OSE.Morale' }}" />
<label>{{localize 'OSE.Morale'}}</label> <label>{{localize 'OSE.Morale'}}</label>
</li> </li>
{{/if}} {{/if}}
</ul> </ul>
<ul class="summary flexrow">
<li class="flex2">
<input type="text" name="data.details.xp" value="{{data.details.xp}}" />
<label>{{localize 'OSE.Experience'}}</label>
</li>
<li class="flex2">
<input type="text" name="data.details.treasure" value="{{data.details.treasure}}" />
<label>{{localize 'OSE.Treasure'}}</label>
</li>
</ul>
</section> </section>

View File

@ -22,9 +22,9 @@
</button> </button>
{{/if}} {{/if}}
{{#if hasSave}} {{#if data.save}}
<button data-action="save" data-ability="{{data.save.ability}}" disabled> <button data-action="save" data-ability="{{data.save}}" disabled>
{{ localize "OSE.SavingThrow" }} {{labels.save}} {{ localize "OSE.SavingThrow" }} {{data.save}}
</button> </button>
{{/if}} {{/if}}

View File

@ -9,7 +9,7 @@
</header> </header>
<section class="sheet-body"> <section class="sheet-body">
<div class="flexrow"> <div class="flexrow">
<div class="stats"> <div class="stats narrow">
<div class="form-group"> <div class="form-group">
<label>{{localize 'OSE.spells.Level'}}</label> <label>{{localize 'OSE.spells.Level'}}</label>
<div class="form-fields"> <div class="form-fields">
@ -34,6 +34,19 @@
<input type="text" name="data.duration" value="{{data.duration}}" data-dtype="String" /> <input type="text" name="data.duration" value="{{data.duration}}" data-dtype="String" />
</div> </div>
</div> </div>
<div class="form-group">
<label>{{localize 'OSE.spells.Save'}}</label>
<div class="form-fields">
<select name="data.save">
{{#select data.save}}
<option value=""></option>
{{#each config.saves as |save a|}}
<option value="{{a}}">{{localize save}}</option>
{{/each}}
{{/select}}
</select>
</div>
</div>
<div class="form-group block-input"> <div class="form-group block-input">
<label>{{localize 'OSE.items.Roll'}}</label> <label>{{localize 'OSE.items.Roll'}}</label>
<div class="form-fields"> <div class="form-fields">