Various/changes from 30th may requestsé
This commit is contained in:
@@ -152,6 +152,10 @@ export class Hero6ActorSheet extends ActorSheet {
|
||||
const characKey = $(event.currentTarget).data("charac-key");
|
||||
this.actor.rollCharac(characKey);
|
||||
});
|
||||
html.find('.roll-perception').click((event) => {
|
||||
this.actor.rollPerception("int");
|
||||
});
|
||||
|
||||
html.find('.roll-direct').click((event) => {
|
||||
const rollFormula = $(event.currentTarget).data("roll-formula")
|
||||
const rollSource = $(event.currentTarget).data("roll-source")
|
||||
@@ -179,7 +183,7 @@ export class Hero6ActorSheet extends ActorSheet {
|
||||
const skillId = li.data("item-id")
|
||||
this.actor.rollWeapon(skillId)
|
||||
});
|
||||
|
||||
|
||||
html.find('.lock-unlock-sheet').click((event) => {
|
||||
this.options.editScore = !this.options.editScore;
|
||||
this.render(true);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -123,9 +123,17 @@ export class Hero6Commands {
|
||||
let formula = params.join(' ')
|
||||
if (formula) {
|
||||
let foundryFormula = Hero6Utility.convertRollHeroSyntax(formula)
|
||||
|
||||
let myRoll = new Roll(foundryFormula).roll({ async: false })
|
||||
await Hero6Utility.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
myRoll.toMessage()
|
||||
let bodyValue = Hero6Utility.computeBodyValue(myRoll)
|
||||
|
||||
let msgFlavor = await renderTemplate('systems/fvtt-hero-system-6/templates/chat/chat-hr-roll.hbs', {myRoll, bodyValue} )
|
||||
let msg = await myRoll.toMessage({
|
||||
user: game.user.id,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
flavor: msgFlavor
|
||||
})
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -53,7 +53,7 @@ export class Hero6RollDialog extends Dialog {
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
var dialog = this;
|
||||
let dialog = this;
|
||||
function onLoad() {
|
||||
}
|
||||
$(function () { onLoad(); });
|
||||
|
||||
@@ -367,20 +367,24 @@ export class Hero6Utility {
|
||||
rollData.result = roll.total
|
||||
rollData.bodyValue = this.computeBodyValue(rollData.roll)
|
||||
|
||||
this.outputRollMessage(rollData)
|
||||
this.outputRollMessage(rollData).catch(function() { ui.notifications.warn("Error during message output.") })
|
||||
}
|
||||
|
||||
/* -------------- ----------------------------- */
|
||||
static async outputRollMessage(rollData) {
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-hero-system-6/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
let msgFlavor = await renderTemplate(`systems/fvtt-hero-system-6/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
let msg = await rollData.roll.toMessage({
|
||||
user: game.user.id,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
flavor: msgFlavor
|
||||
})
|
||||
rollData.roll = duplicate(rollData.roll) // Convert to object
|
||||
msg.setFlag("world", "rolldata", rollData)
|
||||
console.log("Rolldata result", rollData)
|
||||
}
|
||||
|
||||
/* -------------- ----------------------------- */
|
||||
static convertRollHeroSyntax( hero6Formula) {
|
||||
static convertRollHeroSyntax(hero6Formula) {
|
||||
// Ensure we have no space at all
|
||||
//hero6Formula = hero6Formula.replace(/\s/g, '')
|
||||
let hasHalfDice = ""
|
||||
@@ -388,7 +392,7 @@ export class Hero6Utility {
|
||||
hero6Formula = hero6Formula.replace("1/2d6", "d6")
|
||||
hasHalfDice = "+round(1d6)"
|
||||
}
|
||||
|
||||
|
||||
let foundryFormula = hero6Formula + hasHalfDice
|
||||
foundryFormula = foundryFormula.replace(' ', '')
|
||||
console.log("Parsed formula : ", hero6Formula, foundryFormula)
|
||||
@@ -433,7 +437,7 @@ export class Hero6Utility {
|
||||
static blindMessageToGM(chatOptions) {
|
||||
let chatGM = duplicate(chatOptions);
|
||||
chatGM.whisper = this.getUsers(user => user.isGM);
|
||||
chatGM.content = "Blinde message of " + game.user.name + "<br>" + chatOptions.content;
|
||||
chatGM.content = "Blind message of " + game.user.name + "<br>" + chatOptions.content;
|
||||
console.log("blindMessageToGM", chatGM);
|
||||
game.socket.emit("system.fvtt-hero-system-6", { msg: "msg_gm_chat_message", data: chatGM });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user