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

1
.gitignore vendored
View File

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

View File

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

View File

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

View File

@ -4,7 +4,6 @@ import { OseDice } from "../dice.js";
* Override and extend the basic :class:`Item` implementation
*/
export class OseItem extends Item {
/* -------------------------------------------- */
/* Data Preparation */
/* -------------------------------------------- */
@ -82,6 +81,7 @@ export class OseItem extends Item {
this.actor.rollAttack(
{
type: "melee",
save: this.data.data.save,
label: this.name,
dmg: this.data.data.damage,
bonus: data.bonus,
@ -98,6 +98,7 @@ export class OseItem extends Item {
{
type: "missile",
label: this.name,
save: this.data.data.save,
dmg: this.data.data.damage,
},
options
@ -114,7 +115,13 @@ export class OseItem extends Item {
type = "melee";
}
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
);
@ -166,29 +173,42 @@ export class OseItem extends Item {
}
getTags() {
let formatTag = (tag) => {
let formatTag = (tag, icon) => {
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;
switch (this.data.type) {
case "weapon":
let wTags = formatTag(data.damage);
data.tags.forEach(t => {
let wTags = formatTag(data.damage, "fa-tint");
data.tags.forEach((t) => {
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;
case "armor":
return `${formatTag(CONFIG.OSE.armor[data.type])}`;
return `${formatTag(CONFIG.OSE.armor[data.type], "fa-tshirt")}`;
case "item":
return "";
case "spell":
return `${formatTag(data.class)}${formatTag(data.range)}${formatTag(
data.duration
)}${formatTag(CONFIG.OSE.saves_long[data.save])}${formatTag(
data.roll
)}`;
let sTags = `${formatTag(data.class)}${formatTag(
data.range
)}${formatTag(data.duration)}${formatTag(data.roll)}`;
if (data.save) {
sTags += formatTag(CONFIG.OSE.saves_long[data.save], "fa-skull");
}
return sTags;
case "ability":
let 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="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>
<div class="chat-details">
@ -13,6 +17,13 @@
<div class="roll-result"><b>{{localize 'OSE.messages.InflictsDamage'}}</b></div>
</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}}
</div>
</section>
</div>

View File

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