forked from public/foundryvtt-reve-de-dragon
Gestion queues/souffles
- débordement - conquête
This commit is contained in:
41
module/tmr/conquete.js
Normal file
41
module/tmr/conquete.js
Normal file
@ -0,0 +1,41 @@
|
||||
import { Misc } from "../misc.js";
|
||||
import { tmrColors, tmrConstants, TMRUtility } from "../tmr-utility.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class Conquete extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'queue' }
|
||||
match(item) { return Draconique.isQueueDragon(item) && item.name.toLowerCase() == 'conquête'; }
|
||||
manualMessage() { return false }
|
||||
async onActorCreateOwned(actor, item) { await this._creerConquete(actor, item); }
|
||||
|
||||
code() { return 'conquete' }
|
||||
tooltip(linkData) { return `La ${this.tmrLabel(linkData)} doit être conquise` }
|
||||
img() { return 'icons/svg/combat.svg' }
|
||||
|
||||
_createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(),
|
||||
{
|
||||
color: tmrColors.queues, taille: tmrConstants.full, decallage: { x: 2, y: 0 }
|
||||
});
|
||||
}
|
||||
|
||||
async _creerConquete(actor, queue) {
|
||||
let existants = actor.data.items.filter(it => this.isCase(it)).map(it => it.data.coord);
|
||||
let possibles = TMRUtility.filterTMR(tmr => !TMRUtility.isCaseHumide(tmr) && !existants.includes(tmr.coord));
|
||||
let conquete = Misc.rollOneOf(possibles);
|
||||
await this.createCaseTmr(actor, 'Conquête: ' + conquete.label, conquete, queue._id);
|
||||
}
|
||||
|
||||
async onConquete(actor, coord) {
|
||||
let existants = actor.data.items.filter(it => this.isCase(it, coord));
|
||||
for (let casetmr of existants) {
|
||||
await actor.deleteOwnedItem(casetmr._id);
|
||||
await actor.deleteOwnedItem(casetmr.data.sourceid);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user