Various/changes from 30th may requestsé
This commit is contained in:
@@ -60,10 +60,15 @@ export class Hero6Actor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeHitPoints() {
|
||||
computeDerivatedData() {
|
||||
if (this.type == "character") {
|
||||
let newSTREND = this.computeSTREND()
|
||||
if (newSTREND != this.system.characteristics.str.strend) {
|
||||
this.update({ 'system.characteristics.str.strend': newSTREND })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
computeDicesValue() {
|
||||
this.system.biodata.presenceattack = Hero6Utility.getDerivatedDiceFormulas(this.system.characteristics.pre.value)
|
||||
this.system.characteristics.str.strdice = Hero6LiftDice.getLiftDice(this.system.characteristics.str.value)
|
||||
@@ -75,7 +80,7 @@ export class Hero6Actor extends Actor {
|
||||
if (this.type == 'character' || game.user.isGM) {
|
||||
this.system.encCapacity = this.getEncumbranceCapacity()
|
||||
this.buildContainerTree()
|
||||
this.computeHitPoints()
|
||||
this.computeDerivatedData()
|
||||
this.computeDicesValue()
|
||||
}
|
||||
|
||||
@@ -90,7 +95,10 @@ export class Hero6Actor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getEncumbranceCapacity() {
|
||||
return 1;
|
||||
let numLift = this.system.characteristics.str.lift.match(/\d*\s/g)
|
||||
if (numLift && numLift[0] && Number(numLift[0])) {
|
||||
return numLift[0] / 2
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -147,18 +155,6 @@ export class Hero6Actor extends Actor {
|
||||
return listItem
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getConditions() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'condition') || []);
|
||||
Hero6Utility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getWeapons() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon') || []);
|
||||
Hero6Utility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getItemById(id) {
|
||||
let item = this.items.find(item => item.id == id);
|
||||
@@ -324,46 +320,16 @@ export class Hero6Actor extends Actor {
|
||||
}
|
||||
|
||||
/* ------------------------------------------- */
|
||||
async buildContainerTree() {
|
||||
let equipments = duplicate(this.items.filter(item => item.type == "equipment") || [])
|
||||
for (let equip1 of equipments) {
|
||||
if (equip1.system.iscontainer) {
|
||||
equip1.system.contents = []
|
||||
equip1.system.contentsEnc = 0
|
||||
for (let equip2 of equipments) {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compute whole enc
|
||||
buildContainerTree() {
|
||||
let equipments = duplicate(this.items.filter(item => item.type == "equipment") || []);
|
||||
let enc = 0
|
||||
for (let item of equipments) {
|
||||
//item.data.idrDice = Hero6Utility.getDiceFromLevel(Number(item.data.idr))
|
||||
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 equip1 of equipments) {
|
||||
if (Number(equip1.system.weight) && Number(equip1.system.quantity)) {
|
||||
enc += equip1.system.weight * equip1.system.quantity
|
||||
}
|
||||
}
|
||||
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.system.containerid == "") // Returns the root of equipements without container
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -392,7 +358,7 @@ export class Hero6Actor extends Actor {
|
||||
} else {
|
||||
await this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'system.containerid': containerId }])
|
||||
}
|
||||
} else if (object && object.system.containerid) { // remove from container
|
||||
} else if (object?.system?.containerid) { // remove from container
|
||||
console.log("Removeing: ", object)
|
||||
await this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'system.containerid': "" }]);
|
||||
}
|
||||
@@ -409,7 +375,7 @@ export class Hero6Actor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async equipGear(equipmentId) {
|
||||
let item = this.items.find(item => item.id == equipmentId);
|
||||
if (item && item.system) {
|
||||
if (item?.system) {
|
||||
let update = { _id: item.id, "system.equipped": !item.system.equipped };
|
||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
@@ -423,7 +389,7 @@ export class Hero6Actor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getSegments() {
|
||||
let index = Math.min(Math.max(this.system.characteristics.spd.value, 1), 12) // Security bounds
|
||||
let index = [ Math.min(Math.max(this.system.characteristics.spd.value, 1), 12) ] // Security bounds
|
||||
return __speed2Segments[index]
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
@@ -485,6 +451,22 @@ export class Hero6Actor extends Actor {
|
||||
return skill;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeSTREND() {
|
||||
let newSTREND = 0
|
||||
switch (this.system.characteristics.str.strendmode) {
|
||||
case "str20":
|
||||
newSTREND = Math.floor(this.system.characteristics.str.value / 20)
|
||||
break;
|
||||
case "str10":
|
||||
newSTREND = Math.floor(this.system.characteristics.str.value / 10)
|
||||
break;
|
||||
case "str5":
|
||||
newSTREND = Math.floor(this.system.characteristics.str.value / 5)
|
||||
break;
|
||||
}
|
||||
return newSTREND
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async deleteAllItemsByType(itemType) {
|
||||
let items = this.items.filter(item => item.type == itemType);
|
||||
@@ -557,6 +539,18 @@ export class Hero6Actor extends Actor {
|
||||
|
||||
return rollData
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
rollPerception() {
|
||||
let rollData = this.getCommonRollData("int")
|
||||
rollData.isPerception = true
|
||||
rollData.charac.roll = Number(rollData.charac.perceptionroll)
|
||||
rollData.mode = "perception"
|
||||
if (rollData.target) {
|
||||
ui.notifications.warn("You are targetting a token with a skill : please use a Weapon instead.")
|
||||
return
|
||||
}
|
||||
this.startRoll(rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollCharac(chKey) {
|
||||
@@ -588,7 +582,7 @@ export class Hero6Actor extends Actor {
|
||||
rollData.diceFormula = Hero6Utility.convertRollHeroSyntax(item.system.damage)
|
||||
let myRoll = new Roll(rollData.diceFormula).roll({ async: false })
|
||||
await Hero6Utility.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
|
||||
|
||||
rollData.roll = myRoll
|
||||
rollData.result = myRoll.total
|
||||
rollData.bodyValue = Hero6Utility.computeBodyValue(myRoll)
|
||||
@@ -604,11 +598,12 @@ export class Hero6Actor extends Actor {
|
||||
async rollLiftDice() {
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.mode = "lift-dice"
|
||||
rollData.diceFormula = Hero6Utility.convertRollHeroSyntax( Hero6LiftDice.getLiftDice(this.system.characteristics.str.value))
|
||||
rollData.diceFormula = Hero6Utility.convertRollHeroSyntax(Hero6LiftDice.getLiftDice(this.system.characteristics.str.value))
|
||||
let myRoll = new Roll(rollData.diceFormula).roll({ async: false })
|
||||
await Hero6Utility.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
|
||||
rollData.roll = myRoll
|
||||
|
||||
rollData.roll = duplicate(myRoll)
|
||||
rollData.bodyValue = Hero6Utility.computeBodyValue(myRoll)
|
||||
rollData.result = myRoll.total
|
||||
|
||||
let msg = await Hero6Utility.createChatWithRollMode(rollData.alias, {
|
||||
@@ -617,7 +612,7 @@ export class Hero6Actor extends Actor {
|
||||
msg.setFlag("world", "rolldata", rollData)
|
||||
console.log("Rolldata result", rollData)
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollSkill(skillId) {
|
||||
let skill = this.items.get(skillId)
|
||||
|
Reference in New Issue
Block a user