Better use of tokens/actors
This commit is contained in:
parent
a26af23c9c
commit
a63ec19362
@ -407,6 +407,7 @@ export class MournbladeActor extends Actor {
|
|||||||
rollData.alias = this.name
|
rollData.alias = this.name
|
||||||
rollData.actorImg = this.img
|
rollData.actorImg = this.img
|
||||||
rollData.actorId = this.id
|
rollData.actorId = this.id
|
||||||
|
rollData.tokenId = this.token?.id
|
||||||
rollData.img = this.img
|
rollData.img = this.img
|
||||||
rollData.canEclatDoubleD20 = this.canEclatDoubleD20()
|
rollData.canEclatDoubleD20 = this.canEclatDoubleD20()
|
||||||
rollData.doubleD20 = false
|
rollData.doubleD20 = false
|
||||||
@ -433,7 +434,6 @@ export class MournbladeActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollAttribut(attrKey) {
|
async rollAttribut(attrKey) {
|
||||||
let rollData = this.getCommonRollData(attrKey)
|
let rollData = this.getCommonRollData(attrKey)
|
||||||
console.log("RollDatra", rollData)
|
|
||||||
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
||||||
rollDialog.render(true)
|
rollDialog.render(true)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ export class MournbladeRollDialog extends Dialog {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async create(actor, rollData ) {
|
static async create(actor, rollData ) {
|
||||||
|
|
||||||
let options = { classes: ["MournbladeDialog"], width: 340, height: 420, 'z-index': 99999 };
|
let options = { classes: ["MournbladeDialog"], width: 340, height: 'fit-content', 'z-index': 99999 };
|
||||||
let html = await renderTemplate('systems/fvtt-mournblade/templates/roll-dialog-generic.html', rollData);
|
let html = await renderTemplate('systems/fvtt-mournblade/templates/roll-dialog-generic.html', rollData);
|
||||||
|
|
||||||
return new MournbladeRollDialog(actor, rollData, html, options );
|
return new MournbladeRollDialog(actor, rollData, html, options );
|
||||||
|
@ -46,6 +46,17 @@ export class MournbladeUtility {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static getActorFromRollData(rollData) {
|
||||||
|
let actor = game.actors.get(rollData.actorId)
|
||||||
|
if (rollData.tokenId) {
|
||||||
|
let token = canvas.tokens.placeables.find(t => t.id == rollData.tokenId)
|
||||||
|
if (token) {
|
||||||
|
actor = token.actor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return actor
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static getModificateurOptions() {
|
static getModificateurOptions() {
|
||||||
@ -108,7 +119,7 @@ export class MournbladeUtility {
|
|||||||
let messageId = MournbladeUtility.findChatMessageId(event.currentTarget)
|
let messageId = MournbladeUtility.findChatMessageId(event.currentTarget)
|
||||||
let message = game.messages.get(messageId)
|
let message = game.messages.get(messageId)
|
||||||
let rollData = message.getFlag("world", "mournblade-roll")
|
let rollData = message.getFlag("world", "mournblade-roll")
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
await actor.setPredilectionUsed(rollData.competence._id, predIdx)
|
await actor.setPredilectionUsed(rollData.competence._id, predIdx)
|
||||||
rollData.competence = duplicate(actor.getCompetence(rollData.competence._id))
|
rollData.competence = duplicate(actor.getCompetence(rollData.competence._id))
|
||||||
MournbladeUtility.rollMournblade(rollData)
|
MournbladeUtility.rollMournblade(rollData)
|
||||||
@ -183,11 +194,6 @@ export class MournbladeUtility {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static getDefenseState(actorId) {
|
|
||||||
return this.defenderStore[actorId];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static updateRollData(rollData) {
|
static updateRollData(rollData) {
|
||||||
|
|
||||||
@ -292,7 +298,7 @@ export class MournbladeUtility {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async rollMournblade(rollData) {
|
static async rollMournblade(rollData) {
|
||||||
|
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
if (rollData.attrKey == "tochoose") { // No attr selected, force address
|
if (rollData.attrKey == "tochoose") { // No attr selected, force address
|
||||||
rollData.attrKey = "adr"
|
rollData.attrKey = "adr"
|
||||||
}
|
}
|
||||||
@ -473,7 +479,7 @@ export class MournbladeUtility {
|
|||||||
rollData.defenderTokenId = target.id
|
rollData.defenderTokenId = target.id
|
||||||
let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor
|
let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor
|
||||||
rollData.armeDefense = defender.getBestDefenseValue()
|
rollData.armeDefense = defender.getBestDefenseValue()
|
||||||
if ( rollData.armeDefense) {
|
if (rollData.armeDefense) {
|
||||||
rollData.difficulte = rollData.armeDefense.system.totalDefensif
|
rollData.difficulte = rollData.armeDefense.system.totalDefensif
|
||||||
} else {
|
} else {
|
||||||
ui.notifications.warn("Aucune arme de défense équipée, difficulté manuelle à positionner.")
|
ui.notifications.warn("Aucune arme de défense équipée, difficulté manuelle à positionner.")
|
||||||
@ -492,7 +498,7 @@ export class MournbladeUtility {
|
|||||||
let msg = game.messages.get(msgId)
|
let msg = game.messages.get(msgId)
|
||||||
if (msg) {
|
if (msg) {
|
||||||
let rollData = msg.getFlag("world", "mournblade-roll")
|
let rollData = msg.getFlag("world", "mournblade-roll")
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
actor.changeBonneAventure(changed)
|
actor.changeBonneAventure(changed)
|
||||||
rollData.isReroll = true
|
rollData.isReroll = true
|
||||||
rollData.textBonus = "Bonus de Points d'Aventure"
|
rollData.textBonus = "Bonus de Points d'Aventure"
|
||||||
@ -511,7 +517,7 @@ export class MournbladeUtility {
|
|||||||
let msg = game.messages.get(msgId)
|
let msg = game.messages.get(msgId)
|
||||||
if (msg) {
|
if (msg) {
|
||||||
let rollData = msg.getFlag("world", "mournblade-roll")
|
let rollData = msg.getFlag("world", "mournblade-roll")
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
actor.changeEclat(changed)
|
actor.changeEclat(changed)
|
||||||
rollData.isReroll = true
|
rollData.isReroll = true
|
||||||
rollData.textBonus = "Bonus d'Eclat"
|
rollData.textBonus = "Bonus d'Eclat"
|
||||||
@ -526,37 +532,37 @@ export class MournbladeUtility {
|
|||||||
let canApplyBALoyal = function (li) {
|
let canApplyBALoyal = function (li) {
|
||||||
let message = game.messages.get(li.attr("data-message-id"))
|
let message = game.messages.get(li.attr("data-message-id"))
|
||||||
let rollData = message.getFlag("world", "mournblade-roll")
|
let rollData = message.getFlag("world", "mournblade-roll")
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "loyal")
|
return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "loyal")
|
||||||
}
|
}
|
||||||
let canApplyPELoyal = function (li) {
|
let canApplyPELoyal = function (li) {
|
||||||
let message = game.messages.get(li.attr("data-message-id"))
|
let message = game.messages.get(li.attr("data-message-id"))
|
||||||
let rollData = message.getFlag("world", "mournblade-roll")
|
let rollData = message.getFlag("world", "mournblade-roll")
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "loyal")
|
return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "loyal")
|
||||||
}
|
}
|
||||||
let canApplyBAChaotique = function (li) {
|
let canApplyBAChaotique = function (li) {
|
||||||
let message = game.messages.get(li.attr("data-message-id"))
|
let message = game.messages.get(li.attr("data-message-id"))
|
||||||
let rollData = message.getFlag("world", "mournblade-roll")
|
let rollData = message.getFlag("world", "mournblade-roll")
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "chaotique")
|
return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "chaotique")
|
||||||
}
|
}
|
||||||
let canApplyBAChaotique3 = function (li) {
|
let canApplyBAChaotique3 = function (li) {
|
||||||
let message = game.messages.get(li.attr("data-message-id"))
|
let message = game.messages.get(li.attr("data-message-id"))
|
||||||
let rollData = message.getFlag("world", "mournblade-roll")
|
let rollData = message.getFlag("world", "mournblade-roll")
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
return (!rollData.isReroll && actor.getBonneAventure() > 2 && actor.getAlignement() == "chaotique")
|
return (!rollData.isReroll && actor.getBonneAventure() > 2 && actor.getAlignement() == "chaotique")
|
||||||
}
|
}
|
||||||
let canApplyPEChaotique = function (li) {
|
let canApplyPEChaotique = function (li) {
|
||||||
let message = game.messages.get(li.attr("data-message-id"))
|
let message = game.messages.get(li.attr("data-message-id"))
|
||||||
let rollData = message.getFlag("world", "mournblade-roll")
|
let rollData = message.getFlag("world", "mournblade-roll")
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "chaotique")
|
return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "chaotique")
|
||||||
}
|
}
|
||||||
let hasPredilection = function (li) {
|
let hasPredilection = function (li) {
|
||||||
let message = game.messages.get(li.attr("data-message-id"))
|
let message = game.messages.get(li.attr("data-message-id"))
|
||||||
let rollData = message.getFlag("world", "mournblade-roll")
|
let rollData = message.getFlag("world", "mournblade-roll")
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
if (rollData.competence) {
|
if (rollData.competence) {
|
||||||
let nbPred = rollData.competence.data.predilections.filter(pred => !pred.used).length
|
let nbPred = rollData.competence.data.predilections.filter(pred => !pred.used).length
|
||||||
return (!rollData.isReroll && rollData.competence && nbPred > 0)
|
return (!rollData.isReroll && rollData.competence && nbPred > 0)
|
||||||
@ -566,7 +572,7 @@ export class MournbladeUtility {
|
|||||||
let canCompetenceDouble = function (li) {
|
let canCompetenceDouble = function (li) {
|
||||||
let message = game.messages.get(li.attr("data-message-id"))
|
let message = game.messages.get(li.attr("data-message-id"))
|
||||||
let rollData = message.getFlag("world", "mournblade-roll")
|
let rollData = message.getFlag("world", "mournblade-roll")
|
||||||
let actor = game.actors.get(rollData.actorId)
|
let actor = MournbladeUtility.getActorFromRollData(rollData)
|
||||||
if (rollData.competence) {
|
if (rollData.competence) {
|
||||||
return rollData.competence.data.doublebonus
|
return rollData.competence.data.doublebonus
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "fvtt-mournblade",
|
"id": "fvtt-mournblade",
|
||||||
"description": "Mournblade RPG for FoundryVTT",
|
"description": "Mournblade RPG for FoundryVTT",
|
||||||
"version": "10.0.11",
|
"version": "10.0.12",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Uberwald/LeRatierBretonnien",
|
"name": "Uberwald/LeRatierBretonnien",
|
||||||
@ -15,7 +15,7 @@
|
|||||||
"gridUnits": "m",
|
"gridUnits": "m",
|
||||||
"license": "LICENSE.txt",
|
"license": "LICENSE.txt",
|
||||||
"manifest": "https://www.uberwald.me/gitea/public/fvtt-mournblade/raw/branch/v10/system.json",
|
"manifest": "https://www.uberwald.me/gitea/public/fvtt-mournblade/raw/branch/v10/system.json",
|
||||||
"download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-10.0.11.zip",
|
"download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-10.0.12.zip",
|
||||||
"packs": [
|
"packs": [
|
||||||
{
|
{
|
||||||
"type": "Item",
|
"type": "Item",
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Actor": {
|
"Actor": {
|
||||||
"types": [
|
"types": [
|
||||||
"personnage",
|
"personnage"
|
||||||
"pnj"
|
|
||||||
],
|
],
|
||||||
"templates": {
|
"templates": {
|
||||||
"biodata": {
|
"biodata": {
|
||||||
|
Loading…
Reference in New Issue
Block a user