v9 support
This commit is contained in:
		| @@ -139,13 +139,18 @@ export class Misc { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   static firstConnectedGM() { |   static firstConnectedGM() { | ||||||
|  |     if (game.version){ | ||||||
|  |       return game.users.filter(u => u.isGM && u.active)[0]; | ||||||
|  |     } else { | ||||||
|       return game.users.entities.sort(Misc.ascending(u => u.id)).find(u => u.isGM && u.active); |       return game.users.entities.sort(Misc.ascending(u => u.id)).find(u => u.isGM && u.active); | ||||||
|     } |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * @returns true pour un seul utilisateur: le premier GM connecté par ordre d'id |    * @returns true pour un seul utilisateur: le premier GM connecté par ordre d'id | ||||||
|    */ |    */ | ||||||
|   static isUniqueConnectedGM() { |   static isUniqueConnectedGM() { | ||||||
|  |     console.log(game.user.id, Misc.firstConnectedGM()?.id) | ||||||
|     return game.user.id == Misc.firstConnectedGM()?.id; |     return game.user.id == Misc.firstConnectedGM()?.id; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -504,6 +504,7 @@ export class RdDCalendrier extends Application { | |||||||
|   async showAstrologieEditor() { |   async showAstrologieEditor() { | ||||||
|     let calendrierData = duplicate(this.fillCalendrierData()); |     let calendrierData = duplicate(this.fillCalendrierData()); | ||||||
|     let astrologieArray = []; |     let astrologieArray = []; | ||||||
|  |     this.listeNombreAstral = this.listeNombreAstral || []; | ||||||
|     for (let astralData of this.listeNombreAstral) { |     for (let astralData of this.listeNombreAstral) { | ||||||
|       astralData.humanDate = this.getDateFromIndex(astralData.index); |       astralData.humanDate = this.getDateFromIndex(astralData.index); | ||||||
|       for (let vf of astralData.valeursFausses) { |       for (let vf of astralData.valeursFausses) { | ||||||
|   | |||||||
| @@ -83,7 +83,7 @@ export class RdDCombatManager extends Combat { | |||||||
|     const currentId = this.combatant._id; |     const currentId = this.combatant._id; | ||||||
|     // calculate initiative |     // calculate initiative | ||||||
|     for (let cId = 0; cId < ids.length; cId++) { |     for (let cId = 0; cId < ids.length; cId++) { | ||||||
|       const combatant = this.getCombatant(ids[cId]); |       const combatant = this.combatants.get(ids[cId]); | ||||||
|       //if (!c) return results; |       //if (!c) return results; | ||||||
|  |  | ||||||
|       let rollFormula = formula; // Init per default |       let rollFormula = formula; // Init per default | ||||||
| @@ -110,9 +110,13 @@ export class RdDCombatManager extends Combat { | |||||||
|       } |       } | ||||||
|       //console.log("Combatat", c); |       //console.log("Combatat", c); | ||||||
|       const roll = combatant.getInitiativeRoll(rollFormula); |       const roll = combatant.getInitiativeRoll(rollFormula); | ||||||
|  |       if ( !roll.total) { | ||||||
|  |         roll.evaluate( {async: false}); | ||||||
|  |       } | ||||||
|       if (roll.total <= 0) roll.total = 0.00; |       if (roll.total <= 0) roll.total = 0.00; | ||||||
|       console.log("Compute init for", rollFormula, roll.total); |       console.log("Compute init for", rollFormula, roll.total, combatant); | ||||||
|       await this.updateEmbeddedDocuments("Combatant", [{ _id: combatant._id, initiative: roll.total }]); |       let id = combatant._id || combatant.id; | ||||||
|  |       await this.updateEmbeddedDocuments("Combatant", [{ _id: id, initiative: roll.total }]); | ||||||
|  |  | ||||||
|       // Send a chat message |       // Send a chat message | ||||||
|       let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode"); |       let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode"); | ||||||
| @@ -253,7 +257,7 @@ export class RdDCombatManager extends Combat { | |||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   static incDecInit(combatantId, incDecValue) { |   static incDecInit(combatantId, incDecValue) { | ||||||
|     const combatant = game.combat.getCombatant(combatantId); |     const combatant = game.combat.combatants.get(combatantId); | ||||||
|     let initValue = combatant.initiative + incDecValue; |     let initValue = combatant.initiative + incDecValue; | ||||||
|     game.combat.setInitiative(combatantId, initValue); |     game.combat.setInitiative(combatantId, initValue); | ||||||
|   } |   } | ||||||
| @@ -278,7 +282,7 @@ export class RdDCombatManager extends Combat { | |||||||
|   } |   } | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   static rollInitiativeCompetence(combatantId, arme) { |   static rollInitiativeCompetence(combatantId, arme) { | ||||||
|     const combatant = game.combat.getCombatant(combatantId); |     const combatant = game.combat.combatants.get(combatantId); | ||||||
|     if (combatant.actor == undefined) { |     if (combatant.actor == undefined) { | ||||||
|       ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`) |       ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`) | ||||||
|       return []; |       return []; | ||||||
| @@ -344,7 +348,7 @@ export class RdDCombatManager extends Combat { | |||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   static displayInitiativeMenu(html, combatantId) { |   static displayInitiativeMenu(html, combatantId) { | ||||||
|     console.log("Combatant ; ", combatantId); |     console.log("Combatant ; ", combatantId); | ||||||
|     const combatant = game.combat.getCombatant(combatantId); |     const combatant = game.combat.combatants.get(combatantId); | ||||||
|     let armesList = RdDCombatManager.buildListeActionsCombat(combatant); |     let armesList = RdDCombatManager.buildListeActionsCombat(combatant); | ||||||
|  |  | ||||||
|     // Build the relevant submenu |     // Build the relevant submenu | ||||||
|   | |||||||
| @@ -1062,6 +1062,7 @@ ul, li { | |||||||
| /* Sidebar CSS */ | /* Sidebar CSS */ | ||||||
| #sidebar { | #sidebar { | ||||||
|   font-size: 1rem; |   font-size: 1rem; | ||||||
|  |   width:min-content; | ||||||
|   background: rgb(105,85,65) url(img/bg_sid_dark.webp) no-repeat right bottom; |   background: rgb(105,85,65) url(img/bg_sid_dark.webp) no-repeat right bottom; | ||||||
|   background-position: 100%; |   background-position: 100%; | ||||||
|   color: rgba(220,220,220,0.75); |   color: rgba(220,220,220,0.75); | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|   "name": "foundryvtt-reve-de-dragon", |   "name": "foundryvtt-reve-de-dragon", | ||||||
|   "title": "Rêve de Dragon", |   "title": "Rêve de Dragon", | ||||||
|   "description": "Rêve de Dragon RPG for FoundryVTT", |   "description": "Rêve de Dragon RPG for FoundryVTT", | ||||||
|   "version": "1.5.48", |   "version": "1.5.49", | ||||||
|   "manifestPlusVersion": "1.0.0", |   "manifestPlusVersion": "1.0.0", | ||||||
|   "minimumCoreVersion": "0.8.0", |   "minimumCoreVersion": "0.8.0", | ||||||
|   "compatibleCoreVersion": "0.8.9", |   "compatibleCoreVersion": "0.8.9", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user