v10 migration
This commit is contained in:
@ -63,22 +63,22 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeHitPoints() {
|
||||
let hp = duplicate(this.data.data.secondary.hp)
|
||||
let max = (this.data.data.abilities.str.value + this.data.data.abilities.con.value) * 6
|
||||
let hp = duplicate(this.system.secondary.hp)
|
||||
let max = (this.system.abilities.str.value + this.system.abilities.con.value) * 6
|
||||
if (max != hp.max || hp.value > max) {
|
||||
hp.max = max
|
||||
hp.value = max // Init case
|
||||
this.update({ 'data.secondary.hp': hp })
|
||||
this.update({ 'system.secondary.hp': hp })
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
computeEffortPoints() {
|
||||
let effort = duplicate(this.data.data.secondary.effort)
|
||||
let max = (this.data.data.abilities.con.value + this.data.data.abilities.int.value) * 6
|
||||
let effort = duplicate(this.system.secondary.effort)
|
||||
let max = (this.system.abilities.con.value + this.system.abilities.int.value) * 6
|
||||
if (max != effort.max || effort.value > max) {
|
||||
effort.max = max
|
||||
effort.value = max // Init case
|
||||
this.update({ 'data.secondary.effort': effort })
|
||||
this.update({ 'system.secondary.effort': effort })
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ export class CrucibleActor extends Actor {
|
||||
prepareDerivedData() {
|
||||
|
||||
if (this.type == 'character' || game.user.isGM) {
|
||||
this.data.data.encCapacity = this.getEncumbranceCapacity()
|
||||
this.system.encCapacity = this.getEncumbranceCapacity()
|
||||
this.buildContainerTree()
|
||||
this.computeHitPoints()
|
||||
this.computeEffortPoints()
|
||||
@ -108,46 +108,46 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getMoneys() {
|
||||
let comp = this.data.items.filter(item => item.type == 'money');
|
||||
let comp = this.items.filter(item => item.type == 'money');
|
||||
CrucibleUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getFeats() {
|
||||
let comp = duplicate(this.data.items.filter(item => item.type == 'feat') || []);
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'feat') || []);
|
||||
CrucibleUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getFeatsWithDie() {
|
||||
let comp = duplicate(this.data.items.filter(item => item.type == 'feat' && item.data.data.isfeatdie) || []);
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'feat' && item.system.isfeatdie) || []);
|
||||
CrucibleUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getFeatsWithSL() {
|
||||
let comp = duplicate(this.data.items.filter(item => item.type == 'feat' && item.data.data.issl) || []);
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'feat' && item.system.issl) || []);
|
||||
CrucibleUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getLore() {
|
||||
let comp = duplicate(this.data.items.filter(item => item.type == 'spell') || []);
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'spell') || []);
|
||||
CrucibleUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getEquippedWeapons() {
|
||||
let comp = duplicate(this.data.items.filter(item => item.type == 'weapon' && item.data.data.equipped) || []);
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon' && item.system.equipped) || []);
|
||||
CrucibleUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getArmors() {
|
||||
let comp = duplicate(this.data.items.filter(item => item.type == 'armor') || []);
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'armor') || []);
|
||||
CrucibleUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getEquippedArmor() {
|
||||
let comp = this.data.items.find(item => item.type == 'armor' && item.data.data.equipped)
|
||||
let comp = this.items.find(item => item.type == 'armor' && item.system.equipped)
|
||||
if (comp) {
|
||||
return duplicate(comp)
|
||||
}
|
||||
@ -155,12 +155,12 @@ export class CrucibleActor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getShields() {
|
||||
let comp = duplicate(this.data.items.filter(item => item.type == 'shield') || []);
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'shield') || []);
|
||||
CrucibleUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getEquippedShield() {
|
||||
let comp = this.data.items.find(item => item.type == 'shield' && item.data.data.equipped)
|
||||
let comp = this.items.find(item => item.type == 'shield' && item.system.equipped)
|
||||
if (comp) {
|
||||
return duplicate(comp)
|
||||
}
|
||||
@ -168,7 +168,7 @@ export class CrucibleActor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getRace() {
|
||||
let race = this.data.items.filter(item => item.type == 'race')
|
||||
let race = this.items.filter(item => item.type == 'race')
|
||||
return race[0] ?? [];
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
@ -185,25 +185,22 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getWeapons() {
|
||||
let comp = duplicate(this.data.items.filter(item => item.type == 'weapon') || []);
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon') || []);
|
||||
CrucibleUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getItemById(id) {
|
||||
let item = this.data.items.find(item => item.id == id);
|
||||
let item = this.items.find(item => item.id == id);
|
||||
if (item) {
|
||||
item = duplicate(item)
|
||||
if (item.type == 'specialisation') {
|
||||
item.data.dice = CrucibleUtility.getDiceFromLevel(item.data.level);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSkills() {
|
||||
let comp = duplicate(this.data.items.filter(item => item.type == 'skill') || [])
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'skill') || [])
|
||||
for (let skill of comp) {
|
||||
CrucibleUtility.updateSkill(skill)
|
||||
}
|
||||
@ -213,30 +210,30 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getRelevantAbility(statKey) {
|
||||
let comp = duplicate(this.data.items.filter(item => item.type == 'skill' && item.data.data.ability == ability) || []);
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'skill' && item.system.ability == ability) || []);
|
||||
return comp;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async equipItem(itemId) {
|
||||
let item = this.data.items.find(item => item.id == itemId)
|
||||
if (item && item.data.data) {
|
||||
let item = this.items.find(item => item.id == itemId)
|
||||
if (item && item.system) {
|
||||
if (item.type == "armor") {
|
||||
let armor = this.data.items.find(item => item.id != itemId && item.type == "armor" && item.data.data.equipped)
|
||||
let armor = this.items.find(item => item.id != itemId && item.type == "armor" && item.system.equipped)
|
||||
if (armor) {
|
||||
ui.notifications.warn("You already have an armor equipped!")
|
||||
return
|
||||
}
|
||||
}
|
||||
if (item.type == "shield") {
|
||||
let shield = this.data.items.find(item => item.id != itemId && item.type == "shield" && item.data.data.equipped)
|
||||
let shield = this.items.find(item => item.id != itemId && item.type == "shield" && item.system.equipped)
|
||||
if (shield) {
|
||||
ui.notifications.warn("You already have a shield equipped!")
|
||||
return
|
||||
}
|
||||
}
|
||||
let update = { _id: item.id, "data.equipped": !item.data.data.equipped };
|
||||
let update = { _id: item.id, "system.equipped": !item.system.equipped };
|
||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
@ -254,11 +251,11 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* ------------------------------------------- */
|
||||
getEquipments() {
|
||||
return this.data.items.filter(item => item.type == 'shield' || item.type == 'armor' || item.type == "weapon" || item.type == "equipment");
|
||||
return this.items.filter(item => item.type == 'shield' || item.type == 'armor' || item.type == "weapon" || item.type == "equipment");
|
||||
}
|
||||
/* ------------------------------------------- */
|
||||
getEquipmentsOnly() {
|
||||
return duplicate(this.data.items.filter(item => item.type == "equipment") || [])
|
||||
return duplicate(this.items.filter(item => item.type == "equipment") || [])
|
||||
}
|
||||
|
||||
/* ------------------------------------------- */
|
||||
@ -267,33 +264,33 @@ export class CrucibleActor extends Actor {
|
||||
reflex: {
|
||||
"label": "Reflex Save",
|
||||
"img": "systems/fvtt-crucible-rpg/images/icons/saves/reflex_save.webp",
|
||||
"value": this.data.data.abilities.agi.value + this.data.data.abilities.wit.value
|
||||
"value": this.system.abilities.agi.value + this.system.abilities.wit.value
|
||||
},
|
||||
fortitude: {
|
||||
"label": "Fortitude Save",
|
||||
"img": "systems/fvtt-crucible-rpg/images/icons/saves/fortitude_save.webp",
|
||||
"value": this.data.data.abilities.str.value + this.data.data.abilities.con.value
|
||||
"value": this.system.abilities.str.value + this.system.abilities.con.value
|
||||
},
|
||||
willpower: {
|
||||
"label": "Willpower Save",
|
||||
"img": "systems/fvtt-crucible-rpg/images/icons/saves/will_save.webp",
|
||||
"value": this.data.data.abilities.int.value + this.data.data.abilities.cha.value
|
||||
"value": this.system.abilities.int.value + this.system.abilities.cha.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------- */
|
||||
async buildContainerTree() {
|
||||
let equipments = duplicate(this.data.items.filter(item => item.type == "equipment") || [])
|
||||
let equipments = duplicate(this.items.filter(item => item.type == "equipment") || [])
|
||||
for (let equip1 of equipments) {
|
||||
if (equip1.data.iscontainer) {
|
||||
equip1.data.contents = []
|
||||
equip1.data.contentsEnc = 0
|
||||
if (equip1.system.iscontainer) {
|
||||
equip1.system.contents = []
|
||||
equip1.system.contentsEnc = 0
|
||||
for (let equip2 of equipments) {
|
||||
if (equip1._id != equip2._id && equip2.data.containerid == equip1._id) {
|
||||
equip1.data.contents.push(equip2)
|
||||
let q = equip2.data.quantity ?? 1
|
||||
equip1.data.contentsEnc += q * equip2.data.weight
|
||||
if (equip1._id != equip2.id && equip2.system.containerid == equip1.id) {
|
||||
equip1.system.contents.push(equip2)
|
||||
let q = equip2.system.quantity ?? 1
|
||||
equip1.system.contentsEnc += q * equip2.system.weight
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -303,25 +300,25 @@ export class CrucibleActor extends Actor {
|
||||
let enc = 0
|
||||
for (let item of equipments) {
|
||||
//item.data.idrDice = CrucibleUtility.getDiceFromLevel(Number(item.data.idr))
|
||||
if (item.data.equipped) {
|
||||
if (item.data.iscontainer) {
|
||||
enc += item.data.contentsEnc
|
||||
} else if (item.data.containerid == "") {
|
||||
let q = item.data.quantity ?? 1
|
||||
enc += q * item.data.weight
|
||||
if (item.system.equipped) {
|
||||
if (item.system.iscontainer) {
|
||||
enc += item.system.contentsEnc
|
||||
} else if (item.system.containerid == "") {
|
||||
let q = item.system.quantity ?? 1
|
||||
enc += q * item.system.weight
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let item of this.data.items) { // Process items/shields/armors
|
||||
if ((item.type == "weapon" || item.type == "shield" || item.type == "armor") && item.data.data.equipped) {
|
||||
let q = item.data.data.quantity ?? 1
|
||||
enc += q * item.data.data.weight
|
||||
for (let item of this.items) { // Process items/shields/armors
|
||||
if ((item.type == "weapon" || item.type == "shield" || item.type == "armor") && item.system.equipped) {
|
||||
let q = item.system.quantity ?? 1
|
||||
enc += q * item.system.weight
|
||||
}
|
||||
}
|
||||
|
||||
// Store local values
|
||||
this.encCurrent = enc
|
||||
this.containersTree = equipments.filter(item => item.data.containerid == "") // Returns the root of equipements without container
|
||||
this.containersTree = equipments.filter(item => item.system.containerid == "") // Returns the root of equipements without container
|
||||
|
||||
}
|
||||
|
||||
@ -338,36 +335,36 @@ export class CrucibleActor extends Actor {
|
||||
async incDecHP( formula ) {
|
||||
let dmgRoll = new Roll(formula).roll( {async: false})
|
||||
await CrucibleUtility.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode"))
|
||||
let hp = duplicate(this.data.data.secondary.hp)
|
||||
let hp = duplicate(this.system.secondary.hp)
|
||||
hp.value = Number(hp.value) + Number(dmgRoll.total)
|
||||
this.update( {'data.secondary.hp': hp })
|
||||
this.update( {'system.secondary.hp': hp })
|
||||
return Number(dmgRoll.total)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getAbility(abilKey) {
|
||||
return this.data.data.abilities[abilKey];
|
||||
return this.system.abilities[abilKey];
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addObjectToContainer(itemId, containerId) {
|
||||
let container = this.data.items.find(item => item.id == containerId && item.data.data.iscontainer)
|
||||
let object = this.data.items.find(item => item.id == itemId)
|
||||
let container = this.items.find(item => item.id == containerId && item.system.iscontainer)
|
||||
let object = this.items.find(item => item.id == itemId)
|
||||
if (container) {
|
||||
if (object.data.data.iscontainer) {
|
||||
if (object.system.iscontainer) {
|
||||
ui.notifications.warn("Only 1 level of container allowed")
|
||||
return
|
||||
}
|
||||
let alreadyInside = this.data.items.filter(item => item.data.data.containerid && item.data.data.containerid == containerId);
|
||||
if (alreadyInside.length >= container.data.data.containercapacity) {
|
||||
let alreadyInside = this.items.filter(item => item.system.containerid && item.system.containerid == containerId);
|
||||
if (alreadyInside.length >= container.system.containercapacity) {
|
||||
ui.notifications.warn("Container is already full !")
|
||||
return
|
||||
} else {
|
||||
await this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'data.containerid': containerId }])
|
||||
await this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'system.containerid': containerId }])
|
||||
}
|
||||
} else if (object && object.data.data.containerid) { // remove from container
|
||||
} else if (object && object.system.containerid) { // remove from container
|
||||
console.log("Removeing: ", object)
|
||||
await this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'data.containerid': "" }]);
|
||||
await this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'system.containerid': "" }]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,9 +378,9 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async equipGear(equipmentId) {
|
||||
let item = this.data.items.find(item => item.id == equipmentId);
|
||||
if (item && item.data.data) {
|
||||
let update = { _id: item.id, "data.equipped": !item.data.data.equipped };
|
||||
let item = this.items.find(item => item.id == equipmentId);
|
||||
if (item && item.system) {
|
||||
let update = { _id: item.id, "system.equipped": !item.system.equipped };
|
||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
@ -399,26 +396,26 @@ export class CrucibleActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
getSubActors() {
|
||||
let subActors = [];
|
||||
for (let id of this.data.data.subactors) {
|
||||
for (let id of this.system.subactors) {
|
||||
subActors.push(duplicate(game.actors.get(id)))
|
||||
}
|
||||
return subActors;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addSubActor(subActorId) {
|
||||
let subActors = duplicate(this.data.data.subactors);
|
||||
let subActors = duplicate(this.system.subactors);
|
||||
subActors.push(subActorId);
|
||||
await this.update({ 'data.subactors': subActors });
|
||||
await this.update({ 'system.subactors': subActors });
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async delSubActor(subActorId) {
|
||||
let newArray = [];
|
||||
for (let id of this.data.data.subactors) {
|
||||
for (let id of this.system.subactors) {
|
||||
if (id != subActorId) {
|
||||
newArray.push(id);
|
||||
}
|
||||
}
|
||||
await this.update({ 'data.subactors': newArray });
|
||||
await this.update({ 'system.subactors': newArray });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -429,7 +426,7 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getOneSkill(skillId) {
|
||||
let skill = this.data.items.find(item => item.type == 'skill' && item.id == skillId)
|
||||
let skill = this.items.find(item => item.type == 'skill' && item.id == skillId)
|
||||
if (skill) {
|
||||
skill = duplicate(skill);
|
||||
}
|
||||
@ -438,13 +435,13 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async deleteAllItemsByType(itemType) {
|
||||
let items = this.data.items.filter(item => item.type == itemType);
|
||||
let items = this.items.filter(item => item.type == itemType);
|
||||
await this.deleteEmbeddedDocuments('Item', items);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addItemWithoutDuplicate(newItem) {
|
||||
let item = this.data.items.find(item => item.type == newItem.type && item.name.toLowerCase() == newItem.name.toLowerCase())
|
||||
let item = this.items.find(item => item.type == newItem.type && item.name.toLowerCase() == newItem.name.toLowerCase())
|
||||
if (!item) {
|
||||
await this.createEmbeddedDocuments('Item', [newItem]);
|
||||
}
|
||||
@ -452,23 +449,23 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async incrementSkillExp(skillId, inc) {
|
||||
let skill = this.data.items.get(skillId)
|
||||
let skill = this.items.get(skillId)
|
||||
if (skill) {
|
||||
await this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'data.exp': skill.data.data.exp + inc }])
|
||||
await this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'system.exp': skill.system.exp + inc }])
|
||||
let chatData = {
|
||||
user: game.user.id,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')),
|
||||
content: `<div>${this.name} has gained 1 exp in the skill ${skill.name} (exp = ${skill.data.data.exp})</div`
|
||||
content: `<div>${this.name} has gained 1 exp in the skill ${skill.name} (exp = ${skill.system.exp})</div`
|
||||
}
|
||||
ChatMessage.create(chatData)
|
||||
if (skill.data.data.exp >= 25) {
|
||||
await this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'data.exp': 0, 'data.explevel': skill.data.data.explevel + 1 }])
|
||||
if (skill.system.exp >= 25) {
|
||||
await this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'system.exp': 0, 'system.explevel': skill.system.explevel + 1 }])
|
||||
let chatData = {
|
||||
user: game.user.id,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')),
|
||||
content: `<div>${this.name} has gained 1 exp SL in the skill ${skill.name} (new exp SL : ${skill.data.data.explevel}) !</div`
|
||||
content: `<div>${this.name} has gained 1 exp SL in the skill ${skill.name} (new exp SL : ${skill.system.explevel}) !</div`
|
||||
}
|
||||
ChatMessage.create(chatData)
|
||||
}
|
||||
@ -477,21 +474,21 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async incDecQuantity(objetId, incDec = 0) {
|
||||
let objetQ = this.data.items.get(objetId)
|
||||
let objetQ = this.items.get(objetId)
|
||||
if (objetQ) {
|
||||
let newQ = objetQ.data.data.quantity + incDec
|
||||
let newQ = objetQ.system.quantity + incDec
|
||||
if (newQ >= 0) {
|
||||
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.quantity': newQ }]) // pdates one EmbeddedEntity
|
||||
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]) // pdates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async incDecAmmo(objetId, incDec = 0) {
|
||||
let objetQ = this.data.items.get(objetId)
|
||||
let objetQ = this.items.get(objetId)
|
||||
if (objetQ) {
|
||||
let newQ = objetQ.data.data.ammocurrent + incDec;
|
||||
if (newQ >= 0 && newQ <= objetQ.data.data.ammomax) {
|
||||
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.ammocurrent': newQ }]); // pdates one EmbeddedEntity
|
||||
let newQ = objetQ.system.ammocurrent + incDec;
|
||||
if (newQ >= 0 && newQ <= objetQ.system.ammomax) {
|
||||
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.ammocurrent': newQ }]); // pdates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -527,39 +524,46 @@ export class CrucibleActor 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
|
||||
}
|
||||
CrucibleUtility.rollCrucible(rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollSkill(skillId) {
|
||||
let skill = this.data.items.get(skillId)
|
||||
let skill = this.items.get(skillId)
|
||||
if (skill) {
|
||||
if (skill.data.islore && skill.data.level == 0) {
|
||||
if (skill.system.islore && skill.system.level == 0) {
|
||||
ui.notifications.warn("You can't use Lore Skills with a SL of 0.")
|
||||
return
|
||||
}
|
||||
skill = duplicate(skill)
|
||||
CrucibleUtility.updateSkill(skill)
|
||||
let abilityKey = skill.data.ability
|
||||
let abilityKey = skill.system.ability
|
||||
let rollData = this.getCommonRollData(abilityKey)
|
||||
rollData.mode = "skill"
|
||||
rollData.skill = skill
|
||||
rollData.img = skill.img
|
||||
|
||||
if (rollData.target) {
|
||||
ui.notifications.warn("You are targetting a token with a skill : please use a Weapon instead.")
|
||||
return
|
||||
}
|
||||
this.startRoll(rollData)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollWeapon(weaponId) {
|
||||
let weapon = this.data.items.get(weaponId)
|
||||
let weapon = this.items.get(weaponId)
|
||||
if (weapon) {
|
||||
weapon = duplicate(weapon)
|
||||
let skill = this.data.items.find(item => item.name.toLowerCase() == weapon.data.skill.toLowerCase())
|
||||
let skill = this.items.find(item => item.name.toLowerCase() == weapon.system.skill.toLowerCase())
|
||||
if (skill) {
|
||||
skill = duplicate(skill)
|
||||
CrucibleUtility.updateSkill(skill)
|
||||
let abilityKey = skill.data.ability
|
||||
let abilityKey = skill.system.ability
|
||||
let rollData = this.getCommonRollData(abilityKey)
|
||||
rollData.mode = "weapon"
|
||||
rollData.skill = skill
|
||||
@ -575,14 +579,14 @@ export class CrucibleActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollDefenseMelee(attackRollData) {
|
||||
let weapon = this.data.items.get(attackRollData.defenseWeaponId)
|
||||
let weapon = this.items.get(attackRollData.defenseWeaponId)
|
||||
if (weapon) {
|
||||
weapon = duplicate(weapon)
|
||||
let skill = this.data.items.find(item => item.name.toLowerCase() == weapon.data.skill.toLowerCase())
|
||||
let skill = this.items.find(item => item.name.toLowerCase() == weapon.system.skill.toLowerCase())
|
||||
if (skill) {
|
||||
skill = duplicate(skill)
|
||||
CrucibleUtility.updateSkill(skill)
|
||||
let abilityKey = skill.data.ability
|
||||
let abilityKey = skill.system.ability
|
||||
let rollData = this.getCommonRollData(abilityKey)
|
||||
rollData.defenderTokenId = undefined // Cleanup
|
||||
rollData.mode = "weapondefense"
|
||||
@ -651,12 +655,13 @@ export class CrucibleActor extends Actor {
|
||||
multiply = 2
|
||||
}
|
||||
}
|
||||
let diceColor = armor.data.absorprionroll
|
||||
let diceColor = armor.system.absorprionroll
|
||||
let armorResult = await CrucibleUtility.getRollTableFromDiceColor( diceColor, false )
|
||||
let armorValue = (Number(armorResult.data.text) - reduce) * multiply
|
||||
console.log("Armor log", armorResult)
|
||||
let armorValue = (Number(armorResult.text) - reduce) * multiply
|
||||
if ( advantage || disadvantage) {
|
||||
let armorResult2 = await CrucibleUtility.getRollTableFromDiceColor( diceColor, false )
|
||||
let armorValue2 = (Number(armorResult2.data.text) - reduce) * multiply
|
||||
let armorValue2 = (Number(armorResult2.text) - reduce) * multiply
|
||||
if ( advantage) {
|
||||
armorValue = (armorValue2 > armorValue) ? armorValue2 : armorValue
|
||||
messages.push(`Armor advantage - Roll 1 = ${armorValue} - Roll 2 = ${armorValue2}`)
|
||||
@ -685,8 +690,10 @@ export class CrucibleActor extends Actor {
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.mode = "save"
|
||||
rollData.save = save
|
||||
//rollData.img = skill.img
|
||||
|
||||
if (rollData.target) {
|
||||
ui.notifications.warn("You are targetting a token with a save roll - Not authorized.")
|
||||
return
|
||||
}
|
||||
this.startRoll(rollData)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user