Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jonepatr committed Jan 21, 2022
1 parent 8921642 commit cca7da2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/module/entities/TwodsixItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import { TwodsixDiceRoll } from "../utils/TwodsixDiceRoll";
import { TwodsixRollSettings } from "../utils/TwodsixRollSettings";
import TwodsixActor from "./TwodsixActor";
import { DICE_ROLL_MODES } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/constants.mjs";
import { Consumable, Gear, Skills, UsesConsumables, Weapon } from "../../types/template";
import { ItemDataConstructorData } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/itemData";


export default class TwodsixItem extends Item {

public static async create(data: ItemDataConstructorData, options?: DocumentModificationContext): Promise<TwodsixItem> {
const item = await super.create(data, options) as unknown as TwodsixItem;
item?.setFlag('twodsix', 'newItem', true);
if (item?.data.type === 'weapon' && (item.data.img === "" || item.data.img === foundry.data.ItemData.DEFAULT_ICON)) {
await item.update({'img': 'systems/twodsix/assets/icons/default_weapon.png'});
await item.update({ 'img': 'systems/twodsix/assets/icons/default_weapon.png' });
}

return item;
Expand Down Expand Up @@ -65,7 +67,7 @@ export default class TwodsixItem extends Item {
if (gear.consumables.includes(consumableId)) {
console.error(`Twodsix | Consumable already exists for item ${this.id}`);
} else {
await this.update({"data.consumables": gear.consumables.concat(consumableId)}, {});
await this.update({ "data.consumables": gear.consumables.concat(consumableId) }, {});
}
} else {
ui.notifications.error(`Twodsix | Consumable can't be added to item ${this.id}`);
Expand All @@ -76,7 +78,7 @@ export default class TwodsixItem extends Item {
const updatedConsumables = gear.consumables.filter((cId: string) => {
return (cId !== consumableId && cId !== null && this.actor?.items.get(cId) !== undefined);
});
const updateData = {"data.consumables": updatedConsumables};
const updateData = { "data.consumables": updatedConsumables };
if (gear.useConsumableForAttack === consumableId) {
updateData["data.useConsumableForAttack"] = "";
}
Expand Down Expand Up @@ -107,7 +109,7 @@ export default class TwodsixItem extends Item {
diceModifier: undefined
};
if (skill) {
tmpSettings = {characteristic: (<Skills>skill.data.data).characteristic || 'NONE'};
tmpSettings = { characteristic: (<Skills>skill.data.data).characteristic || 'NONE' };
}

let usedAmmo = 1;
Expand Down Expand Up @@ -228,7 +230,7 @@ export default class TwodsixItem extends Item {

const damageFormula = weapon.damage + (bonusDamage ? "+" + bonusDamage : "");
const damageRoll = new Roll(damageFormula, this.actor?.data.data);
const damage: Roll = await damageRoll.evaluate({async: true}); // async: true will be default in foundry 0.10
const damage: Roll = await damageRoll.evaluate({ async: true }); // async: true will be default in foundry 0.10
if (showInChat) {
const results = damage.terms[0]["results"];
const contentData = {
Expand All @@ -246,13 +248,13 @@ export default class TwodsixItem extends Item {
}
);
await damage.toMessage({
speaker: this.actor ? ChatMessage.getSpeaker({actor: this.actor}) : "???",
speaker: this.actor ? ChatMessage.getSpeaker({ actor: this.actor }) : "???",
content: html,
flags: {
"core.canPopout": true,
"transfer": transfer
}
}, {rollMode: rollMode});
}, { rollMode: rollMode });
}
return damage;
}
Expand Down Expand Up @@ -297,9 +299,9 @@ export default class TwodsixItem extends Item {
public async consume(quantity: number): Promise<void> {
const consumableLeft = (<Consumable>this.data.data).currentCount - quantity;
if (consumableLeft >= 0) {
await this.update({"data.currentCount": consumableLeft}, {});
await this.update({ "data.currentCount": consumableLeft }, {});
} else {
throw {name: 'NoAmmoError'};
throw { name: 'NoAmmoError' };
}
}

Expand All @@ -311,7 +313,7 @@ export default class TwodsixItem extends Item {
"data.currentCount": consumable.max
}, {});
} else {
throw {name: 'TooLowQuantityError'};
throw { name: 'TooLowQuantityError' };
}
}
}

0 comments on commit cca7da2

Please sign in to comment.