Better use of tokens/actors
This commit is contained in:
parent
567710d922
commit
6b508c96be
@ -496,7 +496,6 @@ export class HawkmoonActor extends Actor {
|
||||
rollData.alias = this.name
|
||||
rollData.actorImg = this.img
|
||||
rollData.actorId = this.id
|
||||
rollData.isToken = this.isToken
|
||||
rollData.tokenId = this.token?.id
|
||||
rollData.img = this.img
|
||||
rollData.attributs = HawkmoonUtility.getAttributs()
|
||||
|
@ -127,7 +127,7 @@ export class HawkmoonUtility {
|
||||
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)
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
await actor.setPredilectionUsed(rollData.competence._id, predIdx)
|
||||
rollData.competence = duplicate(actor.getCompetence(rollData.competence._id))
|
||||
HawkmoonUtility.rollHawkmoon(rollData)
|
||||
@ -137,7 +137,7 @@ export class HawkmoonUtility {
|
||||
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)
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
actor.rollArmeDegats(rollData.arme._id, rollData.targetVigueur)
|
||||
})
|
||||
}
|
||||
@ -216,8 +216,15 @@ export class HawkmoonUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getDefenseState(actorId) {
|
||||
return this.defenderStore[actorId];
|
||||
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
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -324,7 +331,7 @@ export class HawkmoonUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async rollHawkmoon(rollData) {
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
if (rollData.attrKey == "tochoose") { // No attr selected, force address
|
||||
rollData.attrKey = "adr"
|
||||
}
|
||||
@ -383,12 +390,7 @@ export class HawkmoonUtility {
|
||||
rollData.finalResult = myRoll.total
|
||||
this.computeResult(rollData)
|
||||
if (rollData.isInit) {
|
||||
let actorInit = actor
|
||||
if ( rollData.isToken && rollData.tokenId) {
|
||||
actorInit = game.canvas.tokens.get(rollData.tokenId).actor
|
||||
}
|
||||
actorInit.setFlag("world", "last-initiative", rollData.finalResult)
|
||||
//console.log("IS TOKEN ?????", actor, actor.isToken)
|
||||
actor.setFlag("world", "last-initiative", rollData.finalResult)
|
||||
}
|
||||
|
||||
this.createChatWithRollMode(rollData.alias, {
|
||||
@ -539,7 +541,7 @@ export class HawkmoonUtility {
|
||||
let msg = game.messages.get(msgId)
|
||||
if (msg) {
|
||||
let rollData = msg.getFlag("world", "hawkmoon-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
actor.changeBonneAventure(changed)
|
||||
rollData.isReroll = true
|
||||
rollData.textBonus = "Bonus de Points d'Aventure"
|
||||
@ -558,7 +560,7 @@ export class HawkmoonUtility {
|
||||
let msg = game.messages.get(msgId)
|
||||
if (msg) {
|
||||
let rollData = msg.getFlag("world", "hawkmoon-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
actor.changeEclat(changed)
|
||||
rollData.isReroll = true
|
||||
rollData.textBonus = "Bonus d'Eclat"
|
||||
@ -577,13 +579,13 @@ export class HawkmoonUtility {
|
||||
let canApplyBA = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "hawkmoon-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
return (!rollData.isReroll && actor.getBonneAventure() > 0 )
|
||||
}
|
||||
let canApplyPE = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "hawkmoon-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
return (!rollData.isReroll && actor.getEclat() > 0 )
|
||||
}
|
||||
options.push(
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "fvtt-hawkmoon-cyd",
|
||||
"description": "Hawmoon RPG for FoundryVTT (CYD system - French)",
|
||||
"version": "10.1.0",
|
||||
"version": "10.1.1",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Uberwald/LeRatierBretonnien",
|
||||
@ -35,7 +35,7 @@
|
||||
"gridUnits": "m",
|
||||
"license": "LICENSE.txt",
|
||||
"manifest": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/raw/branch/master/system.json",
|
||||
"download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.1.0.zip",
|
||||
"download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.1.1.zip",
|
||||
"packs": [
|
||||
{
|
||||
"type": "Item",
|
||||
|
Loading…
Reference in New Issue
Block a user