WIP: Attack saves

master
U~man 2020-07-24 20:04:18 +02:00 committed by o-reo
parent 1b01c7ff10
commit f31bc3e790
6 changed files with 70 additions and 34 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules node_modules
dist dist
foundryconfig.json

View File

@ -53,15 +53,15 @@ export class OseActor extends Actor {
isNew() { isNew() {
const data = this.data.data; const data = this.data.data;
if (this.data.type == 'character') { if (this.data.type == "character") {
let ct = 0; let ct = 0;
Object.values(data.scores).forEach((el) => { Object.values(data.scores).forEach((el) => {
ct += el.value; ct += el.value;
}) });
return ct == 0 ? true : false; return ct == 0 ? true : false;
} else if (this.data.type == 'monster') { } else if (this.data.type == "monster") {
let ct = 0; let ct = 0;
Object.values(data.saves).forEach(el => { Object.values(data.saves).forEach((el) => {
ct += el.value; ct += el.value;
}); });
return ct == 0 ? true : false; return ct == 0 ? true : false;
@ -79,21 +79,21 @@ export class OseActor extends Actor {
this.update({ this.update({
"data.saves": { "data.saves": {
death: { death: {
value: saves.d value: saves.d,
}, },
wand: { wand: {
value: saves.w value: saves.w,
}, },
paralysis: { paralysis: {
value: saves.p value: saves.p,
}, },
breath: { breath: {
value: saves.b value: saves.b,
}, },
spell: { spell: {
value: saves.s value: saves.s,
} },
} },
}); });
} }
@ -270,7 +270,7 @@ export class OseActor extends Actor {
rollHitDice(options = {}) { rollHitDice(options = {}) {
const label = game.i18n.localize(`OSE.roll.hd`); const label = game.i18n.localize(`OSE.roll.hd`);
const rollParts = [this.data.data.hp.hd]; const rollParts = [this.data.data.hp.hd];
if (this.data.type == 'character') { if (this.data.type == "character") {
rollParts.push(this.data.data.scores.con.mod); rollParts.push(this.data.data.scores.con.mod);
} }
@ -436,6 +436,7 @@ export class OseActor extends Actor {
rollData: { rollData: {
type: "attack", type: "attack",
thac0: thac0, thac0: thac0,
save: attData.save,
weapon: { weapon: {
parts: dmgParts, parts: dmgParts,
}, },
@ -522,7 +523,7 @@ export class OseActor extends Actor {
value: totalWeight, value: totalWeight,
}; };
if (data.config.movementAuto && option != 'disabled') { if (data.config.movementAuto && option != "disabled") {
this._calculateMovement(); this._calculateMovement();
} }
} }
@ -545,7 +546,7 @@ export class OseActor extends Actor {
data.movement.base = 120; data.movement.base = 120;
} }
} else if (option == "basic") { } else if (option == "basic") {
const armors = this.data.items.filter(i => i.type == "armor"); const armors = this.data.items.filter((i) => i.type == "armor");
let heaviest = 0; let heaviest = 0;
armors.forEach((a) => { armors.forEach((a) => {
if (a.data.equipped) { if (a.data.equipped) {
@ -580,7 +581,9 @@ export class OseActor extends Actor {
const data = this.data.data; const data = this.data.data;
// Compute treasure // Compute treasure
let total = 0; let total = 0;
let treasure = this.data.items.filter(i => (i.type == "item" && i.data.treasure)) let treasure = this.data.items.filter(
(i) => i.type == "item" && i.data.treasure
);
treasure.forEach((item) => { treasure.forEach((item) => {
total += item.data.quantity.value * item.data.cost; total += item.data.quantity.value * item.data.cost;
}); });

View File

@ -165,6 +165,7 @@ export class OseDice {
title: title, title: title,
flavor: flavor, flavor: flavor,
data: data, data: data,
config: CONFIG.OSE,
}; };
// Optionally include a situational bonus // Optionally include a situational bonus

View File

@ -4,7 +4,6 @@ import { OseDice } from "../dice.js";
* Override and extend the basic :class:`Item` implementation * Override and extend the basic :class:`Item` implementation
*/ */
export class OseItem extends Item { export class OseItem extends Item {
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Data Preparation */ /* Data Preparation */
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -82,6 +81,7 @@ export class OseItem extends Item {
this.actor.rollAttack( this.actor.rollAttack(
{ {
type: "melee", type: "melee",
save: this.data.data.save,
label: this.name, label: this.name,
dmg: this.data.data.damage, dmg: this.data.data.damage,
bonus: data.bonus, bonus: data.bonus,
@ -98,6 +98,7 @@ export class OseItem extends Item {
{ {
type: "missile", type: "missile",
label: this.name, label: this.name,
save: this.data.data.save,
dmg: this.data.data.damage, dmg: this.data.data.damage,
}, },
options options
@ -114,7 +115,13 @@ export class OseItem extends Item {
type = "melee"; type = "melee";
} }
this.actor.rollAttack( this.actor.rollAttack(
{ type: type, label: this.name, dmg: data.damage, bonus: data.bonus }, {
type: type,
label: this.name,
save: data.save,
dmg: data.damage,
bonus: data.bonus,
},
options options
); );
@ -166,29 +173,42 @@ export class OseItem extends Item {
} }
getTags() { getTags() {
let formatTag = (tag) => { let formatTag = (tag, icon) => {
if (!tag) return ""; if (!tag) return "";
return `<li class='tag'>${tag}</li>`; let fa = "";
if (icon) {
fa = `<i class="fas ${icon}"></i> `;
}
return `<li class='tag'>${fa}${tag}</li>`;
}; };
const data = this.data.data; const data = this.data.data;
switch (this.data.type) { switch (this.data.type) {
case "weapon": case "weapon":
let wTags = formatTag(data.damage); let wTags = formatTag(data.damage, "fa-tint");
data.tags.forEach(t => { data.tags.forEach((t) => {
wTags += formatTag(t.value); wTags += formatTag(t.value);
}) });
wTags += formatTag(CONFIG.OSE.saves_long[data.save], "fa-skull");
if (data.missile) {
wTags += formatTag(
data.range.short + "/" + data.range.medium + "/" + data.range.long,
"fa-bullseye"
);
}
return wTags; return wTags;
case "armor": case "armor":
return `${formatTag(CONFIG.OSE.armor[data.type])}`; return `${formatTag(CONFIG.OSE.armor[data.type], "fa-tshirt")}`;
case "item": case "item":
return ""; return "";
case "spell": case "spell":
return `${formatTag(data.class)}${formatTag(data.range)}${formatTag( let sTags = `${formatTag(data.class)}${formatTag(
data.duration data.range
)}${formatTag(CONFIG.OSE.saves_long[data.save])}${formatTag( )}${formatTag(data.duration)}${formatTag(data.roll)}`;
data.roll if (data.save) {
)}`; sTags += formatTag(CONFIG.OSE.saves_long[data.save], "fa-skull");
}
return sTags;
case "ability": case "ability":
let roll = ""; let roll = "";
roll += data.roll ? data.roll : ""; roll += data.roll ? data.roll : "";

View File

@ -1,7 +1,11 @@
<section class="ose chat-message"> {{log data}}
<div class="ose chat-card item-card" data-actor-id="{{actor._id}}" data-item-id="{{item._id}}">
{{#if tokenId}}data-token-id="{{tokenId}}"{{/if}}>
<div class="ose chat-block"> <div class="ose chat-block">
<div class="flexrow chat-header"> <div class="flexrow chat-header">
<div class="chat-title"><h2>{{title}}</h2></div> <div class="chat-title">
<h2>{{title}}</h2>
</div>
<div class="chat-img" style="background-image:url('{{data.img}}')"></div> <div class="chat-img" style="background-image:url('{{data.img}}')"></div>
</div> </div>
<div class="chat-details"> <div class="chat-details">
@ -13,6 +17,13 @@
<div class="roll-result"><b>{{localize 'OSE.messages.InflictsDamage'}}</b></div> <div class="roll-result"><b>{{localize 'OSE.messages.InflictsDamage'}}</b></div>
</div> </div>
<div class="damage-roll">{{{rollDamage}}}</div> <div class="damage-roll">{{{rollDamage}}}</div>
{{#if data.rollData.save}}
<div class="card-buttons">
<button data-action="save" data-save="{{data.rollData.save}}" disabled>
{{lookup config.saves_long data.rollData.save}} - {{localize "OSE.spells.Save"}}
</button>
</div>
{{/if}}
{{/if}} {{/if}}
</div> </div>
</section> </div>

View File

@ -101,8 +101,8 @@
<div class="form-fields range"> <div class="form-fields range">
<input <input
type="text" type="text"
name="data.range.close" name="data.range.short"
value="{{data.range.close}}" value="{{data.range.short}}"
data-dtype="Number" data-dtype="Number"
/> />
<div class="sep"></div> <div class="sep"></div>