foundryvtt-reve-de-dragon/module/tmr/conquete.js

43 lines
1.5 KiB
JavaScript
Raw Normal View History

import { Grammar } from "../grammar.js";
2021-05-11 21:45:43 +02:00
import { RdDDice } from "../rdd-dice.js";
import { TMRUtility } from "../tmr-utility.js";
2023-11-15 22:14:00 +01:00
import { tmrTokenZIndex } from "../tmr-constants.js";
import { Draconique } from "./draconique.js";
2023-11-15 22:14:00 +01:00
import { TMRAnimations } from "./animation.js";
export class Conquete extends Draconique {
type() { return 'queue' }
match(item) { return Draconique.isQueueDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('conquete'); }
manualMessage() { return false }
async onActorCreateOwned(actor, item) { await this._creerConquete(actor, item); }
code() { return 'conquete' }
2023-11-15 22:14:00 +01:00
tooltip(linkData) { return `Doit être conquis` }
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/conquete.svg' }
createSprite(pixiTMR) {
2023-11-15 22:14:00 +01:00
return TMRAnimations.withAnimation(
pixiTMR.sprite(this.code(), {
zIndex: tmrTokenZIndex.conquete,
2023-11-15 22:14:00 +01:00
decallage: pixiTMR.sizes.decallage(0, 0),
taille: () => pixiTMR.sizes.half,
}),
pixiTMR,
TMRAnimations.changeZoom()
)
}
async _creerConquete(actor, queue) {
2022-06-12 12:14:55 +02:00
let existants = actor.items.filter(it => this.isCase(it)).map(it => it.system.coord);
let possibles = TMRUtility.filterTMR(tmr => !TMRUtility.isCaseHumide(tmr) && !existants.includes(tmr.coord));
2021-06-05 01:53:30 +02:00
let conquete = await RdDDice.rollOneOf(possibles);
2023-11-15 22:14:00 +01:00
await this.createCaseTmr(actor, 'Conquête', conquete, queue.id);
}
2021-02-28 01:52:58 +01:00
async onActorDeleteCaseTmr(actor, casetmr) {
2022-06-12 12:14:55 +02:00
await actor.deleteEmbeddedDocuments('Item', [casetmr.system.sourceid]);
2021-02-28 01:52:58 +01:00
}
}