2020-05-21 21:48:20 +02:00
/ * *
* Extend the basic ActorSheet with some very simple modifications
* @ extends { ActorSheet }
* /
2020-05-22 22:37:02 +02:00
import { RdDUtility } from "./rdd-utility.js" ;
2020-12-06 18:41:54 +01:00
import { HtmlUtility } from "./html-utility.js" ;
2020-05-22 22:37:02 +02:00
2020-09-20 21:45:46 +02:00
/* -------------------------------------------- */
2020-05-22 00:48:43 +02:00
export class RdDActorSheet extends ActorSheet {
2020-05-21 21:48:20 +02:00
/** @override */
static get defaultOptions ( ) {
2020-12-01 22:18:15 +01:00
RdDUtility . initAfficheContenu ( ) ;
2020-05-21 21:48:20 +02:00
return mergeObject ( super . defaultOptions , {
2020-05-22 00:48:43 +02:00
classes : [ "rdd" , "sheet" , "actor" ] ,
template : "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html" ,
2020-07-27 16:27:41 +02:00
width : 640 ,
2020-11-29 18:21:34 +01:00
//height: 720,
2020-08-14 22:24:35 +02:00
tabs : [ { navSelector : ".sheet-tabs" , contentSelector : ".sheet-body" , initial : "carac" } ] ,
2020-11-20 12:06:54 +01:00
dragDrop : [ { dragSelector : ".item-list .item" , dropSelector : null } ] ,
2020-12-06 22:19:40 +01:00
editCaracComp : false ,
cacherCompetencesNiveauBase : false ,
2020-05-21 21:48:20 +02:00
} ) ;
}
/* -------------------------------------------- */
2020-05-22 19:28:01 +02:00
getData ( ) {
let data = super . getData ( ) ;
2020-12-01 22:18:15 +01:00
2020-12-06 22:19:40 +01:00
// Gestion du lock/unlock des zones éditables (carac+compétences)
data . data . editCaracComp = this . options . editCaracComp ;
data . data . lockUnlockText = ( this . options . editCaracComp ) ? "Bloquer" : "Débloquer" ;
2020-12-15 19:45:46 +01:00
data . data . lockUnlockIcon = ( this . options . editCaracComp ) ? "unlocked.svg" : "locked.svg" ;
2020-12-06 22:19:40 +01:00
// Gestion de l'affichage total/partiel des compétences
data . data . cacherCompetencesNiveauBase = this . options . cacherCompetencesNiveauBase ;
2020-12-09 23:37:19 +01:00
data . data . showHideCompetenceText = ( this . options . cacherCompetencesNiveauBase ) ? "Montrer tout" : "Filtrer" ;
2020-12-15 19:45:46 +01:00
data . data . showHideCompetenceIcon = ( this . options . cacherCompetencesNiveauBase ) ? "no-filter.svg" : "filter.svg" ;
2020-12-06 22:19:40 +01:00
let compCategorieNiveau = RdDUtility . getLevelCategory ( ) ; // recup catégorie
2020-11-24 16:41:15 +01:00
data . itemsByType = RdDUtility . buildItemsClassification ( data . items ) ;
2020-06-07 23:16:29 +02:00
// Competence per category
2020-05-22 19:28:01 +02:00
data . competenceByCategory = { } ;
2020-08-13 22:28:56 +02:00
let competenceXPTotal = 0 ;
2020-05-22 19:28:01 +02:00
if ( data . itemsByType . competence ) {
for ( const item of data . itemsByType . competence ) {
2020-06-07 23:16:29 +02:00
//console.log("Push...", item, item.data.categorie);
2020-05-22 19:28:01 +02:00
let list = data . competenceByCategory [ item . data . categorie ] ;
if ( ! list ) {
list = [ ] ;
data . competenceByCategory [ item . data . categorie ] = list ;
}
2020-08-14 22:24:35 +02:00
if ( ! RdDUtility . isTronc ( item . name ) ) // Ignorer les compétences 'troncs' à ce stade
2020-12-06 22:19:40 +01:00
competenceXPTotal += RdDUtility . computeCompetenceXPCost ( item ) ;
item . data . afficherCompetence = true ;
if ( data . data . cacherCompetencesNiveauBase && ( Number ( item . data . niveau ) == Number ( compCategorieNiveau [ item . data . categorie ] ) ) ) {
item . data . afficherCompetence = false ;
}
2020-05-22 19:28:01 +02:00
list . push ( item ) ;
}
}
2020-12-02 20:52:37 +01:00
this . competenceByCategory = duplicate ( data . competenceByCategory ) ; // Sauvegarde locale
2020-08-14 22:24:35 +02:00
competenceXPTotal += RdDUtility . computeCompetenceTroncXP ( data . itemsByType . competence ) ;
2020-08-13 22:28:56 +02:00
data . data . competenceXPTotal = competenceXPTotal ;
//console.log("XP competence : ", competenceXPTotal);
// Compute current carac sum
let sum = 0 ;
Object . values ( data . data . carac ) . forEach ( carac => { if ( ! carac . derivee ) { sum += parseInt ( carac . value ) } } ) ;
data . data . caracSum = sum ;
2020-06-10 08:23:58 +02:00
// Force empty arme, at least for Esquive
if ( data . itemsByType . arme == undefined ) data . itemsByType . arme = [ ] ;
2020-11-23 20:40:56 +01:00
for ( const arme of data . itemsByType . arme ) {
2020-06-10 08:23:58 +02:00
arme . data . niveau = 0 ; // Per default, TODO to be fixed
for ( const melee of data . competenceByCategory . melee ) {
if ( melee . name == arme . data . competence )
arme . data . niveau = melee . data . niveau
}
2020-09-02 22:00:35 +02:00
for ( const tir of data . competenceByCategory . tir ) {
if ( tir . name == arme . data . competence )
arme . data . niveau = tir . data . niveau
}
for ( const lancer of data . competenceByCategory . lancer ) {
if ( lancer . name == arme . data . competence )
arme . data . niveau = lancer . data . niveau
}
2020-11-23 21:49:30 +01:00
}
// To avoid armour and so on...
data . data . combat = duplicate ( RdDUtility . checkNull ( data . itemsByType [ 'arme' ] ) ) ;
2020-12-05 21:24:31 +01:00
data . data . combat = RdDUtility . finalizeArmeList ( data . data . combat , data . itemsByType . competence , data . data . carac ) ;
2020-06-10 08:23:58 +02:00
if ( data . competenceByCategory && data . competenceByCategory . melee ) {
//Specific case for Esquive and Corps à Corps
for ( const melee of data . competenceByCategory . melee ) {
if ( melee . name == "Esquive" )
2020-12-05 21:24:31 +01:00
data . data . combat . push ( { name : "Esquive" , data : { niveau : melee . data . niveau , description : "" , force : 6 , initiative : "-" , competence : "Esquive" , dommages : 0 } } ) ;
if ( melee . name == "Corps à corps" ) {
2020-12-09 00:36:38 +01:00
let cc _init = RdDUtility . calculInitiative ( melee . data . niveau , data . data . carac [ 'melee' ] . value ) ;
2020-12-05 21:24:31 +01:00
data . data . combat . push ( { name : "Corps à corps" , data : { niveau : melee . data . niveau , description : "" , force : 6 , initiative : cc _init , competence : "Corps à corps" , dommages : data . data . attributs . plusdom . value } } ) ;
}
2020-06-07 23:16:29 +02:00
}
}
2020-12-05 21:24:31 +01:00
this . armesList = duplicate ( data . data . combat ) ;
2020-06-12 22:46:04 +02:00
data . data . carac . taille . isTaille = true ; // To avoid button link;
2020-12-05 02:22:37 +01:00
data . data . compteurs . chance . isChance = true ;
data . data . blessures . resume = this . actor . computeResumeBlessure ( data . data . blessures ) ;
2020-11-11 14:42:11 +01:00
// Mise à jour de l'encombrement total
2020-12-02 14:00:54 +01:00
this . actor . computeEncombrementTotalEtMalusArmure ( ) ;
2020-11-12 14:43:08 +01:00
// Common data
2020-05-22 19:28:01 +02:00
data . data . competenceByCategory = data . competenceByCategory ;
2020-12-20 21:54:09 +01:00
data . data . encTotal = this . actor . encTotal ;
2020-11-04 18:00:42 +01:00
data . data . isGM = game . user . isGM ;
2020-11-15 02:07:41 +01:00
data . ajustementsConditions = CONFIG . RDD . ajustementsConditions ;
data . difficultesLibres = CONFIG . RDD . difficultesLibres ;
2020-12-06 22:19:40 +01:00
2020-11-12 14:43:08 +01:00
// low is normal, this the base used to compute the grid.
2020-11-18 20:16:59 +01:00
data . data . fatigue = {
malus : RdDUtility . calculMalusFatigue ( data . data . sante . fatigue . value , data . data . sante . endurance . max ) ,
html : "<table class='table-fatigue'>" + RdDUtility . makeHTMLfatigueMatrix ( data . data . sante . fatigue . value , data . data . sante . endurance . max ) . html ( ) + "</table>"
}
2020-11-18 16:57:58 +01:00
2020-11-20 12:06:54 +01:00
RdDUtility . filterItemsPerTypeForSheet ( data ) ;
data . data . sortReserve = data . data . reve . reserve . list ;
2020-11-18 16:57:58 +01:00
RdDUtility . buildArbreDeConteneur ( this , data ) ;
2020-11-27 12:20:13 +01:00
data . data . surEncombrementMessage = ( data . data . compteurs . surenc . value < 0 ) ? "Sur-Encombrement!" : "" ;
2020-11-12 14:43:08 +01:00
2020-05-22 19:28:01 +02:00
return data ;
}
2020-12-27 22:21:08 +01:00
2020-11-11 11:43:13 +01:00
/* -------------------------------------------- */
async _onDrop ( event ) {
2020-11-28 09:59:30 +01:00
await RdDUtility . processItemDropEvent ( this , event ) ;
2020-11-18 16:57:58 +01:00
super . _onDrop ( event ) ;
2020-11-11 11:43:13 +01:00
}
2020-11-12 14:43:08 +01:00
2020-11-12 17:06:19 +01:00
/* -------------------------------------------- */
async confirmerSuppression ( li ) {
let itemId = li . data ( "item-id" ) ;
let d = new Dialog ( {
title : "Confirmer la suppression" ,
content : "<p>Etes vous certain de vouloir supprimer cet objet ?</p>" ,
buttons : {
delete : {
icon : '<i class="fas fa-check"></i>' ,
label : "Supprimer" ,
callback : ( ) => {
2020-11-16 09:41:46 +01:00
console . log ( "Delete : " , itemId ) ;
2020-11-12 17:06:19 +01:00
this . actor . deleteOwnedItem ( itemId ) ;
li . slideUp ( 200 , ( ) => this . render ( false ) ) ;
}
} ,
cancel : {
icon : '<i class="fas fa-times"></i>' ,
label : "Annuler"
}
} ,
default : "cancel" ,
} ) ;
d . render ( true ) ;
}
2020-12-02 20:52:37 +01:00
/* -------------------------------------------- */
afficheResumeArchetype ( ) {
let levelCategory = RdDUtility . getLevelCategory ( ) ;
let labelCategory = RdDUtility . getLabelCategory ( ) ;
let contentHTML = "" ;
for ( let compCategory in this . competenceByCategory ) {
console . log ( ">>>>" , compCategory ) ;
contentHTML += "<br><b>" + labelCategory [ compCategory ] + "</b>" ;
for ( let comp of this . competenceByCategory [ compCategory ] ) {
if ( ! comp . data . niveau _archetype ) comp . data . niveau _archetype = levelCategory [ compCategory ] ;
contentHTML += "<br>" + comp . name + " : " + comp . data . niveau _archetype ;
}
}
let dialogData = {
content : contentHTML ,
buttons : {
one : {
icon : '<i class="fas fa-check"></i>' ,
label : "Fermer"
}
}
}
new Dialog ( dialogData ) . render ( true ) ;
}
2020-12-15 08:37:52 +01:00
/* -------------------------------------------- */
async createEmptyTache ( ) {
2020-12-15 21:28:55 +01:00
await this . actor . createOwnedItem ( { name : 'Nouvelle tache' , type : 'tache' } , { renderSheet : true } ) ;
2020-12-15 08:37:52 +01:00
}
2020-12-15 22:44:49 +01:00
/* -------------------------------------------- */
async creerObjet ( ) {
let itemType = $ ( "#creer-equipement" ) . val ( ) ;
await this . actor . createOwnedItem ( { name : 'Nouveau ' + itemType , type : itemType } , { renderSheet : true } ) ;
}
/* -------------------------------------------- */
async selectObjetType ( ) {
let itemType = [ "objet" , "arme" , "armure" , "conteneur" , "herbe" , "ingredient" , "livre" , "potion" , "munition" , "monnaie" ] ;
let options = '<span class="competence-label">Selectionnez le type d\'équipement</span><select id="creer-equipement">' ;
for ( let typeName of itemType ) {
options += '<option value="' + typeName + '">' + typeName + '</option>'
}
options += '</select>' ;
let d = new Dialog ( {
title : "Créer un équipement" ,
content : options ,
buttons : {
one : {
icon : '<i class="fas fa-check"></i>' ,
label : "Créer l'objet" ,
callback : ( ) => this . creerObjet ( )
}
}
} ) ;
d . render ( true ) ;
}
2020-11-10 13:53:51 +01:00
/* -------------------------------------------- */
2020-05-21 21:48:20 +02:00
/** @override */
activateListeners ( html ) {
super . activateListeners ( html ) ;
2020-06-12 11:47:41 +02:00
2020-12-20 02:05:47 +01:00
HtmlUtility . _showControlWhen ( $ ( ".gm-only" ) , game . user . isGM ) ;
2020-12-01 01:17:18 +01:00
2020-05-21 21:48:20 +02:00
// Everything below here is only needed if the sheet is editable
if ( ! this . options . editable ) return ;
// Update Inventory Item
html . find ( '.item-edit' ) . click ( ev => {
const li = $ ( ev . currentTarget ) . parents ( ".item" ) ;
2020-11-05 20:23:16 +01:00
const item = this . actor . getOwnedItem ( li . data ( "item-id" ) ) ;
2020-05-21 21:48:20 +02:00
item . sheet . render ( true ) ;
} ) ;
2020-11-07 21:06:37 +01:00
2020-05-21 21:48:20 +02:00
// Delete Inventory Item
html . find ( '.item-delete' ) . click ( ev => {
const li = $ ( ev . currentTarget ) . parents ( ".item" ) ;
2020-11-12 17:06:19 +01:00
this . confirmerSuppression ( li ) ;
2020-05-21 21:48:20 +02:00
} ) ;
2020-12-01 01:17:18 +01:00
html . find ( '#encaisser-direct' ) . click ( ev => {
2020-12-27 19:55:51 +01:00
this . actor . encaisser ( ) ;
2020-11-07 21:06:37 +01:00
} ) ;
2020-12-01 01:17:18 +01:00
html . find ( '#remise-a-neuf' ) . click ( ev => {
if ( game . user . isGM ) {
this . actor . remiseANeuf ( ) ;
}
} ) ;
2020-12-15 08:37:52 +01:00
html . find ( '#creer-tache' ) . click ( ev => {
this . createEmptyTache ( ) ;
} ) ;
2020-12-15 22:44:49 +01:00
html . find ( '#creer-un-objet' ) . click ( ev => {
this . selectObjetType ( ) ;
} ) ;
2020-07-27 16:27:41 +02:00
// Blessure control
html . find ( '.blessure-control' ) . click ( ev => {
const li = $ ( ev . currentTarget ) . parents ( ".item" ) ;
let btype = li . data ( "blessure-type" ) ;
let index = li . data ( 'blessure-index' ) ;
let active = $ ( ev . currentTarget ) . data ( 'blessure-active' ) ;
//console.log(btype, index, active);
this . actor . manageBlessureFromSheet ( btype , index , active ) . then ( this . render ( true ) ) ;
} ) ;
// Blessure data
html . find ( '.blessures-soins' ) . change ( ev => {
const li = $ ( ev . currentTarget ) . parents ( ".item" ) ;
let btype = li . data ( 'blessure-type' ) ;
let index = li . data ( 'blessure-index' ) ;
let psoins = li . find ( 'input[name=premiers_soins]' ) . val ( ) ;
let pcomplets = li . find ( 'input[name=soins_complets]' ) . val ( ) ;
let jours = li . find ( 'input[name=jours]' ) . val ( ) ;
let loc = li . find ( 'input[name=localisation]' ) . val ( ) ;
//console.log(btype, index, psoins, pcomplets, jours, loc);
this . actor . setDataBlessureFromSheet ( btype , index , psoins , pcomplets , jours , loc ) . then ( this . render ( true ) ) ;
2020-07-20 12:02:07 +02:00
} ) ;
2020-06-23 23:34:12 +02:00
// Equip Inventory Item
html . find ( '.item-equip' ) . click ( ev => {
const li = $ ( ev . currentTarget ) . parents ( ".item" ) ;
2020-11-05 20:23:16 +01:00
this . actor . equiperObjet ( li . data ( "item-id" ) ) ;
2020-06-23 23:34:12 +02:00
this . render ( true ) ;
} ) ;
2020-06-12 22:46:04 +02:00
// Roll Carac
html . find ( '.carac-label a' ) . click ( ( event ) => {
let caracName = event . currentTarget . attributes . name . value ;
this . actor . rollCarac ( caracName . toLowerCase ( ) ) ;
} ) ;
2020-12-06 21:56:59 +01:00
html . find ( '#chance-actuelle' ) . click ( ( event ) => {
this . actor . rollCarac ( 'chance-actuelle' ) ;
2020-12-06 18:41:54 +01:00
} ) ;
2020-12-06 19:29:10 +01:00
html . find ( '#chance-appel' ) . click ( ( event ) => {
2020-12-06 23:31:23 +01:00
this . actor . rollAppelChance ( ) ;
2020-12-06 19:29:10 +01:00
} ) ;
2020-12-11 08:29:24 +01:00
html . find ( '#jet-astrologie' ) . click ( ( event ) => {
this . actor . astrologieNombresAstraux ( ) ;
} ) ;
2020-05-22 22:37:02 +02:00
// Roll Skill
html . find ( '.competence-label a' ) . click ( ( event ) => {
let compName = event . currentTarget . text ;
this . actor . rollCompetence ( compName ) ;
} ) ;
2020-12-15 08:37:52 +01:00
html . find ( '.tache-label a' ) . click ( ( event ) => {
const li = $ ( event . currentTarget ) . parents ( ".item" ) ;
let tacheId = li . data ( 'item-id' ) ;
this . actor . rollTache ( tacheId ) ;
} ) ;
2020-11-15 12:26:19 +01:00
// Points de reve actuel
html . find ( '.ptreve-actuel a' ) . click ( ( event ) => {
2020-12-06 21:56:59 +01:00
this . actor . rollCarac ( 'reve-actuel' ) ;
} ) ;
2020-11-15 12:26:19 +01:00
// Roll Weapon1
2020-06-07 23:16:29 +02:00
html . find ( '.arme-label a' ) . click ( ( event ) => {
let armeName = event . currentTarget . text ;
2020-11-23 20:40:56 +01:00
let competenceName = event . currentTarget . attributes [ 'data-competence-name' ] . value ;
2020-12-08 03:04:00 +01:00
this . actor . rollArme ( competenceName , armeName ) ;
2020-06-07 23:16:29 +02:00
} ) ;
2020-12-05 21:24:31 +01:00
// Initiative pour l'arme
html . find ( '.arme-initiative a' ) . click ( ( event ) => {
let combatant = game . combat . data . combatants . find ( c => c . actor . data . _id == this . actor . data . _id ) ;
if ( combatant ) {
let armeName = event . currentTarget . attributes [ 'data-arme-name' ] . value ;
let arme = this . armesList . find ( a => a . name == armeName ) ;
RdDUtility . rollInitiativeCompetence ( combatant . _id , arme ) ;
} else {
ui . notifications . info ( "Impossible de lancer l'initiative sans être dans un combat." ) ;
}
} ) ;
2020-12-30 15:56:17 +01:00
// Display TMR, visuualisation
2020-12-01 01:17:18 +01:00
html . find ( '#visu-tmr' ) . click ( ( event ) => {
2020-11-14 20:46:39 +01:00
this . actor . displayTMR ( "visu" ) ;
} ) ;
2020-07-25 10:29:28 +02:00
// Display TMR, normal
2020-12-01 01:17:18 +01:00
html . find ( '#monte-tmr' ) . click ( ( event ) => {
2020-11-14 20:46:39 +01:00
this . actor . displayTMR ( "normal" ) ;
2020-07-25 10:29:28 +02:00
} ) ;
// Display TMR, fast
2020-12-01 01:17:18 +01:00
html . find ( '#monte-tmr-rapide' ) . click ( ( event ) => {
2020-11-14 20:46:39 +01:00
this . actor . displayTMR ( "rapide" ) ;
2020-07-24 10:51:11 +02:00
} ) ;
2020-12-01 01:17:18 +01:00
html . find ( '#dormir-une-heure' ) . click ( ( event ) => {
2020-11-16 04:32:42 +01:00
this . actor . dormir ( 1 ) ;
2020-11-24 18:54:13 +01:00
} ) ;
2020-12-01 01:17:18 +01:00
html . find ( '#dormir-chateau-dormant' ) . click ( ( event ) => {
2020-11-24 18:54:13 +01:00
this . actor . dormirChateauDormant ( ) ;
} ) ;
2020-11-16 04:32:42 +01:00
2020-07-24 10:51:11 +02:00
// Display info about queue
html . find ( '.queuesouffle-label a' ) . click ( ( event ) => {
2020-07-27 16:27:41 +02:00
let myID = event . currentTarget . attributes [ 'data-item-id' ] . value ;
2020-07-24 10:51:11 +02:00
const item = this . actor . getOwnedItem ( myID ) ;
item . sheet . render ( true ) ;
} ) ;
// Display info about queue
2020-07-05 21:45:25 +02:00
html . find ( '.sort-label a' ) . click ( ( event ) => {
2020-07-24 10:51:11 +02:00
let myID = event . currentTarget . attributes [ 'data-id' ] . value ;
const item = this . actor . getOwnedItem ( myID ) ;
item . sheet . render ( true ) ;
2020-07-05 21:45:25 +02:00
} ) ;
2020-07-24 10:51:11 +02:00
2020-12-01 22:18:15 +01:00
// Display info about queue
html . find ( '.conteneur-name a' ) . click ( ( event ) => {
let myID = event . currentTarget . attributes [ 'data-item-id' ] . value ;
RdDUtility . toggleAfficheContenu ( myID ) ;
this . render ( true ) ;
} ) ;
2020-11-20 12:06:54 +01:00
if ( this . options . editCaracComp ) {
// On carac change
html . find ( '.carac-value' ) . change ( ( event ) => {
let caracName = event . currentTarget . name . replace ( ".value" , "" ) . replace ( "data.carac." , "" ) ;
//console.log("Value changed :", event, caracName);
this . actor . updateCarac ( caracName , parseInt ( event . target . value ) ) ;
} ) ;
// On competence change
html . find ( '.competence-value' ) . change ( ( event ) => {
let compName = event . currentTarget . attributes . compname . value ;
//console.log("Competence changed :", compName);
this . actor . updateCompetence ( compName , parseInt ( event . target . value ) ) ;
} ) ;
// On competence xp change
html . find ( '.competence-xp' ) . change ( ( event ) => {
let compName = event . currentTarget . attributes . compname . value ;
this . actor . updateCompetenceXP ( compName , parseInt ( event . target . value ) ) ;
} ) ;
}
// Gestion du bouton lock/unlock
2020-12-06 22:19:40 +01:00
html . find ( '.lock-unlock-sheet' ) . click ( ( event ) => {
2020-11-20 12:06:54 +01:00
this . options . editCaracComp = ! this . options . editCaracComp ;
this . render ( true ) ;
} ) ;
2020-12-06 22:19:40 +01:00
html . find ( '.show-hide-competences' ) . click ( ( event ) => {
this . options . cacherCompetencesNiveauBase = ! this . options . cacherCompetencesNiveauBase ;
this . render ( true ) ;
} ) ;
2020-07-14 22:19:29 +02:00
// On pts de reve change
html . find ( '.pointsreve-value' ) . change ( ( event ) => {
let reveValue = event . currentTarget . value ;
let reve = duplicate ( this . actor . data . data . reve . reve ) ;
reve . value = reveValue ;
2020-07-28 09:20:01 +02:00
this . actor . update ( { "data.reve.reve" : reve } ) ;
2020-06-01 23:50:10 +02:00
} ) ;
2020-11-16 03:52:34 +01:00
// On seuil de reve change
html . find ( '.seuil-reve-value' ) . change ( ( event ) => {
console . log ( "seuil-reve-value" , event . currentTarget )
this . actor . setPointsDeSeuil ( event . currentTarget . value ) ;
} ) ;
2020-07-14 22:19:29 +02:00
2020-12-18 01:10:03 +01:00
html . find ( '#attribut-protection-edit' ) . change ( ( event ) => {
this . actor . updateProtectionValue ( event . currentTarget . attributes . name . value , parseInt ( event . target . value ) ) ;
} ) ;
2020-08-29 22:52:41 +02:00
// On stress change
html . find ( '.compteur-edit' ) . change ( ( event ) => {
let fieldName = event . currentTarget . attributes . name . value ;
this . actor . updateCompteurValue ( fieldName , parseInt ( event . target . value ) ) ;
} ) ;
2020-12-29 01:34:15 +01:00
html . find ( '#ethylisme' ) . change ( ( event ) => {
this . actor . setEthylisme ( parseInt ( event . target . value ) ) ;
} ) ;
2020-08-29 22:52:41 +02:00
2020-12-02 20:52:37 +01:00
// Dialog d'archetype
html . find ( "#affiche-archetype" ) . click ( ( event ) => {
this . afficheResumeArchetype ( )
} ) ;
2020-08-29 22:52:41 +02:00
html . find ( '#stress-test' ) . click ( ( event ) => {
this . actor . stressTest ( ) ;
this . render ( true ) ;
} ) ;
2020-12-16 02:54:28 +01:00
html . find ( '#moral-malheureux' ) . click ( ( event ) => {
this . actor . jetDeMoral ( 'malheureuse' ) ;
this . render ( true ) ;
} ) ;
html . find ( '#moral-neutre' ) . click ( ( event ) => {
this . actor . jetDeMoral ( 'neutre' ) ;
this . render ( true ) ;
} ) ;
html . find ( '#moral-heureux' ) . click ( ( event ) => {
this . actor . jetDeMoral ( 'heureuse' ) ;
this . render ( true ) ;
} ) ;
2020-12-06 20:11:30 +01:00
html . find ( '#ethylisme-test' ) . click ( ( event ) => {
this . actor . ethylismeTest ( ) ;
this . render ( true ) ;
} ) ;
2020-12-06 21:39:55 +01:00
html . find ( '#jet-vie' ) . click ( ( event ) => {
this . actor . jetVie ( ) ;
this . render ( true ) ;
} ) ;
2020-05-28 23:36:09 +02:00
2020-06-23 23:34:12 +02:00
html . find ( '#vie-plus' ) . click ( ( event ) => {
2020-05-28 23:36:09 +02:00
this . actor . santeIncDec ( "vie" , 1 ) ;
this . render ( true ) ;
} ) ;
2020-06-23 23:34:12 +02:00
html . find ( '#vie-moins' ) . click ( ( event ) => {
2020-05-28 23:36:09 +02:00
this . actor . santeIncDec ( "vie" , - 1 ) ;
this . render ( true ) ;
} ) ;
2020-06-23 23:34:12 +02:00
html . find ( '#endurance-plus' ) . click ( ( event ) => {
2020-05-28 23:36:09 +02:00
this . actor . santeIncDec ( "endurance" , 1 ) ;
this . render ( true ) ;
} ) ;
2020-06-23 23:34:12 +02:00
html . find ( '#endurance-moins' ) . click ( ( event ) => {
2020-05-28 23:36:09 +02:00
this . actor . santeIncDec ( "endurance" , - 1 ) ;
this . render ( true ) ;
} ) ;
2020-11-18 18:37:15 +01:00
html . find ( '#ptreve-actuel-plus' ) . click ( ( event ) => {
2020-11-27 10:21:20 +01:00
this . actor . reveActuelIncDec ( 1 ) ;
2020-11-18 18:37:15 +01:00
this . render ( true ) ;
} ) ;
2020-11-17 19:29:18 +01:00
html . find ( '#ptreve-actuel-moins' ) . click ( ( event ) => {
2020-11-27 10:21:20 +01:00
this . actor . reveActuelIncDec ( - 1 ) ;
2020-11-17 19:29:18 +01:00
this . render ( true ) ;
} ) ;
2020-06-23 23:34:12 +02:00
html . find ( '#fatigue-plus' ) . click ( ( event ) => {
2020-05-28 23:36:09 +02:00
this . actor . santeIncDec ( "fatigue" , 1 ) ;
this . render ( true ) ;
} ) ;
2020-06-23 23:34:12 +02:00
html . find ( '#fatigue-moins' ) . click ( ( event ) => {
2020-05-28 23:36:09 +02:00
this . actor . santeIncDec ( "fatigue" , - 1 ) ;
this . render ( true ) ;
} ) ;
2020-05-21 21:48:20 +02:00
}
2020-05-28 23:36:09 +02:00
2020-05-21 21:48:20 +02:00
/* -------------------------------------------- */
/** @override */
setPosition ( options = { } ) {
const position = super . setPosition ( options ) ;
const sheetBody = this . element . find ( ".sheet-body" ) ;
const bodyHeight = position . height - 192 ;
sheetBody . css ( "height" , bodyHeight ) ;
return position ;
}
/* -------------------------------------------- */
/** @override */
_updateObject ( event , formData ) {
// Update the Actor
return this . object . update ( formData ) ;
}
}