ENH: Reset initiative option
							parent
							
								
									ade4cd7d40
								
							
						
					
					
						commit
						002e97988a
					
				|  | @ -162,7 +162,8 @@ | ||||||
|   "OSE.Setting.Initiative": "Initiative", |   "OSE.Setting.Initiative": "Initiative", | ||||||
|   "OSE.Setting.InitiativeHint": "Grouped or individual initiative. Unique individual is only rolled at the start of the combat", |   "OSE.Setting.InitiativeHint": "Grouped or individual initiative. Unique individual is only rolled at the start of the combat", | ||||||
|   "OSE.Setting.InitiativeOnce": "Unique individual Initiative", |   "OSE.Setting.InitiativeOnce": "Unique individual Initiative", | ||||||
|   "OSE.Setting.InitiativeReroll": "Individual Initiative per Round", |   "OSE.Setting.InitiativeReroll": "Roll individual Initiative each Round", | ||||||
|  |   "OSE.Setting.InitiativeReset": "Reset individual Initiative each Round", | ||||||
|   "OSE.Setting.InitiativeGroup": "Grouped Initiative", |   "OSE.Setting.InitiativeGroup": "Grouped Initiative", | ||||||
|   "OSE.Setting.AscendingAC": "Ascending Armor Class", |   "OSE.Setting.AscendingAC": "Ascending Armor Class", | ||||||
|   "OSE.Setting.AscendingACHint": "The more the better", |   "OSE.Setting.AscendingACHint": "The more the better", | ||||||
|  |  | ||||||
|  | @ -162,7 +162,8 @@ | ||||||
|   "OSE.Setting.Initiative": "Initiative", |   "OSE.Setting.Initiative": "Initiative", | ||||||
|   "OSE.Setting.InitiativeHint": "Initiative groupée ou individuelle. L'initiative unique est tirée une seule fois en début de combat.", |   "OSE.Setting.InitiativeHint": "Initiative groupée ou individuelle. L'initiative unique est tirée une seule fois en début de combat.", | ||||||
|   "OSE.Setting.InitiativeOnce": "Initiative unique individuelle", |   "OSE.Setting.InitiativeOnce": "Initiative unique individuelle", | ||||||
|   "OSE.Setting.InitiativeReroll": "Initiative individuelle", |   "OSE.Setting.InitiativeReroll": "Initiative relancée chaque tour", | ||||||
|  |   "OSE.Setting.InitiativeReset": "Initiative mise à zéro chaque tour", | ||||||
|   "OSE.Setting.InitiativeGroup": "Initiative groupée", |   "OSE.Setting.InitiativeGroup": "Initiative groupée", | ||||||
|   "OSE.Setting.AscendingAC": "Classe d'Armure Ascendante", |   "OSE.Setting.AscendingAC": "Classe d'Armure Ascendante", | ||||||
|   "OSE.Setting.AscendingACHint": "Le plus est le mieux", |   "OSE.Setting.AscendingACHint": "Le plus est le mieux", | ||||||
|  |  | ||||||
|  | @ -31,6 +31,14 @@ export class OseCombat { | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   static async resetInitiative(combat, data) { | ||||||
|  |     let updates = []; | ||||||
|  |     combat.data.combatants.forEach((c, i) => { | ||||||
|  |       updates.push({_id: c._id, initiative: ""}); | ||||||
|  |     }); | ||||||
|  |     await combat.updateEmbeddedEntity("Combatant", updates); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   static async individualInitiative(combat, data) { |   static async individualInitiative(combat, data) { | ||||||
|     let updates = []; |     let updates = []; | ||||||
|     let messages = []; |     let messages = []; | ||||||
|  | @ -43,7 +51,7 @@ export class OseCombat { | ||||||
|       if (combat.settings.skipDefeated && c.defeated) { |       if (combat.settings.skipDefeated && c.defeated) { | ||||||
|         value = -790; |         value = -790; | ||||||
|       } |       } | ||||||
|       updates.push({ _id: c._id, initiative: value }); |       updates.push({ _id: c._id, initiative: "value" }); | ||||||
| 
 | 
 | ||||||
|       // Determine the roll mode
 |       // Determine the roll mode
 | ||||||
|       let rollMode = game.settings.get("core", "rollMode"); |       let rollMode = game.settings.get("core", "rollMode"); | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ export const registerSettings = function () { | ||||||
|     choices: { |     choices: { | ||||||
|       disabled: "OSE.Setting.InitiativeOnce", |       disabled: "OSE.Setting.InitiativeOnce", | ||||||
|       rerolled: "OSE.Setting.InitiativeReroll", |       rerolled: "OSE.Setting.InitiativeReroll", | ||||||
|  |       reset: "OSE.Setting.InitiativeReset", | ||||||
|       group: "OSE.Setting.InitiativeGroup", |       group: "OSE.Setting.InitiativeGroup", | ||||||
|     }, |     }, | ||||||
|     onChange: _ => window.location.reload() |     onChange: _ => window.location.reload() | ||||||
|  |  | ||||||
|  | @ -128,10 +128,12 @@ Hooks.on("preUpdateCombat", async (combat, data, diff, id) => { | ||||||
|   if (!data.round) { |   if (!data.round) { | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|   if (init == "group") { |   if (init === "group") { | ||||||
|     OseCombat.rollInitiative(combat, data, diff, id); |     OseCombat.rollInitiative(combat, data, diff, id); | ||||||
|   } else if (init == "rerolled") { |   } else if (init === "rerolled") { | ||||||
|     OseCombat.individualInitiative(combat, data, diff, id); |     OseCombat.individualInitiative(combat, data, diff, id); | ||||||
|  |   } else if (init === "reset") { | ||||||
|  |     OseCombat.resetInitiative(combat, data, diff, id); | ||||||
|   } |   } | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue