2021-01-21 17:16:01 +01:00
|
|
|
|
|
|
|
export class SoSFlipDialog extends Dialog {
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
constructor(flipData, html) {
|
|
|
|
let conf = {
|
|
|
|
title: 'Flip Dialog',
|
|
|
|
content: html,
|
|
|
|
buttons: {
|
2021-01-24 23:18:50 +01:00
|
|
|
'flip-close': { label: 'Cancel and Close', callback: html => this.onFlipClose() }
|
2021-01-21 17:16:01 +01:00
|
|
|
},
|
|
|
|
default: 'flip'
|
|
|
|
};
|
|
|
|
super(conf, { classes: ["sosdialog"], width: 800, height: 800 });
|
|
|
|
|
|
|
|
this.flipData = flipData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
onFlipClose( ) {
|
2021-01-24 23:18:50 +01:00
|
|
|
this.close();
|
2021-01-21 17:16:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async updateFlip( flipData ) {
|
|
|
|
console.log("UPDATE !!!", flipData);
|
|
|
|
$('.view-deck').remove();
|
|
|
|
$("#view-deck").append(await flipData.actor.cardDeck.getDeckHTML());
|
|
|
|
|
|
|
|
$('.view-edge').remove();
|
|
|
|
$("#view-edge").append(await flipData.actor.cardDeck.getEdgeHTML());
|
2021-01-24 23:18:50 +01:00
|
|
|
|
|
|
|
$('.edge-card').click((event) => {
|
|
|
|
let flipData = duplicate(this.flipData);
|
|
|
|
flipData.modifier = $('#modifier').val();
|
|
|
|
flipData.tn = $('#tn').val();
|
|
|
|
flipData.edgeName = event.currentTarget.attributes['data-edge-card'].value;
|
|
|
|
flipData.cardOrigin = "Edge";
|
|
|
|
if ( flipData.mode == 'skill') {
|
|
|
|
flipData.stat = duplicate( flipData.statList[ $('#statSelect').val() ] );
|
|
|
|
}
|
|
|
|
this.flipData.actor.cardDeck.doFlipFromDeckOrEdge(flipData);
|
|
|
|
this.onFlipClose();
|
|
|
|
});
|
|
|
|
|
2021-01-21 17:16:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
|
|
|
this.bringToTop();
|
|
|
|
|
|
|
|
var dialog = this;
|
|
|
|
|
|
|
|
function onLoad() {
|
|
|
|
let flipData = dialog.flipData;
|
|
|
|
//RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
|
|
|
//$("#diffLibre").val(Misc.toInt(rollData.diffLibre));
|
|
|
|
//$("#diffConditions").val(Misc.toInt(rollData.diffConditions));
|
|
|
|
dialog.updateFlip(flipData);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup everything onload
|
|
|
|
$(function () { onLoad(); });
|
|
|
|
|
2021-01-24 23:18:50 +01:00
|
|
|
html.find('.class-view-deck').click((event) => {
|
|
|
|
let flipData = duplicate(this.flipData);
|
|
|
|
flipData.modifier = html.find('#modifier').val();
|
|
|
|
flipData.tn = html.find('#tn').val();
|
|
|
|
if ( flipData.mode == 'skill') {
|
2021-01-25 11:16:45 +01:00
|
|
|
let statKey = $('#statSelect').val();
|
|
|
|
flipData.stat = duplicate( flipData.statList[ statKey ] );
|
2021-01-24 23:18:50 +01:00
|
|
|
}
|
|
|
|
flipData.cardOrigin = "Deck";
|
|
|
|
flipData.tn = html.find('#tn').val();
|
|
|
|
dialog.flipData.actor.cardDeck.doFlipFromDeckOrEdge(flipData);
|
|
|
|
dialog.onFlipClose();
|
2021-01-21 17:16:01 +01:00
|
|
|
});
|
2021-01-24 23:18:50 +01:00
|
|
|
|
2021-01-21 17:16:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|