Divers fixes + fiches creatures
This commit is contained in:
@@ -20,7 +20,7 @@ export class HawkmoonActorSheet extends ActorSheet {
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
|
||||
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
|
||||
editScore: false
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -48,6 +48,7 @@ export class HawkmoonActorSheet extends ActorSheet {
|
||||
combat: this.actor.getCombatValues(),
|
||||
equipements: duplicate(this.actor.getEquipments()),
|
||||
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
|
||||
habitat: await TextEditor.enrichHTML(this.object.system.biodata.habitat, {async: true}),
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
editScore: this.options.editScore,
|
||||
@@ -120,13 +121,13 @@ export class HawkmoonActorSheet extends ActorSheet {
|
||||
} );
|
||||
|
||||
html.find('.roll-initiative').click((event) => {
|
||||
this.actor.rollAttribut("pre", 1)
|
||||
this.actor.rollAttribut("pre", true)
|
||||
})
|
||||
|
||||
html.find('.roll-attribut').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
let attrKey = li.data("attr-key")
|
||||
this.actor.rollAttribut(attrKey, 2)
|
||||
this.actor.rollAttribut(attrKey, false)
|
||||
})
|
||||
html.find('.roll-competence').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
@@ -184,10 +185,4 @@ export class HawkmoonActorSheet extends ActorSheet {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
_updateObject(event, formData) {
|
||||
// Update the Actor
|
||||
return this.object.update(formData);
|
||||
}
|
||||
}
|
||||
|
@@ -291,6 +291,10 @@ export class HawkmoonActor extends Actor {
|
||||
return { isValid: false }
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getVigueur() {
|
||||
return this.system.sante.vigueur
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getBonneAventure() {
|
||||
return this.system.bonneaventure.actuelle
|
||||
}
|
||||
@@ -409,8 +413,9 @@ export class HawkmoonActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getInitiativeScore() {
|
||||
return Number(this.system.attributs.adr.value) + Number(this.system.combat.initbonus)
|
||||
return this.lastInit || -1
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getBestDefenseValue() {
|
||||
let defenseList = this.items.filter(item => (item.type == "arme") && item.system.equipped)
|
||||
@@ -484,9 +489,10 @@ export class HawkmoonActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollAttribut(attrKey, multiplier = 1) {
|
||||
async rollAttribut(attrKey, isInit = false) {
|
||||
let rollData = this.getCommonRollData(attrKey)
|
||||
rollData.multiplier = multiplier
|
||||
rollData.multiplier = (isInit)? 1 : 2
|
||||
rollData.isInit = isInit
|
||||
let rollDialog = await HawkmoonRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
}
|
||||
@@ -506,9 +512,6 @@ export class HawkmoonActor extends Actor {
|
||||
if (arme.type == "arme") {
|
||||
arme = this.prepareArme(arme)
|
||||
}
|
||||
if (arme.type == "bouclier") {
|
||||
arme = this.prepareBouclier(arme)
|
||||
}
|
||||
let rollData = this.getCommonRollData(arme.system.attrKey, arme.system.competence._id)
|
||||
rollData.arme = arme
|
||||
console.log("ARME!", rollData)
|
||||
@@ -517,17 +520,18 @@ export class HawkmoonActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollArmeDegats(armeId) {
|
||||
async rollArmeDegats(armeId, targetVigueur = undefined) {
|
||||
let arme = this.items.get(armeId)
|
||||
if (arme.type == "arme") {
|
||||
arme = this.prepareArme(arme)
|
||||
}
|
||||
if (arme.type == "bouclier") {
|
||||
arme = this.prepareBouclier(arme)
|
||||
}
|
||||
console.log("DEGATS", arme)
|
||||
let roll = new Roll( "1d10+"+arme.system.totalDegats).roll({ async: false })
|
||||
await HawkmoonUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"));
|
||||
let nbEtatPerdus = 0
|
||||
if (targetVigueur) {
|
||||
nbEtatPerdus = Math.floor(roll.total / targetVigueur)
|
||||
}
|
||||
let rollData = {
|
||||
arme: arme,
|
||||
finalResult: roll.total,
|
||||
@@ -535,6 +539,8 @@ export class HawkmoonActor extends Actor {
|
||||
actorImg: this.img,
|
||||
actorId: this.id,
|
||||
actionImg: arme.img,
|
||||
targetVigueur: targetVigueur,
|
||||
nbEtatPerdus: nbEtatPerdus
|
||||
}
|
||||
HawkmoonUtility.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-hawkmoon-cyd/templates/chat-degats-result.html`, rollData)
|
||||
|
@@ -9,11 +9,9 @@ export class HawkmoonCombat extends Combat {
|
||||
for (let cId = 0; cId < ids.length; cId++) {
|
||||
const c = this.combatants.get(ids[cId]);
|
||||
let id = c._id || c.id;
|
||||
let initBonus = c.actor ? c.actor.getInitiativeScore() : 0
|
||||
let roll = new Roll("1d10 + "+initBonus).roll({ async: false})
|
||||
await HawkmoonUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"))
|
||||
let initValue = c.actor ? c.actor.getInitiativeScore() : 0
|
||||
//console.log("Init bonus", initBonus, roll.total)
|
||||
await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: roll.total } ]);
|
||||
await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: initValue } ]);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
26
modules/hawkmoon-creature-sheet.js
Normal file
26
modules/hawkmoon-creature-sheet.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
*/
|
||||
|
||||
import { HawkmoonActorSheet } from "./hawkmoon-actor-sheet.js";
|
||||
import { HawkmoonUtility } from "./hawkmoon-utility.js";
|
||||
import { HawkmoonAutomation } from "./hawkmoon-automation.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class HawkmoonCreatureSheet extends HawkmoonActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["fvtt-hawkmoon-cyd", "sheet", "actor"],
|
||||
template: "systems/fvtt-hawkmoon-cyd/templates/creature-sheet.html",
|
||||
width: 640,
|
||||
height: 720,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
|
||||
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
|
||||
editScore: false
|
||||
})
|
||||
}
|
||||
}
|
@@ -11,6 +11,8 @@ export const defaultItemImg = {
|
||||
historique: "systems/fvtt-hawkmoon-cyd/assets/icons/historique.webp",
|
||||
profil: "systems/fvtt-hawkmoon-cyd/assets/icons/profil.webp",
|
||||
artefact: "systems/fvtt-hawkmoon-cyd/assets/icons/artefact.webp",
|
||||
contact: "systems/fvtt-hawkmoon-cyd/assets/icons/contacts.webp",
|
||||
ressource: "systems/fvtt-hawkmoon-cyd/assets/icons/ressources.webp",
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -11,6 +11,7 @@
|
||||
import { HawkmoonActor } from "./hawkmoon-actor.js";
|
||||
import { HawkmoonItemSheet } from "./hawkmoon-item-sheet.js";
|
||||
import { HawkmoonActorSheet } from "./hawkmoon-actor-sheet.js";
|
||||
import { HawkmoonCreatureSheet } from "./hawkmoon-creature-sheet.js";
|
||||
import { HawkmoonCelluleSheet } from "./hawkmoon-cellule-sheet.js";
|
||||
import { HawkmoonUtility } from "./hawkmoon-utility.js";
|
||||
import { HawkmoonCombat } from "./hawkmoon-combat.js";
|
||||
@@ -55,7 +56,8 @@ Hooks.once("init", async function () {
|
||||
// Register sheet application classes
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("fvtt-hawkmoon-cyd", HawkmoonActorSheet, { types: ["personnage"], makeDefault: true })
|
||||
Actors.registerSheet("fvtt-hawkmoon-cyd", HawkmoonCelluleSheet, { types: ["cellule"], makeDefault: false });
|
||||
Actors.registerSheet("fvtt-hawkmoon-cyd", HawkmoonCreatureSheet, { types: ["creature"], makeDefault: true })
|
||||
Actors.registerSheet("fvtt-hawkmoon-cyd", HawkmoonCelluleSheet, { types: ["cellule"], makeDefault: true });
|
||||
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("fvtt-hawkmoon-cyd", HawkmoonItemSheet, { makeDefault: true })
|
||||
|
@@ -132,6 +132,14 @@ export class HawkmoonUtility {
|
||||
rollData.competence = duplicate(actor.getCompetence(rollData.competence._id))
|
||||
HawkmoonUtility.rollHawkmoon(rollData)
|
||||
})
|
||||
|
||||
html.on("click", '.roll-chat-degat', async event => {
|
||||
let messageId = HawkmoonUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "hawkmoon-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.rollArmeDegats(rollData.arme._id, rollData.targetVigueur)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -290,10 +298,9 @@ export class HawkmoonUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeResult(rollData) {
|
||||
if (rollData.mainDice == "1d20") {
|
||||
rollData.diceResult = rollData.roll.terms[0].results[0].result
|
||||
if (rollData.mainDice.includes("d20") ) {
|
||||
let diceValue = rollData.roll.terms[0].results[0].result
|
||||
diceValue *= (rollData.doubleD20) ? 2 : 1
|
||||
//console.log("PAIR/IMP", diceValue)
|
||||
if (diceValue % 2 == 1) {
|
||||
//console.log("PAIR/IMP2", diceValue)
|
||||
rollData.finalResult -= rollData.roll.terms[0].results[0].result // Substract value
|
||||
@@ -310,6 +317,7 @@ export class HawkmoonUtility {
|
||||
rollData.isHeroique = ((rollData.finalResult - rollData.difficulte) >= 10)
|
||||
rollData.isDramatique = ((rollData.finalResult - rollData.difficulte) <= -10)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -372,6 +380,9 @@ export class HawkmoonUtility {
|
||||
|
||||
rollData.finalResult = myRoll.total
|
||||
this.computeResult(rollData)
|
||||
if (rollData.isInit) {
|
||||
actor.lastInit = rollData.finalResult
|
||||
}
|
||||
|
||||
this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-hawkmoon-cyd/templates/chat-generic-result.html`, rollData)
|
||||
@@ -423,7 +434,7 @@ export class HawkmoonUtility {
|
||||
chatGM.whisper = this.getUsers(user => user.isGM);
|
||||
chatGM.content = "Blinde message of " + game.user.name + "<br>" + chatOptions.content;
|
||||
console.log("blindMessageToGM", chatGM);
|
||||
game.socket.emit("system.fvtt-weapons-of-the-gods", { msg: "msg_gm_chat_message", data: chatGM });
|
||||
game.socket.emit("system.fvtt-hawkmoon-cyd", { msg: "msg_gm_chat_message", data: chatGM });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -501,6 +512,7 @@ export class HawkmoonUtility {
|
||||
rollData.defenderTokenId = target.id
|
||||
let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor
|
||||
rollData.armeDefense = defender.getBestDefenseValue()
|
||||
rollData.targetVigueur = defender.getVigueur()
|
||||
if ( rollData.armeDefense) {
|
||||
rollData.difficulte = rollData.armeDefense.system.totalDefensif
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user