2021-02-12 18:31:49 +01:00
|
|
|
import { Grammar } from "../grammar.js";
|
2021-02-12 01:44:27 +01:00
|
|
|
import { Misc } from "../misc.js";
|
2021-02-12 15:01:10 +01:00
|
|
|
import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js";
|
2021-02-12 01:44:27 +01:00
|
|
|
import { Draconique } from "./draconique.js";
|
|
|
|
|
|
|
|
export class Conquete extends Draconique {
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
type() { return 'queue' }
|
2021-02-12 18:31:49 +01:00
|
|
|
match(item) { return Draconique.isQueueDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('conquete'); }
|
2021-02-12 01:44:27 +01:00
|
|
|
manualMessage() { return false }
|
|
|
|
async onActorCreateOwned(actor, item) { await this._creerConquete(actor, item); }
|
|
|
|
|
|
|
|
code() { return 'conquete' }
|
2021-05-03 20:02:10 +02:00
|
|
|
tooltip(linkData) { return `${this.tmrLabel(linkData)}: doit être conquis` }
|
2021-02-12 01:44:27 +01:00
|
|
|
img() { return 'icons/svg/combat.svg' }
|
|
|
|
|
2021-02-12 18:31:49 +01:00
|
|
|
createSprite(pixiTMR) {
|
2021-02-12 01:44:27 +01:00
|
|
|
return pixiTMR.sprite(this.code(),
|
|
|
|
{
|
2021-02-12 15:01:10 +01:00
|
|
|
zIndex: tmrTokenZIndex.conquete,
|
|
|
|
color: tmrColors.queues,
|
|
|
|
taille: tmrConstants.full,
|
|
|
|
decallage: { x: 2, y: 0 }
|
2021-02-12 01:44:27 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async _creerConquete(actor, queue) {
|
2021-03-29 23:41:08 +02:00
|
|
|
let existants = actor.data.items.filter(it => this.isCase(it)).map(it => Misc.data(it).data.coord);
|
2021-02-12 01:44:27 +01:00
|
|
|
let possibles = TMRUtility.filterTMR(tmr => !TMRUtility.isCaseHumide(tmr) && !existants.includes(tmr.coord));
|
|
|
|
let conquete = Misc.rollOneOf(possibles);
|
2021-03-29 23:41:08 +02:00
|
|
|
await this.createCaseTmr(actor, 'Conquête: ' + conquete.label, conquete, queue.id);
|
2021-02-12 01:44:27 +01:00
|
|
|
}
|
|
|
|
|
2021-02-28 01:52:58 +01:00
|
|
|
async onActorDeleteCaseTmr(actor, casetmr) {
|
2021-03-29 23:41:08 +02:00
|
|
|
await actor.deleteEmbeddedDocuments('Item', [casetmr.data.sourceid]);
|
2021-02-28 01:52:58 +01:00
|
|
|
}
|
|
|
|
|
2021-02-12 01:44:27 +01:00
|
|
|
}
|