mirror of
				https://github.com/em-squared/5e-drs.git
				synced 2025-10-31 05:24:20 +00:00 
			
		
		
		
	tooltips créatures
This commit is contained in:
		
							parent
							
								
									37e28207f0
								
							
						
					
					
						commit
						e15a84fa0e
					
				
					 7 changed files with 281 additions and 5 deletions
				
			
		|  | @ -70,6 +70,114 @@ export function displayMonsterTypeSizeAlignment (monster, hideAlignment = false, | |||
|   return result | ||||
| } | ||||
| 
 | ||||
| // Affiche la Classe d'armure
 | ||||
| export function displayAC (monster) { | ||||
|   let ac = 10 | ||||
|   let hasMageArmor = false | ||||
|   let mageArmorAc = 13 | ||||
|   let mageArmor = '' | ||||
|   let armor = '' | ||||
|   // Le monstre n'a pas d'armure.
 | ||||
|   // CA = 10 + Dex
 | ||||
|   if (!monster.frontmatter.ac.armorType) { | ||||
|     ac = 10 + getModifier(monster.frontmatter.abilityScores.dex) | ||||
|   } else { | ||||
|     // Le type d'armure n'est pas formalisé. On prend la valeur brute
 | ||||
|     if (monster.frontmatter.ac.armorType == 'custom') { | ||||
|       return monster.frontmatter.ac.value | ||||
|     } | ||||
| 
 | ||||
|     // Le monstre a une armure naturelle.
 | ||||
|     // CA =  10 + Armure naturelle + Dex
 | ||||
|     if (monster.frontmatter.ac.armorType == 'armure naturelle') { | ||||
|       armor = monster.frontmatter.ac.armorType | ||||
|       if (parseInt(monster.frontmatter.ac.value)) { | ||||
|         ac = ac + parseInt(monster.frontmatter.ac.value) + getModifier(monster.frontmatter.abilityScores.dex) | ||||
|       } else { | ||||
|         ac = ac + getModifier(monster.frontmatter.abilityScores.dex) | ||||
|       } | ||||
|     } else if (monster.frontmatter.ac.armorType == 'armure du mage') { | ||||
|       hasMageArmor = true | ||||
|       ac = ac + getModifier(monster.frontmatter.abilityScores.dex) | ||||
|       mageArmorAc = mageArmorAc + getModifier(monster.frontmatter.abilityScores.dex) | ||||
|       armor = mageArmorAc + ' avec armure du mage' | ||||
|     } else { | ||||
|       // Le monstre a un type d'armure défini.
 | ||||
|       // On calcule sa CA selon le type
 | ||||
|       let armorType = armorTypes[monster.frontmatter.ac.armorType] | ||||
| 
 | ||||
|       // Le type d'armure n'existe pas. On l'ignore.
 | ||||
|       // CA = 10 + Dex
 | ||||
|       if (!armorType) { | ||||
|         ac = ac + getModifier(monster.frontmatter.abilityScores.dex) | ||||
|       } else { | ||||
|         // L'armure n'impose pas de limite de Dex
 | ||||
|         armor = monster.frontmatter.ac.armorType | ||||
|         if (armorType.maxDex === false) { | ||||
|           ac = armorType.value + getModifier(monster.frontmatter.abilityScores.dex) | ||||
|         } else { | ||||
|           // La limite de Dex de l'armure est inférieure à la Dex du monstre
 | ||||
|           if (armorType.maxDex === 0) { | ||||
|             ac = armorType.value | ||||
|           } else if ((armorType.maxDex !== 0) && (armorType.maxDex <= getModifier(monster.frontmatter.abilityScores.dex))) { | ||||
|             ac = armorType.value + armorType.maxDex | ||||
|           } else { | ||||
|             ac = armorType.value + getModifier(monster.frontmatter.abilityScores.dex) | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   // Le monstre a un bouclier. Sa CA augmente de 2.
 | ||||
|   if (monster.frontmatter.ac.hasShield) { | ||||
|     ac = ac + 2 | ||||
|     mageArmorAc = mageArmorAc + 2 | ||||
|     if (armor != '') { | ||||
|       armor += ', ' | ||||
|     } | ||||
|     armor += 'bouclier' | ||||
| 
 | ||||
|     if (hasMageArmor) { | ||||
|       armor = mageArmorAc + ' avec armure du mage, bouclier' | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   if (armor != '') { | ||||
|     ac += ' (' + armor + ')' | ||||
|   } | ||||
| 
 | ||||
|   return ac | ||||
| } | ||||
| 
 | ||||
| // Affiche les points de vie
 | ||||
| export function displayHP (monster) { | ||||
|   if (monster.frontmatter.customHP) { | ||||
|     return monster.frontmatter.customHP | ||||
|   } else if (monster.frontmatter.hitDiceCount) { | ||||
|     let hitDieSize = 8 // Dé de vie moyen par défaut
 | ||||
|     if (monster.frontmatter.hitDieSize) { | ||||
|       hitDieSize = monster.frontmatter.hitDieSize | ||||
|     } else if (monster.frontmatter.size) { | ||||
|       hitDieSize = stats.sizes[monster.frontmatter.size].hitDie | ||||
|     } | ||||
|     let hitPointsBonus = 0 | ||||
|     if (monster.frontmatter.hitDiceCount > 1) { | ||||
|       hitPointsBonus = Math.floor(monster.frontmatter.hitDiceCount / 2) | ||||
|     } | ||||
|     let averageHP = monster.frontmatter.hitDiceCount * (hitDieSize / 2) + monster.frontmatter.hitDiceCount * getModifier(monster.frontmatter.abilityScores.con) + hitPointsBonus | ||||
|     let conMod = "" | ||||
|     if (getModifier(monster.frontmatter.abilityScores.con) != 0) { | ||||
|       conMod = monster.frontmatter.hitDiceCount * getModifier(monster.frontmatter.abilityScores.con) | ||||
|       conMod = displayBonus(conMod) | ||||
|     } | ||||
|     return averageHP + ' (' + monster.frontmatter.hitDiceCount + "d" + hitDieSize + conMod + ')' | ||||
|   } | ||||
|   return "" | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // Retourne le nombre de points de combat pour un indice de dangerosité
 | ||||
| export function getPCbyChallenge(challenge) { | ||||
|   let challengeIndex = CHALLENGES.findIndex(item => item.value == challenge) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Maxime Moraine
						Maxime Moraine