ENH: Saving throws
parent
44c33d397e
commit
bc9cf50416
|
@ -39,10 +39,6 @@ export class OseActorSheetCharacter extends OseActorSheet {
|
||||||
getData() {
|
getData() {
|
||||||
const data = super.getData();
|
const data = super.getData();
|
||||||
|
|
||||||
for (let [a, score] of Object.entries(data.data.scores)) {
|
|
||||||
data.data.scores[a].label = game.i18n.localize(`OSE.scores.${a}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
data.config.variableWeaponDamage = game.settings.get(
|
data.config.variableWeaponDamage = game.settings.get(
|
||||||
"ose",
|
"ose",
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
export const OSE = {
|
export const OSE = {
|
||||||
scores: {
|
scores: {
|
||||||
str: "OSE.scores.str.long",
|
str: "OSE.scores.str.long",
|
||||||
int: "OSE.scores.int.long",
|
int: "OSE.scores.int.long",
|
||||||
dex: "OSE.scores.dex.long",
|
dex: "OSE.scores.dex.long",
|
||||||
wis: "OSE.scores.wis.long",
|
wis: "OSE.scores.wis.long",
|
||||||
con: "OSE.scores.con.long",
|
con: "OSE.scores.con.long",
|
||||||
cha: "OSE.scores.cha.long"
|
cha: "OSE.scores.cha.long",
|
||||||
},
|
},
|
||||||
saves: {
|
saves_short: {
|
||||||
death: "OSE.saves.death.short",
|
death: "OSE.saves.death.short",
|
||||||
wand: "OSE.saves.wand.short",
|
wand: "OSE.saves.wand.short",
|
||||||
paralysis: "OSE.saves.paralysis.short",
|
paralysis: "OSE.saves.paralysis.short",
|
||||||
breath: "OSE.saves.breath.short",
|
breath: "OSE.saves.breath.short",
|
||||||
spell: "OSE.saves.spell.short"
|
spell: "OSE.saves.spell.short",
|
||||||
}
|
},
|
||||||
};
|
saves_long: {
|
||||||
|
death: "OSE.saves.death.long",
|
||||||
|
wand: "OSE.saves.wand.long",
|
||||||
|
paralysis: "OSE.saves.paralysis.long",
|
||||||
|
breath: "OSE.saves.breath.long",
|
||||||
|
spell: "OSE.saves.spell.long",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
|
@ -48,6 +48,7 @@ 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) {
|
||||||
|
@ -59,6 +60,7 @@ 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!");
|
||||||
}
|
}
|
||||||
|
@ -99,6 +101,7 @@ export class OseItem extends Item {
|
||||||
hasDamage: this.hasDamage,
|
hasDamage: this.hasDamage,
|
||||||
isSpell: this.data.type === "spell",
|
isSpell: this.data.type === "spell",
|
||||||
hasSave: this.hasSave,
|
hasSave: this.hasSave,
|
||||||
|
config: CONFIG.OSE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Render the chat card template
|
// Render the chat card template
|
||||||
|
@ -137,7 +140,11 @@ export class OseItem extends Item {
|
||||||
const header = event.currentTarget;
|
const header = event.currentTarget;
|
||||||
const card = header.closest(".chat-card");
|
const card = header.closest(".chat-card");
|
||||||
const content = card.querySelector(".card-content");
|
const content = card.querySelector(".card-content");
|
||||||
content.style.display = content.style.display === "none" ? "block" : "none";
|
if (content.style.display == "none") {
|
||||||
|
$(content).slideDown(200);
|
||||||
|
} else {
|
||||||
|
$(content).slideUp(200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,20 +177,20 @@ export class OseItem extends Item {
|
||||||
let targets = [];
|
let targets = [];
|
||||||
if ( isTargetted ) {
|
if ( isTargetted ) {
|
||||||
targets = this._getChatCardTargets(card);
|
targets = this._getChatCardTargets(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attack and Damage Rolls
|
||||||
|
if ( action === "damage" ) await item.rollDamage({event});
|
||||||
|
else if ( action === "formula" ) await item.rollFormula({event});
|
||||||
|
|
||||||
|
// Saving Throws for card targets
|
||||||
|
else if ( action == "save" ) {
|
||||||
if ( !targets.length ) {
|
if ( !targets.length ) {
|
||||||
ui.notifications.warn(`You must have one or more controlled Tokens in order to use this option.`);
|
ui.notifications.warn(`You must have one or more controlled Tokens in order to use this option.`);
|
||||||
return button.disabled = false;
|
return button.disabled = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Attack and Damage Rolls
|
|
||||||
else if ( action === "damage" ) await item.rollDamage({event});
|
|
||||||
else if ( action === "formula" ) await item.rollFormula({event});
|
|
||||||
|
|
||||||
// Saving Throws for card targets
|
|
||||||
else if ( action === "save" ) {
|
|
||||||
for ( let t of targets ) {
|
for ( let t of targets ) {
|
||||||
await t.rollAbilitySave(button.dataset.ability, {event});
|
await t.rollSave(button.dataset.save, {event});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,9 @@ Hooks.once("init", async function () {
|
||||||
*/
|
*/
|
||||||
Hooks.once("setup", function () {
|
Hooks.once("setup", function () {
|
||||||
// Localize CONFIG objects once up-front
|
// Localize CONFIG objects once up-front
|
||||||
const toLocalize = [];
|
const toLocalize = ["saves_short", "saves_long", "scores"];
|
||||||
for (let o of toLocalize) {
|
for (let o of toLocalize) {
|
||||||
CONFIG.MAJI[o] = Object.entries(CONFIG.OSE[o]).reduce((obj, e) => {
|
CONFIG.OSE[o] = Object.entries(CONFIG.OSE[o]).reduce((obj, e) => {
|
||||||
obj[e[0]] = game.i18n.localize(e[1]);
|
obj[e[0]] = game.i18n.localize(e[1]);
|
||||||
return obj;
|
return obj;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
color: $colorOlive;
|
color: $colorOlive;
|
||||||
&:hover {
|
&:hover {
|
||||||
color: #111;
|
color: #111;
|
||||||
text-shadow: 0 0 10px red;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{{#if tokenId}}data-token-id="{{tokenId}}" {{/if}}>
|
{{#if tokenId}}data-token-id="{{tokenId}}" {{/if}}>
|
||||||
<header class="card-header flexrow">
|
<header class="card-header flexrow">
|
||||||
<img src="{{item.img}}" title="{{item.name}}" width="36" height="36" />
|
<img src="{{item.img}}" title="{{item.name}}" width="36" height="36" />
|
||||||
<h3 class="item-name">{{item.name}}</h3>
|
<h3 class="item-name"><a>{{item.name}}</a></h3>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="card-content" style="display:none;">
|
<div class="card-content" style="display:none;">
|
||||||
|
@ -23,8 +23,8 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if data.save}}
|
{{#if data.save}}
|
||||||
<button data-action="save" data-ability="{{data.save}}" disabled>
|
<button data-action="save" data-save="{{data.save}}" disabled>
|
||||||
{{ localize "OSE.SavingThrow" }} {{data.save}}
|
{{lookup config.saves_long data.save}} {{ localize "OSE.SavingThrow" }}
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@
|
||||||
<select name="data.save">
|
<select name="data.save">
|
||||||
{{#select data.save}}
|
{{#select data.save}}
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
{{#each config.saves as |save a|}}
|
{{#each config.saves_short as |save a|}}
|
||||||
<option value="{{a}}">{{localize save}}</option>
|
<option value="{{a}}">{{save}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in New Issue