43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
import { Grammar } from "../grammar.js";
|
|
import { RdDDice } from "../rdd-dice.js";
|
|
import { TMRUtility } from "../tmr-utility.js";
|
|
import { tmrTokenZIndex } from "../tmr-constants.js";
|
|
import { Draconique } from "./draconique.js";
|
|
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' }
|
|
tooltip(linkData) { return `Doit être conquis` }
|
|
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/conquete.svg' }
|
|
|
|
createSprite(pixiTMR) {
|
|
return TMRAnimations.withAnimation(
|
|
pixiTMR.sprite(this.code(), {
|
|
zIndex: tmrTokenZIndex.conquete,
|
|
decallage: pixiTMR.sizes.decallage(0, 0),
|
|
taille: () => pixiTMR.sizes.half,
|
|
}),
|
|
pixiTMR,
|
|
TMRAnimations.changeZoom()
|
|
)
|
|
}
|
|
|
|
async _creerConquete(actor, queue) {
|
|
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));
|
|
let conquete = await RdDDice.rollOneOf(possibles);
|
|
await this.createCaseTmr(actor, 'Conquête', conquete, queue.id);
|
|
}
|
|
|
|
async onActorDeleteCaseTmr(actor, casetmr) {
|
|
await actor.deleteEmbeddedDocuments('Item', [casetmr.system.sourceid]);
|
|
}
|
|
|
|
}
|