forked from public/foundryvtt-reve-de-dragon
Add new Compendium
This commit is contained in:
@ -37,20 +37,51 @@ export class RdDTMRDialog extends Dialog {
|
||||
this.cellw = 55;
|
||||
this.actor = actor;
|
||||
this.sort = sort;
|
||||
this.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list);
|
||||
//console.log(this.rencontresExistantes);
|
||||
this.pixiApp = new PIXI.Application( {width: 720, height: 860 } );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
displayPreviousRencontres() {
|
||||
for (let rencontre of this.rencontresExistantes) {
|
||||
rencontre.circle = new PIXI.Graphics();
|
||||
rencontre.circle.beginFill(0x101010, 0.8);
|
||||
rencontre.circle.drawCircle(0, 0, 6);
|
||||
rencontre.circle.endFill();
|
||||
let coordXY = TMRUtility.convertToCellCoord( rencontre.coord );
|
||||
let basey = (coordXY.x % 2 == 0) ? this.col1_y : this.col2_y;
|
||||
let myx = 28+(coordXY.x * this.cellw);
|
||||
let myy = basey+28+(coordXY.y * this.cellh);
|
||||
rencontre.circle.x = myx - (this.cellw/2)+16;
|
||||
rencontre.circle.y = myy - (this.cellh/2)+16;
|
||||
this.pixiApp.stage.addChild(rencontre.circle);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
updatePreviousRencontres() {
|
||||
for (let rencontre of this.rencontresExistantes) {
|
||||
this.pixiApp.stage.removeChild( rencontre.circle );
|
||||
}
|
||||
this.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list);
|
||||
this.displayPreviousRencontres();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async derober() {
|
||||
await this.maximize();
|
||||
let rencontre = duplicate(this.actor.data.data.reve.rencontre);
|
||||
rencontre.list.push( {coord: this.actor.data.data.reve.tmrpos.coord, rencontre: this.currentRencontre} );
|
||||
await this.actor.addTMRRencontre( this.currentRencontre );
|
||||
console.log("-> derober", this.currentRencontre);
|
||||
ChatMessage.create( { title: "TMR", content: game.user.name + " s'est dérobé et quitte les TMR.", user: game.user._id, whisper: ChatMessage.getWhisperRecipients("GM") } );
|
||||
this.close();
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async refouler(data) {
|
||||
ChatMessage.create( { title: "TMR", content: game.user.name + " a refoulé une rencontre.", user: game.user._id, whisper: ChatMessage.getWhisperRecipients("GM") } );
|
||||
await this.actor.deleteTMRRencontreAtPosition( ); // Remove the stored rencontre if necessary
|
||||
let result = await this.actor.ajouterRefoulement(1);
|
||||
this.updatePreviousRencontres();
|
||||
if (result == "souffle") {
|
||||
let souffle = TMRUtility.getSouffle();
|
||||
}
|
||||
@ -60,20 +91,24 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async matriser(data) {
|
||||
|
||||
this.actor.deleteTMRRencontreAtPosition( ); // Remove the stored rencontre if necessary
|
||||
this.updatePreviousRencontres();
|
||||
await this.maximize();
|
||||
|
||||
let draconic = this.actor.getBestDraconic();
|
||||
let carac = this.actor.getCurrentReve();
|
||||
let level = draconic.data.niveau - this.currentRencontre.force;
|
||||
console.log("Maitriser", carac, draconic.data.niveau, this.currentRencontre.force);
|
||||
let scoreDef = CONFIG.RDD.resolutionTable[carac][level+10];
|
||||
let myroll = new Roll("d100");
|
||||
myroll.roll();
|
||||
if ( myroll.total > scoreDef.score ) {
|
||||
TMRUtility.processRencontreEchec( this.actor, this.rencontre);
|
||||
this.close();
|
||||
ChatMessage.create( { title: "TMR", content: game.user.name + " a perdu sa rencontre.", user: game.user._id, whisper: ChatMessage.getWhisperRecipients("GM") } );
|
||||
this.close();
|
||||
} else {
|
||||
TMRUtility.processRencontreReussite( this.actor, this.rencontre);
|
||||
ChatMessage.create( { title: "TMR", content: game.user.name + " a gagné sa rencontre.", user: game.user._id, whisper: ChatMessage.getWhisperRecipients("GM") } );
|
||||
}
|
||||
console.log("-> matriser", this.currentRencontre);
|
||||
this.updateValuesDisplay();
|
||||
@ -83,26 +118,30 @@ export class RdDTMRDialog extends Dialog {
|
||||
async manageRencontre(coordTMR, cellDescr)
|
||||
{
|
||||
// Roll until diffent than '8'
|
||||
this.currentRencontre = undefined;
|
||||
let rencontre
|
||||
let val = 8;
|
||||
while (val == 8) {
|
||||
let myroll = new Roll("d7");
|
||||
myroll.roll();
|
||||
val = myroll.total;
|
||||
if ( val == 7 ) {
|
||||
rencontre = TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
|
||||
this.currentRencontre = undefined;
|
||||
for (let previousRencontre of this.rencontresExistantes ) {
|
||||
if ( previousRencontre.coord == coordTMR)
|
||||
rencontre = previousRencontre.rencontre;
|
||||
}
|
||||
if ( rencontre == undefined ) {
|
||||
let val = 8;
|
||||
while (val == 8) {
|
||||
let myroll = new Roll("d7");
|
||||
myroll.roll();
|
||||
val = myroll.total;
|
||||
if ( val == 7 ) {
|
||||
rencontre = TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
|
||||
rencontre.force = new Roll(rencontre.data.force).roll().total;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rencontre) { // Manages it
|
||||
let myroll = new Roll(rencontre.data.force);
|
||||
myroll.roll();
|
||||
rencontre.force = myroll.total;
|
||||
this.currentRencontre = rencontre;
|
||||
this.currentRencontre = duplicate(rencontre);
|
||||
await this.minimize();
|
||||
let diag = new Dialog( { title: "Rencontre en TMR!",
|
||||
content: "Vous recontrez un " + rencontre.name + " de force " + myroll.total + "<br>",
|
||||
content: "Vous recontrez un " + rencontre.name + " de force " + rencontre.force + "<br>",
|
||||
buttons: {
|
||||
derober: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
@ -251,7 +290,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
cell1.append( this.pixiApp.view );
|
||||
|
||||
// load the texture we need
|
||||
this.pixiApp.loader.add('tmr', 'systems/foundryvtt-reve-de-dragon/styles/ui/tmp_main_r1.webp').load((loader, resources) => {
|
||||
await this.pixiApp.loader.add('tmr', 'systems/foundryvtt-reve-de-dragon/styles/ui/tmp_main_r1.webp').load((loader, resources) => {
|
||||
// This creates a texture from a 'bunny.png' image
|
||||
const mytmr = new PIXI.Sprite(resources.tmr.texture);
|
||||
// Setup the position of the bunny
|
||||
@ -272,11 +311,12 @@ export class RdDTMRDialog extends Dialog {
|
||||
this.circle.drawCircle(0, 0, 15);
|
||||
this.circle.endFill();
|
||||
this.updateSprites( this );
|
||||
|
||||
|
||||
// Add the bunny to the scene we are building
|
||||
this.pixiApp.stage.addChild(mytmr);
|
||||
this.pixiApp.stage.addChild(this.circle);
|
||||
//this.updateSprites();
|
||||
|
||||
this.displayPreviousRencontres();
|
||||
} );
|
||||
|
||||
await this.actor.santeIncDec("fatigue", 1); // 1 point defatigue
|
||||
|
Reference in New Issue
Block a user