Initial release
This commit is contained in:
@ -14,8 +14,8 @@ export class MaleficesActorSheet extends ActorSheet {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["fvtt-malefices", "sheet", "actor"],
|
||||
template: "systems/fvtt-malefices/templates/actors/actor-sheet.hbs",
|
||||
width: 960,
|
||||
height: 720,
|
||||
width: 640,
|
||||
height: 640,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "skills" }],
|
||||
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
|
||||
editScore: true
|
||||
@ -38,7 +38,6 @@ export class MaleficesActorSheet extends ActorSheet {
|
||||
armes: duplicate(this.actor.getArmes()),
|
||||
equipements: duplicate(this.actor.getEquipements()),
|
||||
subActors: duplicate(this.actor.getSubActors()),
|
||||
focusData: this.actor.computeFinalFocusData(),
|
||||
encCurrent: this.actor.encCurrent,
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
@ -113,13 +112,11 @@ export class MaleficesActorSheet extends ActorSheet {
|
||||
|
||||
html.find('.roll-attribut').click((event) => {
|
||||
let attrKey = $(event.currentTarget).data("attr-key")
|
||||
let skillKey = $(event.currentTarget).data("skill-key")
|
||||
this.actor.rollSkill(attrKey, skillKey)
|
||||
this.actor.rollAttribut(attrKey)
|
||||
});
|
||||
html.find('.roll-arme').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const weponId = li.data("item-id")
|
||||
this.actor.rollWeapon(weponId)
|
||||
const armeId = $(event.currentTarget).data("arme-id")
|
||||
this.actor.rollArme(armeId)
|
||||
});
|
||||
|
||||
html.find('.lock-unlock-sheet').click((event) => {
|
||||
|
@ -198,15 +198,9 @@ export class MaleficesActor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getInitiativeScore(combatId, combatantId) {
|
||||
if (this.type == 'character') {
|
||||
let init = this.getFlag("world", "initiative" )
|
||||
console.log("INIT", init)
|
||||
if (!init || init == -1) {
|
||||
ChatMessage.create( { content: "Roll your initiative for this combat"} )
|
||||
}
|
||||
return init
|
||||
}
|
||||
return -1;
|
||||
let init = Math.floor(this.system.attributs.physique.value+this.system.attributs.habilete.value)
|
||||
let subvalue = new Roll("1d20").roll({async: false})
|
||||
return init + (subvalue / 100)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -268,6 +262,12 @@ export class MaleficesActor extends Actor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getAtttributImage( attrKey) {
|
||||
return `systems/fvtt-malefices/images/icons/${attrKey}.webp`
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCommonRollData() {
|
||||
|
||||
@ -276,50 +276,54 @@ export class MaleficesActor extends Actor {
|
||||
rollData.actorImg = this.img
|
||||
rollData.actorId = this.id
|
||||
rollData.img = this.img
|
||||
rollData.phyMalus = this.getPhysiqueMalus()
|
||||
|
||||
console.log("ROLLDATA", rollData)
|
||||
|
||||
return rollData
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getPhysiqueMalus() {
|
||||
if ( this.system.attributs.constitution.value <= 8) {
|
||||
return -(9 - this.system.attributs.constitution.value)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollAtribut(attrKey, skillKey) {
|
||||
let attr = this.system.attributes[attrKey]
|
||||
let skill = attr.skills[skillKey]
|
||||
if (skill) {
|
||||
skill = duplicate(skill)
|
||||
skill.name = MaleficesUtility.upperFirst(skillKey)
|
||||
skill.attr = duplicate(attr)
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.mode = "skill"
|
||||
rollMode.skillKey = skillKey
|
||||
rollData.skill = skill
|
||||
rollData.title = "Roll Skill " + skill.name
|
||||
rollData.img = skill.img
|
||||
this.startRoll(rollData)
|
||||
}
|
||||
rollAttribut(attrKey) {
|
||||
let attr = this.system.attributs[attrKey]
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.attr = duplicate(attr)
|
||||
rollData.mode = "attribut"
|
||||
rollData.title = attr.label
|
||||
rollData.img = this.getAtttributImage(attrKey)
|
||||
this.startRoll(rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollArme(weaponId) {
|
||||
let weapon = this.items.get(weaponId)
|
||||
if (weapon) {
|
||||
weapon = duplicate(weapon)
|
||||
this.prepareWeapon(weapon)
|
||||
let arme = this.items.get(weaponId)
|
||||
if (arme) {
|
||||
arme = duplicate(arme)
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.modifier = this.system.bonus[weapon.system.weapontype]
|
||||
rollData.mode = "weapon"
|
||||
rollData.weapon = weapon
|
||||
rollData.img = weapon.img
|
||||
if (arme.system.armetype == "mainsnues" || arme.system.armetype == "epee") {
|
||||
rollData.attr = { label: "(Physique+Habilité)/2", value: Math.floor( (this.getPhysiqueMalus()+this.system.attributs.physique+this.system.attributs.habilite) / 2) }
|
||||
} else {
|
||||
rollData.attr = duplicate(this.system.attributs.habilite)
|
||||
}
|
||||
rollData.mode = "arme"
|
||||
rollData.arme = arme
|
||||
rollData.img = arme.img
|
||||
rollData.title = arme.name
|
||||
this.startRoll(rollData)
|
||||
} else {
|
||||
ui.notifications.warn("Unable to find the relevant weapon ")
|
||||
ui.notifications.warn("Impossible de trouver l'arme concernée ")
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async startRoll(rollData) {
|
||||
this.syncRoll(rollData)
|
||||
let rollDialog = await MaleficesRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ import { MaleficesRollDialog } from "./malefices-roll-dialog.js";
|
||||
export class MaleficesCommands {
|
||||
|
||||
static init() {
|
||||
if (!game.system.Malefices.commands) {
|
||||
const MaleficesCommands = new MaleficesCommands();
|
||||
if (!game.system.malefices.commands) {
|
||||
const commands = new MaleficesCommands();
|
||||
//crucibleCommands.registerCommand({ path: ["/char"], func: (content, msg, params) => crucibleCommands.createChar(msg), descr: "Create a new character" });
|
||||
//crucibleCommands.registerCommand({ path: ["/pool"], func: (content, msg, params) => crucibleCommands.poolRoll(msg), descr: "Generic Roll Window" });
|
||||
game.system.Malefices.commands = MaleficesCommands;
|
||||
game.system.malefices.commands = commands;
|
||||
}
|
||||
}
|
||||
constructor() {
|
||||
|
@ -58,7 +58,7 @@ export class MaleficesItemSheet extends ItemSheet {
|
||||
editable: this.isEditable,
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
system: duplicate(this.object.system),
|
||||
config: duplicate(game.system.malefices),
|
||||
config: duplicate(game.system.malefices.config),
|
||||
limited: this.object.limited,
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
|
@ -58,12 +58,15 @@ export class MaleficesRollDialog extends Dialog {
|
||||
}
|
||||
$(function () { onLoad(); });
|
||||
|
||||
html.find('#bonusMalusRoll').change((event) => {
|
||||
this.rollData.bonusMalusRoll = event.currentTarget.value
|
||||
html.find('#bonusMalusSituation').change((event) => {
|
||||
this.rollData.bonusMalusSituation = Number(event.currentTarget.value)
|
||||
})
|
||||
html.find('#targetCheck').change((event) => {
|
||||
this.rollData.targetCheck = event.currentTarget.value
|
||||
html.find('#bonusMalusPerso').change((event) => {
|
||||
this.rollData.bonusMalusPerso = Number(event.currentTarget.value)
|
||||
})
|
||||
|
||||
html.find('#bonusMalusDef').change((event) => {
|
||||
this.rollData.bonusMalusDef = Number(event.currentTarget.value)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
@ -155,20 +155,7 @@ export class MaleficesUtility {
|
||||
const templatePaths = [
|
||||
'systems/fvtt-malefices/templates/actors/editor-notes-gm.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-item-nav.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-item-description.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-common-item-fields.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-damage-types.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-weapon-types.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-weapon-categories.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-attributes.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-equipment-types.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-armor-types.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-spell-types.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-spell-levels.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-spell-schools.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-focus-bond.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-focus-treatment.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-options-focus-core.hbs',
|
||||
'systems/fvtt-malefices/templates/items/partial-item-description.hbs'
|
||||
]
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
@ -508,26 +495,10 @@ export class MaleficesUtility {
|
||||
static async rollMalefices(rollData) {
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
|
||||
|
||||
// Build the dice formula
|
||||
let diceFormula = "1d12"
|
||||
if (rollData.skill) {
|
||||
diceFormula += "+" + rollData.skill.finalvalue
|
||||
}
|
||||
if (rollData.crafting) {
|
||||
diceFormula += "+" + rollData.crafting.system.level
|
||||
}
|
||||
if (rollData.spellAttack) {
|
||||
diceFormula += "+" + rollData.spellAttack
|
||||
}
|
||||
diceFormula += "+" + rollData.bonusMalusRoll
|
||||
|
||||
if (rollData.skill && rollData.skill.good) {
|
||||
diceFormula += "+1d4"
|
||||
}
|
||||
if (rollData.weapon ) {
|
||||
diceFormula += "+" + rollData.weapon.attackBonus
|
||||
}
|
||||
let diceFormula = "1d20"
|
||||
rollData.target = rollData.attr.value + rollData.bonusMalusPerso + rollData.bonusMalusSituation + rollData.bonusMalusDef
|
||||
rollData.diceFormula = diceFormula
|
||||
|
||||
// Performs roll
|
||||
@ -540,22 +511,26 @@ export class MaleficesUtility {
|
||||
rollData.roll = myRoll
|
||||
|
||||
rollData.isSuccess = false
|
||||
if (rollData.targetCheck != "none") {
|
||||
if (myRoll.total >= Number(rollData.targetCheck)) {
|
||||
rollData.isSuccess = true
|
||||
}
|
||||
if (myRoll.total <= rollData.target ) {
|
||||
rollData.isSuccess = true
|
||||
}
|
||||
|
||||
if (rollData.spell) {
|
||||
actor.spentFocusPoints(rollData.spell)
|
||||
if (myRoll.total == 1 ) {
|
||||
rollData.isSuccess = true
|
||||
rollData.isCritical = true
|
||||
}
|
||||
if (myRoll.total == 20 ) {
|
||||
rollData.isSuccess = false
|
||||
rollData.isFumble = true
|
||||
}
|
||||
if (myRoll.total <= Math.floor(rollData.target/3) ) {
|
||||
rollData.isPart = true
|
||||
}
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-malefices/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
})
|
||||
msg.setFlag("world", "rolldata", rollData)
|
||||
if (rollData.skillKey == "initiative") {
|
||||
console.log("REGISTERED")
|
||||
if (rollData.mode == "initiative") {
|
||||
actor.setFlag("world", "initiative", myRoll.total)
|
||||
}
|
||||
|
||||
@ -649,8 +624,9 @@ export class MaleficesUtility {
|
||||
static getBasicRollData() {
|
||||
let rollData = {
|
||||
rollId: randomID(16),
|
||||
bonusMalusRoll: 0,
|
||||
targetCheck: "none",
|
||||
bonusMalusPerso: 0,
|
||||
bonusMalusSituation: 0,
|
||||
bonusMalusDef: 0,
|
||||
rollMode: game.settings.get("core", "rollMode")
|
||||
}
|
||||
MaleficesUtility.updateWithTarget(rollData)
|
||||
|
Reference in New Issue
Block a user