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.Duration": "Duration",
"OSE.spells.Level": "Level",
"OSE.spells.Save": "Save",
"OSE.abilities.Requirements": "Requirements",

View File

@ -117,6 +117,14 @@ export class OseActorSheet extends ActorSheet {
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);
}
@ -141,6 +149,9 @@ export class OseActorSheet extends ActorSheet {
super._onResize(event);
let html = $(event.path);
let resizable = html.find(".resizable");
if (resizable.length == 0) {
return;
}
resizable.each((_, el) => {
let heightDelta = this.position.height - this.options.height;
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 });
});
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 => {
let box = $(event.currentTarget.parentElement.parentElement.parentElement);
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 {
/**
@ -8,11 +8,11 @@ export class OseActor extends Actor {
prepareData() {
super.prepareData();
const data = this.data.data;
// Determine Initiative
if (game.settings.get('ose', 'individualInit')) {
data.initiative.value = data.initiative.mod ;
if (this.data.type == 'character') {
if (game.settings.get("ose", "individualInit")) {
data.initiative.value = data.initiative.mod;
if (this.data.type == "character") {
const mods = this.computeModifiers();
data.initiative.value += mods.dex;
}
@ -20,7 +20,7 @@ export class OseActor extends Actor {
data.initiative.value = 0;
}
}
/* -------------------------------------------- */
/* -------------------------------------------- */
/* Socket Listeners and Handlers
/* -------------------------------------------- */
@ -29,14 +29,17 @@ export class OseActor extends Actor {
/* -------------------------------------------- */
rollSave(save, options = {}) {
const label = game.i18n.localize(`OSE.saves.${save}.long`);
const rollParts = ['1d20'];
const rollParts = ["1d20"];
const data = {...this.data, ...{
rollData : {
type: 'Save',
stat: save
}
}};
const data = {
...this.data,
...{
rollData: {
type: "Save",
stat: save,
},
},
};
// Roll and return
return OseDice.Roll({
@ -44,21 +47,24 @@ export class OseActor extends Actor {
parts: rollParts,
data: data,
speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${label} ${game.i18n.localize('OSE.SavingThrow')}`,
title: `${label} ${game.i18n.localize('OSE.SavingThrow')}`,
flavor: `${label} ${game.i18n.localize("OSE.SavingThrow")}`,
title: `${label} ${game.i18n.localize("OSE.SavingThrow")}`,
});
}
rollCheck(score, options = {}) {
const label = game.i18n.localize(`OSE.scores.${score}.long`);
const rollParts = ['1d20'];
const rollParts = ["1d20"];
const data = {...this.data, ...{
rollData : {
type: 'Check',
stat: score
}
}};
const data = {
...this.data,
...{
rollData: {
type: "Check",
stat: score,
},
},
};
// Roll and return
return OseDice.Roll({
@ -66,21 +72,24 @@ export class OseActor extends Actor {
parts: rollParts,
data: data,
speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${label} ${game.i18n.localize('OSE.AbilityCheck')}`,
title: `${label} ${game.i18n.localize('OSE.AbilityCheck')}`,
flavor: `${label} ${game.i18n.localize("OSE.AbilityCheck")}`,
title: `${label} ${game.i18n.localize("OSE.AbilityCheck")}`,
});
}
rollExploration(expl, options = {}) {
const label = game.i18n.localize(`OSE.exploration.${expl}.long`);
const rollParts = ['1d6'];
const rollParts = ["1d6"];
const data = {...this.data, ...{
rollData : {
type: 'Exploration',
stat: expl
}
}};
const data = {
...this.data,
...{
rollData: {
type: "Exploration",
stat: expl,
},
},
};
// Roll and return
return OseDice.Roll({
@ -88,42 +97,45 @@ export class OseActor extends Actor {
parts: rollParts,
data: data,
speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${label} ${game.i18n.localize('OSE.ExplorationCheck')}`,
title: `${label} ${game.i18n.localize('OSE.ExplorationCheck')}`,
flavor: `${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 rollParts = ['1d20',];
const rollParts = ["1d20"];
const mods = this.computeModifiers();
if (attack == 'Missile') {
if (attack == "Missile") {
rollParts.push(
'+',
"+",
mods.dex.toString(),
'+',
"+",
this.data.data.thac0.mod.missile.toString()
);
} else if (attack == 'Melee') {
} else if (attack == "Melee") {
rollParts.push(
'+',
"+",
mods.str.toString(),
'+',
"+",
this.data.data.thac0.mod.melee.toString()
);
}
if (game.settings.get('ose', 'ascendingAC')) {
rollParts.push('+', this.data.data.thac0.bba.toString());
if (game.settings.get("ose", "ascendingAC")) {
rollParts.push("+", this.data.data.thac0.bba.toString());
}
const data = {...this.data, ...{
rollData : {
type: 'Attack',
stat: attack,
mods: mods
}
}};
const data = {
...this.data,
...{
rollData: {
type: "Attack",
stat: attack,
mods: mods,
},
},
};
// Roll and return
return OseDice.Roll({
@ -131,12 +143,24 @@ export class OseActor extends Actor {
parts: rollParts,
data: data,
speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${label} ${game.i18n.localize('OSE.Attack')}`,
title: `${label} ${game.i18n.localize('OSE.Attack')}`,
flavor: `${label} ${game.i18n.localize("OSE.Attack")}`,
title: `${label} ${game.i18n.localize("OSE.Attack")}`,
});
}
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) => {
switch (val) {
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 {
$detailsHeight: 44px;
ul li {
list-style: none;
padding: 0;
}
.panel {
border: 1px solid $colorDark;
.panel-title {
@ -77,7 +72,8 @@
position: absolute;
transform: rotate(90deg);
top: 365px;
right: -169px;
right: -168px;
border-bottom: 1px solid black;
width: 320px;
z-index: -1;
.item {
@ -103,6 +99,7 @@
padding: 5px 0;
height: calc(100% - 140px);
.attributes {
list-style: none;
margin: 0;
padding: 0;
.attribute {

View File

@ -1,37 +1,47 @@
.ose.sheet.item {
.profile-img {
border: none;
flex: 0 0 84px;
height: 84px;
.profile-img {
border: none;
flex: 0 0 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 {
.stats {
flex: 0 0 90px;
border-right: 1px groove rgba(0, 0, 0, 0.2);
padding-right: 2px;
.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;
}
}
}
.editor {
height: 240px;
}
.weapon-editor .editor {
height: 215px;
}
}
}

View File

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

View File

@ -131,7 +131,7 @@
{{ localize "OSE.HitDiceShort" }}
</h4>
<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" />
</div>
</li>

View File

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

View File

@ -3,17 +3,16 @@
<li class="attribute health">
<h4 class="attribute-name box-title" title="{{localize 'OSE.Health'}}">{{ localize "OSE.HealthShort" }}</h4>
<div class="attribute-value flexrow">
<input name="data.hp.value" type="text" value="{{data.hp.value}}" data-dtype="Number"
placeholder="10" />
<input name="data.hp.value" type="text" value="{{data.hp.value}}" data-dtype="Number" placeholder="0" />
<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>
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{localize 'OSE.HitDice'}}">{{ localize "OSE.HitDiceShort" }}
</h4>
<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>
</li>
<li class="attribute">
@ -33,12 +32,20 @@
</div>
{{/if}}
</li>
<li class="attribute">
<h4 class="attribute-name box-title" title="{{localize 'OSE.Thac0'}}">{{ localize "OSE.Thac0" }}</h4>
<li class="attribute attack" data-attack="Melee">
{{#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">
<input name="data.thac0.value" type="text" value="{{data.thac0.value}}" placeholder="0"
data-dtype="Number" />
</div>
{{/if}}
</li>
{{#if data.retainer.enabled}}
<li class="attribute">

View File

@ -5,38 +5,28 @@
</h1>
<ul class="summary flexrow">
<li class="flex2">
<input type="text" name="data.details.alignment" value="{{data.details.alignment}}"
placeholder="{{ localize 'OSE.Alignment' }}" />
<input type="text" name="data.details.alignment" value="{{data.details.alignment}}" />
<label>{{localize 'OSE.Alignment'}}</label>
</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>
<input type="text" name="data.details.appearing" value="{{data.details.appearing}}"
placeholder="{{ localize 'OSE.Appearing' }}" />
<input type="text" name="data.details.appearing" value="{{data.details.appearing}}" />
<label>{{localize 'OSE.Appearing'}}</label>
</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}}
<li>
<input type="text" name="data.details.morale" value="{{data.details.morale}}"
placeholder="{{ localize 'OSE.Morale' }}" />
<input type="text" name="data.details.morale" value="{{data.details.morale}}" />
<label>{{localize 'OSE.Morale'}}</label>
</li>
{{/if}}
</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>

View File

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

View File

@ -9,7 +9,7 @@
</header>
<section class="sheet-body">
<div class="flexrow">
<div class="stats">
<div class="stats narrow">
<div class="form-group">
<label>{{localize 'OSE.spells.Level'}}</label>
<div class="form-fields">
@ -34,6 +34,19 @@
<input type="text" name="data.duration" value="{{data.duration}}" data-dtype="String" />
</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">
<label>{{localize 'OSE.items.Roll'}}</label>
<div class="form-fields">