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