ENH: Fix formula formatting, Morale check
parent
401d78f435
commit
70309c960e
|
@ -146,6 +146,11 @@ export class OseActorSheetCharacter extends OseActorSheet {
|
||||||
actorObject.rollCheck(score, { event: event });
|
actorObject.rollCheck(score, { event: event });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
html.find(".hit-dice .attribute-name a").click((ev) => {
|
||||||
|
let actorObject = this.actor;
|
||||||
|
actorObject.rollHitDice({ event: event });
|
||||||
|
});
|
||||||
|
|
||||||
html.find(".exploration .attribute-name a").click((ev) => {
|
html.find(".exploration .attribute-name a").click((ev) => {
|
||||||
let actorObject = this.actor;
|
let actorObject = this.actor;
|
||||||
let element = event.currentTarget;
|
let element = event.currentTarget;
|
||||||
|
|
|
@ -37,8 +37,8 @@ export class OseActor extends Actor {
|
||||||
...this.data,
|
...this.data,
|
||||||
...{
|
...{
|
||||||
rollData: {
|
rollData: {
|
||||||
type: "Save",
|
type: "Above",
|
||||||
stat: save,
|
target: this.data.data.saves[save].value,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -54,6 +54,32 @@ export class OseActor extends Actor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rollMorale(options = {}) {
|
||||||
|
const label = game.i18n.localize(`OSE.Morale`);
|
||||||
|
const rollParts = ["2d6"];
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
...this.data,
|
||||||
|
...{
|
||||||
|
rollData: {
|
||||||
|
type: "Below",
|
||||||
|
target: this.data.data.details.morale,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Roll and return
|
||||||
|
return OseDice.Roll({
|
||||||
|
event: options.event,
|
||||||
|
parts: rollParts,
|
||||||
|
data: data,
|
||||||
|
skipDialog: true,
|
||||||
|
speaker: ChatMessage.getSpeaker({ actor: this }),
|
||||||
|
flavor: `${label} ${game.i18n.localize("OSE.Roll")}`,
|
||||||
|
title: `${label} ${game.i18n.localize("OSE.Roll")}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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"];
|
||||||
|
@ -79,6 +105,31 @@ export class OseActor extends Actor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rollHitDice(options = {}) {
|
||||||
|
const label = game.i18n.localize(`OSE.HitDice`);
|
||||||
|
const rollParts = [this.data.data.hp.hd];
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
...this.data,
|
||||||
|
...{
|
||||||
|
rollData: {
|
||||||
|
type: "Hit Dice"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Roll and return
|
||||||
|
return OseDice.Roll({
|
||||||
|
event: options.event,
|
||||||
|
parts: rollParts,
|
||||||
|
data: data,
|
||||||
|
skipDialog: true,
|
||||||
|
speaker: ChatMessage.getSpeaker({ actor: this }),
|
||||||
|
flavor: `${label} ${game.i18n.localize("OSE.Roll")}`,
|
||||||
|
title: `${label} ${game.i18n.localize("OSE.Roll")}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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"];
|
||||||
|
|
|
@ -135,6 +135,11 @@ export class OseActorSheetMonster extends OseActorSheet {
|
||||||
return this.actor.createOwnedItem(itemData, {});
|
return this.actor.createOwnedItem(itemData, {});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
html.find(".morale-check a").click((ev) => {
|
||||||
|
let actorObject = this.actor;
|
||||||
|
actorObject.rollMorale({ event: event });
|
||||||
|
});
|
||||||
|
|
||||||
// Handle default listeners last so system listeners are triggered first
|
// Handle default listeners last so system listeners are triggered first
|
||||||
super.activateListeners(html);
|
super.activateListeners(html);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,16 +34,23 @@ export class OseDice {
|
||||||
-3,
|
-3,
|
||||||
9
|
9
|
||||||
)}</b> (${thac})</div>`;
|
)}</b> (${thac})</div>`;
|
||||||
// ADD DAMAGE ROLL
|
|
||||||
}
|
}
|
||||||
} else if (data.rollData.type == "Save") {
|
} else if (data.rollData.type == "Above") {
|
||||||
// SAVING THROWS
|
// SAVING THROWS
|
||||||
let sv = data.data.saves[data.rollData.stat].value;
|
let sv = data.rollData.target;
|
||||||
if (roll.total >= sv) {
|
if (roll.total >= sv) {
|
||||||
details = `<div class='roll-result roll-success'><b>Success!</b> (${sv})</div>`;
|
details = `<div class='roll-result roll-success'><b>Success!</b> (${sv})</div>`;
|
||||||
} else {
|
} else {
|
||||||
details = `<div class='roll-result roll-fail'><b>Failure</b> (${sv})</div>`;
|
details = `<div class='roll-result roll-fail'><b>Failure</b> (${sv})</div>`;
|
||||||
}
|
}
|
||||||
|
} else if (data.rollData.type == "Below") {
|
||||||
|
// Morale
|
||||||
|
let m = data.rollData.target;
|
||||||
|
if (roll.total <= m) {
|
||||||
|
details = `<div class='roll-result roll-success'><b>Success!</b> (${m})</div>`;
|
||||||
|
} else {
|
||||||
|
details = `<div class='roll-result roll-fail'><b>Failure</b> (${m})</div>`;
|
||||||
|
}
|
||||||
} else if (data.rollData.type == "Check") {
|
} else if (data.rollData.type == "Check") {
|
||||||
// SCORE CHECKS
|
// SCORE CHECKS
|
||||||
let sc = data.data.scores[data.rollData.stat].value;
|
let sc = data.data.scores[data.rollData.stat].value;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { OseDice } from "../dice.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override and extend the basic :class:`Item` implementation
|
* Override and extend the basic :class:`Item` implementation
|
||||||
*/
|
*/
|
||||||
|
@ -48,7 +50,6 @@ export class OseItem extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
rollWeapon() {
|
rollWeapon() {
|
||||||
console.log("WEAPON");
|
|
||||||
if (this.data.data.missile) {
|
if (this.data.data.missile) {
|
||||||
this.actor.rollAttack({type: 'missile', label: this.name, dmg: this.data.data.damage});
|
this.actor.rollAttack({type: 'missile', label: this.name, dmg: this.data.data.damage});
|
||||||
} else if (this.data.data.melee) {
|
} else if (this.data.data.melee) {
|
||||||
|
@ -60,25 +61,32 @@ export class OseItem extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
async rollFormula(options={}) {
|
async rollFormula(options={}) {
|
||||||
console.log("FORMULA");
|
|
||||||
if ( !this.data.data.roll ) {
|
if ( !this.data.data.roll ) {
|
||||||
throw new Error("This Item does not have a formula to roll!");
|
throw new Error("This Item does not have a formula to roll!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define Roll Data
|
const label = `${this.name}`;
|
||||||
const rollData = {
|
const rollParts = [this.data.data.roll];
|
||||||
item: this.data.data
|
|
||||||
};
|
|
||||||
const title = `${this.name} - Roll`;
|
|
||||||
|
|
||||||
// Invoke the roll and submit it to chat
|
const data = {
|
||||||
const roll = new Roll(rollData.item.roll, rollData).roll();
|
...this.data,
|
||||||
roll.toMessage({
|
...{
|
||||||
speaker: ChatMessage.getSpeaker({actor: this.actor}),
|
rollData: {
|
||||||
flavor: this.data.data.chatFlavor || title,
|
type: "Formula"
|
||||||
rollMode: game.settings.get("core", "rollMode")
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Roll and return
|
||||||
|
return OseDice.Roll({
|
||||||
|
event: options.event,
|
||||||
|
parts: rollParts,
|
||||||
|
data: data,
|
||||||
|
skipDialog: true,
|
||||||
|
speaker: ChatMessage.getSpeaker({ actor: this }),
|
||||||
|
flavor: `${label} ${game.i18n.localize("OSE.Roll")}`,
|
||||||
|
title: `${label} ${game.i18n.localize("OSE.Roll")}`,
|
||||||
});
|
});
|
||||||
return roll;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
.ose.actor.monster {
|
.ose.actor.monster {
|
||||||
min-height: 565px;
|
min-height: 565px;
|
||||||
min-width: 460px;
|
min-width: 460px;
|
||||||
|
.header-details {
|
||||||
|
.summary {
|
||||||
|
.morale-check {
|
||||||
|
line-height: 35px;
|
||||||
|
flex: 0 0 20px;
|
||||||
|
&:hover {
|
||||||
|
color: $colorDark;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.sheet-body {
|
.sheet-body {
|
||||||
.editor {
|
.editor {
|
||||||
height: 300px;
|
height: 300px;
|
||||||
|
|
|
@ -29,11 +29,21 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"saves": {
|
"saves": {
|
||||||
"death": 10,
|
"death": {
|
||||||
"wand": 10,
|
"value": 10
|
||||||
"paralysis": 10,
|
},
|
||||||
"breath": 10,
|
"wand": {
|
||||||
"spell": 10
|
"value": 10
|
||||||
|
},
|
||||||
|
"paralysis": {
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
"breath": {
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
"spell": {
|
||||||
|
"value": 10
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"movement": {
|
"movement": {
|
||||||
"base": 120
|
"base": 120
|
||||||
|
|
|
@ -126,9 +126,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="flexrow">
|
<div class="flexrow">
|
||||||
<ul class="attributes flexrow">
|
<ul class="attributes flexrow">
|
||||||
<li class="attribute">
|
<li class="attribute hit-dice">
|
||||||
<h4 class="attribute-name box-title" title="{{ localize 'OSE.HitDice' }}">
|
<h4 class="attribute-name box-title" title="{{ localize 'OSE.HitDice' }}">
|
||||||
{{ localize "OSE.HitDiceShort" }}
|
<a>{{ localize "OSE.HitDiceShort" }}</a>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="attribute-value">
|
<div class="attribute-value">
|
||||||
<input name="data.hp.hd" type="text" value="{{data.hp.hd}}" placeholder=""
|
<input name="data.hp.hd" type="text" value="{{data.hp.hd}}" placeholder=""
|
||||||
|
|
|
@ -13,9 +13,12 @@
|
||||||
<label>{{localize 'OSE.Appearing'}}</label>
|
<label>{{localize 'OSE.Appearing'}}</label>
|
||||||
</li>
|
</li>
|
||||||
{{#if config.morale}}
|
{{#if config.morale}}
|
||||||
<li>
|
<li class="flexrow">
|
||||||
<input type="text" name="data.details.morale" value="{{data.details.morale}}" />
|
<div>
|
||||||
<label>{{localize 'OSE.Morale'}}</label>
|
<input type="text" name="data.details.morale" value="{{data.details.morale}}" />
|
||||||
|
<label>{{localize 'OSE.Morale'}}</label>
|
||||||
|
</div>
|
||||||
|
<div class="morale-check"><a><i class="fas fa-dice"></i></a></div>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if data.roll}}
|
{{#if data.roll}}
|
||||||
<button data-action="formula">{{ localize "OSE.Roll"}}</button>
|
<button data-action="formula">{{ localize "OSE.Roll"}} {{data.roll}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue