forked from public/foundryvtt-reve-de-dragon
Réduction de l'espace des TMR
This commit is contained in:
107
module/tmr/animation.js
Normal file
107
module/tmr/animation.js
Normal file
@ -0,0 +1,107 @@
|
||||
// pixiTMR.animate(pixiApp => pixiApp.ticker.add((delta) => {
|
||||
// if (!sprite.waveAnimation) {
|
||||
// sprite.waveAnimation = {
|
||||
// originx: sprite.x,
|
||||
// movex: 0,
|
||||
// step: 0.03
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (Math.abs(sprite.waveAnimation.movex) > 2) {
|
||||
// sprite.waveAnimation.step = -sprite.waveAnimation.step
|
||||
// }
|
||||
// sprite.waveAnimation.movex += sprite.waveAnimation.step;
|
||||
// }
|
||||
// sprite.x = sprite.waveAnimation.originx + sprite.waveAnimation.movex
|
||||
// }));
|
||||
|
||||
// return pixiTMR.square(this.code(),
|
||||
// {
|
||||
// zIndex: tmrTokenZIndex.trounoir,
|
||||
// tint: tmrColors.trounoir,
|
||||
// alpha: 1,
|
||||
// taille: () => pixiTMR.sizes.full,
|
||||
// decallage: {
|
||||
// x: -pixiTMR.sizes.half,
|
||||
// y: -pixiTMR.sizes.half
|
||||
// }
|
||||
// })
|
||||
|
||||
export class TMRAnimations {
|
||||
|
||||
static withAnimation(sprite, pixiTMR, ...animations) {
|
||||
if (animations.length > 0) {
|
||||
animations.forEach(animation =>
|
||||
pixiTMR.animate(pixiApp => pixiApp.ticker.add(delta => animation(sprite, delta)))
|
||||
)
|
||||
}
|
||||
return sprite
|
||||
}
|
||||
|
||||
static rotation(options = { frequence: () => 1, angle: () => 1 }) {
|
||||
return (sprite, delta) => {
|
||||
if (!sprite.tmrConfig) {
|
||||
sprite.tmrConfig = { nextTick: 0 }
|
||||
}
|
||||
sprite.tmrConfig.nextTick -= delta
|
||||
if (sprite.tmrConfig.nextTick <= 0) {
|
||||
sprite.tmrConfig.nextTick = options.frequence(delta)
|
||||
sprite.angle += options.angle(delta)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static changeZoom(range = { min: 0.8, max: 1.2, step: 0.005 }) {
|
||||
return (sprite, delta) => {
|
||||
if (!sprite.tmrConfig) {
|
||||
sprite.tmrConfig = TMRAnimations.startRange(range)
|
||||
}
|
||||
sprite.tmrConfig.current += (sprite.tmrConfig.step * delta)
|
||||
if (sprite.tmrConfig.current < sprite.tmrConfig.min) {
|
||||
sprite.tmrConfig.step = Math.abs(sprite.tmrConfig.step)
|
||||
}
|
||||
else if (sprite.tmrConfig.current > sprite.tmrConfig.max) {
|
||||
sprite.tmrConfig.step = -Math.abs(sprite.tmrConfig.step)
|
||||
|
||||
}
|
||||
const taille = sprite.tmrConfig.current * sprite.taille()
|
||||
sprite.width = taille
|
||||
sprite.height = taille
|
||||
}
|
||||
}
|
||||
|
||||
static verticalAxis(options = { step: 1 }) {
|
||||
return (sprite, delta) => {
|
||||
if (!sprite.tmrConfig) {
|
||||
sprite.tmrConfig = this.startRange({
|
||||
min: -Math.PI / 2,
|
||||
max: Math.PI / 2,
|
||||
step: options.step * Math.PI / 180,
|
||||
})
|
||||
}
|
||||
sprite.tmrConfig.current += (sprite.tmrConfig.step * delta)
|
||||
sprite.width = Math.cos(sprite.tmrConfig.current) * sprite.taille()
|
||||
}
|
||||
}
|
||||
|
||||
static startRange(range) {
|
||||
range.current = TMRAnimations.randomInSegment(range)
|
||||
const min = range.min
|
||||
if (min > range.max) {
|
||||
range.min = range.max
|
||||
range.max = min
|
||||
}
|
||||
return range
|
||||
}
|
||||
|
||||
static outOfRange(range) {
|
||||
return range.current < range.min || range.current > range.max
|
||||
}
|
||||
|
||||
static randomInSegment(range) {
|
||||
const min = range.min
|
||||
const max = range.max
|
||||
const step = range.step
|
||||
return min + (Math.floor(Math.random() / step) * step) * (max - min)
|
||||
}
|
||||
}
|
@ -4,10 +4,6 @@ import { Misc } from "../misc.js";
|
||||
|
||||
export class AugmentationSeuil extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'tete' }
|
||||
match(item) { return Draconique.isTeteDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('augmentation du seuil de reve'); }
|
||||
manualMessage() { return false }
|
||||
|
@ -20,10 +20,10 @@ export class CarteTmr extends Draconique {
|
||||
const img = PixiTMR.getImgFromCode(this.code())
|
||||
const sprite = new PIXI.Sprite(PIXI.utils.TextureCache[img]);
|
||||
// Setup the position of the TMR
|
||||
sprite.x = 0;
|
||||
sprite.y = 0;
|
||||
sprite.width = 722;
|
||||
sprite.height = 860;
|
||||
sprite.x = pixiTMR.pixiApp.screen.x;
|
||||
sprite.y = pixiTMR.pixiApp.screen.y;
|
||||
sprite.width = pixiTMR.pixiApp.screen.width;
|
||||
sprite.height = pixiTMR.pixiApp.screen.height;
|
||||
// Rotate around the center
|
||||
sprite.anchor.set(0);
|
||||
sprite.buttonMode = true;
|
||||
@ -31,9 +31,5 @@ export class CarteTmr extends Draconique {
|
||||
return sprite;
|
||||
}
|
||||
|
||||
computeTooltip(coordTMR) {
|
||||
const tmr = TMRUtility.getTMR(coordTMR)
|
||||
return tmr? TMRUtility.getTMRLabel(coordTMR) : '';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,40 +1,38 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { RdDDice } from "../rdd-dice.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
import { TMRAnimations } from "./animation.js";
|
||||
|
||||
export class Conquete extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
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 `${this.tmrLabel(linkData)}: doit être conquis` }
|
||||
img() { return 'icons/svg/combat.svg' }
|
||||
tooltip(linkData) { return `Doit être conquis` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/conquete.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(),
|
||||
{
|
||||
return TMRAnimations.withAnimation(
|
||||
pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.conquete,
|
||||
color: tmrColors.queues,
|
||||
taille: tmrConstants.full,
|
||||
decallage: { x: 2, y: 0 }
|
||||
});
|
||||
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.label, conquete, queue.id);
|
||||
await this.createCaseTmr(actor, 'Conquête', conquete, queue.id);
|
||||
}
|
||||
|
||||
async onActorDeleteCaseTmr(actor, casetmr) {
|
||||
|
@ -1,34 +1,30 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class Debordement extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'souffle' }
|
||||
match(item) { return Draconique.isSouffleDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('debordement'); }
|
||||
manualMessage() { return false }
|
||||
async onActorCreateOwned(actor, souffle) {
|
||||
const existants = actor.items.filter(it => this.isCase(it)).map(it => it.system.coord);
|
||||
const tmr = await TMRUtility.getTMRAleatoire(it => !(TMRUtility.isCaseHumide(it) || existants.includes(it.coord)));
|
||||
await this.createCaseTmr(actor, 'Debordement: ' + tmr.label, tmr, souffle.id);
|
||||
await this.createCaseTmr(actor, 'Debordement', tmr, souffle.id);
|
||||
}
|
||||
|
||||
code() { return 'debordement' }
|
||||
tooltip(linkData) { return `Débordement en ${this.tmrLabel(linkData)}` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/wave.webp' }
|
||||
tooltip(linkData) { return `Débordement` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/debordement.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(), {
|
||||
const sprite = pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.casehumide,
|
||||
alpha: 0.6,
|
||||
taille: tmrConstants.full,
|
||||
decallage: tmrConstants.center
|
||||
});
|
||||
decallage: pixiTMR.sizes.decallage(0, 2/3),
|
||||
taille: () => pixiTMR.sizes.half,
|
||||
})
|
||||
return sprite;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,8 @@
|
||||
import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrColors, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class DemiReve extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return '' }
|
||||
match(item) { return false; }
|
||||
manualMessage() { return false }
|
||||
@ -18,9 +14,9 @@ export class DemiReve extends Draconique {
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
const sprite = pixiTMR.sprite(this.code(), {
|
||||
color: tmrColors.demireve,
|
||||
tint: tmrColors.demireve,
|
||||
zIndex: tmrTokenZIndex.demireve,
|
||||
taille: (tmrConstants.full * 0.7)
|
||||
taille: () => pixiTMR.sizes.twoThird
|
||||
});
|
||||
pixiTMR.animate(pixiApp => pixiApp.ticker.add((delta) => sprite.rotation -= 0.01 * delta));
|
||||
return sprite;
|
||||
|
@ -1,14 +1,12 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { Misc } from "../misc.js";
|
||||
import { RdDDice } from "../rdd-dice.js";
|
||||
import { TMRUtility, TMRType} from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { TMRUtility, TMRType } from "../tmr-utility.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
import { TMRAnimations } from "./animation.js";
|
||||
|
||||
export class Desorientation extends Draconique {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'souffle' }
|
||||
match(item) { return Draconique.isSouffleDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('desorientation'); }
|
||||
@ -28,24 +26,27 @@ export class Desorientation extends Draconique {
|
||||
|
||||
code() { return 'desorientation' }
|
||||
tooltip(linkData) { return `Désorientation, cette case n'existe plus !` }
|
||||
img() { return 'icons/svg/explosion.svg' }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/desorientation.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(),
|
||||
{
|
||||
return TMRAnimations.withAnimation(
|
||||
pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.trounoir,
|
||||
color: tmrColors.trounoir,
|
||||
alpha: 1,
|
||||
taille: tmrConstants.full,
|
||||
decallage: { x: 2, y: 2 },
|
||||
});
|
||||
taille: () => pixiTMR.sizes.full,
|
||||
}),
|
||||
pixiTMR,
|
||||
TMRAnimations.rotation({
|
||||
frequence: delta => 2^(2 + Math.random() * 12) * 70,
|
||||
angle: delta => (Math.floor(Math.random() * 2) - 1) * 30
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
async _creerCasesTmr(actor, type, souffle) {
|
||||
const existants = actor.items.filter(it => this.isCase(it)).map(it => it.system.coord);
|
||||
let tmrs = TMRUtility.filterTMR(it => it.type == type && !existants.includes(it.coord));
|
||||
for (let tmr of tmrs) {
|
||||
await this.createCaseTmr(actor, 'Désorientation: ' + tmr.label, tmr, souffle.id);
|
||||
await this.createCaseTmr(actor, 'Désorientation', tmr, souffle.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,14 +9,15 @@ const registeredEffects = [
|
||||
* Définition des informations d'une "draconique" (queue, ombre, tête, souffle) qui influence les TMR
|
||||
*/
|
||||
export class Draconique {
|
||||
static init() {
|
||||
}
|
||||
|
||||
static isCaseTMR(item) { return item.type == TYPES.casetmr; }
|
||||
static isQueueDragon(item) { return item.isQueueDragon(); }
|
||||
static isSouffleDragon(item) { return item.type == TYPES.souffle; }
|
||||
static isTeteDragon(item) { return item.type == TYPES.tete; }
|
||||
static isQueueSouffle(item) { return Draconique.isQueueDragon(item) || Draconique.isSouffleDragon(item); }
|
||||
|
||||
tmrLabel(linkData) { return TMRUtility.getTMRLabel(linkData.system.coord); }
|
||||
|
||||
static register(draconique) {
|
||||
registeredEffects[draconique.code()] = draconique;
|
||||
if (draconique.img()) {
|
||||
@ -33,6 +34,8 @@ export class Draconique {
|
||||
return registeredEffects[code];
|
||||
}
|
||||
|
||||
tmrLabel(linkData) { return TMRUtility.getTMRLabel(linkData.system.coord); }
|
||||
|
||||
/**
|
||||
* @param item un Item quelconque
|
||||
* @returns true si l'item correspond
|
||||
@ -96,32 +99,13 @@ export class Draconique {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* methode en charge de recalculer le tooltip lorsque la souris bouge
|
||||
* @param {*} event evenement contenant les coordonnées
|
||||
* @param {*} sprite sprite pour laquelle calculer le tooltip
|
||||
*/
|
||||
computeTooltip(event, sprite) {
|
||||
if (sprite.isOver) {
|
||||
const oddq = TMRUtility.computeEventOddq(event);
|
||||
const coord = TMRUtility.oddqToCoordTMR(oddq);
|
||||
const tmr = TMRUtility.getTMR(coord)
|
||||
if (tmr){
|
||||
const label = TMRUtility.getTMRLabel(coord);
|
||||
const text = this.tooltip(this.linkData);
|
||||
return text ? `${coord}: ${label}\n${text}` : `${coord}: ${label}`
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* factory d'élément graphique PIXI correpsondant à l'objet draconique
|
||||
* @param {*} pixiTMR instance de PixiTMR qui gère les tooltips, les méthodes de création de sprite standard, les clicks.
|
||||
*/
|
||||
createSprite(pixiTMR) {
|
||||
if (this.img()) {
|
||||
return pixiTMR.sprite(this.code());
|
||||
return pixiTMR.sprite(this.code())
|
||||
}
|
||||
else {
|
||||
return pixiTMR.circle()
|
||||
@ -143,7 +127,9 @@ export class Draconique {
|
||||
|
||||
async createCaseTmr(actor, label, tmr, sourceId = undefined) {
|
||||
const casetmrData = {
|
||||
name: label, type: 'casetmr', img: this.img(),
|
||||
name: label,
|
||||
type: 'casetmr',
|
||||
img: this.img(),
|
||||
system: { coord: tmr.coord, specific: this.code(), sourceid: sourceId }
|
||||
};
|
||||
await actor.createEmbeddedDocuments('Item', [casetmrData]);
|
||||
|
@ -20,9 +20,9 @@ import { Grammar } from "../grammar.js";
|
||||
import { AugmentationSeuil } from "./augmentation-seuil.js";
|
||||
import { TYPES } from "../item.js";
|
||||
|
||||
|
||||
export class EffetsDraconiques {
|
||||
static carteTmr = new CarteTmr();
|
||||
|
||||
static demiReve = new DemiReve();
|
||||
static rencontre = new Rencontre();
|
||||
static sortReserve = new SortReserve();
|
||||
@ -39,10 +39,13 @@ export class EffetsDraconiques {
|
||||
static pelerinage = new Pelerinage();
|
||||
static periple = new Periple();
|
||||
static urgenceDraconique = new UrgenceDraconique();
|
||||
|
||||
static augmentationSeuil = new AugmentationSeuil();
|
||||
|
||||
static init() {
|
||||
Draconique.init();
|
||||
Draconique.register(EffetsDraconiques.carteTmr);
|
||||
// icône TMR
|
||||
Draconique.register(EffetsDraconiques.demiReve);
|
||||
Draconique.register(EffetsDraconiques.rencontre);
|
||||
Draconique.register(EffetsDraconiques.sortReserve);
|
||||
@ -59,6 +62,7 @@ export class EffetsDraconiques {
|
||||
Draconique.register(EffetsDraconiques.pelerinage);
|
||||
Draconique.register(EffetsDraconiques.periple);
|
||||
Draconique.register(EffetsDraconiques.urgenceDraconique);
|
||||
// effets sans icône TMR
|
||||
Draconique.register(EffetsDraconiques.augmentationSeuil)
|
||||
}
|
||||
|
||||
@ -184,5 +188,4 @@ export class EffetsDraconiques {
|
||||
return EffetsDraconiques.soufflesDragon(actor, 'péage').length > 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,39 +1,32 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class FermetureCites extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'souffle' }
|
||||
match(item) { return Draconique.isSouffleDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('fermeture des cites'); }
|
||||
manualMessage() { return false }
|
||||
async onActorCreateOwned(actor, souffle) { await this._fermerLesCites(actor, souffle); }
|
||||
|
||||
code() { return 'fermeture' }
|
||||
tooltip(linkData) { return `La ${this.tmrLabel(linkData)} est fermée` }
|
||||
img() { return 'icons/svg/door-closed.svg' }
|
||||
tooltip(linkData) { return `Cité fermée` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/fermeture.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(),
|
||||
{
|
||||
zIndex: tmrTokenZIndex.conquete,
|
||||
color: tmrColors.souffle,
|
||||
alpha: 0.9,
|
||||
taille: tmrConstants.full,
|
||||
decallage: { x: 2, y: 0 }
|
||||
});
|
||||
return pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.conquete,
|
||||
decallage: pixiTMR.sizes.decallage(0, 0),
|
||||
taille: () => pixiTMR.sizes.full
|
||||
})
|
||||
}
|
||||
|
||||
async _fermerLesCites(actor, souffle) {
|
||||
let existants = actor.items.filter(it => this.isCase(it)).map(it => it.system.coord);
|
||||
let ouvertes = TMRUtility.filterTMR(it => it.type == 'cite' && !existants.includes(it.coord));
|
||||
for (let tmr of ouvertes) {
|
||||
await this.createCaseTmr(actor, 'Fermeture: ' + tmr.label, tmr, souffle.id);
|
||||
await this.createCaseTmr(actor, 'Fermeture', tmr, souffle.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,36 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
import { TMRAnimations } from "./animation.js";
|
||||
|
||||
export class Pelerinage extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'queue' }
|
||||
match(item) { return Draconique.isQueueDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('pelerinage'); }
|
||||
manualMessage() { return false }
|
||||
|
||||
async onActorCreateOwned(actor, queue) {
|
||||
async onActorCreateOwned(actor, queue) {
|
||||
let tmr = await TMRUtility.getTMRAleatoire();
|
||||
await this.createCaseTmr(actor, 'Pèlerinage: ' + tmr.label, tmr, queue.id);
|
||||
await this.createCaseTmr(actor, 'Pèlerinage', tmr, queue.id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
code() { return 'pelerinage' }
|
||||
tooltip(linkData) { return `Votre pèlerinage en ${this.tmrLabel(linkData)}` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/pelerin.webp' }
|
||||
|
||||
tooltip(linkData) { return `Lieu de pèlerinage` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/pelerinage.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.conquete,
|
||||
alpha: 1,
|
||||
taille: tmrConstants.full,
|
||||
decallage: tmrConstants.center
|
||||
});
|
||||
return TMRAnimations.withAnimation(
|
||||
pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.conquete,
|
||||
decallage: pixiTMR.sizes.decallage(0, 0),
|
||||
taille: () => pixiTMR.sizes.half,
|
||||
}),
|
||||
pixiTMR,
|
||||
TMRAnimations.changeZoom()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
async onActorDeleteCaseTmr(actor, casetmr) {
|
||||
await actor.deleteEmbeddedDocuments('Item', [casetmr.system.sourceid]);
|
||||
}
|
||||
|
@ -1,15 +1,12 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { RdDDice } from "../rdd-dice.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
import { TMRAnimations } from "./animation.js";
|
||||
|
||||
export class Periple extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'souffle' }
|
||||
match(item) { return Draconique.isSouffleDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('periple'); }
|
||||
manualMessage() { return false }
|
||||
@ -18,22 +15,25 @@ export class Periple extends Draconique {
|
||||
let terrain = (await RdDDice.rollTotal("1d2")) == 1 ? 'sanctuaire' : 'necropole';
|
||||
let tmrs = TMRUtility.getListTMR(terrain);
|
||||
for (let tmr of tmrs) {
|
||||
await this.createCaseTmr(actor, 'Périple: ' + tmr.label, tmr, souffle.id);
|
||||
await this.createCaseTmr(actor, 'Périple', tmr, souffle.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
code() { return 'periple' }
|
||||
tooltip(linkData) { return `Votre Périple passe par ${this.tmrLabel(linkData)}` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/pelerin.webp' }
|
||||
tooltip(linkData) { return `Etape de périple` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/periple.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.conquete,
|
||||
alpha: 1,
|
||||
taille: tmrConstants.full,
|
||||
decallage: tmrConstants.center
|
||||
});
|
||||
return TMRAnimations.withAnimation(
|
||||
pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.conquete,
|
||||
decallage: pixiTMR.sizes.decallage(0, 0),
|
||||
taille: () => pixiTMR.sizes.half
|
||||
}),
|
||||
pixiTMR,
|
||||
TMRAnimations.changeZoom()
|
||||
)
|
||||
}
|
||||
getDifficulte(tmr) {
|
||||
switch (tmr.type) {
|
||||
|
@ -1,35 +1,61 @@
|
||||
import { SYSTEM_RDD } from "../constants.js";
|
||||
import { Misc } from "../misc.js";
|
||||
import { RdDTMRDialog } from "../rdd-tmr-dialog.js";
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { TMRConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { EffetsDraconiques } from "./effets-draconiques.js";
|
||||
|
||||
export const tooltipStyle = new PIXI.TextStyle({
|
||||
fontFamily: 'CaslonAntique',
|
||||
fontSize: 18,
|
||||
fill: '#FFFFFF',
|
||||
stroke: '#000000',
|
||||
strokeThickness: 3
|
||||
});
|
||||
|
||||
|
||||
export class PixiTMR {
|
||||
|
||||
static textures = []
|
||||
|
||||
constructor(tmrDialog) {
|
||||
static getImgFromCode(code) {
|
||||
return PixiTMR.textures[code]
|
||||
}
|
||||
|
||||
static register(name, img) {
|
||||
PixiTMR.textures[name] = img;
|
||||
}
|
||||
static async init() {
|
||||
await Promise.all(
|
||||
Object.values(PixiTMR.textures)
|
||||
.filter(img => img != undefined)
|
||||
.map(async img => PIXI.Sprite.from(await PIXI.Assets.load(img)))
|
||||
)
|
||||
}
|
||||
|
||||
constructor(tmrDialog, displaySize) {
|
||||
this.tmrDialog = tmrDialog;
|
||||
|
||||
this.callbacksOnAnimate = [];
|
||||
|
||||
this.pixiApp = new PIXI.Application({ width: 720, height: 860 });
|
||||
this.sizes = new TMRConstants({ size: displaySize })
|
||||
this.pixiApp = new PIXI.Application(PixiTMR.computeTMRSize(this.sizes));
|
||||
this.pixiApp.eventMode = 'static';
|
||||
this.pixiApp.stage.sortableChildren = true;
|
||||
this.tooltip = new PIXI.Text('', tooltipStyle);
|
||||
|
||||
this.tooltipStyle = new PIXI.TextStyle({
|
||||
fontFamily: 'CaslonAntique',
|
||||
fontSize: 16,
|
||||
fill: '#FFFFFF',
|
||||
stroke: '#000000',
|
||||
strokeThickness: 4
|
||||
});
|
||||
|
||||
this.tooltip = new PIXI.Text('', this.tooltipStyle);
|
||||
this.tooltip.zIndex = 1000
|
||||
|
||||
this.pixiApp.stage.addChild(this.tooltip);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.pixiApp.ticker.stop();
|
||||
}
|
||||
static computeTMRSize(sizeConstants) {
|
||||
return { width: sizeConstants.cellw * 13 + sizeConstants.marginx, height: sizeConstants.cellh / 2 + sizeConstants.cellh * 15 + sizeConstants.marginy }
|
||||
}
|
||||
|
||||
resizeTMR(displaySize) {
|
||||
this.sizes = new TMRConstants({ size: displaySize })
|
||||
const appSize = PixiTMR.computeTMRSize(this.sizes)
|
||||
this.pixiApp.renderer.resize(appSize.width, appSize.height)
|
||||
this.tooltipStyle.fontSize = Math.max(this.sizes.size / 4, 16)
|
||||
}
|
||||
|
||||
get view() {
|
||||
@ -48,24 +74,11 @@ export class PixiTMR {
|
||||
.on('pointerout', event => this.onHideTooltip(event));
|
||||
}
|
||||
|
||||
async load(onLoad = (loader, resources) => { }) {
|
||||
// WIP - Deprecated since v7 : let loader = new PIXI.Loader();
|
||||
for (const [name, img] of Object.entries(PixiTMR.textures)) {
|
||||
const texture = await PIXI.Assets.load(img);
|
||||
let image = PIXI.Sprite.from(texture);
|
||||
}
|
||||
onLoad();
|
||||
async loadAnimations() {
|
||||
for (let onAnimate of this.callbacksOnAnimate) {
|
||||
onAnimate();
|
||||
}
|
||||
}
|
||||
|
||||
static getImgFromCode(code) {
|
||||
return PixiTMR.textures[code]
|
||||
}
|
||||
|
||||
static register(name, img) {
|
||||
PixiTMR.textures[name] = img;
|
||||
this.pixiApp.ticker.start();
|
||||
}
|
||||
|
||||
animate(animation = pixiApp => { }) {
|
||||
@ -90,33 +103,48 @@ export class PixiTMR {
|
||||
|
||||
sprite(code, options = {}) {
|
||||
let img = PixiTMR.getImgFromCode(code)
|
||||
const texture = PIXI.utils.TextureCache[img];
|
||||
const texture = PIXI.utils.TextureCache[img]
|
||||
if (!texture) {
|
||||
console.error("Texture manquante", code, PIXI.utils.TextureCache)
|
||||
return;
|
||||
}
|
||||
let sprite = new PIXI.Sprite(texture);
|
||||
sprite.width = options.taille ?? tmrConstants.half;
|
||||
sprite.height = options.taille ?? tmrConstants.half;
|
||||
sprite.anchor.set(0.5);
|
||||
if (options.color) {
|
||||
sprite.tint = options.color;
|
||||
sprite.taille = options.taille ?? (() => this.sizes.half)
|
||||
|
||||
sprite.width = sprite.taille()
|
||||
sprite.height = sprite.taille()
|
||||
sprite.anchor.set(0.5)
|
||||
if (options.tint) {
|
||||
sprite.tint = options.tint
|
||||
}
|
||||
sprite.zIndex = options.zIndex ?? tmrTokenZIndex.casehumide + 1;
|
||||
sprite.alpha = options.alpha ?? 0.75;
|
||||
sprite.decallage = options.decallage ?? tmrConstants.center;
|
||||
this.pixiApp.stage.addChild(sprite);
|
||||
return sprite;
|
||||
sprite.zIndex = options.zIndex ?? tmrTokenZIndex.casehumide + 1
|
||||
sprite.alpha = options.alpha ?? 1
|
||||
sprite.decallage = options.decallage ?? this.sizes.center
|
||||
this.pixiApp.stage.addChild(sprite)
|
||||
return sprite
|
||||
}
|
||||
|
||||
circle(code, options = {}) {
|
||||
let sprite = new PIXI.Graphics()
|
||||
sprite.taille = options.taille ?? (() => this.sizes.half)
|
||||
sprite.decallage = options.decallage ?? this.sizes.topLeft
|
||||
sprite.beginFill(options.tint, options.opacity)
|
||||
sprite.drawCircle(0, 0, sprite.taille())
|
||||
sprite.endFill()
|
||||
this.pixiApp.stage.addChild(sprite)
|
||||
return sprite
|
||||
}
|
||||
|
||||
square(code, options = {}) {
|
||||
let sprite = new PIXI.Graphics();
|
||||
sprite.beginFill(options.color, options.opacity);
|
||||
sprite.drawCircle(0, 0, (options.taille ?? 12) / 2);
|
||||
sprite.endFill();
|
||||
sprite.decallage = options.decallage ?? tmrConstants.topLeft;
|
||||
this.pixiApp.stage.addChild(sprite);
|
||||
return sprite;
|
||||
sprite.taille = options.taille ?? (() => this.sizes.half)
|
||||
sprite.decallage = options.decallage ?? this.sizes.topLeft
|
||||
sprite.beginFill(options.tint, options.opacity)
|
||||
const size = sprite.taille();
|
||||
sprite.drawRect(0, 0, size, size)
|
||||
sprite.endFill()
|
||||
this.pixiApp.stage.addChild(sprite)
|
||||
return sprite
|
||||
}
|
||||
|
||||
onClickBackground(event) {
|
||||
@ -131,7 +159,7 @@ export class PixiTMR {
|
||||
this.tooltip.text = this.computeTooltip(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onShowTooltip(event) {
|
||||
if (!this.carteTMR.isOver) {
|
||||
this.setTooltipPosition(event);
|
||||
@ -149,25 +177,27 @@ export class PixiTMR {
|
||||
}
|
||||
|
||||
computeTooltip(event) {
|
||||
const oddq = TMRUtility.computeEventOddq(event);
|
||||
const oddq = this.sizes.computeEventOddq(event);
|
||||
const coordTMR = TMRUtility.oddqToCoordTMR(oddq);
|
||||
const tmr = TMRUtility.getTMR(coordTMR)
|
||||
if (tmr) {
|
||||
const labelTMR = TMRUtility.getTMRLabel(coordTMR);
|
||||
const tmrTooltip = `${coordTMR}: ${TMRUtility.getTMRLabel(coordTMR)}`;
|
||||
const tokenTooltips = this.tmrDialog.allTokens
|
||||
.filter(token => token.coordTMR() == coordTMR)
|
||||
.map(token => token.tooltip);
|
||||
const tmrTooltip = `${coordTMR}: ${labelTMR}`;
|
||||
return [tmrTooltip, ...tokenTooltips].reduce(Misc.joining('\n'))
|
||||
}
|
||||
}
|
||||
|
||||
setTooltipPosition(event) {
|
||||
var { x, y } = TMRUtility.computeEventPosition(event);
|
||||
const oddq = TMRUtility.computeOddq(x, y);
|
||||
computeEventOddq(event) {
|
||||
return this.sizes.computeEventOddq(event)
|
||||
}
|
||||
|
||||
this.tooltip.x = x + (oddq.col > 8 ? -3 * tmrConstants.full : tmrConstants.half);
|
||||
this.tooltip.y = y + (oddq.row > 10 ? -tmrConstants.half : tmrConstants.half);
|
||||
setTooltipPosition(event) {
|
||||
const oddq = this.sizes.computeEventOddq(event);
|
||||
|
||||
this.tooltip.x = oddq.x + (oddq.col > 7 ? -3 * this.sizes.full : this.sizes.quarter);
|
||||
this.tooltip.y = oddq.y + (oddq.row > 10 ? -this.sizes.size : 0);
|
||||
}
|
||||
|
||||
positionToken(token) {
|
||||
@ -175,11 +205,11 @@ export class PixiTMR {
|
||||
const sprite = token.sprite;
|
||||
const oddq = TMRUtility.coordTMRToOddq(token.coordTMR());
|
||||
|
||||
const decallagePairImpair = (oddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
const dx = (sprite.decallage == undefined) ? 0 : sprite.decallage.x;
|
||||
const dy = (sprite.decallage == undefined) ? 0 : sprite.decallage.y;
|
||||
sprite.x = tmrConstants.gridx + (oddq.col * tmrConstants.cellw) + dx;
|
||||
sprite.y = tmrConstants.gridy + (oddq.row * tmrConstants.cellh) + dy + decallagePairImpair;
|
||||
const decallagePairImpair = (oddq.col % 2 == 0) ? this.sizes.col1_y : this.sizes.col2_y;
|
||||
const dx = sprite.decallage?.x ?? 0
|
||||
const dy = sprite.decallage?.y ?? 0
|
||||
sprite.x = this.sizes.gridx + (oddq.col * this.sizes.cellw) + dx;
|
||||
sprite.y = this.sizes.gridy + (oddq.row * this.sizes.cellh) + dy + decallagePairImpair;
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,10 +220,9 @@ export class PixiTMR {
|
||||
}
|
||||
|
||||
getCaseRectangle(oddq) {
|
||||
let decallagePairImpair = (oddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
let x = tmrConstants.gridx + (oddq.col * tmrConstants.cellw) - (tmrConstants.cellw / 2);
|
||||
let y = tmrConstants.gridy + (oddq.row * tmrConstants.cellh) - (tmrConstants.cellh / 2) + decallagePairImpair;
|
||||
return { x: x, y: y, w: tmrConstants.cellw, h: tmrConstants.cellh };
|
||||
const decallagePairImpair = (oddq.col % 2 == 0) ? this.sizes.col1_y : this.sizes.col2_y;
|
||||
const x = this.sizes.gridx + (oddq.col * this.sizes.cellw) - (this.sizes.cellw / 2);
|
||||
const y = this.sizes.gridy + (oddq.row * this.sizes.cellh) - (this.sizes.cellh / 2) + decallagePairImpair;
|
||||
return { x, y, w: this.sizes.cellw, h: this.sizes.cellh };
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +1,30 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class PontImpraticable extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'souffle' }
|
||||
match(item) { return Draconique.isSouffleDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('impraticabilite des ponts'); }
|
||||
|
||||
async onActorCreateOwned(actor, souffle) {
|
||||
const ponts = TMRUtility.getListTMR('pont');
|
||||
for (let tmr of ponts) {
|
||||
await this.createCaseTmr(actor, 'Pont impraticable: ' + tmr.label, tmr, souffle.id);
|
||||
await this.createCaseTmr(actor, 'Pont impraticable', tmr, souffle.id);
|
||||
}
|
||||
}
|
||||
|
||||
code() { return 'pont-impraticable' }
|
||||
tooltip(linkData) { return `${this.tmrLabel(linkData)} impraticable` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/wave.webp' }
|
||||
tooltip(linkData) { return `Pont impraticable` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/debordement.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(),
|
||||
{
|
||||
zIndex: tmrTokenZIndex.casehumide,
|
||||
alpha: 0.6,
|
||||
taille: tmrConstants.full,
|
||||
decallage: tmrConstants.center
|
||||
decallage: pixiTMR.sizes.decallage(0, 2/3),
|
||||
taille: () => pixiTMR.sizes.half,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,31 +1,26 @@
|
||||
import { ChatUtility } from "../chat-utility.js";
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class PresentCites extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'tete' }
|
||||
match(item) { return Draconique.isTeteDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('present des cites'); }
|
||||
manualMessage() { return false }
|
||||
async onActorCreateOwned(actor, tete) { await this._ajouterPresents(actor, tete); }
|
||||
|
||||
code() { return 'present-cites' }
|
||||
tooltip(linkData) { return `La ${this.tmrLabel(linkData)} a un présent` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/gift.webp' }
|
||||
tooltip(linkData) { return `La cité a un présent` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/present.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(),
|
||||
{
|
||||
zIndex: tmrTokenZIndex.tetes,
|
||||
alpha: 0.9,
|
||||
taille: tmrConstants.third,
|
||||
decallage: tmrConstants.topRight
|
||||
decallage: pixiTMR.sizes.decallage(-1, -1),
|
||||
taille: () => pixiTMR.sizes.third
|
||||
});
|
||||
}
|
||||
|
||||
@ -40,7 +35,7 @@ export class PresentCites extends Draconique {
|
||||
else {
|
||||
let cites = TMRUtility.filterTMR(it => it.type == 'cite');
|
||||
for (let tmr of cites) {
|
||||
await this.createCaseTmr(actor, 'Présent: ' + tmr.label, tmr, tete.id);
|
||||
await this.createCaseTmr(actor, 'Présent', tmr, tete.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,26 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class QueteEaux extends Draconique {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'tete' }
|
||||
match(item) { return Draconique.isTeteDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes("quete des eaux"); }
|
||||
manualMessage() { return "Vous devrez re-configurer votre Quête des Eaux une fois un lac ou marais vaincu" }
|
||||
manualMessage() { return "Vous devrez re-configurer votre Nouvelle Quête des Eaux une fois un lac ou marais vaincu" }
|
||||
async onActorCreateOwned(actor, tete) {
|
||||
await this.createCaseTmr(actor, "Quête des eaux à déterminer", { coord: 'A0' }, tete.id);
|
||||
await this.createCaseTmr(actor, "Nouvelle Quête des Eaux", { coord: 'A0' }, tete.id);
|
||||
}
|
||||
|
||||
code() { return 'maitrisee' }
|
||||
tooltip(linkData) { return `Quête des eaux, le ${this.tmrLabel(linkData)} est maîtrisé` }
|
||||
img() { return 'icons/svg/bridge.svg' }
|
||||
tooltip(linkData) { return `Quête des eaux, ${TMRUtility.getTMRType(linkData.system.coord)} maîtrisé` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/maitrisee.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.casehumide + 1,
|
||||
color: tmrColors.tetes,
|
||||
decallage: tmrConstants.topRight
|
||||
decallage: pixiTMR.sizes.decallage(0, -2 / 3),
|
||||
taille: () => pixiTMR.sizes.half
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,8 @@
|
||||
import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class Rencontre extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return '' }
|
||||
match(item) { return false; }
|
||||
manualMessage() { return false }
|
||||
@ -14,14 +10,13 @@ export class Rencontre extends Draconique {
|
||||
|
||||
code() { return 'rencontre' }
|
||||
tooltip(rencontre) { return `${rencontre.name} de force ${rencontre.system.force}` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/heures/hd06.webp' }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/rencontre.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.rencontre,
|
||||
color: tmrColors.rencontre,
|
||||
taille: tmrConstants.full,
|
||||
decallage: { x: 2, y: 2 }
|
||||
});
|
||||
decallage: pixiTMR.sizes.decallage(0, 0),
|
||||
taille: () => pixiTMR.sizes.twoThird,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class ReserveExtensible extends Draconique {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'tete' }
|
||||
match(item) { return Draconique.isTeteDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes("reserve extensible"); }
|
||||
manualMessage() { return "Vous pouvez re-configurer votre Réserve extensible" }
|
||||
manualMessage() { return "Vous pouvez re-configurer votre Nouvelle Réserve extensible" }
|
||||
async onActorCreateOwned(actor, tete) {
|
||||
const existants = actor.items.filter(it => this.isCase(it)).map(it => it.system.coord);
|
||||
const selectedTMR = await TMRUtility.getTMRAleatoire(tmr => !(tmr.type == 'fleuve' || existants.includes(tmr.coord)));
|
||||
@ -18,14 +15,15 @@ export class ReserveExtensible extends Draconique {
|
||||
}
|
||||
|
||||
code() { return 'reserve_extensible' }
|
||||
tooltip(linkData) { return `Réserve extensible en ${this.tmrLabel(linkData)} !` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/treasure-chest.webp' }
|
||||
tooltip(linkData) { return `Réserve extensible` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/reserve.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.tetes,
|
||||
alpha: 0.7,
|
||||
decallage: tmrConstants.left
|
||||
decallage: pixiTMR.sizes.decallage(-1, 1),
|
||||
taille: () => pixiTMR.sizes.third
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,8 @@
|
||||
import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class SortReserve extends Draconique {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return '' }
|
||||
match(item) { return false; }
|
||||
manualMessage() { return false }
|
||||
@ -14,13 +10,13 @@ export class SortReserve extends Draconique {
|
||||
|
||||
code() { return 'sortreserve' }
|
||||
tooltip(sort) { return `${sort.name}, r${sort.system.ptreve}` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/scroll.webp' }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/sort-reserve.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.sort,
|
||||
alpha: 0.5,
|
||||
decallage: tmrConstants.right
|
||||
decallage: pixiTMR.sizes.decallage(-1, 0),
|
||||
taille: () => pixiTMR.sizes.third,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,26 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class TerreAttache extends Draconique {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'tete' }
|
||||
match(item) { return Draconique.isTeteDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes("terre d'attache"); }
|
||||
manualMessage() { return "Vous pouvez re-configurer votre Terre d'Attache" }
|
||||
manualMessage() { return "Vous pouvez re-configurer votre Nouvelle Terre d'attache" }
|
||||
|
||||
async onActorCreateOwned(actor, tete) {
|
||||
await this.createCaseTmr(actor, "Terre d'attache à déterminer", { coord: 'A0' }, tete.id);
|
||||
await this.createCaseTmr(actor, "Nouvelle Terre d'attache", { coord: 'A0' }, tete.id);
|
||||
}
|
||||
|
||||
code() { return 'attache' }
|
||||
tooltip(linkData) { return `Terre d'attache en ${this.tmrLabel(linkData)} !` }
|
||||
img() { return 'icons/svg/anchor.svg' }
|
||||
tooltip(linkData) { return `Terre d'attache` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/attache.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.tetes,
|
||||
color: tmrColors.tetes,
|
||||
decallage: tmrConstants.topLeft
|
||||
decallage: pixiTMR.sizes.decallage(-1, -1),
|
||||
taille: () => pixiTMR.sizes.third
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
|
||||
export class TrouNoir extends Draconique {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
type() { return 'souffle' }
|
||||
match(item) { return Draconique.isSouffleDragon(item) && Grammar.toLowerCaseNoAccent(item.name).includes('trou noir'); }
|
||||
@ -15,21 +12,19 @@ export class TrouNoir extends Draconique {
|
||||
async onActorCreateOwned(actor, souffle) {
|
||||
const existants = actor.items.filter(it => this.isCase(it)).map(it => it.system.coord);
|
||||
const selectedTMR = await TMRUtility.getTMRAleatoire(tmr => !(TMRUtility.isCaseHumide(tmr) || existants.includes(tmr.coord)));
|
||||
await this.createCaseTmr(actor, 'Trou noir: ' + selectedTMR.label, selectedTMR, souffle.id);
|
||||
await this.createCaseTmr(actor, 'Trou noir', selectedTMR, souffle.id);
|
||||
}
|
||||
|
||||
code() { return 'trounoir' }
|
||||
tooltip(linkData) { return `Trou noir en ${this.tmrLabel(linkData)} !` }
|
||||
img() { return 'icons/svg/explosion.svg' }
|
||||
tooltip(linkData) { return `Trou noir` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/trounoir.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(),
|
||||
{
|
||||
zIndex: tmrTokenZIndex.trounoir,
|
||||
color: tmrColors.trounoir,
|
||||
alpha: 1, taille:
|
||||
tmrConstants.full,
|
||||
decallage: { x: 2, y: 2 },
|
||||
decallage: pixiTMR.sizes.decallage(0, 0),
|
||||
taille: () => pixiTMR.sizes.full,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,10 @@ import { Grammar } from "../grammar.js";
|
||||
import { Misc } from "../misc.js";
|
||||
import { RdDRollTables } from "../rdd-rolltables.js";
|
||||
import { TMRUtility } from "../tmr-utility.js";
|
||||
import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { tmrTokenZIndex } from "../tmr-constants.js";
|
||||
import { Draconique } from "./draconique.js";
|
||||
import { TYPES } from "../item.js";
|
||||
import { TMRAnimations } from "./animation.js";
|
||||
|
||||
export class UrgenceDraconique extends Draconique {
|
||||
|
||||
@ -28,7 +29,7 @@ export class UrgenceDraconique extends Draconique {
|
||||
const demiReve = actor.getDemiReve();
|
||||
coordSortsReserve.sort(Misc.ascending(t => TMRUtility.distanceCoordTMR(t, demiReve)));
|
||||
const tmr = TMRUtility.getTMR(coordSortsReserve[0]);
|
||||
await this.createCaseTmr(actor, 'Urgence draconique: ' + tmr.label, tmr, queue.id);
|
||||
await this.createCaseTmr(actor, 'Urgence draconique', tmr, queue.id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,16 +38,18 @@ export class UrgenceDraconique extends Draconique {
|
||||
}
|
||||
|
||||
code() { return 'urgence' }
|
||||
tooltip(linkData) { return `Urgence draconique!` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/pelerin.webp' }
|
||||
tooltip(linkData) { return `Urgence draconique` }
|
||||
img() { return 'systems/foundryvtt-reve-de-dragon/icons/tmr/urgence.svg' }
|
||||
|
||||
createSprite(pixiTMR) {
|
||||
return pixiTMR.sprite(this.code(),
|
||||
{
|
||||
return TMRAnimations.withAnimation(
|
||||
pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.conquete,
|
||||
color: tmrColors.queues,
|
||||
taille: tmrConstants.full,
|
||||
decallage: { x: 2, y: 0 }
|
||||
});
|
||||
decallage: pixiTMR.sizes.decallage(0, 0),
|
||||
taille: () => pixiTMR.sizes.half,
|
||||
}),
|
||||
pixiTMR,
|
||||
TMRAnimations.changeZoom()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user