Skip to content

Commit

Permalink
Merge branch 'release/4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
megastruktur committed Sep 5, 2022
2 parents 43e1b63 + 2bda47e commit 00bed1c
Show file tree
Hide file tree
Showing 51 changed files with 1,204 additions and 1,183 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v.4.0
- Update to FoundryVTT v10 with migrations by @drewg13

v.3.19
- system.json updated to v3.19

Expand Down
6 changes: 3 additions & 3 deletions module/blades-active-effect.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class BladesActiveEffect extends ActiveEffect {
if ( this.isSuppressed ) return null;
//this allows for math and actor data references in the change values. Probably not necessary for
// blades, but it was simple, and you never know what users will do. Probably ruin everything.
change.value = Roll.replaceFormulaData(change.value, actor.data);
change.value = Roll.replaceFormulaData(change.value, actor.system);
try {
change.value = Roll.safeEval(change.value).toString();
} catch (e) {
Expand Down Expand Up @@ -70,7 +70,7 @@ export class BladesActiveEffect extends ActiveEffect {
console.log("delete effect");
return effect.delete();
case "toggle":
return effect.update({disabled: !effect.data.disabled});
return effect.update({disabled: !effect.disabled});
}
}

Expand Down Expand Up @@ -111,7 +111,7 @@ export class BladesActiveEffect extends ActiveEffect {
for ( let e of effects ) {
e._getSourceName(); // Trigger a lookup for the source name
if ( e.isSuppressed ) categories.suppressed.effects.push(e);
else if ( e.data.disabled ) categories.inactive.effects.push(e);
else if ( e.disabled ) categories.inactive.effects.push(e);
else if ( e.isTemporary ) categories.temporary.effects.push(e);
else categories.passive.effects.push(e);
}
Expand Down
53 changes: 28 additions & 25 deletions module/blades-actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,20 @@ export class BladesActorSheet extends BladesSheet {
/* -------------------------------------------- */

/** @override */
getData() {
var data = super.getData();
data.editable = this.options.editable;
data.isGM = game.user.isGM;
const actorData = data.data;
data.actor = actorData;
data.data = actorData.data;
async getData(options) {
const superData = super.getData( options );
const sheetData = superData.data;
sheetData.owner = superData.owner;
sheetData.editable = superData.editable;
sheetData.isGM = game.user.isGM;

// Prepare active effects
data.effects = BladesActiveEffect.prepareActiveEffectCategories(this.actor.effects);
sheetData.effects = BladesActiveEffect.prepareActiveEffectCategories(this.actor.effects);

// Calculate Load
let loadout = 0;
data.items.forEach(i => {loadout += (i.type === "item") ? parseInt(i.data.load) : 0});
data.data.loadout = loadout;

// Encumbrance Levels
let load_level=["BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Normal","BITD.Normal","BITD.Heavy","BITD.Encumbered",
"BITD.Encumbered","BITD.Encumbered","BITD.OverMax"];
let mule_level=["BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Normal","BITD.Normal",
"BITD.Heavy","BITD.Encumbered","BITD.OverMax"];
let mule_present=0;

sheetData.items.forEach(i => {loadout += (i.type === "item") ? parseInt(i.system.load) : 0});

//Sanity Check
if (loadout < 0) {
loadout = 0;
Expand All @@ -53,24 +44,36 @@ export class BladesActorSheet extends BladesSheet {
loadout = 10;
}

sheetData.system.loadout = loadout;

// Encumbrance Levels
let load_level=["BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Normal","BITD.Normal","BITD.Heavy","BITD.Encumbered",
"BITD.Encumbered","BITD.Encumbered","BITD.OverMax"];
let mule_level=["BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Light","BITD.Normal","BITD.Normal",
"BITD.Heavy","BITD.Encumbered","BITD.OverMax"];
let mule_present=0;


//look for Mule ability
// @todo - fix translation.
data.items.forEach(i => {
if (i.type == "ability" && i.name == "(C) Mule") {
sheetData.items.forEach(i => {
if (i.type === "ability" && i.name === "(C) Mule") {
mule_present = 1;
}
});

//set encumbrance level
if (mule_present) {
data.data.load_level=mule_level[loadout];
sheetData.system.load_level=mule_level[loadout];
} else {
data.data.load_level=load_level[loadout];
sheetData.system.load_level=load_level[loadout];
}

data.load_levels = {"BITD.Light":"BITD.Light", "BITD.Normal":"BITD.Normal", "BITD.Heavy":"BITD.Heavy"};

return data;
sheetData.system.load_levels = {"BITD.Light":"BITD.Light", "BITD.Normal":"BITD.Normal", "BITD.Heavy":"BITD.Heavy"};

sheetData.system.description = await TextEditor.enrichHTML(sheetData.system.description, {secrets: sheetData.owner, async: true});

return sheetData;
}

/* -------------------------------------------- */
Expand Down
58 changes: 29 additions & 29 deletions module/blades-actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export class BladesActor extends Actor {
/** @override */
static async create(data, options={}) {

data.token = data.token || {};
data.prototypeToken = data.prototypeToken || {};

// For Crew and Character set the Token to sync with charsheet.
switch (data.type) {
case 'character':
case 'crew':
case '\uD83D\uDD5B clock':
data.token.actorLink = true;
data.prototypeToken.actorLink = true;
break;
}

Expand All @@ -26,11 +26,11 @@ export class BladesActor extends Actor {

/** @override */
getRollData() {
const data = super.getRollData();
const rollData = super.getRollData();

data.dice_amount = this.getAttributeDiceToThrow();
rollData.dice_amount = this.getAttributeDiceToThrow();

return data;
return rollData;
}

/* -------------------------------------------- */
Expand All @@ -41,10 +41,10 @@ export class BladesActor extends Actor {

// Calculate Dice to throw.
let dice_amount = {};
for (var attribute_name in this.data.data.attributes) {
for (const attribute_name in this.system.attributes) {
dice_amount[attribute_name] = 0;
for (var skill_name in this.data.data.attributes[attribute_name].skills) {
dice_amount[skill_name] = parseInt(this.data.data.attributes[attribute_name].skills[skill_name]['value'][0])
for (const skill_name in this.system.attributes[attribute_name].skills) {
dice_amount[skill_name] = parseInt(this.system.attributes[attribute_name].skills[skill_name]['value'][0])

// We add a +1d for every skill higher than 0.
if (dice_amount[skill_name] > 0) {
Expand All @@ -64,7 +64,7 @@ export class BladesActor extends Actor {
// const roll = new Roll("1d20 + @abilities.wis.mod", actor.getRollData());
let attribute_label = BladesHelpers.getAttributeLabel(attribute_name);

var content = `
let content = `
<h2>${game.i18n.localize('BITD.Roll')} ${game.i18n.localize(attribute_label)}</h2>
<form>
<div class="form-group">
Expand Down Expand Up @@ -103,7 +103,7 @@ export class BladesActor extends Actor {
</div><br/>
</form>
`;

new Dialog({
title: `${game.i18n.localize('BITD.Roll')} ${game.i18n.localize(attribute_label)}`,
content: content,
Expand All @@ -130,7 +130,7 @@ export class BladesActor extends Actor {
}

/* -------------------------------------------- */

async rollAttribute(attribute_name = "", additional_dice_amount = 0, position, effect, note) {

let dice_amount = 0;
Expand All @@ -153,27 +153,27 @@ export class BladesActor extends Actor {
* which can be performed.
*/
createListOfActions() {

let text, attribute, skill;
let attributes = this.data.data.attributes;
let attributes = this.system.attributes;

for ( attribute in attributes ) {
var skills = attributes[attribute].skills;

const skills = attributes[attribute].skills;

text += `<optgroup label="${attribute} Actions">`;
text += `<option value="${attribute}">${attribute} (Resist)</option>`;

for ( skill in skills ) {
text += `<option value="${skill}">${skill}</option>`;
}

text += `</optgroup>`;

}

return text;

}

/* -------------------------------------------- */
Expand All @@ -183,33 +183,33 @@ export class BladesActor extends Actor {
*
* @param {int} rs
* Min die modifier
* @param {int} re
* @param {int} re
* Max die modifier
* @param {int} s
* Selected die
*/
createListOfDiceMods(rs, re, s) {

var text = ``;
var i = 0;

if ( s == "" ) {
s = 0;
}

for ( i = rs; i <= re; i++ ) {
var plus = "";
if ( i >= 0 ) { plus = "+" };
text += `<option value="${i}"`;
if ( i == s ) {
text += ` selected`;
}

text += `>${plus}${i}d</option>`;
}

return text;

}

/* -------------------------------------------- */
Expand Down
23 changes: 12 additions & 11 deletions module/blades-clock-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,31 @@ export class BladesClockSheet extends BladesSheet {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["blades-in-the-dark", "sheet", "actor", "clock"],
template: "systems/blades-in-the-dark/templates/actors/clock-sheet.html",
width: 700,
height: 970,
width: 420,
height: 400,
});
}

/* -------------------------------------------- */

/** @override */
getData() {
var data = super.getData();
data.editable = this.options.editable;
const actorData = data.data;
data.actor = actorData;
data.data = actorData.data;
return data;
getData(options) {
const superData = super.getData( options );
const sheetData = superData.data;
sheetData.owner = superData.owner;
sheetData.editable = superData.editable;
sheetData.isGM = game.user.isGM;

return sheetData;
}

/* -------------------------------------------- */

/** @override */
async _updateObject(event, formData) {
let image_path = `systems/blades-in-the-dark/styles/assets/progressclocks-svg/Progress Clock ${formData['data.type']}-${formData['data.value']}.svg`;
let image_path = `systems/blades-in-the-dark/styles/assets/progressclocks-svg/Progress Clock ${formData['system.type']}-${formData['system.value']}.svg`;
formData['img'] = image_path;
formData['token.img'] = image_path;
formData['prototypeToken.texture.src'] = image_path;
let data = [];
let update = {
img: image_path,
Expand Down
30 changes: 15 additions & 15 deletions module/blades-crew-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,32 @@ export class BladesCrewSheet extends BladesSheet {
/* -------------------------------------------- */

/** @override */
getData() {
const data = super.getData();
data.editable = this.options.editable;
const actorData = data.data;
data.actor = actorData;
data.data = actorData.data;
getData(options) {
const superData = super.getData( options );
const sheetData = superData.data;
sheetData.owner = superData.owner;
sheetData.editable = superData.editable;
sheetData.isGM = game.user.isGM;

// Calculate Turfs amount.
// We already have Lair, so set to -1.
let turfs_amount = 0

data.items.forEach(item => {
sheetData.items.forEach(item => {

if (item.type === "crew_type") {
// Object.entries(item.data.turfs).forEach(turf => {turfs_amount += (turf.value === true) ? 1 : 0});
Object.entries(item.data.turfs).forEach(([key, turf]) => {
Object.entries(item.system.turfs).forEach(([key, turf]) => {
if (turf.name === 'BITD.Turf') {
turfs_amount += (turf.value === true) ? 1 : 0;
}
});
}

});
data.data.turfs_amount = turfs_amount;
sheetData.system.turfs_amount = turfs_amount;

return data;
return sheetData;
}

/* -------------------------------------------- */
Expand Down Expand Up @@ -79,11 +79,11 @@ export class BladesCrewSheet extends BladesSheet {
// Toggle Turf
html.find('.turf-select').click( async ev => {
const element = $(ev.currentTarget).parents(".item");

let item_id = element.data("itemId")
let turf_id = $(ev.currentTarget).data("turfId");
let turf_current_status = $(ev.currentTarget).data("turfStatus");
let turf_checkbox_name = 'data.turfs.' + turf_id + '.value';
let turf_checkbox_name = 'system.turfs.' + turf_id + '.value';

await this.actor.updateEmbeddedDocuments('Item', [{
_id: item_id,
Expand All @@ -94,13 +94,13 @@ export class BladesCrewSheet extends BladesSheet {
// Cohort Block Harm handler
html.find('.cohort-block-harm input[type="radio"]').change( async ev => {
const element = $(ev.currentTarget).parents(".item");

let item_id = element.data("itemId")
let harm_id = $(ev.currentTarget).val();

await this.actor.updateEmbeddedDocuments('Item', [{
_id: item_id,
"data.harm": [harm_id]}]);
"system.harm": [harm_id]}]);
this.render(false);
});
}
Expand All @@ -115,7 +115,7 @@ export class BladesCrewSheet extends BladesSheet {
// Update the Item
await super._updateObject(event, formData);

if (event.target && event.target.name === "data.tier") {
if (event.target && event.target.name === "system.tier") {
this.render(true);
}
}
Expand Down
Loading

0 comments on commit 00bed1c

Please sign in to comment.