Various automations fixes
This commit is contained in:
@@ -11,7 +11,7 @@ export class DarkStarsActorSheet extends ActorSheet {
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ["fvtt-dark-stars", "sheet", "actor"],
|
||||
template: "systems/fvtt-dark-stars/templates/actors/actor-sheet.hbs",
|
||||
width: 960,
|
||||
@@ -25,7 +25,7 @@ export class DarkStarsActorSheet extends ActorSheet {
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = this.object.system
|
||||
let actorData = duplicate(objectData)
|
||||
let actorData = foundry.utils.duplicate(objectData)
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
@@ -39,21 +39,23 @@ export class DarkStarsActorSheet extends ActorSheet {
|
||||
limited: this.object.limited,
|
||||
skills: this.actor.getSkills( ),
|
||||
perks: this.actor.getPerks( ),
|
||||
weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ),
|
||||
ammos: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getAmmos()) ),
|
||||
spells: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getSpells()) ),
|
||||
powers: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getPowers()) ),
|
||||
armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())),
|
||||
shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())),
|
||||
equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ),
|
||||
equippedWeapons: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquippedWeapons()) ),
|
||||
cybers: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getCybers()) ),
|
||||
genetics: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getGenetics()) ),
|
||||
weapons: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getWeapons()) ),
|
||||
ammos: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getAmmos()) ),
|
||||
spells: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getSpells()) ),
|
||||
powers: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getPowers()) ),
|
||||
armors: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getArmors())),
|
||||
shields: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getShields())),
|
||||
equipments: this.actor.checkAndPrepareEquipments(foundry.utils.duplicate(this.actor.getEquipmentsOnly()) ),
|
||||
equippedWeapons: this.actor.checkAndPrepareEquipments(foundry.utils.duplicate(this.actor.getEquippedWeapons()) ),
|
||||
cybers: this.actor.checkAndPrepareEquipments(foundry.utils.duplicate(this.actor.getCybers()) ),
|
||||
genetics: this.actor.checkAndPrepareEquipments(foundry.utils.duplicate(this.actor.getGenetics()) ),
|
||||
equippedArmor: this.actor.getEquippedArmor(),
|
||||
equippedShield: this.actor.getEquippedShield(),
|
||||
subActors: duplicate(this.actor.getSubActors()),
|
||||
subActors: foundry.utils.duplicate(this.actor.getSubActors()),
|
||||
encCapacity: this.actor.getEncumbranceCapacity(),
|
||||
conditions: this.actor.getConditions(),
|
||||
tasks: this.actor.getCumulativeTasks(),
|
||||
config: game.system.darkstars.config,
|
||||
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
|
||||
notes: await TextEditor.enrichHTML(this.object.system.biodata.notes, {async: true}),
|
||||
containersTree: this.actor.containersTree,
|
||||
@@ -145,7 +147,16 @@ export class DarkStarsActorSheet extends ActorSheet {
|
||||
const skillId = li.data("item-id")
|
||||
this.actor.rollSkill(skillId)
|
||||
});
|
||||
|
||||
html.find('.roll-attribute').click((event) => {
|
||||
const attrKey = $(event.currentTarget).data("attr-key")
|
||||
this.actor.rollAttribute(attrKey)
|
||||
})
|
||||
html.find('.start-cumulative-task').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
const skillId = li.data("item-id")
|
||||
this.actor.rollSkill(skillId, true)
|
||||
})
|
||||
|
||||
html.find('.roll-weapon').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const skillId = li.data("item-id")
|
||||
|
@@ -43,8 +43,6 @@ export class DarkStarsActor extends Actor {
|
||||
}
|
||||
|
||||
if (data.type == 'character') {
|
||||
const skills = await DarkStarsUtility.loadCompendium("fvtt-dark-stars.skills");
|
||||
data.items = skills.map(i => i.toObject())
|
||||
}
|
||||
if (data.type == 'npc') {
|
||||
}
|
||||
@@ -120,54 +118,59 @@ export class DarkStarsActor extends Actor {
|
||||
}
|
||||
|
||||
getEquippedWeapons() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon' && item.system.equipped) || []);
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'weapon' && item.system.equipped) || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getArmors() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'armor') || []);
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'armor') || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getSpells() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'spell') || []);
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'spell') || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getPowers() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'psychic') || []);
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'psychic') || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getCumulativeTasks() {
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'cumulativetask') || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getEquippedArmor() {
|
||||
let comp = this.items.find(item => item.type == 'armor' && item.system.equipped)
|
||||
if (comp) {
|
||||
return duplicate(comp)
|
||||
return foundry.utils.duplicate(comp)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCybers() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'cyber') || []);
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'cyber') || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getGenetics() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'genetic') || []);
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'genetic') || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getShields() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'shield') || []);
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'shield') || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getEquippedShield() {
|
||||
let comp = this.items.find(item => item.type == 'shield' && item.system.equipped)
|
||||
if (comp) {
|
||||
return duplicate(comp)
|
||||
return foundry.utils.duplicate(comp)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
@@ -177,7 +180,7 @@ export class DarkStarsActor extends Actor {
|
||||
if (item.type == "weapon" && item.system.needammo) {
|
||||
let ammo = this.items.find(ammo => ammo.type == "ammo" && item.system.ammoid == ammo.id)
|
||||
if (ammo) {
|
||||
item.ammo = duplicate(ammo)
|
||||
item.ammo = foundry.utils.duplicate(ammo)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,29 +195,34 @@ export class DarkStarsActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getConditions() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'condition') || []);
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'condition') || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getWeapons() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon') || []);
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'weapon') || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getAmmos() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'ammo') || []);
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'ammo') || []);
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getItemById(id) {
|
||||
let item = this.items.find(item => item.id == id);
|
||||
if (item) {
|
||||
item = duplicate(item)
|
||||
getItemById(id, duplicate = true) {
|
||||
let item = this.items.find(it => it.id == id)
|
||||
if (item && duplicate) {
|
||||
item = foundry.utils.duplicate(item)
|
||||
}
|
||||
return item;
|
||||
return item
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getItem(id) {
|
||||
let item = this.items.get(id)
|
||||
return item
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
setWeaponAmmo(weaponId, ammoId) {
|
||||
@@ -233,14 +241,14 @@ export class DarkStarsActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
updateSkill(skill) {
|
||||
skill.derivated = duplicate(this.system.derivated[skill.system.base])
|
||||
skill.derivated = foundry.utils.duplicate(this.system.derivated[skill.system.base])
|
||||
skill.total = skill.system.value + skill.derivated.value + skill.system.bonus
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSkills() {
|
||||
this.computeDerivated()
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'skill') || [])
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'skill') || [])
|
||||
for (let skill of comp) {
|
||||
this.updateSkill(skill)
|
||||
}
|
||||
@@ -250,7 +258,7 @@ export class DarkStarsActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getPerks() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'perk') || [])
|
||||
let comp = foundry.utils.duplicate(this.items.filter(item => item.type == 'perk') || [])
|
||||
DarkStarsUtility.sortArrayObjectsByName(comp)
|
||||
return comp
|
||||
}
|
||||
@@ -295,7 +303,7 @@ export class DarkStarsActor extends Actor {
|
||||
}
|
||||
/* ------------------------------------------- */
|
||||
getEquipmentsOnly() {
|
||||
return duplicate(this.items.filter(item => item.type == "equipment") || [])
|
||||
return foundry.utils.duplicate(this.items.filter(item => item.type == "equipment") || [])
|
||||
}
|
||||
|
||||
/* ------------------------------------------- */
|
||||
@@ -321,7 +329,7 @@ export class DarkStarsActor extends Actor {
|
||||
|
||||
/* ------------------------------------------- */
|
||||
async buildContainerTree() {
|
||||
let equipments = duplicate(this.items.filter(item => item.type == "equipment") || [])
|
||||
let equipments = foundry.utils.duplicate(this.items.filter(item => item.type == "equipment") || [])
|
||||
for (let equip1 of equipments) {
|
||||
if (equip1.system.iscontainer) {
|
||||
equip1.system.contents = []
|
||||
@@ -375,7 +383,7 @@ export class DarkStarsActor extends Actor {
|
||||
async incDecHP(formula) {
|
||||
let dmgRoll = new Roll(formula + "[dark-starsorange]").roll({ async: false })
|
||||
await DarkStarsUtility.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode"))
|
||||
let hp = duplicate(this.system.secondary.hp)
|
||||
let hp = foundry.utils.duplicate(this.system.secondary.hp)
|
||||
hp.value = Number(hp.value) + Number(dmgRoll.total)
|
||||
this.update({ 'system.secondary.hp': hp })
|
||||
return Number(dmgRoll.total)
|
||||
@@ -429,9 +437,10 @@ export class DarkStarsActor extends Actor {
|
||||
return this.items.find(i => i.type == "perk" && i.name.toLowerCase() === "last word")
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getInitiativeScore() {
|
||||
async getInitiativeScore() {
|
||||
let initFormula = (this.system.derivated.si.value + this.system.derivated.si.bonus) + "d6"
|
||||
let initRoll = new Roll(initFormula).roll({ async: false })
|
||||
let initRoll = await new Roll(initFormula).roll()
|
||||
await DarkStarsUtility.showDiceSoNice(initRoll, game.settings.get("core", "rollMode"))
|
||||
return initRoll.total
|
||||
}
|
||||
|
||||
@@ -439,13 +448,13 @@ export class DarkStarsActor extends Actor {
|
||||
getSubActors() {
|
||||
let subActors = [];
|
||||
for (let id of this.system.subactors) {
|
||||
subActors.push(duplicate(game.actors.get(id)))
|
||||
subActors.push(foundry.utils.duplicate(game.actors.get(id)))
|
||||
}
|
||||
return subActors;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addSubActor(subActorId) {
|
||||
let subActors = duplicate(this.system.subactors);
|
||||
let subActors = foundry.utils.duplicate(this.system.subactors);
|
||||
subActors.push(subActorId);
|
||||
await this.update({ 'system.subactors': subActors });
|
||||
}
|
||||
@@ -464,7 +473,7 @@ export class DarkStarsActor extends Actor {
|
||||
getOneSkill(skillId) {
|
||||
let skill = this.items.find(item => item.type == 'skill' && item.id == skillId)
|
||||
if (skill) {
|
||||
skill = duplicate(skill);
|
||||
skill = foundry.utils.duplicate(skill);
|
||||
}
|
||||
return skill;
|
||||
}
|
||||
@@ -560,7 +569,7 @@ export class DarkStarsActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
modifyRerolls( value) {
|
||||
let rerolls = duplicate(this.system.various.rerolls)
|
||||
let rerolls = foundry.utils.duplicate(this.system.various.rerolls)
|
||||
rerolls.value += value
|
||||
this.update({ 'system.various.rerolls': rerolls })
|
||||
}
|
||||
@@ -576,7 +585,9 @@ export class DarkStarsActor extends Actor {
|
||||
let rollData = DarkStarsUtility.getBasicRollData()
|
||||
rollData.alias = this.name
|
||||
rollData.actorImg = this.img
|
||||
rollData.actorId = this.id
|
||||
console.log("Prepare common roll data for actor", this)
|
||||
rollData.tokenId = this.token?.id
|
||||
rollData.actorId = this.id
|
||||
rollData.img = this.img
|
||||
rollData.armors = this.getArmors()
|
||||
rollData.conditions = this.getConditions()
|
||||
@@ -616,24 +627,23 @@ export class DarkStarsActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollAbility(abilityKey) {
|
||||
let rollData = this.getCommonRollData(abilityKey)
|
||||
rollData.mode = "ability"
|
||||
if (rollData.target) {
|
||||
ui.notifications.warn("You are targetting a token with a skill : please use a Weapon instead.")
|
||||
return
|
||||
}
|
||||
DarkStarsUtility.rollDarkStars(rollData)
|
||||
rollAttribute(attrKey) {
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.attr = foundry.utils.duplicate(this.system.attributes[attrKey])
|
||||
rollData.mode = "attribute"
|
||||
rollData.title = "Attribute " + rollData.attr.label
|
||||
this.startRoll(rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollSkill(skillId) {
|
||||
async rollSkill(skillId, isCumulative = false, taskId = undefined) {
|
||||
let skill = this.items.get(skillId)
|
||||
if (skill) {
|
||||
skill = duplicate(skill)
|
||||
skill = foundry.utils.duplicate(skill)
|
||||
this.updateSkill(skill)
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.mode = "skill"
|
||||
rollData.isCumulative = isCumulative
|
||||
rollData.title = "Skill " + skill.name
|
||||
rollData.skill = skill
|
||||
rollData.img = skill.img
|
||||
@@ -641,6 +651,17 @@ export class DarkStarsActor extends Actor {
|
||||
ui.notifications.warn("You are targetting a token with a skill : please use a Weapon instead.")
|
||||
return
|
||||
}
|
||||
if (isCumulative) {
|
||||
rollData.title = "Cumulative Task " + skill.name
|
||||
if (!taskId) {
|
||||
let cumulativeTask = await this.createEmbeddedDocuments("Item", [{name: "Cumulative task " + skill.name, type: "cumulativetask",
|
||||
'system.skill': skill.name}])
|
||||
//console.log("Task", cumulativeTask)
|
||||
rollData.taskId = cumulativeTask[0].id
|
||||
}else {
|
||||
rollData.taskId = cumulativeTask[0].id
|
||||
}
|
||||
}
|
||||
this.startRoll(rollData)
|
||||
}
|
||||
}
|
||||
@@ -649,10 +670,10 @@ export class DarkStarsActor extends Actor {
|
||||
rollWeapon(weaponId) {
|
||||
let weapon = this.items.get(weaponId)
|
||||
if (weapon) {
|
||||
weapon = duplicate(weapon)
|
||||
weapon = foundry.utils.duplicate(weapon)
|
||||
let skill = this.items.find(item => item.name.toLowerCase() == weapon.system.skill.toLowerCase())
|
||||
if (skill) {
|
||||
skill = duplicate(skill)
|
||||
skill = foundry.utils.duplicate(skill)
|
||||
this.updateSkill(skill)
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.mode = "weapon"
|
||||
|
@@ -21,7 +21,7 @@ export class DarkStarsCombat extends Combat {
|
||||
for (let cId of ids) {
|
||||
const c = this.combatants.get(cId);
|
||||
let id = c._id || c.id;
|
||||
let initScore = c.actor ? c.actor.getInitiativeScore(this.id, id) : -1;
|
||||
let initScore = c.actor ? await c.actor.getInitiativeScore(this.id, id) : -1;
|
||||
await this.updateEmbeddedDocuments("Combatant", [{ _id: id, initiative: initScore }]);
|
||||
setTimeout(() => this.processOtherTurns(c, initScore), 400)
|
||||
}
|
||||
|
@@ -1,6 +1,72 @@
|
||||
|
||||
export const DARKSTARS_CONFIG = {
|
||||
|
||||
sizeOptions: {
|
||||
"1": "Tiny",
|
||||
"2": "Small",
|
||||
"3": "Medium",
|
||||
"4": "Large",
|
||||
"5": "Huge",
|
||||
"6": "Gargantuan"
|
||||
},
|
||||
classNPC: {
|
||||
"none": "None",
|
||||
"chaplain": "Chaplain",
|
||||
"magus": "Magus",
|
||||
"martial": "Martial",
|
||||
"skalawag": "Skalawag",
|
||||
"warden": "Warden"
|
||||
},
|
||||
synergyBonus: {
|
||||
"0": "0",
|
||||
"5": "+5%",
|
||||
"+6": "+6%",
|
||||
"+7": "+7%",
|
||||
"+8": "+8%",
|
||||
"+9": "+9%",
|
||||
"+10": "+10%"
|
||||
},
|
||||
attributeModifier: [
|
||||
{value: "0", label: "None"},
|
||||
{value: "-1", label: "Difficult (-1)"},
|
||||
{value: "-3", label: "Hard (-3)"},
|
||||
{value: "-6", label: "Very Hard (-6)"},
|
||||
{value: "-9", label: "Impossible (-9)"}
|
||||
],
|
||||
weaponAiming: {
|
||||
"none": "None",
|
||||
" arm": "Arm (-50)",
|
||||
"head": "Head (-50)",
|
||||
"torso": "Torso(-30)",
|
||||
"leg": "Leg (-30)",
|
||||
"hand": "Hand/Weapon (-70)"
|
||||
},
|
||||
rollModifiers: [
|
||||
{ "value": "-80", "label": "-80%" },
|
||||
{ "value": "-70", "label": "-70%" },
|
||||
{ "value": "-60", "label": "-60%" },
|
||||
{ "value": "-50", "label": "-50%" },
|
||||
{ "value": "-40", "label": "-40%" },
|
||||
{ "value": "-30", "label": "-30%" },
|
||||
{ "value": "-20", "label": "-20%" },
|
||||
{ "value": "-10", "label": "-10%" },
|
||||
{ "value": "0", "label": "0%" },
|
||||
{ "value": "+10", "label": "+10%" },
|
||||
{ "value": "+20", "label": "+20%" },
|
||||
{ "value": "+30", "label": "+30%" },
|
||||
{ "value": "+40", "label": "+40%" }
|
||||
],
|
||||
abilityValues: {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"2": "2",
|
||||
"3": "3",
|
||||
"4": "4",
|
||||
"5": "5",
|
||||
"6": "6",
|
||||
"7": "7",
|
||||
"8": "8"
|
||||
},
|
||||
basebonus : {
|
||||
"csb": "CSB",
|
||||
"ssb": "SSB",
|
||||
|
@@ -9,7 +9,7 @@ export class DarkStarsItemSheet extends ItemSheet {
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ["fvtt-dark-stars", "sheet", "item"],
|
||||
template: "systems/fvtt-dark-stars/templates/items/item-sheet.hbs",
|
||||
dragDrop: [{ dragSelector: null, dropSelector: null }],
|
||||
@@ -49,7 +49,7 @@ export class DarkStarsItemSheet extends ItemSheet {
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
|
||||
let objectData = duplicate(this.object.system)
|
||||
let objectData = foundry.utils.duplicate(this.object.system)
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
@@ -87,7 +87,7 @@ export class DarkStarsItemSheet extends ItemSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
postItem() {
|
||||
let chatData = duplicate(DarkStarsUtility.data(this.item));
|
||||
let chatData = foundry.utils.duplicate(DarkStarsUtility.data(this.item));
|
||||
if (this.actor) {
|
||||
chatData.actor = { id: this.actor.id };
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ export class DarkStarsNPCSheet extends ActorSheet {
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
classes: ["dark-stars-rpg", "sheet", "actor"],
|
||||
template: "systems/fvtt-dark-stars/templates/npc-sheet.hbs",
|
||||
width: 640,
|
||||
@@ -25,7 +25,7 @@ export class DarkStarsNPCSheet extends ActorSheet {
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = this.object.system
|
||||
let actorData = duplicate(objectData)
|
||||
let actorData = foundry.utils.duplicate(objectData)
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
@@ -38,21 +38,22 @@ export class DarkStarsNPCSheet extends ActorSheet {
|
||||
data: actorData,
|
||||
limited: this.object.limited,
|
||||
skills: this.actor.getSkills( ),
|
||||
weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ),
|
||||
armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())),
|
||||
shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())),
|
||||
spells: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getLore())),
|
||||
equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ),
|
||||
equippedWeapons: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquippedWeapons()) ),
|
||||
weapons: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getWeapons()) ),
|
||||
armors: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getArmors())),
|
||||
shields: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getShields())),
|
||||
spells: this.actor.checkAndPrepareEquipments( foundry.utils.duplicate(this.actor.getLore())),
|
||||
equipments: this.actor.checkAndPrepareEquipments(foundry.utils.duplicate(this.actor.getEquipmentsOnly()) ),
|
||||
equippedWeapons: this.actor.checkAndPrepareEquipments(foundry.utils.duplicate(this.actor.getEquippedWeapons()) ),
|
||||
equippedArmor: this.actor.getEquippedArmor(),
|
||||
equippedShield: this.actor.getEquippedShield(),
|
||||
feats: duplicate(this.actor.getFeats()),
|
||||
subActors: duplicate(this.actor.getSubActors()),
|
||||
race: duplicate(this.actor.getRace()),
|
||||
moneys: duplicate(this.actor.getMoneys()),
|
||||
feats: foundry.utils.duplicate(this.actor.getFeats()),
|
||||
subActors: foundry.utils.duplicate(this.actor.getSubActors()),
|
||||
race: foundry.utils.duplicate(this.actor.getRace()),
|
||||
moneys: foundry.utils.duplicate(this.actor.getMoneys()),
|
||||
encCapacity: this.actor.getEncumbranceCapacity(),
|
||||
saveRolls: this.actor.getSaveRoll(),
|
||||
conditions: this.actor.getConditions(),
|
||||
config: game.system.darkstars.config,
|
||||
containersTree: this.actor.containersTree,
|
||||
encCurrent: this.actor.encCurrent,
|
||||
options: this.options,
|
||||
|
@@ -67,8 +67,14 @@ export class DarkStarsRollDialog extends Dialog {
|
||||
html.find('#weapon-aiming').change((event) => {
|
||||
this.rollData.weaponAiming = String(event.currentTarget.value)
|
||||
})
|
||||
|
||||
|
||||
|
||||
html.find('#synergy-bonus').change((event) => {
|
||||
this.rollData.synergyBonus = Number(event.currentTarget.value)
|
||||
})
|
||||
html.find('#extra-time').change((event) => {
|
||||
this.rollData.extraTime = event.currentTarget.checked
|
||||
})
|
||||
html.find('#attribute-modifier').change((event) => {
|
||||
this.rollData.attributeModifier = Number(event.currentTarget.value)
|
||||
})
|
||||
}
|
||||
}
|
@@ -11,9 +11,7 @@ export class DarkStarsUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async init() {
|
||||
Hooks.on('renderChatLog', (log, html, data) => DarkStarsUtility.chatListeners(html));
|
||||
/*Hooks.on("dropCanvasData", (canvas, data) => {
|
||||
DarkStarsUtility.dropItemOnToken(canvas, data)
|
||||
});*/
|
||||
Hooks.on('renderChatMessage', (message, html, data) => DarkStarsUtility.chatMessageHandler(message, html, data))
|
||||
|
||||
DarkStarsCommands.init();
|
||||
|
||||
@@ -43,13 +41,28 @@ export class DarkStarsUtility {
|
||||
return __locationNames[key]
|
||||
})
|
||||
|
||||
|
||||
this.gameSettings()
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------- */
|
||||
static gameSettings() {
|
||||
static async processOpposed(rollData) {
|
||||
if (this.currentOpposition) {
|
||||
let opposed = {
|
||||
winner: this.currentOpposition,
|
||||
looser: rollData,
|
||||
isOpposed : true
|
||||
}
|
||||
if (rollData.degrees > this.currentOpposition.degrees ) {
|
||||
opposed.winner = rollData
|
||||
opposed.looser = this.currentOpposition
|
||||
}
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-dark-stars/templates/chat/chat-opposition-result.hbs`, opposed)
|
||||
})
|
||||
await msg.setFlag("world", "darkstars-roll-data", opposed)
|
||||
} else {
|
||||
this.currentOpposition = rollData
|
||||
ui.notifications.info("Opposed rolls started with " + rollData.alias );
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------- */
|
||||
@@ -60,13 +73,13 @@ export class DarkStarsUtility {
|
||||
|
||||
/*-------------------------------------------- */
|
||||
static getSkills() {
|
||||
return duplicate(this.skills)
|
||||
return foundry.utils.duplicate(this.skills)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async ready() {
|
||||
const skills = await DarkStarsUtility.loadCompendium("fvtt-dark-stars.sprawl");
|
||||
this.skills = skills.filter(i=> i.type =="skill").map(i => i.toObject() );
|
||||
this.skills = skills.filter(i => i.type == "skill").map(i => i.toObject());
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -96,6 +109,13 @@ export class DarkStarsUtility {
|
||||
rollData.roll = undefined
|
||||
this.rollDarkStars(rollData)
|
||||
})
|
||||
html.on("click", '.chat-roll-opposed', event => {
|
||||
let messageId = this.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "darkstars-roll-data")
|
||||
this.processOpposed(rollData)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -103,10 +123,8 @@ export class DarkStarsUtility {
|
||||
|
||||
const templatePaths = [
|
||||
'systems/fvtt-dark-stars/templates/partials/editor-notes-gm.hbs',
|
||||
'systems/fvtt-dark-stars/templates/partials/partial-roll-select.hbs',
|
||||
'systems/fvtt-dark-stars/templates/partials/partial-actor-ability-block.hbs',
|
||||
'systems/fvtt-dark-stars/templates/partials/partial-actor-status.hbs',
|
||||
'systems/fvtt-dark-stars/templates/partials/partial-options-abilities.hbs',
|
||||
'systems/fvtt-dark-stars/templates/partials/partial-item-nav.hbs',
|
||||
'systems/fvtt-dark-stars/templates/partials/partial-item-description.hbs',
|
||||
'systems/fvtt-dark-stars/templates/partials/partial-actor-equipment.hbs'
|
||||
@@ -275,12 +293,41 @@ export class DarkStarsUtility {
|
||||
static async rollDarkStars(rollData) {
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
if (rollData.tokenId) {
|
||||
actor = game.canvas.tokens.get(rollData.tokenId).actor
|
||||
}
|
||||
|
||||
// Specific attribute
|
||||
if (rollData.attr) {
|
||||
rollData.isSuccess = false
|
||||
rollData.isFailure = false
|
||||
rollData.targetNumber = Math.max( rollData.attr.value + rollData.attributeModifier, 0)
|
||||
let myRoll = await new Roll("1d10").roll()
|
||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
if (myRoll.total <= rollData.targetNumber) {
|
||||
rollData.isSuccess = true
|
||||
rollData.isFailure = false
|
||||
}
|
||||
rollData.roll = foundry.utils.duplicate(myRoll)
|
||||
rollData.diceResult = myRoll.total
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-dark-stars/templates/chat/chat-attribute-result.hbs`, rollData)
|
||||
})
|
||||
msg.setFlag("world", "darkstars-roll-data", rollData)
|
||||
return
|
||||
}
|
||||
|
||||
// ability/save/size => 0
|
||||
rollData.percentValue = 0
|
||||
if (rollData.skill) {
|
||||
rollData.percentValue = rollData.skill.total
|
||||
}
|
||||
if (rollData.synergyBonus) {
|
||||
rollData.percentValue += rollData.synergyBonus
|
||||
}
|
||||
if (rollData.extraTime) {
|
||||
rollData.percentValue += 30
|
||||
}
|
||||
rollData.percentValue += rollData.bonusMalus
|
||||
rollData.diceFormula = "1d100"
|
||||
|
||||
@@ -293,20 +340,21 @@ export class DarkStarsUtility {
|
||||
rollData.locationMalus = this.getAimingMalus(rollData.weaponAiming)
|
||||
rollData.percentValue += rollData.locationMalus
|
||||
}
|
||||
rollData.percentValue = Math.max(rollData.percentValue, 0)
|
||||
|
||||
// Performs roll
|
||||
console.log("Roll formula", rollData.diceFormula)
|
||||
let myRoll = rollData.roll
|
||||
if (!myRoll) { // New rolls only of no rerolls
|
||||
myRoll = new Roll(rollData.diceFormula).roll({ async: false })
|
||||
myRoll = await new Roll(rollData.diceFormula).roll()
|
||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
}
|
||||
rollData.roll = duplicate(myRoll)
|
||||
rollData.roll = foundry.utils.duplicate(myRoll)
|
||||
rollData.diceResult = myRoll.total
|
||||
rollData.isCriticalSuccess = rollData.diceResult <= rollData.skill.derivated.value
|
||||
rollData.isCriticalFailure = rollData.diceResult == 100
|
||||
rollData.isSuccess = rollData.diceResult == 1 || rollData.diceResult <= rollData.percentValue
|
||||
rollData.isFailure = rollData.diceResult == 100 || rollData.diceResult > rollData.percentValue
|
||||
rollData.degrees = Math.floor(rollData.percentValue / 10) - Math.floor(rollData.diceResult / 10)
|
||||
rollData.degrees = Math.floor((rollData.percentValue - rollData.diceResult) / 10)
|
||||
rollData.damageMultiplier = rollData.isCriticalSuccess ? 2 : 1
|
||||
|
||||
if (rollData.reroll) {
|
||||
@@ -322,7 +370,21 @@ export class DarkStarsUtility {
|
||||
// Compute
|
||||
rollData.locationMultiplier = this.locationMultiplier(rollData.weaponAiming)
|
||||
}
|
||||
|
||||
|
||||
// Task management
|
||||
if (rollData.taskId) {
|
||||
let task = actor.getItem(rollData.taskId)
|
||||
console.log(" Task", task, rollData.taskId)
|
||||
if (task) {
|
||||
let newCumulated = rollData.degrees + task.system.cumulated
|
||||
let nbrolls = task.system.nbrolls + 1
|
||||
task.update({ 'system.cumulated': newCumulated, 'system.nbrolls': nbrolls })
|
||||
rollData.taskName = task.name
|
||||
rollData.taskCumulated = newCumulated
|
||||
rollData.taskNbrolls = nbrolls
|
||||
}
|
||||
}
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-dark-stars/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
})
|
||||
@@ -350,6 +412,19 @@ export class DarkStarsUtility {
|
||||
static getUsers(filter) {
|
||||
return game.users.filter(filter).map(user => user.id);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static async chatMessageHandler(message, html, data) {
|
||||
const chatCard = html.find('.gm-actions')
|
||||
if (chatCard.length > 0) {
|
||||
// If the user is the message author or the actor owner, proceed
|
||||
const actor = game.actors.get(data.message.speaker.actor)
|
||||
if (actor?.isOwner) return
|
||||
else if (game.user.isGM || data.author.id === game.user.id) return
|
||||
const divButtons = chatCard.find('.gm-actions')
|
||||
divButtons.hide()
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getWhisperRecipients(rollMode, name) {
|
||||
switch (rollMode) {
|
||||
@@ -367,7 +442,7 @@ export class DarkStarsUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static blindMessageToGM(chatOptions) {
|
||||
let chatGM = duplicate(chatOptions);
|
||||
let chatGM = foundry.utils.duplicate(chatOptions);
|
||||
chatGM.whisper = this.getUsers(user => user.isGM);
|
||||
chatGM.content = "Blinde message of " + game.user.name + "<br>" + chatOptions.content;
|
||||
console.log("blindMessageToGM", chatGM);
|
||||
@@ -428,11 +503,15 @@ export class DarkStarsUtility {
|
||||
/* -------------------------------------------- */
|
||||
static getBasicRollData() {
|
||||
let rollData = {
|
||||
rollId: randomID(16),
|
||||
rollId: foundry.utils.randomID(16),
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
bonusMalus: 0,
|
||||
isAboveEffectiveRange: false,
|
||||
weaponAiming: "none"
|
||||
weaponAiming: "none",
|
||||
synergyBonus: 0,
|
||||
extraTime: false,
|
||||
attributeModifier: 0,
|
||||
config: game.system.darkstars.config,
|
||||
}
|
||||
DarkStarsUtility.updateWithTarget(rollData)
|
||||
return rollData
|
||||
|
Reference in New Issue
Block a user