Merge pull request '13.0.10 - Les papilles d'Illysis' (#774) from VincentVk/foundryvtt-reve-de-dragon:v13 into v13
All checks were successful
Release Creation / build (release) Successful in 1m45s

Reviewed-on: #774
This commit is contained in:
2025-10-05 21:39:20 +02:00
109 changed files with 1791 additions and 709 deletions

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 256px; width: 256px;"><g class="" transform="translate(0,-28)" style=""><path d="M259.063 25.094c-56.045 0-106.836 9.775-144.438 26.125-18.8 8.174-34.34 17.96-45.594 29.53-11.254 11.57-18.28 25.338-18.28 40.188 0 9.936 3.17 19.388 8.625 28.03-10.218 21.883-15.844 45.794-15.844 70.782 0 103.158 95.757 187.844 215.532 187.844 119.776 0 215.563-84.686 215.563-187.844 0-24.99-5.653-48.897-15.875-70.78 5.454-8.644 8.625-18.096 8.625-28.032 0-14.85-7.026-28.617-18.28-40.188-11.256-11.57-26.825-21.356-45.626-29.53-37.603-16.35-88.363-26.126-144.408-26.126zm0 18.687c53.848 0 102.554 9.6 136.968 24.564 17.208 7.482 30.775 16.306 39.658 25.437 8.882 9.133 13 18.115 13 27.157 0 9.043-4.118 18.057-13 27.188-8.883 9.13-22.45 17.956-39.657 25.438-34.413 14.963-83.12 24.562-136.967 24.562-53.85 0-102.555-9.6-136.97-24.563-17.206-7.48-30.804-16.306-39.687-25.437-8.882-9.13-12.97-18.145-12.97-27.188 0-9.042 4.088-18.024 12.97-27.156 8.883-9.13 22.48-17.954 39.688-25.436 34.414-14.964 83.12-24.563 136.97-24.563zm-7.782 17.282c-80.57 0-146 26.008-146 57.844 0 31.836 65.43 57.81 146 57.813 40.04 0 76.404-6.613 102.782-16.94-21.316 3.34-45.064 5.845-70.656 5.845-86.066 0-155.937-21.656-155.937-47.906s69.868-47.282 155.936-47.282c20.43 0 39.926.725 57.813 2.906-24.816-7.704-55.957-12.28-89.94-12.28zM87.657 360.5c-9.916 19.897-14.758 36.638-15.78 49.03-1.23 14.906 2.752 22.238 6.655 24.626 3.905 2.388 11.497 2.48 23.376-5.75 9.25-6.41 20.16-17.73 31.375-34.406-16.778-9.432-32.1-20.71-45.624-33.5zm342.75.063c-13.532 12.782-28.872 24.043-45.656 33.468 11.21 16.666 22.13 27.97 31.375 34.376 11.88 8.23 19.472 8.138 23.375 5.75 3.903-2.388 7.886-9.72 6.656-24.625-1.022-12.38-5.855-29.098-15.75-48.967zm-199.25 64.25c1.36 21.275 5.296 37.554 10.344 48.468 6.272 13.56 13.26 17.82 17.72 17.908 4.457.088 11.14-3.683 17.374-16.907 5.133-10.89 9.165-27.52 10.437-49.467a267.366 267.366 0 0 1-27.967 1.468c-9.437 0-18.75-.506-27.907-1.467z" fill="#fff" fill-opacity="1" transform="translate(25.6, 25.6) scale(0.9, 0.9) rotate(0, 256, 256) skewX(0) skewY(0)"></path></g></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

1
assets/ui/fatigue.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 256px; width: 256px;"><g class="" transform="translate(0,-28)" style=""><path d="M249.094 18.25c-42.675 0-81.852 25.486-110.938 68.438C109.07 129.637 90.72 189.74 90.72 256.28c0 66.543 18.35 126.643 47.436 169.595s68.263 68.47 110.938 68.47 81.883-25.518 110.97-68.47c29.084-42.952 47.436-103.052 47.436-169.594 0-66.54-18.352-126.64-47.438-169.592C330.978 43.736 291.77 18.25 249.094 18.25zm-128.97 241.313c18.356 18.096 37.528 26.765 55.72 27.562 18.19.797 35.927-6.096 52.125-21.5l12.874 13.53c-19.214 18.274-42.25 27.658-65.813 26.626-23.56-1.03-47.1-12.3-68-32.905l13.095-13.313zm264.782 0 13.125 13.312C377.135 293.48 353.564 304.75 330 305.78c-23.563 1.033-46.598-8.35-65.813-26.624l12.875-13.53c16.2 15.403 33.934 22.296 52.125 21.5 18.192-.798 37.365-9.467 55.72-27.563zM251.562 371.656c36.423-.156 72.996 19.144 77.438 58.406-51.33 13.296-102.67 12.767-154 0 3.858-38.638 40.14-58.25 76.563-58.406z" fill="#fff" fill-opacity="1" transform="translate(25.6, 25.6) scale(0.9, 0.9) rotate(0, 256, 256) skewX(0) skewY(0)"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 256px; width: 256px;"><g class="" transform="translate(0,-28)" style=""><path d="M45.95 14.553c-19.38.81-30.594 11.357-30.282 30.283l19.768 30.78c4.43-1.213 9.36-3.838 14.248-7.335l42.474 59.935c-17.018 20.83-31.258 44.44-42.71 70.836l26.55 26.552c11.275-23.6 24.634-44.826 39.918-63.864l210.82 297.475 166.807 33.213L460.33 325.62 162.78 114.745c19.907-16.108 41.842-29.91 65.652-41.578l-26.553-26.55c-27.206 11.803-51.442 26.576-72.735 44.292L69.39 48.56c3.443-4.823 6.062-9.735 7.342-14.242l-30.78-19.765zm400.84 86.933v.008l.003-.008h-.002zm0 .008-28.028 124.97-25.116-80.593-18.105 70.667-26.862-49.64-.584 57.818 128.484 91.69 15.184 87.017-1.168-186.885-34.457 39.713-9.346-154.756zm-300.95 27.98 222.224 196.368 25.645 66.75-66.75-25.645L130.6 144.734a308.453 308.453 0 0 1 15.238-15.26zm32.305 196.274v.004h.005l-.005-.004zm.005.004 28.028 22.775-36.21 4.088 57.82 19.272-105.706 4.09 115.05 27.45L136.1 422.114l127.316 25.696-67.164 43.803 208.494 1.752-87.017-15.185-104.54-150.676-35.037-1.752z" fill="#fff" fill-opacity="1" transform="translate(25.6, 25.6) scale(0.9, 0.9) rotate(0, 256, 256) skewX(0) skewY(0)"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

1
assets/ui/part-force.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 256px; width: 256px;"><g class="" transform="translate(0,-28)" style=""><path d="M227.227 21.777c-1.845 0-3.704.05-5.567.157-15.314.875-30.76 5.305-39.494 10.863l-.008 73.15c2.884-.094 5.777-.147 8.676-.142 23.382.036 47.104 3.286 68.47 9.513l.01-87.507c-7.034-3.518-19.178-6.03-32.087-6.033zm80.74 9.16c-11.925.15-23.077 2.364-29.967 5.596l-.008 77.602v7.658c38.486 15.67 64.814 42.48 58.735 78.764l-.96 5.73-5.562 1.674c-17.45 5.253-34.872 9.703-52.225 13.335v25.234c25.562-.704 51.327-2.687 77.145-6.098l.02-197.928c-8.284-5.563-23.508-10.243-38.842-11.328a100.065 100.065 0 0 0-8.336-.238zM143.223 46.294a99.206 99.206 0 0 0-16.491 1.172c-15.67 2.454-31.477 8.565-40.406 15.402l-.01 72.955c18.808-15.81 46.704-25.143 77.15-28.54l.007-57.966c-4.82-1.752-12.018-2.916-20.25-3.023zm258.394 3.46c-10.804.117-20.722 1.93-27.043 4.655l-.02 183.182c25.074-4.02 50.16-9.412 75.122-16.358l1.99-158.447c-8.352-5.9-23.648-11.025-39.05-12.553a100.98 100.98 0 0 0-11-.478zm-222.775 74.202c-53.72.702-101.407 20.365-97.887 66.6 15.836-3.918 30.84-5.893 44.94-6.1 34.84-.51 64.213 9.704 87.318 27.613 34.608-3.11 69.852-10 105.412-20.314.14-41.287-74.098-68.657-139.783-67.8zm-48.877 78.65c-1.296-.003-2.603.012-3.92.045-17.256.436-36.45 4.03-57.566 11.037 5.79 53.808 26.325 106.41 58.5 143.346 6.226 7.15 12.856 13.712 19.875 19.615 29.303 9.282 69.26 12.917 110.534 12.14 3.777-55.805-8.717-108.357-36.193-142.74-21.265-26.61-51.064-43.39-91.232-43.444zm129.326 22.282a545.177 545.177 0 0 1-27.995 4.15 138.77 138.77 0 0 1 4.502 5.346c3.146 3.937 6.094 8.062 8.873 12.334 9.916.144 19.868.125 29.857-.106H259.29v-21.723zm191.817 15.343c-65.406 17.826-131.462 25.41-195.85 25.315 16.998 35.144 23.828 78.093 21.013 122.6 42.482-2.08 85.03-8.23 118.187-15.983 26.693-32.78 47.37-77.118 56.65-131.932zM400.51 389.9c-38.334 9.145-87.95 16.056-136.873 17.454-47.67 1.36-94.336-2.228-129.448-15.262l-.01 78.93c27.187 12.568 76.414 20.205 127.318 20.298 51.224.094 104.214-7.173 139-20.773l.012-80.647z" fill="#fff" fill-opacity="1" transform="translate(25.6, 25.6) scale(0.9, 0.9) rotate(0, 256, 256) skewX(0) skewY(0)"></path></g></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 256px; width: 256px;"><g class="" transform="translate(0,-28)" style=""><path d="M275.03 20c35.223 49.563 53.59 113.64 55.69 173.47C315.154 143 289.092 88.423 250.81 48.75c40.294 79.527 51.15 172.312 37.938 256.094-12.287-75.777-40.564-159.524-92.375-227.156 29.6 70.937 36.64 149.785 24.813 221.843-8.745-51.804-25.41-107.4-52.594-158.81 13.023 54.315 12.854 107.64 3.437 159.28l21.657 6.813 15 4.718-11.28 10.908c-10.68 10.332-19.868 21.905-27.345 34.343 93.614 35.486 232.952 64.53 298.032 41.376-41.02 56.466-210.332 13.822-309.313-18.687-1.514 3.775-2.918 7.594-4.124 11.467a152.536 152.536 0 0 0-6.062 29.657l176.47 66.375c98.5 31.095 150.5-24.62 158.655-81.72C505.253 254.472 485.016 105.66 426.06 20h-22.187c40.092 65.52 66.67 154.216 60.47 255.344-8.154-79.833-42.8-157.214-98.44-219.5 38.676 85.094 56.566 185.746 34.376 288.625.057-118.816-33.1-225.865-105.092-324.47H275.03zm-110.186 1.594c41.255 29.176 74.328 74.093 97.5 120.656-7.702-46.15-21.3-86.79-44-120.656h-53.5zm176.375 0c28.882 15.143 52.096 36.614 71.28 66.78-7.14-27.79-17.217-49.85-31.438-66.78H341.22zM123.686 304.406a179.344 179.344 0 0 1-4.062 64L18.812 336.344V366l91.938 29.094a178.602 178.602 0 0 1-30.313 48.28l50.094 15.75c-3.038-24.898-1.136-49.885 6.282-73.718 7.446-23.92 20.223-46.108 37.032-65.22l-50.156-15.78z" fill="#fff" fill-opacity="1" transform="translate(25.6, 25.6) scale(0.9, 0.9) rotate(0, 256, 256) skewX(0) skewY(0)"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,5 +1,28 @@
# 13.0 # 13.0
## 13.0.10 - Les papilles d'Illysis
- Ajout d'un statut "saignement" en cas de blessure grave ou critique sans premiers soins
- Nouvelle fenêtre de jets de dés
- jets de méditation
- jets de tâches
- jets de caractéristiques
- jets de compétences
- Boutons d'initiative et d'attaque V2
- fenêtre d'attaque
- choix des armes
- gestion des particulières
- message au défenseur
- gestion des demi-surprises (attaquant/défenseur)
- gestion des tactiques (attaquant/défenseur)
- en cours nouvelle fenêtre de jets
- jets de compétence avec messages
- jets de cuisine séparés avec messages (pour gérer plus tard les spécificités: fabricatioon de plats)
- gestion des empoignades
- Technique: suppression de warnings foundry sur renderTemplate
## 13.0.9 - Le combat d'Illysis ## 13.0.9 - Le combat d'Illysis
- Fix - Fix
- La montée en TMR fonctionne - La montée en TMR fonctionne

View File

@@ -96,6 +96,7 @@ select,
--gradient-red: linear-gradient(150deg, rgba(255, 0, 0, 0.3), rgba(255, 200, 128, 0.05), rgba(255, 200, 128, 0.1), rgba(255, 10, 0, 0.3)); --gradient-red: linear-gradient(150deg, rgba(255, 0, 0, 0.3), rgba(255, 200, 128, 0.05), rgba(255, 200, 128, 0.1), rgba(255, 10, 0, 0.3));
--gradient-violet: linear-gradient(150deg, rgba(100, 45, 124, 0.6), rgba(216, 157, 192, 0.3), rgba(177, 157, 216, 0.5), rgba(107, 62, 121, 0.3), rgba(100, 45, 124, 0.6)); --gradient-violet: linear-gradient(150deg, rgba(100, 45, 124, 0.6), rgba(216, 157, 192, 0.3), rgba(177, 157, 216, 0.5), rgba(107, 62, 121, 0.3), rgba(100, 45, 124, 0.6));
--gradient-purple-black: linear-gradient(150deg, rgba(0, 0, 0, 0.7), rgba(100, 45, 124, 0.4), rgba(82, 17, 131, 0.3), rgba(100, 45, 124, 0.4), rgba(0, 0, 0, 0.7)); --gradient-purple-black: linear-gradient(150deg, rgba(0, 0, 0, 0.7), rgba(100, 45, 124, 0.4), rgba(82, 17, 131, 0.3), rgba(100, 45, 124, 0.4), rgba(0, 0, 0, 0.7));
--gradient-warning: linear-gradient(150deg, hsla(32, 100%, 50%, 0.3), hsla(52, 60%, 50%, 0.1), hsla(32, 60%, 50%, 0.1), hsla(32, 100%, 50%, 0.3));
--gradient-silver-light: linear-gradient(30deg, rgba(61, 55, 93, 0.2), rgba(178, 179, 196, 0.1), rgba(59, 62, 63, 0.2), rgba(206, 204, 199, 0.1), rgba(61, 46, 49, 0.2)); --gradient-silver-light: linear-gradient(30deg, rgba(61, 55, 93, 0.2), rgba(178, 179, 196, 0.1), rgba(59, 62, 63, 0.2), rgba(206, 204, 199, 0.1), rgba(61, 46, 49, 0.2));
--gradient-daylight: conic-gradient(from 0deg, hsla(50, 100%, 80%, 0.7), hsla(30, 30%, 40%, 0.1) 25%, hsla(250, 50%, 40%, 0.1) 25%, hsla(250, 30%, 30%, 0.7) 50%, hsla(250, 50%, 40%, 0.1) 75%, hsla(30, 30%, 40%, 0.1) 75%, hsla(50, 100%, 80%, 0.7)); --gradient-daylight: conic-gradient(from 0deg, hsla(50, 100%, 80%, 0.7), hsla(30, 30%, 40%, 0.1) 25%, hsla(250, 50%, 40%, 0.1) 25%, hsla(250, 30%, 30%, 0.7) 50%, hsla(250, 50%, 40%, 0.1) 75%, hsla(30, 30%, 40%, 0.1) 75%, hsla(50, 100%, 80%, 0.7));
--background-custom-button: linear-gradient(to bottom, hsla(208, 38%, 21%, 0.988) 5%, hsla(202, 42%, 14%, 0.671) 100%); --background-custom-button: linear-gradient(to bottom, hsla(208, 38%, 21%, 0.988) 5%, hsla(202, 42%, 14%, 0.671) 100%);
@@ -528,6 +529,10 @@ select,
flex-direction: row; flex-direction: row;
margin: 0.1rem 0; margin: 0.1rem 0;
} }
.system-foundryvtt-reve-de-dragon .roll-dialog roll-choix roll-section subline .warning {
border-radius: 6px;
background: var(--gradient-warning);
}
.system-foundryvtt-reve-de-dragon .roll-dialog roll-choix roll-section roll-part-img { .system-foundryvtt-reve-de-dragon .roll-dialog roll-choix roll-section roll-part-img {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -655,7 +660,8 @@ select,
width: 1.5rem; width: 1.5rem;
text-align: center; text-align: center;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat {
font-family: CaslonAntique; font-family: CaslonAntique;
display: grid; display: grid;
grid-template-areas: "img header buttons" "img resume buttons" "details details details" "actions actions actions"; grid-template-areas: "img header buttons" "img resume buttons" "details details details" "actions actions actions";
@@ -663,51 +669,61 @@ select,
grid-template-rows: max-content max-content max-content max-content; grid-template-rows: max-content max-content max-content max-content;
gap: 0 0.5rem; gap: 0 0.5rem;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-img { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-img,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-img {
grid-area: img; grid-area: img;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-img img { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-img img,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-img img {
border: 0; border: 0;
max-height: 3rem; max-height: 3rem;
max-width: 3rem; max-width: 3rem;
object-fit: contain; object-fit: contain;
height: 100%; height: 100%;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-header { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-header,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-header {
grid-area: header; grid-area: header;
font-weight: bold; font-weight: bold;
font-size: 0.9rem; font-size: 0.9rem;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-resume { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-resume,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-resume {
grid-area: resume; grid-area: resume;
text-align: justify; text-align: justify;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-details { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-details,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-details {
grid-area: details; grid-area: details;
text-align: justify; text-align: justify;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-actions { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-actions,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-actions {
grid-area: actions; grid-area: actions;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-actions a { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-actions a,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-actions a {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-actions a img { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-actions a img,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-actions a img {
margin-right: 0.5rem; margin-right: 0.5rem;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-buttons { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-buttons,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-buttons {
grid-area: buttons; grid-area: buttons;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-buttons a { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-buttons a,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-buttons a {
border-radius: 0.2rem; border-radius: 0.2rem;
cursor: pointer; cursor: pointer;
padding: 0.2rem; padding: 0.2rem;
@@ -718,14 +734,17 @@ select,
display: inline-block; display: inline-block;
align-items: center; align-items: center;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-buttons a img { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-buttons a img,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-buttons a img {
max-width: 1rem; max-width: 1rem;
max-height: 1rem; max-height: 1rem;
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-buttons a:hover { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-buttons a:hover,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-buttons a:hover {
background: var(--background-custom-button-hover); background: var(--background-custom-button-hover);
} }
.system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-buttons a:active { .system-foundryvtt-reve-de-dragon .chat-message div.roll-chat div.chat-buttons a:active,
.system-foundryvtt-reve-de-dragon .dialog-content div.roll-chat div.chat-buttons a:active {
position: relative; position: relative;
top: 1px; top: 1px;
} }
@@ -1954,13 +1973,13 @@ select,
justify-content: flex-start; justify-content: flex-start;
flex-direction: column; flex-direction: column;
position: absolute; position: absolute;
top: 4.6rem; top: 10rem;
left: -19rem; left: -9rem;
} }
.system-foundryvtt-reve-de-dragon .token-hud-ext.soins { .system-foundryvtt-reve-de-dragon .token-hud-ext.soins {
flex-direction: column; flex-direction: column;
position: absolute; position: absolute;
top: 14.7rem; top: 15.5rem;
left: -6rem; left: -6rem;
max-width: 8rem; max-width: 8rem;
line-height: 1rem; line-height: 1rem;
@@ -1975,14 +1994,18 @@ select,
width: 9rem; width: 9rem;
height: fit-content; height: fit-content;
border-radius: 0.3rem; border-radius: 0.3rem;
min-width: 6rem; min-width: 8rem;
flex-basis: auto; flex-basis: auto;
padding: 0; padding: 0;
line-height: 0.95rem; line-height: 1.6rem;
margin: 0.2rem; margin: 0.2rem;
display: flex;
flex-direction: row;
align-items: center;
} }
.system-foundryvtt-reve-de-dragon .rdd-hud-menu label { .system-foundryvtt-reve-de-dragon div.control-icon.token-hud-icon select,
font-size: 0.8rem; .system-foundryvtt-reve-de-dragon div.control-icon.token-hud-icon label {
font-size: 1rem;
} }
.system-foundryvtt-reve-de-dragon .item-checkbox { .system-foundryvtt-reve-de-dragon .item-checkbox {
height: 25px; height: 25px;

View File

@@ -27,6 +27,11 @@
--gradient-red: linear-gradient(150deg, rgba(255, 0, 0, 0.3), rgba(255, 200, 128, 0.05),rgba(255, 200, 128, 0.1), rgba(255,10,0,0.3)); --gradient-red: linear-gradient(150deg, rgba(255, 0, 0, 0.3), rgba(255, 200, 128, 0.05),rgba(255, 200, 128, 0.1), rgba(255,10,0,0.3));
--gradient-violet: linear-gradient(150deg, rgba(100, 45, 124, 0.6), rgba(216, 157, 192, 0.3), rgba(177, 157, 216, 0.5), rgba(107, 62, 121, 0.3), rgba(100, 45, 124, 0.6)); --gradient-violet: linear-gradient(150deg, rgba(100, 45, 124, 0.6), rgba(216, 157, 192, 0.3), rgba(177, 157, 216, 0.5), rgba(107, 62, 121, 0.3), rgba(100, 45, 124, 0.6));
--gradient-purple-black: linear-gradient(150deg, rgba(0, 0, 0, 0.7), rgba(100, 45, 124, 0.4), rgba(82, 17, 131, 0.3),rgba(100, 45, 124, 0.4), rgba(0, 0, 0, 0.7)); --gradient-purple-black: linear-gradient(150deg, rgba(0, 0, 0, 0.7), rgba(100, 45, 124, 0.4), rgba(82, 17, 131, 0.3),rgba(100, 45, 124, 0.4), rgba(0, 0, 0, 0.7));
--gradient-warning: linear-gradient(150deg,
hsla(32, 100%, 50%, 0.3),
hsla(52, 60%, 50%, 0.1),
hsla(32, 60%, 50%, 0.1),
hsla(32, 100%, 50%, 0.3));
--gradient-silver-light: linear-gradient(30deg, rgba(61, 55, 93, 0.2), rgba(178, 179, 196, 0.1), rgba(59, 62, 63, 0.2), rgba(206, 204, 199, 0.1), rgba(61, 46, 49, 0.2)); --gradient-silver-light: linear-gradient(30deg, rgba(61, 55, 93, 0.2), rgba(178, 179, 196, 0.1), rgba(59, 62, 63, 0.2), rgba(206, 204, 199, 0.1), rgba(61, 46, 49, 0.2));
--gradient-daylight: conic-gradient( --gradient-daylight: conic-gradient(
from 0deg, from 0deg,

View File

@@ -1319,13 +1319,13 @@
justify-content: flex-start; justify-content: flex-start;
flex-direction: column; flex-direction: column;
position: absolute; position: absolute;
top: 4.6rem; top: 10rem;
left: -19rem; left: -9rem;
} }
.token-hud-ext.soins { .token-hud-ext.soins {
flex-direction: column; flex-direction: column;
position: absolute; position: absolute;
top: 14.7rem; top: 15.5rem;
left: -6rem; left: -6rem;
max-width: 8rem; max-width: 8rem;
line-height: 1rem; line-height: 1rem;
@@ -1341,14 +1341,18 @@
width: 9rem; width: 9rem;
height: fit-content; height: fit-content;
border-radius: 0.3rem; border-radius: 0.3rem;
min-width: 6rem; min-width: 8rem;
flex-basis: auto; flex-basis: auto;
padding: 0; padding: 0;
line-height: 0.95rem; line-height: 1.6rem;
margin: 0.2rem; margin: 0.2rem;
}
.rdd-hud-menu label { display: flex;
font-size: 0.8rem; flex-direction: row;
align-items: center;
select, label {
font-size: 1rem;
}
} }
/* ======================================== */ /* ======================================== */
.item-checkbox { .item-checkbox {

View File

@@ -1,87 +1,86 @@
.chat-message { .chat-message div.roll-chat,
div.roll-chat { .dialog-content div.roll-chat {
font-family: CaslonAntique; font-family: CaslonAntique;
display: grid; display: grid;
grid-template-areas: grid-template-areas:
"img header buttons" "img header buttons"
"img resume buttons" "img resume buttons"
"details details details" "details details details"
"actions actions actions"; "actions actions actions";
grid-template-columns: 3rem 1fr 1.4rem; grid-template-columns: 3rem 1fr 1.4rem;
grid-template-rows: max-content max-content max-content max-content; grid-template-rows: max-content max-content max-content max-content;
gap: 0 0.5rem; gap: 0 0.5rem;
div.chat-img { div.chat-img {
grid-area: img; grid-area: img;
display: flex;
flex-direction: column;
img {
border: 0;
max-height: 3rem;
max-width: 3rem;
object-fit: contain;
height: 100%;
}
}
div.chat-header {
grid-area: header;
font-weight: bold;
font-size: 0.9rem;
}
div.chat-resume {
grid-area: resume;
text-align: justify;
}
div.chat-details {
grid-area: details;
text-align: justify;
display: flex;
flex-direction: column;
}
div.chat-actions {
grid-area: actions;
display: flex;
flex-direction: column;
a {
display: flex; display: flex;
flex-direction: column; flex-direction: row;
img { img {
border: 0; margin-right: 0.5rem;
max-height: 3rem;
max-width: 3rem;
object-fit: contain;
height: 100%;
} }
} }
div.chat-header { }
grid-area: header;
font-weight: bold; div.chat-buttons {
font-size: 0.9rem; grid-area: buttons;
} display: flex;
div.chat-resume { flex-direction: column;
grid-area: resume;
text-align: justify; a {
} border-radius: 0.2rem;
div.chat-details { cursor: pointer;
grid-area: details; padding: 0.2rem;
text-align: justify; position: relative;
display: flex; box-shadow: inset 1x 1px #a6827e;
flex-direction: column; color: var(--color-controls);
} border: 1px ridge #846109;
div.chat-actions { display: inline-block;
grid-area: actions; align-items: center;
display: flex;
flex-direction: column; img {
a { max-width: 1rem;
display: flex; max-height: 1rem;
flex-direction: row;
img {
margin-right: 0.5rem;
}
} }
} }
div.chat-buttons { a:hover {
grid-area: buttons; background: var(--background-custom-button-hover);
display: flex;
flex-direction: column;
a {
border-radius: 0.2rem;
cursor: pointer;
padding: 0.2rem;
position: relative;
box-shadow: inset 1x 1px #a6827e;
color: var(--color-controls);
border: 1px ridge #846109;
display: inline-block;
align-items: center;
img {
max-width: 1rem;
max-height: 1rem;
}
}
a:hover {
background: var(--background-custom-button-hover);
}
a:active{
position:relative;
top:1px;
}
} }
a:active{
position:relative;
top:1px;
}
} }
} }

View File

@@ -89,8 +89,12 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
margin: 0.1rem 0; margin: 0.1rem 0;
.warning {
border-radius: 6px;
background: var(--gradient-warning);
}
} }
roll-part-img { roll-part-img {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@@ -1,4 +1,4 @@
import { SYSTEM_RDD } from "../constants.js"; import { renderTemplate, SYSTEM_RDD } from "../constants.js";
import { RdDUtility } from "../rdd-utility.js"; import { RdDUtility } from "../rdd-utility.js";
const DETAIL_VENTE = 'detailVente'; const DETAIL_VENTE = 'detailVente';

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "../constants.js";
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";
import { RdDUtility } from "../rdd-utility.js"; import { RdDUtility } from "../rdd-utility.js";
import { ChatVente } from "./chat-vente.js"; import { ChatVente } from "./chat-vente.js";

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "../constants.js";
import { HtmlUtility } from "../html-utility.js"; import { HtmlUtility } from "../html-utility.js";
import { RdDUtility } from "../rdd-utility.js"; import { RdDUtility } from "../rdd-utility.js";
import { ChatVente } from "./chat-vente.js"; import { ChatVente } from "./chat-vente.js";

View File

@@ -3,7 +3,7 @@ import { HtmlUtility } from "./html-utility.js";
import { RdDBonus } from "./rdd-bonus.js"; import { RdDBonus } from "./rdd-bonus.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDCombatManager } from "./rdd-combat.js"; import { RdDCombatManager } from "./rdd-combat.js";
import { RdDCarac } from "./rdd-carac.js"; import { CARACS, RdDCarac } from "./rdd-carac.js";
import { DialogSplitItem } from "./dialog-split-item.js"; import { DialogSplitItem } from "./dialog-split-item.js";
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js"; import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
import { RdDSheetUtility } from "./rdd-sheet-utility.js"; import { RdDSheetUtility } from "./rdd-sheet-utility.js";
@@ -174,7 +174,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
await this.getBlessure(event)?.setSoinsBlessure({ soinscomplets: { bonus: Number(event.currentTarget.value) } }) await this.getBlessure(event)?.setSoinsBlessure({ soinscomplets: { bonus: Number(event.currentTarget.value) } })
}); });
this.html.find('.roll-chance-actuelle').click(async event => await this.actor.rollCarac('chance-actuelle')) this.html.find('.roll-chance-actuelle').click(async event => await this.actor.rollCarac(CARACS.CHANCE_ACTUELLE))
this.html.find('.button-appel-chance').click(async event => await this.actor.rollAppelChance()) this.html.find('.button-appel-chance').click(async event => await this.actor.rollAppelChance())
this.html.find('[name="jet-astrologie"]').click(async event => await this.actor.astrologieNombresAstraux()) this.html.find('[name="jet-astrologie"]').click(async event => await this.actor.astrologieNombresAstraux())
@@ -208,7 +208,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
} }
// Points de reve actuel // Points de reve actuel
this.html.find('.roll-reve-actuel').click(async event => await this.actor.rollCarac('reve-actuel', { resistance: true })) this.html.find('.roll-reve-actuel').click(async event => await this.actor.rollCarac(CARACS.REVE_ACTUEL, { resistance: true }))
this.html.find('.action-empoignade').click(async event => await RdDEmpoignade.onAttaqueEmpoignadeFromItem(RdDSheetUtility.getItem(event, this.actor))) this.html.find('.action-empoignade').click(async event => await RdDEmpoignade.onAttaqueEmpoignadeFromItem(RdDSheetUtility.getItem(event, this.actor)))
this.html.find('.roll-arme').click(async event => { this.html.find('.roll-arme').click(async event => {

View File

@@ -2,6 +2,9 @@
* class providing the actor and token, and choosing the name and image from the token if available. * class providing the actor and token, and choosing the name and image from the token if available.
*/ */
export class ActorToken { export class ActorToken {
static fromTokenActor(token, actor){
return token ? ActorToken.fromToken(token) : ActorToken.fromActor(actor)
}
static fromActorId(actorId, onError = () => undefined) { static fromActorId(actorId, onError = () => undefined) {
actorId = actorId ?? (canvas.tokens.controlled.length > 0 actorId = actorId ?? (canvas.tokens.controlled.length > 0

View File

@@ -17,9 +17,9 @@ import { Draconique } from "./tmr/draconique.js";
import { CARACS, LIST_CARAC_PERSONNAGE, RdDCarac } from "./rdd-carac.js"; import { CARACS, LIST_CARAC_PERSONNAGE, RdDCarac } from "./rdd-carac.js";
import { DialogConsommer } from "./dialog-item-consommer.js"; import { DialogConsommer } from "./dialog-item-consommer.js";
import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js"; import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js";
import { RollDataAjustements } from "./rolldata-ajustements.js"; import { RollDataAjustements } from "./rolldata-ajustements-v1.js";
import { RdDPossession } from "./rdd-possession.js"; import { RdDPossession } from "./rdd-possession.js";
import { ACTOR_TYPES, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { ACTOR_TYPES, renderTemplate, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
import { RdDConfirm } from "./rdd-confirm.js"; import { RdDConfirm } from "./rdd-confirm.js";
import { DialogRepos } from "./sommeil/dialog-repos.js"; import { DialogRepos } from "./sommeil/dialog-repos.js";
import { RdDBaseActor } from "./actor/base-actor.js"; import { RdDBaseActor } from "./actor/base-actor.js";
@@ -47,6 +47,9 @@ import { RdDRollResult } from "./rdd-roll-result.js";
import { RdDInitiative } from "./initiative.mjs"; import { RdDInitiative } from "./initiative.mjs";
import RollDialog from "./roll/roll-dialog.mjs"; import RollDialog from "./roll/roll-dialog.mjs";
import { OptionsAvancees, ROLL_DIALOG_V2, ROLL_DIALOG_V2_TEST } from "./settings/options-avancees.js"; import { OptionsAvancees, ROLL_DIALOG_V2, ROLL_DIALOG_V2_TEST } from "./settings/options-avancees.js";
import { ROLL_TYPE_MEDITATION } from "./roll/roll-constants.mjs";
import { PART_TACHE } from "./roll/roll-part-tache.mjs";
import { PART_COMP } from "./roll/roll-part-comp.mjs";
export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre'] export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre']
@@ -98,6 +101,8 @@ export class RdDActor extends RdDBaseActorSang {
} }
isPersonnage() { return true } isPersonnage() { return true }
isFeminin() { return this.system.sexe.length > 0 && this.system.sexe.charAt(0).toLowerCase() == 'f' }
isHautRevant() { return this.system.attributs.hautrevant.value != "" } isHautRevant() { return this.system.attributs.hautrevant.value != "" }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -136,12 +141,12 @@ export class RdDActor extends RdDBaseActorSang {
} }
listActions({ isAttaque = false, isEquipe = false }) { listActions({ isAttaque = false, isEquipe = false }) {
// Recupération des armes // Recupération des attaques
const actions = this.listActionsAttaque() const actions = this.listActionsAttaque()
.filter(it => !isEquipe || it.arme.system.equipe) .filter(it => !isEquipe || it.arme.system.equipe)
if (!isAttaque && this.system.attributs.hautrevant.value) { if (!isAttaque && this.system.attributs.hautrevant.value) {
actions.push({ name: "Draconic", action: 'haut-reve', initOnly: true }) actions.push({ label: "Draconic", action: 'haut-reve', initOnly: true })
} }
return actions return actions
} }
@@ -177,7 +182,7 @@ export class RdDActor extends RdDBaseActorSang {
const actions = [] const actions = []
const uniques = [] const uniques = []
const addAttaque = (arme, main) => { const addAttaque = (arme, main = undefined, action = 'attaque') => {
const dommagesArme = RdDItemArme.valeurMain(arme.system.dommages, main) const dommagesArme = RdDItemArme.valeurMain(arme.system.dommages, main)
const forceRequise = RdDItemArme.valeurMain(arme.system.force ?? 0, main) const forceRequise = RdDItemArme.valeurMain(arme.system.force ?? 0, main)
const ecaillesEfficacite = arme.system.magique ? arme.system.ecaille_efficacite : 0; const ecaillesEfficacite = arme.system.magique ? arme.system.ecaille_efficacite : 0;
@@ -196,7 +201,7 @@ export class RdDActor extends RdDBaseActorSang {
const ajustement = (arme.parent?.getEtatGeneral() ?? 0) + ecaillesEfficacite const ajustement = (arme.parent?.getEtatGeneral() ?? 0) + ecaillesEfficacite
actions.push({ actions.push({
name: arme.name + (main ? ' ' + main : ''), label: arme.name + (main ? ' ' + main : ''),
action: 'attaque', action: 'attaque',
initOnly: false, initOnly: false,
arme: arme, arme: arme,
@@ -206,22 +211,23 @@ export class RdDActor extends RdDBaseActorSang {
equipe: arme.system.equipe, equipe: arme.system.equipe,
dommagesArme: dommagesArme, dommagesArme: dommagesArme,
forceRequise: forceRequise, forceRequise: forceRequise,
initiative: RdDInitiative.calculInitiative(niveau, caracValue, ajustement) initiative: RdDInitiative.getRollInitiative(caracValue, niveau, ajustement)
}) })
} }
addAttaque(RdDItemArme.empoignade(this))
addAttaque(RdDItemArme.corpsACorps(this))
this.itemTypes[ITEM_TYPES.arme] this.itemTypes[ITEM_TYPES.arme]
.filter(it => it.isAttaque()) .filter(it => it.isAttaque())
.sort(Misc.ascending(it => it.name)) .sort(Misc.ascending(it => it.name))
.forEach(arme => { .forEach(arme => {
if (arme.system.unemain && arme.system.competence) { addAttaque(arme, ATTAQUE_TYPE.UNE_MAIN) } if (arme.system.unemain && arme.system.competence && arme.system.resistance > 0) { addAttaque(arme, ATTAQUE_TYPE.UNE_MAIN) }
if (arme.system.deuxmains && arme.system.competence) { addAttaque(arme, ATTAQUE_TYPE.DEUX_MAINS) } if (arme.system.deuxmains && arme.system.competence && arme.system.resistance > 0) { addAttaque(arme, ATTAQUE_TYPE.DEUX_MAINS) }
if (arme.system.lancer) { addAttaque(arme, ATTAQUE_TYPE.LANCER) } if (arme.system.lancer && arme.system.resistance > 0) { addAttaque(arme, ATTAQUE_TYPE.LANCER) }
if (arme.system.tir) { addAttaque(arme, ATTAQUE_TYPE.TIR) } if (arme.system.tir) { addAttaque(arme, ATTAQUE_TYPE.TIR) }
}) })
addAttaque(RdDItemArme.pugilat(this), ATTAQUE_TYPE.CORPS_A_CORPS)
addAttaque(RdDItemArme.empoignade(this), ATTAQUE_TYPE.CORPS_A_CORPS, 'empoignade')
return actions return actions
} }
@@ -1342,7 +1348,7 @@ export class RdDActor extends RdDBaseActorSang {
async _apprecierCuisine(item, seForcer) { async _apprecierCuisine(item, seForcer) {
const surmonteExotisme = await this._surmonterExotisme(item, seForcer); const surmonteExotisme = await this._surmonterExotisme(item, seForcer);
if (surmonteExotisme) { if (surmonteExotisme) {
await this.apprecier('gout', 'cuisine', item.system.qualite, item.system.boisson ? "apprécie la boisson" : "apprécie le plat"); await this.apprecier(CARACS.ODORATGOUT, 'cuisine', item.system.qualite, item.system.boisson ? "apprécie la boisson" : "apprécie le plat");
} }
else if (seForcer) { else if (seForcer) {
await this.jetDeMoral('malheureux'); await this.jetDeMoral('malheureux');
@@ -1360,7 +1366,7 @@ export class RdDActor extends RdDBaseActorSang {
if (exotisme < 0 || qualite < 0) { if (exotisme < 0 || qualite < 0) {
const competence = qualite > 0 ? 'cuisine' : undefined const competence = qualite > 0 ? 'cuisine' : undefined
const difficulte = Math.min(exotisme, qualite) const difficulte = Math.min(exotisme, qualite)
const rolled = await this.doRollCaracCompetence('volonte', competence, difficulte, { title: `tente de surmonter l'exotisme de ${item.name}` }) const rolled = await this.doRollCaracCompetence(CARACS.VOLONTE, competence, difficulte, { title: `tente de surmonter l'exotisme de ${item.name}` })
return rolled.isSuccess return rolled.isSuccess
} }
return true; return true;
@@ -1922,6 +1928,20 @@ export class RdDActor extends RdDBaseActorSang {
} }
async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) { async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) {
if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
const rollData = {
ids: { actorId: this.id },
type: { allowed: [PART_COMP], current: PART_COMP },
selected: {
carac: {key: caracName },
comp: { key: compName, forced: options.forced }
}
}
RollDialog.create(rollData, options)
return
}
RdDEmpoignade.checkEmpoignadeEnCours(this) RdDEmpoignade.checkEmpoignadeEnCours(this)
const competence = this.getCompetence(compName); const competence = this.getCompetence(compName);
await this.openRollDialog({ await this.openRollDialog({
@@ -1944,23 +1964,34 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollTache(id, options = {}) { async rollTache(id, options = {}) {
RdDEmpoignade.checkEmpoignadeEnCours(this) RdDEmpoignade.checkEmpoignadeEnCours(this)
const tacheData = this.getTache(id) const tache = this.getTache(id)
const compData = this.getCompetence(tacheData.system.competence) if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
compData.system.defaut_carac = tacheData.system.carac; // Patch ! const rollData = {
ids: { actorId: this.id },
selected: { tache: { key: tache.id, forced: options.forced} },
type: { allowed: [PART_TACHE], current: PART_TACHE }
}
RollDialog.create(rollData, options)
return
}
const compData = this.getCompetence(tache.system.competence)
compData.system.defaut_carac = tache.system.carac; // Patch !
await this.openRollDialog({ await this.openRollDialog({
name: 'jet-competence', name: 'jet-competence',
label: 'Jet de Tâche ' + tacheData.name, label: 'Jet de Tâche ' + tache.name,
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.hbs', template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.hbs',
rollData: { rollData: {
competence: compData, competence: compData,
tache: tacheData, tache: tache,
diffLibre: tacheData.system.difficulte, diffLibre: tache.system.difficulte,
diffConditions: 0, diffConditions: 0,
use: { libre: false, conditions: true }, use: { libre: false, conditions: true },
carac: { carac: {
[tacheData.system.carac]: foundry.utils.duplicate(this.system.carac[tacheData.system.carac]) [tache.system.carac]: foundry.utils.duplicate(this.system.carac[tache.system.carac])
} }
}, },
callbacks: [{ action: r => this._tacheResult(r, options) }] callbacks: [{ action: r => this._tacheResult(r, options) }]
@@ -2014,6 +2045,17 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollMeditation(id) { async rollMeditation(id) {
const meditation = foundry.utils.duplicate(this.getMeditation(id)); const meditation = foundry.utils.duplicate(this.getMeditation(id));
if (meditation && OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
const rollData = {
ids: { actorId: this.id },
selected: { meditation: { key: id } },
type: { allowed: [ROLL_TYPE_MEDITATION], current: ROLL_TYPE_MEDITATION }
}
await RollDialog.create(rollData)
return
}
const competence = foundry.utils.duplicate(this.getCompetence(meditation.system.competence)); const competence = foundry.utils.duplicate(this.getCompetence(meditation.system.competence));
competence.system.defaut_carac = "intellect"; // Meditation = toujours avec intellect competence.system.defaut_carac = "intellect"; // Meditation = toujours avec intellect
let meditationData = { let meditationData = {
@@ -2414,14 +2456,17 @@ export class RdDActor extends RdDBaseActorSang {
if (!blessure.system.premierssoins.done) { if (!blessure.system.premierssoins.done) {
const tache = await this.getTacheBlessure(blesse, blessure); const tache = await this.getTacheBlessure(blesse, blessure);
return await this.rollTache(tache.id, { return await this.rollTache(tache.id, {
onRollAutomate: async r => blesse.onRollTachePremiersSoins(blessureId, r) onRollAutomate: async r => blesse.onRollTachePremiersSoins(blessureId, r),
title: 'Premiers soins',
forced: true
}); });
} }
if (!blessure.system.soinscomplets.done) { else if (!blessure.system.soinscomplets.done) {
const diff = blessure.system.difficulte + (blessure.system.premierssoins.bonus ?? 0); const diff = blessure.system.difficulte + (blessure.system.premierssoins.bonus ?? 0);
return await this.rollCaracCompetence("dexterite", "Chirurgie", diff, { return await this.rollCaracCompetence(CARACS.DEXTERITE, "Chirurgie", diff, {
title: "Soins complets", title: "Soins complets",
onRollAutomate: r => blesse.onRollSoinsComplets(blessureId, r) onRollAutomate: r => blesse.onRollSoinsComplets(blessureId, r),
forced: true
}) })
} }
} }
@@ -2436,6 +2481,7 @@ export class RdDActor extends RdDBaseActorSang {
}) })
} }
const blessure = this.getItem(blessureId, 'blessure') const blessure = this.getItem(blessureId, 'blessure')
if (blessure && !blessure.system.premierssoins.done) { if (blessure && !blessure.system.premierssoins.done) {
const tache = rollData.tache; const tache = rollData.tache;
if (rollData.rolled.isETotal) { if (rollData.rolled.isETotal) {
@@ -2916,7 +2962,9 @@ export class RdDActor extends RdDBaseActorSang {
break break
case ITEM_TYPES.race: case ITEM_TYPES.race:
await this.onCreateOwnedRace(item, options, id) await this.onCreateOwnedRace(item, options, id)
break
} }
await super.onCreateItem(item, options, id)
await item.onCreateItemTemporel(this); await item.onCreateItemTemporel(this);
await item.onCreateDecoupeComestible(this); await item.onCreateDecoupeComestible(this);
} }
@@ -3062,12 +3110,7 @@ export class RdDActor extends RdDBaseActorSang {
actorId: this.id actorId: this.id
} }
} }
await RollDialog.create(rollData, { await RollDialog.create(rollData, { onRollDone: RollDialog.onRollDoneClose })
onRollDone: (dialog) => {
if (!OptionsAvancees.isUsing(ROLL_DIALOG_V2_TEST))
dialog.close()
}
})
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@@ -1,4 +1,4 @@
import { ENTITE_INCARNE, SHOW_DICE, SYSTEM_RDD } from "../constants.js"; import { ENTITE_INCARNE, renderTemplate, SHOW_DICE, SYSTEM_RDD } from "../constants.js";
import { Grammar } from "../grammar.js"; import { Grammar } from "../grammar.js";
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";
import { RdDResolutionTable } from "../rdd-resolution-table.js"; import { RdDResolutionTable } from "../rdd-resolution-table.js";
@@ -11,7 +11,7 @@ import { ITEM_TYPES } from "../constants.js";
import { StatusEffects, STATUSES } from "../settings/status-effects.js"; import { StatusEffects, STATUSES } from "../settings/status-effects.js";
import { Targets } from "../targets.js"; import { Targets } from "../targets.js";
import { RdDConfirm } from "../rdd-confirm.js"; import { RdDConfirm } from "../rdd-confirm.js";
import { RdDCarac } from "../rdd-carac.js"; import { CARACS, RdDCarac } from "../rdd-carac.js";
import { RdDRollResult } from "../rdd-roll-result.js"; import { RdDRollResult } from "../rdd-roll-result.js";
import { RdDItemArme } from "../item/arme.js"; import { RdDItemArme } from "../item/arme.js";
@@ -23,8 +23,12 @@ import { RdDCombat } from "../rdd-combat.js";
import { RdDEmpoignade } from "../rdd-empoignade.js"; import { RdDEmpoignade } from "../rdd-empoignade.js";
import { RdDPossession } from "../rdd-possession.js"; import { RdDPossession } from "../rdd-possession.js";
import { BASE_CORPS_A_CORPS, BASE_ESQUIVE, POSSESSION_SANS_DRACONIC } from "../item/base-items.js"; import { BASE_CORPS_A_CORPS, BASE_ESQUIVE, POSSESSION_SANS_DRACONIC } from "../item/base-items.js";
import { RollDataAjustements } from "../rolldata-ajustements.js"; import { RollDataAjustements } from "../rolldata-ajustements-v1.js";
import { MappingCreatureArme } from "../item/mapping-creature-arme.mjs"; import { MappingCreatureArme } from "../item/mapping-creature-arme.mjs";
import RollDialog from "../roll/roll-dialog.mjs";
import { ATTAQUE_ROLL_TYPES, DEFAULT_ROLL_TYPES, DIFF, ROLL_TYPE_ATTAQUE, ROLL_TYPE_COMP, ROLL_TYPE_JEU, ROLL_TYPE_MEDITATION, ROLL_TYPE_OEUVRE, ROLL_TYPE_TACHE } from "../roll/roll-constants.mjs";
import { OptionsAvancees, ROLL_DIALOG_V2 } from "../settings/options-avancees.js";
import { PART_COMP } from "../roll/roll-part-comp.mjs";
/** /**
* Classe de base pour les acteurs disposant de rêve (donc, pas des objets) * Classe de base pour les acteurs disposant de rêve (donc, pas des objets)
@@ -377,9 +381,22 @@ export class RdDBaseActorReve extends RdDBaseActor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollCarac(caracName, options = {}) { async rollCarac(caracName, options = {}) {
if (Grammar.equalsInsensitive(caracName, 'taille')) { if (Grammar.equalsInsensitive(caracName, CARACS.TAILLE)) {
return return
} }
if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
const rollData = {
ids: { actorId: this.id },
type: { allowed: [PART_COMP], current: PART_COMP },
selected: {
carac: { key: caracName },
comp: options.resistance ? { key: undefined, forced: true } : undefined
}
}
RollDialog.create(rollData, options)
return
}
foundry.utils.mergeObject(options, { resistance: false, diff: 0 }, { overwrite: false }) foundry.utils.mergeObject(options, { resistance: false, diff: 0 }, { overwrite: false })
RdDEmpoignade.checkEmpoignadeEnCours(this) RdDEmpoignade.checkEmpoignadeEnCours(this)
let selectedCarac = this.getCaracByName(caracName) let selectedCarac = this.getCaracByName(caracName)
@@ -407,9 +424,33 @@ export class RdDBaseActorReve extends RdDBaseActor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollCompetenceV2(rollData) {
rollData.ids = rollData?.ids ?? {}
rollData.type = rollData.type ?? { allowed: DEFAULT_ROLL_TYPES }
rollData.ids.actorId = this.id
await RollDialog.create(rollData)
}
async rollCompetence(idOrName, options = { tryTarget: true, arme: undefined }) { async rollCompetence(idOrName, options = { tryTarget: true, arme: undefined }) {
RdDEmpoignade.checkEmpoignadeEnCours(this) RdDEmpoignade.checkEmpoignadeEnCours(this)
const competence = this.getCompetence(idOrName); const competence = this.getCompetence(idOrName);
if (competence.type != ITEM_TYPES.competencecreature && OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
const rollData = {
selected: {
comp: { key: competence.name },
diff: { type: DIFF.LIBRE, value: competence.system.default_diffLibre ?? 0 }
}
}
if (options.arme) {
rollData.selected.attaque = { arme: { id: options.arme.id }, comp: { id: competence.id } }
rollData.type = { allowed: ATTAQUE_ROLL_TYPES }
}
await this.rollCompetenceV2(rollData)
return
}
let rollData = { let rollData = {
carac: this.system.carac, carac: this.system.carac,
competence: competence, competence: competence,
@@ -427,7 +468,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
RdDCombat.rddCombatTarget(target, this, token).attaque(competence, arme) RdDCombat.rddCombatTarget(target, this, token).attaque(competence, arme)
} }
}); });
return; return
} }
// Transformer la competence de créature // Transformer la competence de créature
MappingCreatureArme.setRollDataCreature(rollData) MappingCreatureArme.setRollDataCreature(rollData)
@@ -449,6 +490,46 @@ export class RdDBaseActorReve extends RdDBaseActor {
} }
} }
rollAttaque(token) {
token = token ?? RdDUtility.getSelectedToken(this)
if (Targets.hasTargets()) {
Targets.selectOneTargetToken(target => {
if (Targets.isTargetEntite(target)) {
ui.notifications.warn(`Vous ne pouvez pas attaquer une entité non incarnée!!!!`)
return
}
RdDCombat.rddCombatTarget(target, this, token).attaqueV2();
})
}
else {
return RdDConfirm.confirmer({
settingConfirmer: "confirmer-combat-sans-cible",
content: `<p>Voulez vous faire une attaque sans choisir de cible valide?
<br>Tous les jets de combats devront être gérés à la main
</p>`,
title: 'Ne pas utiliser les automatisation de combat',
buttonLabel: "Pas d'automatisation",
onAction: async () => {
this.rollCompetenceV2({
ids: {
actorId: this.id,
actorTokenId: token?.id,
},
selected: {
conditions: { value: 0 }
},
type: {
allowed: [ROLL_TYPE_COMP, ROLL_TYPE_ATTAQUE, ROLL_TYPE_OEUVRE, ROLL_TYPE_TACHE, ROLL_TYPE_JEU],
current: ROLL_TYPE_COMP
}
})
}
})
}
}
/** -------------------------------------------- /** --------------------------------------------
* @param {*} arme item d'arme/compétence de créature * @param {*} arme item d'arme/compétence de créature
* @param {*} categorieArme catégorie d'attaque à utiliser: competence (== melee), lancer, tir; naturelle, possession * @param {*} categorieArme catégorie d'attaque à utiliser: competence (== melee), lancer, tir; naturelle, possession

View File

@@ -34,17 +34,17 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
getFatigueActuelle() { getFatigueActuelle() {
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) { if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
return Math.max(0, Math.min(this.getFatigueMax(), Misc.toInt(this.system.sante.fatigue?.value))) return Math.max(0, Math.min(this.getFatigueMax(), Misc.toInt(this.system.sante.fatigue?.value)))
} }
return 0; return 0;
} }
isCumulFatigueCauseSommeil(cumulFatigue){ isCumulFatigueCauseSommeil(cumulFatigue) {
return ReglesOptionnelles.isUsing("appliquer-fatigue") return ReglesOptionnelles.isUsing("appliquer-fatigue")
? (this.getFatigueRestante() <= cumulFatigue) ? (this.getFatigueRestante() <= cumulFatigue)
: (this.getEnduranceActuelle() <= cumulFatigue) : (this.getEnduranceActuelle() <= cumulFatigue)
} }
getFatigueRestante() {return this.getFatigueMax() - this.getFatigueActuelle() } getFatigueRestante() { return this.getFatigueMax() - this.getFatigueActuelle() }
getFatigueMin() { return this.system.sante.endurance.max - this.system.sante.endurance.value } getFatigueMin() { return this.system.sante.endurance.max - this.system.sante.endurance.value }
malusFatigue() { malusFatigue() {
@@ -161,7 +161,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
if (ReglesOptionnelles.isUsing("appliquer-fatigue") && sante.fatigue && fatigue > 0) { if (ReglesOptionnelles.isUsing("appliquer-fatigue") && sante.fatigue && fatigue > 0) {
sante.fatigue.value = Math.max(sante.fatigue.value + fatigue, this.getFatigueMin()); sante.fatigue.value = Math.max(sante.fatigue.value + fatigue, this.getFatigueMin());
} }
await this.update({ "system.sante": sante }) await this.update({ "system.sante": sante }, { render: true })
if (this.isDead()) { if (this.isDead()) {
await this.setEffect(STATUSES.StatusComma, true); await this.setEffect(STATUSES.StatusComma, true);
} }
@@ -195,7 +195,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
const endActuelle = this.getEnduranceActuelle(); const endActuelle = this.getEnduranceActuelle();
const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg?.loc.label ?? '', attackerToken); const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg?.loc.label ?? '', attackerToken);
if (blessure.isCritique()) { if (blessure.isCritique()) {
encaissement.endurance = endActuelle; encaissement.endurance = endActuelle
} }
if (blessure.isMort()) { if (blessure.isMort()) {

View File

@@ -56,10 +56,8 @@ export class RdDBaseActorSheet extends foundry.appv1.sheets.ActorSheet {
this._appliquerRechercheObjets(formData.conteneurs, formData.inventaires); this._appliquerRechercheObjets(formData.conteneurs, formData.inventaires);
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs); formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
formData.competences.filter(it => it.type == ITEM_TYPES.competencecreature) formData.competences.filter(it => it.type == ITEM_TYPES.competencecreature)
.forEach(it => { .forEach(it => it.isdommages = it.isDommages()
const competenceCreature = new RdDItemCompetenceCreature(it.toObject(), { parent: it.parent }); )
it.isdommages = competenceCreature.isDommages();
})
return formData; return formData;
} }

View File

@@ -1,6 +1,6 @@
import { ChatVente } from "../achat-vente/chat-vente.js"; import { ChatVente } from "../achat-vente/chat-vente.js";
import { ChatUtility } from "../chat-utility.js"; import { ChatUtility } from "../chat-utility.js";
import { SYSTEM_SOCKET_ID } from "../constants.js"; import { renderTemplate, SYSTEM_SOCKET_ID } from "../constants.js";
import { Grammar } from "../grammar.js"; import { Grammar } from "../grammar.js";
import { Monnaie } from "../item-monnaie.js"; import { Monnaie } from "../item-monnaie.js";
import { ITEM_TYPES } from "../constants.js"; import { ITEM_TYPES } from "../constants.js";
@@ -10,6 +10,7 @@ import { RdDConfirm } from "../rdd-confirm.js";
import { RdDUtility } from "../rdd-utility.js"; import { RdDUtility } from "../rdd-utility.js";
import { SystemCompendiums } from "../settings/system-compendiums.js"; import { SystemCompendiums } from "../settings/system-compendiums.js";
import { RdDItem } from "../item.js"; import { RdDItem } from "../item.js";
import { STATUSES } from "../settings/status-effects.js";
export class RdDBaseActor extends Actor { export class RdDBaseActor extends Actor {
@@ -45,8 +46,10 @@ export class RdDBaseActor extends Actor {
} }
static init() { static init() {
Handlebars.registerHelper('actor-isFeminin', actor => actor.isFeminin())
Hooks.on("preUpdateItem", (item, change, options, id) => Misc.documentIfResponsible(item.parent)?.onPreUpdateItem(item, change, options, id)) Hooks.on("preUpdateItem", (item, change, options, id) => Misc.documentIfResponsible(item.parent)?.onPreUpdateItem(item, change, options, id))
Hooks.on("createItem", (item, options, id) => Misc.documentIfResponsible(item.parent)?.onCreateItem(item, options, id)) Hooks.on("createItem", (item, options, id) => Misc.documentIfResponsible(item.parent)?.onCreateItem(item, options, id))
Hooks.on("updateItem", (item, options, id) => Misc.documentIfResponsible(item.parent)?.onUpdateItem(item, options, id))
Hooks.on("deleteItem", (item, options, id) => Misc.documentIfResponsible(item.parent)?.onDeleteItem(item, options, id)) Hooks.on("deleteItem", (item, options, id) => Misc.documentIfResponsible(item.parent)?.onDeleteItem(item, options, id))
Hooks.on("updateActor", (actor, change, options, actorId) => Misc.documentIfResponsible(actor)?.onUpdateActor(change, options, actorId)) Hooks.on("updateActor", (actor, change, options, actorId) => Misc.documentIfResponsible(actor)?.onUpdateActor(change, options, actorId))
} }
@@ -218,6 +221,7 @@ export class RdDBaseActor extends Actor {
isHautRevant() { return false } isHautRevant() { return false }
isVehicule() { return false } isVehicule() { return false }
isPersonnage() { return false } isPersonnage() { return false }
isFeminin() { return false }
getItem(id, type = undefined) { getItem(id, type = undefined) {
const item = this.items.get(id); const item = this.items.get(id);
if (type == undefined || (item?.type == type)) { if (type == undefined || (item?.type == type)) {
@@ -243,7 +247,28 @@ export class RdDBaseActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async onPreUpdateItem(item, change, options, id) { } async onPreUpdateItem(item, change, options, id) { }
async onCreateItem(item, options, id) { }
async onCreateItem(item, options, id) {
switch (item.type) {
case ITEM_TYPES.blessure:
await this.changeBleedingState()
break
}
}
async onUpdateItem(item, options, id) {
switch (item.type) {
case ITEM_TYPES.blessure:
await this.changeBleedingState()
break
}
}
async changeBleedingState() {
const bleeding = this.itemTypes[ITEM_TYPES.blessure].find(it => it.isBleeding())
await this.setEffect(STATUSES.StatusBleeding, bleeding ? true : false)
}
async onUpdateActor(update, options, actorId) { } async onUpdateActor(update, options, actorId) { }
async onDeleteItem(item, options, id) { async onDeleteItem(item, options, id) {
if (item.isInventaire()) { if (item.isInventaire()) {
@@ -738,7 +763,7 @@ export class RdDBaseActor extends Actor {
name: this.getAlias(), name: this.getAlias(),
system: { description: this.system.description } system: { description: this.system.description }
} }
foundry.applications.handlebars.renderTemplate('systems/foundryvtt-reve-de-dragon/templates/post-actor.hbs', chatData) renderTemplate('systems/foundryvtt-reve-de-dragon/templates/post-actor.hbs', chatData)
.then(html => ChatMessage.create(RdDUtility.chatDataSetup(html, modeOverride))); .then(html => ChatMessage.create(RdDUtility.chatDataSetup(html, modeOverride)));
} }
@@ -769,11 +794,15 @@ export class RdDBaseActor extends Actor {
return this.itemTypes[ITEM_TYPES.possession] return this.itemTypes[ITEM_TYPES.possession]
.map(p => { .map(p => {
return { return {
name: p.name, label: p.name,
action: 'possession', action: 'possession',
possessionid: p.system.possessionid, possessionid: p.system.possessionid,
} }
}) })
} }
listActionsCombat() {
const possessions = this.listActionsPossessions()
return possessions.length > 0 ? possessions : this.listActions({})
}
} }

View File

@@ -1,5 +1,5 @@
import { Grammar } from "../../grammar.js" import { Grammar } from "../../grammar.js"
import { RdDItemArme } from "../../item/arme.js" import { EMPOIGNADE, RdDItemArme } from "../../item/arme.js"
import { RdDItemCompetence } from "../../item-competence.js" import { RdDItemCompetence } from "../../item-competence.js"
import { RdDItemSort } from "../../item-sort.js" import { RdDItemSort } from "../../item-sort.js"
import { ITEM_TYPES } from "../../constants.js" import { ITEM_TYPES } from "../../constants.js"
@@ -141,7 +141,7 @@ export class Mapping {
static prepareArmes(actor) { static prepareArmes(actor) {
const armes = actor.items.filter(it => it.type == ITEM_TYPES.arme) const armes = actor.items.filter(it => it.type == ITEM_TYPES.arme)
armes.push(RdDItemArme.corpsACorps(actor)); armes.push(RdDItemArme.pugilat(actor));
armes.push(RdDItemArme.empoignade(actor)); armes.push(RdDItemArme.empoignade(actor));
return armes.map(arme => [ return armes.map(arme => [
arme.system.unemain ? Mapping.prepareArme(actor, arme, '(1 main)') : undefined, arme.system.unemain ? Mapping.prepareArme(actor, arme, '(1 main)') : undefined,
@@ -175,7 +175,7 @@ export class Mapping {
const dommages = Misc.toSignedString(dmgArme + RdDBonus.bonusDmg(actor, maniement, dmgArme)) const dommages = Misc.toSignedString(dmgArme + RdDBonus.bonusDmg(actor, maniement, dmgArme))
switch (arme.system.mortalite) { switch (arme.system.mortalite) {
case 'non-mortel': return `(${dommages})` case 'non-mortel': return `(${dommages})`
case 'empoignade': return '-' case EMPOIGNADE: return '-'
} }
return dommages return dommages
} }
@@ -274,11 +274,10 @@ export class Mapping {
} }
static getDescription(actor) { static getDescription(actor) {
const sexe = actor.system.sexe const naissance = actor.isFeminin() ? 'née' : 'né'
const sexeFeminin = sexe.length > 0 && sexe.charAt(0).toLowerCase() == 'f' ? 'Née' : 'Né'
const race = ['', 'humain'].includes(Grammar.toLowerCaseNoAccent(actor.system.race)) ? '' : (actor.system.race + ' ') const race = ['', 'humain'].includes(Grammar.toLowerCaseNoAccent(actor.system.race)) ? '' : (actor.system.race + ' ')
const heure = actor.system.heure const heure = actor.system.heure
const hn = `${sexeFeminin} à l'heure ${RdDTimestamp.definition(heure).avecArticle}` const hn = `${naissance} à l'heure ${RdDTimestamp.definition(heure).avecArticle}`
const age = (actor.system.age && actor.system.age >0) ? `${actor.system.age} ans` : undefined const age = (actor.system.age && actor.system.age >0) ? `${actor.system.age} ans` : undefined
const taille = actor.system.taille const taille = actor.system.taille
const poids = actor.system.poids const poids = actor.system.poids

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "../../constants.js";
export class TextRollManager { export class TextRollManager {

View File

@@ -1,5 +1,5 @@
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { renderTemplate, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
import { RdDTimestamp } from "./time/rdd-timestamp.js"; import { RdDTimestamp } from "./time/rdd-timestamp.js";
import { RdDTextEditor } from "./apps/rdd-text-roll-editor.js"; import { RdDTextEditor } from "./apps/rdd-text-roll-editor.js";
@@ -190,7 +190,7 @@ export class ChatUtility {
if (rddTimestamp) { if (rddTimestamp) {
const timestamp = new RdDTimestamp(rddTimestamp); const timestamp = new RdDTimestamp(rddTimestamp);
const timestampData = timestamp.toCalendrier(); const timestampData = timestamp.toCalendrier();
const dateHeure = await foundry.applications.handlebars.renderTemplate('systems/foundryvtt-reve-de-dragon/templates/common/date-heure.hbs', timestampData); const dateHeure = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/common/date-heure.hbs', timestampData);
$(html).find('header.message-header .message-sender').after(dateHeure) $(html).find('header.message-header .message-sender').after(dateHeure)
} }
} }

View File

@@ -1,5 +1,6 @@
import { RdDBaseActor } from "../actor/base-actor.js"; import { RdDBaseActor } from "../actor/base-actor.js";
import { ChatUtility } from "../chat-utility.js"; import { ChatUtility } from "../chat-utility.js";
import { renderTemplate } from "../constants.js";
const INFO_COEUR = 'info-coeur'; const INFO_COEUR = 'info-coeur';

View File

@@ -9,17 +9,19 @@ export const ENTITE_INCARNE = 'incarne'
export const ENTITE_NONINCARNE = 'nonincarne' export const ENTITE_NONINCARNE = 'nonincarne'
export const ENTITE_BLURETTE = 'blurette' export const ENTITE_BLURETTE = 'blurette'
export const renderTemplate = foundry.applications.handlebars.renderTemplate
export const RDD_CONFIG = { export const RDD_CONFIG = {
niveauEthylisme : [ niveauEthylisme: [
{value: "1", label: "Aucun"}, { value: "1", label: "Aucun" },
{value: "0", label: "Eméché (0)"}, { value: "0", label: "Eméché (0)" },
{value: "-1", label: "Gris (-1)"}, { value: "-1", label: "Gris (-1)" },
{value: "-2", label: "Pinté (-2)"}, { value: "-2", label: "Pinté (-2)" },
{value: "-3", label: "Pas Frais (-3)"}, { value: "-3", label: "Pas Frais (-3)" },
{value: "-4", label: "Ivre (-4)"}, { value: "-4", label: "Ivre (-4)" },
{value: "-5", label: "Bu (-5)"}, { value: "-5", label: "Bu (-5)" },
{value: "-6", label: "Complètement fait (-6)"}, { value: "-6", label: "Complètement fait (-6)" },
{value: "-7", label: "Ivre mort (-7)"} { value: "-7", label: "Ivre mort (-7)" }
], ],
categorieEntite: { categorieEntite: {
"cauchemar": "Cauchemar", "cauchemar": "Cauchemar",
@@ -30,28 +32,34 @@ export const RDD_CONFIG = {
"nonincarne": "Non Incarnée", "nonincarne": "Non Incarnée",
"blurette": "Blurette" "blurette": "Blurette"
}, },
heuresRdD : [ heuresRdD: [
{value : "vaisseau", label: "Vaisseau", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd01.webp"}, { value: "vaisseau", label: "Vaisseau", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd01.webp" },
{value : "sirene", label: "Sirène", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd02.webp"}, { value: "sirene", label: "Sirène", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd02.webp" },
{value : "faucon", label: "Faucon", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd03.webp"}, { value: "faucon", label: "Faucon", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd03.webp" },
{value : "couronne", label: "Couronne", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd04.webp"}, { value: "couronne", label: "Couronne", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd04.webp" },
{value : "dragon", label: "Dragon", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd05.webp"}, { value: "dragon", label: "Dragon", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd05.webp" },
{value : "epees", label: "Epées", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd06.webp"}, { value: "epees", label: "Epées", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd06.webp" },
{value : "lyre", label: "Lyre", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd07.webp"}, { value: "lyre", label: "Lyre", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd07.webp" },
{value : "serpent", label: "Serpent", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd08.webp"}, { value: "serpent", label: "Serpent", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd08.webp" },
{value : "poissonacrobate", label: "Poisson Acrobate", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd09.webp"}, { value: "poissonacrobate", label: "Poisson Acrobate", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd09.webp" },
{value : "araignee", label: "Araignée", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd10.webp"}, { value: "araignee", label: "Araignée", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd10.webp" },
{value : "roseau", label: "Roseau", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd11.webp"}, { value: "roseau", label: "Roseau", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd11.webp" },
{value : "chateaudormant", label: "Chateau Dormant", img: "modules/foundryvtt-reve-de-dragon/icons/heures/hd12.webp"} { value: "chateaudormant", label: "Chateau Dormant", img: "systems/foundryvtt-reve-de-dragon/icons/heures/hd12.webp" }
], ],
raretes: [ raretes: [
{value: "Commune", label: "Commune"}, { value: "Commune", label: "Commune" },
{value: "Frequente", label: "Fréquente"}, { value: "Frequente", label: "Fréquente" },
{value: "Rare", label: "Rare"}, { value: "Rare", label: "Rare" },
{value: "Rarissime", label: "Rarissime"} { value: "Rarissime", label: "Rarissime" }
] ],
particuliere: {
force: { key: 'force', descr: 'en force', img: 'systems/foundryvtt-reve-de-dragon/assets/ui/part-force.svg'},
finesse: { key: 'finesse', descr: 'en finesse', img: 'systems/foundryvtt-reve-de-dragon/assets/ui/part-finesse.svg'},
rapidite: { key: 'finesse', descr: 'en rapidité', img: 'systems/foundryvtt-reve-de-dragon/assets/ui/part-rapidite.svg'},
}
} }
export const ACTOR_TYPES = { export const ACTOR_TYPES = {
personnage: 'personnage', personnage: 'personnage',
creature: 'creature', creature: 'creature',
@@ -107,13 +115,3 @@ export const ITEM_TYPES = {
extraitpoetique: 'extraitpoetique', extraitpoetique: 'extraitpoetique',
} }
export const CATEGORIES_COMPETENCES = {
"generale": { base: -4, label: "Générales" },
"particuliere": { base: -8, label: "Particulières" },
"specialisee": { base: -11, label: "Spécialisées" },
"connaissance": { base: -11, label: "Connaissances" },
"draconic": { base: -11, label: "Draconic" },
"melee": { base: -6, label: "Mêlée" },
"tir": { base: -8, label: "Tir" },
"lancer": { base: -8, label: "Lancer" }
}

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "./constants.js"
export class DialogChoixXpCarac extends Dialog { export class DialogChoixXpCarac extends Dialog {

View File

@@ -1,4 +1,4 @@
import { SYSTEM_RDD } from "./constants.js"; import { renderTemplate, SYSTEM_RDD } from "./constants.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { HtmlUtility } from "./html-utility.js"; import { HtmlUtility } from "./html-utility.js";
import { RdDTimestamp } from "./time/rdd-timestamp.js"; import { RdDTimestamp } from "./time/rdd-timestamp.js";

View File

@@ -1,4 +1,5 @@
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { renderTemplate } from "./constants.js";
import { HtmlUtility } from "./html-utility.js"; import { HtmlUtility } from "./html-utility.js";
import { RdDItemSigneDraconique } from "./item/signedraconique.js"; import { RdDItemSigneDraconique } from "./item/signedraconique.js";
import { TMRUtility } from "./tmr-utility.js"; import { TMRUtility } from "./tmr-utility.js";

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "./constants.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "./constants.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
export class DialogConsommer extends Dialog { export class DialogConsommer extends Dialog {

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "./constants.js"
export class DialogSelect extends Dialog { export class DialogSelect extends Dialog {
static extractIdNameImg(it) { return { id: it.id, name: it.name, img: it.img } } static extractIdNameImg(it) { return { id: it.id, name: it.name, img: it.img } }

View File

@@ -1,4 +1,4 @@
import { Misc } from "./misc.js"; import { renderTemplate } from "./constants.js";
export class DialogSplitItem extends Dialog { export class DialogSplitItem extends Dialog {

View File

@@ -1,4 +1,4 @@
import { HIDE_DICE, SHOW_DICE } from "./constants.js"; import { HIDE_DICE, renderTemplate, SHOW_DICE } from "./constants.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
/** /**

View File

@@ -1,4 +1,4 @@
import { ITEM_TYPES } from "../constants.js" import { ITEM_TYPES, renderTemplate } from "../constants.js"
import { RdDItemSort } from "../item-sort.js" import { RdDItemSort } from "../item-sort.js"
import { Misc } from "../misc.js" import { Misc } from "../misc.js"

View File

@@ -1,7 +1,65 @@
export const MAP_PHASE = {
possession: { label: "possession", rang: 10 },
draconic: { label: "draconic", rang: 9 },
tir: { label: "tir", rang: 8 },
lancer: { label: "lancer", rang: 7 },
arme: { label: "mêlée", rang: 5 },
pugilat: { label: "pugilat", rang: 4 },
naturelle: { label: "créature", rang: 4 },
empoignade: { label: "empoignade", rang: 3 },
autre: { label: "autre action", rang: 2 },
demi: { label: "demi-surprise", rang: 0 },
totale: { label: "surprise totale", rang: -1 },
}
export const PHASE = Object.values(MAP_PHASE)
export class RdDInitiative { export class RdDInitiative {
static calculInitiative(niveau, caracValue, bonus = 0) { static getRollInitiative(caracValue, niveau, bonus = 0) {
let base = niveau + Math.floor(caracValue / 2) + bonus; const base = RdDInitiative.ajustementInitiative(caracValue, niveau, bonus)
return "1d6" + (base >= 0 ? "+" : "") + base; return "1d6" + (base >= 0 ? "+" : "") + base
}
static ajustementInitiative(caracValue, niveau, bonus) {
return niveau + Math.floor(caracValue / 2) + bonus
}
static formule(phase, carac, niveau, bonusMalus) {
const ajustement = RdDInitiative.ajustementInitiative(carac, niveau, bonusMalus)
return { phase, ajustement }
}
static phaseArme(categorie, arme) {
switch (categorie) {
case "tir":
case "lancer":
return MAP_PHASE[categorie]
default:
switch (arme.system.cac) {
case "empoignade":
case "pugilat":
case "naturelle":
return MAP_PHASE[arme.system.cac]
default:
return MAP_PHASE['arme']
}
}
}
static phase(keyOrRang) {
return MAP_PHASE[keyOrRang] ?? PHASE.find(it => it.rang == keyOrRang) ?? MAP_PHASE.autre
}
static async roll(formule) {
const sign = formule.ajustement >= 0 ? "+" : ""
const roll = new Roll(`1d6 + ${sign} + ${formule.ajustement}`)
await roll.evaluate()
const value = Math.max(roll.total, 0)
return {
roll: roll,
value: value,
init: formule.phase.rang + value / 100,
label: formule.phase.label
}
} }
} }

View File

@@ -10,15 +10,15 @@ export class RdDItemCompetenceCreature extends RdDItem {
static get defaultIcon() { return "systems/foundryvtt-reve-de-dragon/icons/competence_defaut.webp" } static get defaultIcon() { return "systems/foundryvtt-reve-de-dragon/icons/competence_defaut.webp" }
isAttaque() { return this.getCategorieAttaque() != undefined }
isParade() { return this.system.iscombat && (this.system.categorie_parade ?? '') != '' } isParade() { return this.system.iscombat && (this.system.categorie_parade ?? '') != '' }
isBouclier() { return this.system.categorie_parade.includes('bouclier') } isBouclier() { return this.system.categorie_parade.includes('bouclier') }
attaqueCreature() { attaqueCreature() {
const categorieAttaque = this.getCategorieAttaque() const categorieAttaque = this.getCategorieAttaque()
if (categorieAttaque != undefined) { if (categorieAttaque != undefined) {
const initative = RdDInitiative.calculInitiative(this.system.niveau, this.system.carac_value); const initative = RdDInitiative.getRollInitiative(this.system.carac_value, this.system.niveau);
const attaque = { const attaque = {
name: this.name, label: this.name,
action: this.isCompetencePossession() ? 'possession' : 'attaque', action: this.isCompetencePossession() ? 'possession' : 'attaque',
initOnly: false, initOnly: false,
arme: new RdDItemArme({ arme: new RdDItemArme({
@@ -51,10 +51,6 @@ export class RdDItemCompetenceCreature extends RdDItem {
return undefined; return undefined;
} }
isAttaque() {
return this.getCategorieAttaque() != undefined
}
getCategorieAttaque() { getCategorieAttaque() {
switch (this.system.categorie) { switch (this.system.categorie) {
case "melee": case "melee":

View File

@@ -1,4 +1,4 @@
import { ITEM_TYPES } from "./constants.js"; import { ITEM_TYPES, renderTemplate } from "./constants.js";
import { BASE_CORPS_A_CORPS, BASE_ESQUIVE, CATEGORIES_COMPETENCES, CATEGORIES_COMPETENCES_CREATURES } from "./item/base-items.js"; import { BASE_CORPS_A_CORPS, BASE_ESQUIVE, CATEGORIES_COMPETENCES, CATEGORIES_COMPETENCES_CREATURES } from "./item/base-items.js";
import { ITEM_ACTIONS, DEFAULT_ACTIONS, COMMON_ACTIONS } from "./item/item-actions.js"; import { ITEM_ACTIONS, DEFAULT_ACTIONS, COMMON_ACTIONS } from "./item/item-actions.js";

View File

@@ -4,6 +4,7 @@ import { BASE_CORPS_A_CORPS } from "./base-items.js";
import { Grammar } from "../grammar.js"; import { Grammar } from "../grammar.js";
import { RdDInitiative } from "../initiative.mjs"; import { RdDInitiative } from "../initiative.mjs";
import { MappingCreatureArme } from "./mapping-creature-arme.mjs"; import { MappingCreatureArme } from "./mapping-creature-arme.mjs";
import { Misc } from "../misc.js";
const nomCategorieParade = { const nomCategorieParade = {
"sans-armes": "Sans arme", "sans-armes": "Sans arme",
@@ -21,11 +22,16 @@ const nomCategorieParade = {
export const ATTAQUE_TYPE = { export const ATTAQUE_TYPE = {
UNE_MAIN: '(1 main)', UNE_MAIN: '(1 main)',
DEUX_MAINS: '(2 mains)', DEUX_MAINS: '(2 mains)',
CORPS_A_CORPS: '(corps à corps)',
COMPETENCE: 'competence', COMPETENCE: 'competence',
TIR: '(tir)', TIR: '(tir)',
LANCER: '(lancer)' LANCER: '(lancer)'
} }
export const CORPS_A_CORPS = 'Corps à corps'
export const PUGILAT = 'pugilat'
export const EMPOIGNADE = 'empoignade'
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDItemArme extends RdDItem { export class RdDItemArme extends RdDItem {
@@ -62,7 +68,7 @@ export class RdDItemArme extends RdDItem {
case ITEM_TYPES.competencecreature: case ITEM_TYPES.competencecreature:
return MappingCreatureArme.armeCreature(arme); return MappingCreatureArme.armeCreature(arme);
} }
return RdDItemArme.corpsACorps(); return RdDItemArme.pugilat();
} }
static getCompetenceArme(arme, maniement) { static getCompetenceArme(arme, maniement) {
@@ -76,6 +82,7 @@ export class RdDItemArme extends RdDItem {
case ATTAQUE_TYPE.DEUX_MAINS: return arme.competence2Mains() case ATTAQUE_TYPE.DEUX_MAINS: return arme.competence2Mains()
case ATTAQUE_TYPE.TIR: case 'tir': return arme.system.tir case ATTAQUE_TYPE.TIR: case 'tir': return arme.system.tir
case ATTAQUE_TYPE.LANCER: case 'lancer': return arme.system.lancer; case ATTAQUE_TYPE.LANCER: case 'lancer': return arme.system.lancer;
case ATTAQUE_TYPE.CORPS_A_CORPS: return CORPS_A_CORPS
} }
} }
return undefined return undefined
@@ -244,47 +251,41 @@ export class RdDItemArme extends RdDItem {
} }
isAttaque() { isAttaque() {
return this.system.resistance > 0 || this.system.portee_courte > 0 return this.system.resistance > 0 || (this.system.tir != '' && this.system.portee_courte > 0)
} }
static corpsACorps(actor) { static pugilat(actor) {
let competence = actor?.getCompetenceCorpsACorps() ?? BASE_CORPS_A_CORPS return RdDItemArme.$corpsACorps(actor, 'Pugilat', PUGILAT)
let melee = actor ? actor.system.carac['melee'].value : 0 }
static empoignade(actor) {
return RdDItemArme.$corpsACorps(actor, 'Empoignade', EMPOIGNADE)
}
static $corpsACorps(actor, name, cac, system) {
const competence = actor?.getCompetenceCorpsACorps() ?? BASE_CORPS_A_CORPS
const melee = actor ? actor.system.carac['melee'].value : 0
return new RdDItemArme({ return new RdDItemArme({
_id: competence.id, _id: Misc.fakeId(cac),
name: 'Corps à corps', name: name,
type: ITEM_TYPES.arme, type: ITEM_TYPES.arme,
img: competence.img, img: competence.img,
system: { system: {
initiative: RdDInitiative.calculInitiative(competence.system.niveau, melee), initiative: RdDInitiative.getRollInitiative(melee, competence.system.niveau),
equipe: true, equipe: true,
rapide: true, rapide: true,
force: 0, force: 0,
dommages: "0", dommages: "0",
dommagesReels: 0, dommagesReels: 0,
mortalite: 'non-mortel', mortalite: cac == EMPOIGNADE ? EMPOIGNADE : 'non-mortel',
competence: 'Corps à corps', competence: CORPS_A_CORPS,
resistance: 1, resistance: 1,
baseInit: 4, baseInit: cac == EMPOIGNADE ? 3 : 4,
cac: 'pugilat', cac: cac,
deuxmains: true, deuxmains: true,
categorie_parade: 'sans-armes' categorie_parade: 'sans-armes'
} }
}) })
} }
static mainsNues(actor) {
const mainsNues = RdDItemArme.corpsACorps(actor)
mainsNues.name = 'Mains nues'
return mainsNues;
}
static empoignade(actor) {
const empoignade = RdDItemArme.corpsACorps(actor)
empoignade.name = 'Empoignade'
empoignade.system.cac = 'empoignade'
empoignade.system.baseInit = 3
empoignade.system.mortalite = 'empoignade'
return empoignade
}
} }

View File

@@ -209,6 +209,9 @@ export class RdDItemBlessure extends RdDItem {
isCritique() { isCritique() {
return this.system.gravite > 4 && this.system.gravite <= 6 return this.system.gravite > 4 && this.system.gravite <= 6
} }
isBleeding() {
return this.system.gravite > 2 && !this.system.premierssoins.done
}
isMort() { isMort() {
return this.system.gravite > 6 return this.system.gravite > 6
} }

View File

@@ -3,7 +3,6 @@ import { RdDInitiative } from "../initiative.mjs";
export class MappingCreatureArme { export class MappingCreatureArme {
/* -------------------------------------------- */ /* -------------------------------------------- */
static setRollDataCreature(rollData) { static setRollDataCreature(rollData) {
const code = Grammar.toLowerCaseNoAccentNoSpace(rollData.competence.name); const code = Grammar.toLowerCaseNoAccentNoSpace(rollData.competence.name);
@@ -26,7 +25,7 @@ export class MappingCreatureArme {
competence: item.name, competence: item.name,
cac: categorieAttaque == "naturelle" ? "naturelle" : "", cac: categorieAttaque == "naturelle" ? "naturelle" : "",
niveau: item.system.niveau, niveau: item.system.niveau,
initiative: RdDInitiative.calculInitiative(item.system.niveau, item.system.carac_value), initiative: RdDInitiative.getRollInitiative(item.system.carac_value, item.system.niveau),
equipe: true, equipe: true,
resistance: 100, resistance: 100,
dommagesReels: item.system.dommages, dommagesReels: item.system.dommages,

View File

@@ -34,9 +34,13 @@ export class Misc {
return ((n % m) + m) % m; return ((n % m) + m) % m;
} }
static inRange(value, min,max){ static inRange(value, min, max) {
if (min > max) {
return Misc.inRange(value, max, min)
}
return Math.max(min, Math.min(value, max)) return Math.max(min, Math.min(value, max))
} }
static sum() { static sum() {
return (a, b) => Number(a) + Number(b); return (a, b) => Number(a) + Number(b);
} }
@@ -61,6 +65,10 @@ export class Misc {
return 0; return 0;
} }
static fakeId(base) {
return (base + foundry.utils.randomID(16)).substring(0, 16)
}
static typeName(type, subType) { static typeName(type, subType) {
return subType ? game.i18n.localize(`TYPES.${type}.${subType}`) return subType ? game.i18n.localize(`TYPES.${type}.${subType}`)
: ''; : '';
@@ -111,6 +119,10 @@ export class Misc {
list.forEach(it => addToObj(obj, it)) list.forEach(it => addToObj(obj, it))
return obj; return obj;
} }
static indexed(list, index = 'index') {
let i = 0;
return list.map(it => { it[index] = i++; return it })
}
static concat(lists) { static concat(lists) {
return lists.reduce((a, b) => a.concat(b), []); return lists.reduce((a, b) => a.concat(b), []);

View File

@@ -55,21 +55,20 @@ export class RdDBonus {
dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere + dmg.dmgForceInsuffisante dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere + dmg.dmgForceInsuffisante
return dmg; return dmg;
} }
static dmgRollV2(rollData, current) { static dmgRollV2(rollData, attaque) {
const actor = rollData.active.actor const actor = rollData.active.actor
const attaque = current.attaque
const arme = attaque.arme const arme = attaque.arme
const dmgArme = RdDBonus.dmgArme(arme, attaque.dommagesArme) const dmgArme = RdDBonus.dmgArme(arme, attaque.dommagesArme)
const dmg = { const dmg = {
total: 0, total: 0,
dmgArme: dmgArme, dmgArme: dmgArme,
penetration: arme.penetration(), penetration: arme?.penetration() ?? 0,
diff: attaque.diff, diff: attaque.diff,
dmgTactique: current.tactique?.dmg ?? 0, dmgTactique: attaque.tactique?.dmg ?? 0,
dmgParticuliere: 0, // TODO RdDBonus._dmgParticuliere(rollData), dmgParticuliere: RdDBonus._dmgParticuliere(rollData),
dmgSurprise: rollData.opponent?.surprise?.dmg ?? 0, dmgSurprise: rollData.opponent?.surprise?.dmg ?? 0,
mortalite: RdDBonus.mortalite(current.dmg?.mortalite, arme.system.mortalite, rollData.opponent?.actor?.isEntite()), mortalite: RdDBonus.mortalite(attaque.dmg?.mortalite, arme?.system.mortalite, rollData.opponent?.actor?.isEntite()),
dmgActor: RdDBonus.bonusDmg(actor, attaque.carac.key, dmgArme, attaque.forceRequise), dmgActor: RdDBonus.bonusDmg(actor, attaque.carac.key, dmgArme, attaque.forceRequise),
dmgForceInsuffisante: Math.min(0, actor.getForce() - attaque.forceRequise), dmgForceInsuffisante: Math.min(0, actor.getForce() - attaque.forceRequise),
dmgDiffLibre: ReglesOptionnelles.isUsing('degat-ajout-malus-libre') ? Math.abs(attaque.diff ?? 0) : 0 dmgDiffLibre: ReglesOptionnelles.isUsing('degat-ajout-malus-libre') ? Math.abs(attaque.diff ?? 0) : 0

View File

@@ -1,5 +1,5 @@
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { ENTITE_BLURETTE, HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { ENTITE_BLURETTE, HIDE_DICE, renderTemplate, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDBonus } from "./rdd-bonus.js"; import { RdDBonus } from "./rdd-bonus.js";
@@ -10,15 +10,16 @@ import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
import { Targets } from "./targets.js"; import { Targets } from "./targets.js";
import { RdDEmpoignade } from "./rdd-empoignade.js"; import { RdDEmpoignade } from "./rdd-empoignade.js";
import { RdDRollResult } from "./rdd-roll-result.js"; import { RdDRollResult } from "./rdd-roll-result.js";
import { RdDItemArme } from "./item/arme.js"; import { EMPOIGNADE, RdDItemArme } from "./item/arme.js";
import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetence } from "./item-competence.js";
import { RdDInitiative } from "./initiative.mjs"; import { MAP_PHASE, RdDInitiative } from "./initiative.mjs";
import RollDialog from "./roll/roll-dialog.mjs"; import RollDialog from "./roll/roll-dialog.mjs";
import { PART_DEFENSE } from "./roll/roll-part-defense.mjs"; import { PART_DEFENSE } from "./roll/roll-part-defense.mjs";
import { RollDialogAdapter } from "./roll/roll-dialog-adapter.mjs"; import { RollDialogAdapter } from "./roll/roll-dialog-adapter.mjs";
import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll/roll-constants.mjs"; import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll/roll-constants.mjs";
import { OptionsAvancees, ROLL_DIALOG_V2_TEST } from "./settings/options-avancees.js"; import { OptionsAvancees, ROLL_DIALOG_V2, ROLL_DIALOG_V2_TEST } from "./settings/options-avancees.js";
import { MappingCreatureArme } from "./item/mapping-creature-arme.mjs"; import { MappingCreatureArme } from "./item/mapping-creature-arme.mjs";
import { RollBasicParts } from "./roll/roll-basic-parts.mjs";
/* -------------------------------------------- */ /* -------------------------------------------- */
const premierRoundInit = [ const premierRoundInit = [
@@ -67,7 +68,7 @@ export class RdDCombatManager extends Combat {
if (Misc.isFirstConnectedGM()) { if (Misc.isFirstConnectedGM()) {
await this.finDeRound({ terminer: true }) await this.finDeRound({ terminer: true })
ChatUtility.removeChatMessageContaining(`<div data-combatid="${this.id}" data-combatmessage="actor-turn-summary">`) ChatUtility.removeChatMessageContaining(`<div data-combatid="${this.id}" data-combatmessage="actor-turn-summary">`)
game.messages.filter(m => ChatUtility.getMessageData(m, 'attacker-roll') != undefined && ChatUtility.getMessageData(m, 'defender-roll') != undefined) game.messages.filter(m => ChatUtility.getMessageData(m, 'rollData') != undefined && ChatUtility.getMessageData(m, 'rollData') != undefined)
.forEach(it => it.delete()) .forEach(it => it.delete())
RdDEmpoignade.deleteAllEmpoignades() RdDEmpoignade.deleteAllEmpoignades()
} }
@@ -106,14 +107,18 @@ export class RdDCombatManager extends Combat {
return combatant.actor return combatant.actor
} }
static calculAjustementInit(actor, arme) { static bonusArme(arme) {
const efficacite = (arme?.system.magique) ? arme.system.ecaille_efficacite : 0 return (arme?.system.magique) ? arme.system.ecaille_efficacite : 0
const etatGeneral = actor.getEtatGeneral() ?? 0
return efficacite + etatGeneral
} }
/************************************************************************************/ static etatGeneral(actor) {
return actor.getEtatGeneral() ?? 0;
}
/** ***********************************************************************************
* @override lance l'initiative de plusieurs combattants (tous/ous les PNJs) en une fois
*/
async rollInitiative(ids, messageOptions = {}) { async rollInitiative(ids, messageOptions = {}) {
console.log(`${game.system.title} | Combat.rollInitiative()`, ids, messageOptions) console.log(`${game.system.title} | Combat.rollInitiative()`, ids, messageOptions)
ids = typeof ids === "string" ? [ids] : ids ids = typeof ids === "string" ? [ids] : ids
@@ -121,18 +126,17 @@ export class RdDCombatManager extends Combat {
return this return this
} }
async rollInitRdD(id, formula, messageOptions = {}) { async rollInitRdD(id, formule, messageOptions = {}) {
const combatant = this.combatants.get(id); const combatant = this.combatants.get(id);
const actor = RdDCombatManager.getActorCombatant(combatant) const actor = RdDCombatManager.getActorCombatant(combatant)
if (actor) { if (actor) {
const rollFormula = formula ?? RdDCombatManager.getFirstInitRollFormula(actor) formule = formule ?? RdDCombatManager.getFirstInitRollFormula(actor)
const roll = combatant.getInitiativeRoll(rollFormula); const init = await RdDInitiative.roll(formule)
if (!roll.total) {
await roll.evaluate(); await this.updateEmbeddedDocuments("Combatant", [{
} _id: combatant._id || combatant.id,
const total = Math.max(roll.total, 0.00); initiative: init.init, 'system.init': init
console.log("Compute init for", rollFormula, roll, total, combatant); }])
await this.updateEmbeddedDocuments("Combatant", [{ _id: combatant._id || combatant.id, initiative: 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");
@@ -144,10 +148,10 @@ export class RdDCombatManager extends Combat {
alias: combatant.token?.name, alias: combatant.token?.name,
sound: CONFIG.sounds.dice, sound: CONFIG.sounds.dice,
}, },
flavor: `${combatant.token?.name} a fait son jet d'Initiative (${messageOptions.info})<br>` flavor: `${combatant.token?.name} a une initiatyive de ${init.value} : ${messageOptions.info}<br>`
}, },
messageOptions); messageOptions);
roll.toMessage(messageData, { rollMode, create: true }); init.roll.toMessage(messageData, { rollMode, create: true });
RdDCombatManager.processPremierRoundInit(); RdDCombatManager.processPremierRoundInit();
} }
@@ -159,16 +163,11 @@ export class RdDCombatManager extends Combat {
if (actions.length > 0) { if (actions.length > 0) {
const action = actions[0] const action = actions[0]
const init = RdDCombatManager.getInitData(actor, action) const init = RdDCombatManager.getInitData(actor, action)
const ajustement = RdDCombatManager.calculAjustementInit(actor, action) const ajustement = RdDCombatManager.bonusArme(action.arme) + RdDCombatManager.etatGeneral(actor)
return RdDCombatManager.formuleInitiative(init.offset, init.carac, init.niveau, ajustement); return RdDInitiative.formule(init.phase, init.carac, init.niveau, ajustement);
} }
let ajustement = RdDCombatManager.calculAjustementInit(actor, undefined); return RdDInitiative.formule(MAP_PHASE['autre'], 10, 0, actor.getEtatGeneral() ?? 0);
return RdDCombatManager.formuleInitiative(2, 10, 0, ajustement);
}
static formuleInitiative(rang, carac, niveau, bonusMalus) {
return `${rang} +( (${RdDInitiative.calculInitiative(niveau, carac, bonusMalus)} )/100)`;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -180,7 +179,6 @@ export class RdDCombatManager extends Combat {
for (let combatant of game.combat.combatants) { for (let combatant of game.combat.combatants) {
if (combatant.initiativeData?.arme?.type == "arme") { if (combatant.initiativeData?.arme?.type == "arme") {
// TODO: get init data premier round // TODO: get init data premier round
const initiativeData = combatant.initiativeData;
const action = combatant.initiativeData.arme; const action = combatant.initiativeData.arme;
const fromArme = Grammar.toLowerCaseNoAccentNoSpace(action.system.initpremierround) const fromArme = Grammar.toLowerCaseNoAccentNoSpace(action.system.initpremierround)
const initData = premierRoundInit.find(it => fromArme.includes(initData.pattern)) const initData = premierRoundInit.find(it => fromArme.includes(initData.pattern))
@@ -200,10 +198,27 @@ export class RdDCombatManager extends Combat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static incDecInit(combatantId, incDecValue) {
const combatant = game.combat.combatants.get(combatantId); static applyInitiativeCommand(combatantId, command, commandValue) {
let initValue = combatant.initiative + incDecValue; switch (command) {
game.combat.setInitiative(combatantId, initValue); case 'delta': return RdDCombatManager.incDecInit(combatantId, commandValue);
case 'autre': return RdDCombatManager.rollInitiativeAction(combatantId,
{ name: "Autre action", action: 'autre', system: { initOnly: true, competence: "Autre action" } });
}
}
static async incDecInit(combatantId, incDecValue) {
const combatant = game.combat.combatants.get(combatantId)
if (combatant?.initiative && incDecValue != 0) {
const value = combatant.system.init.value + incDecValue
const newInit = combatant.initiative + incDecValue / 100;
await game.combat.updateEmbeddedDocuments("Combatant", [{
_id: combatantId,
initiative: newInit,
'system.init.value': value,
'system.init.init': newInit,
}])
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -220,56 +235,42 @@ export class RdDCombatManager extends Combat {
} }
} }
options = [ options = [
{ name: "Incrémenter initiative", condition: true, icon: '<i class="fa-solid fa-plus"></i>', callback: target => { RdDCombatManager.incDecInit(target.data('combatant-id'), +0.01); } }, { name: "Incrémenter initiative", condition: true, icon: '<i class="fa-solid fa-plus"></i>', callback: target => { RdDCombatManager.incDecInit(target.data('combatant-id'), +1); } },
{ name: "Décrémenter initiative", condition: true, icon: '<i class="fa-solid fa-minus"></i>', callback: target => { RdDCombatManager.incDecInit(target.data('combatant-id'), -0.01); } } { name: "Décrémenter initiative", condition: true, icon: '<i class="fa-solid fa-minus"></i>', callback: target => { RdDCombatManager.incDecInit(target.data('combatant-id'), -1); } }
].concat(options); ].concat(options);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async rollInitiativeAction(combatantId, action) { static async rollInitiativeAction(combatantId, action) {
const combatant = game.combat.combatants.get(combatantId) const combatant = game.combat.combatants.get(combatantId)
const actor = RdDCombatManager.getActorCombatant(combatant) const actor = RdDCombatManager.getActorCombatant(combatant)
if (actor == undefined) { return [] }
combatant.initiativeData = { arme: action } // pour reclasser l'init au round 0 if (actor == undefined) { return }
const init = RdDCombatManager.getInitData(actor, action) const init = RdDCombatManager.getInitData(actor, action)
const ajustement = RdDCombatManager.calculAjustementInit(actor, action.arme) const ajustement = RdDCombatManager.bonusArme(actor, action.arme) + RdDCombatManager.etatGeneral(actor)
const rollFormula = RdDCombatManager.formuleInitiative(init.offset, init.carac, init.niveau, ajustement); const formule = RdDInitiative.formule(init.phase, init.carac, init.niveau, ajustement);
await game.combat.rollInitRdD(combatantId, rollFormula, init); await game.combat.rollInitRdD(combatantId, formule, init);
combatant.initiativeData combatant.initiativeData = { action, formule } // pour reclasser l'init au round 0
} }
static getInitData(actor, action) { static getInitData(actor, action) {
if (actor.getSurprise() == "totale") { return { offset: -1, info: "Surprise Totale", carac: 0, niveau: 0 } } if (actor.getSurprise() == "totale") { return { phase: MAP_PHASE['totale'], info: "Surprise Totale", carac: 0, niveau: 0 } }
if (actor.getSurprise() == "demi") { return { offset: 0, info: "Demi Surprise", carac: 0, niveau: 0 } } if (actor.getSurprise() == "demi") { return { phase: MAP_PHASE['demi'], info: "Demi Surprise", carac: 0, niveau: 0 } }
if (action.action == 'autre') { return { offset: 2, info: "Autre Action", carac: 0, niveau: 0 } } if (action.action == 'autre') { return { phase: MAP_PHASE['autre'], info: "Autre Action", carac: 0, niveau: 0 } }
if (action.action == 'possession') { return { offset: 10, info: "Possession", carac: actor.getReveActuel(), niveau: 0 } } if (action.action == 'possession') { return { phase: MAP_PHASE['possession'], info: "Possession", carac: actor.getReveActuel(), niveau: 0 } }
if (action.action == 'haut-reve') { return { offset: 9, info: "Draconic", carac: actor.getReveActuel(), niveau: 0 } } if (action.action == 'haut-reve') { return { phase: MAP_PHASE['draconic'], info: "Draconic", carac: actor.getReveActuel(), niveau: 0 } }
const comp = action.comp const comp = action.comp
return { return {
offset: RdDCombatManager.initOffset(comp?.system.categorie, action.arme), phase: RdDInitiative.phaseArme(comp?.system.categorie, action.arme),
info: action.name + " / " + comp.name, info: action.label,
carac: actor.getCaracInit(comp), carac: actor.getCaracInit(comp),
niveau: comp?.system.niveau ?? (['(lancer)', '(tir)'].includes(action.main) ? -8 : -6) niveau: comp?.system.niveau ?? (['(lancer)', '(tir)'].includes(action.main) ? -8 : -6)
} }
} }
static initOffset(categorie, arme) {
switch (categorie) {
case "tir": return 8
case "lancer": return 7
default:
switch (arme.system.cac) {
case "empoignade": return 3
case "pugilat": return 4
case "naturelle": return 4
default: return 5
}
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static displayInitiativeMenu(html, combatantId) { static displayInitiativeMenu(html, combatantId) {
const combatant = game.combat.combatants.get(combatantId) const combatant = game.combat.combatants.get(combatantId)
@@ -297,13 +298,8 @@ export class RdDCombatManager extends Combat {
? possessions ? possessions
: actor.listActions({ isEquipe: true }) : actor.listActions({ isEquipe: true })
for (let index = 0; index < actions.length; index++) { return Misc.indexed(actions)
actions[index].index = index
}
return actions
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -383,8 +379,13 @@ export class RdDCombat {
let defenderToken = canvas.tokens.get(msg.defenderToken.id) let defenderToken = canvas.tokens.get(msg.defenderToken.id)
if (defenderToken && Misc.isFirstConnectedGM()) { if (defenderToken && Misc.isFirstConnectedGM()) {
const rddCombat = RdDCombat.rddCombatForAttackerAndDefender(msg.attackerId, msg.attackerToken.id, msg.defenderToken.id) const rddCombat = RdDCombat.rddCombatForAttackerAndDefender(msg.attackerId, msg.attackerToken.id, msg.defenderToken.id)
rddCombat?.removeChatMessageActionsPasseArme(msg.defenderRoll.passeArme) rddCombat?.removeChatMessageActionsPasseArme(msg.paramChatDefense.attackerRoll.passeArme)
rddCombat?._chatMessageDefense(msg.paramChatDefense, msg.defenderRoll) if (msg.defenderRoll.ids) {/* TODO: delete roll V1 */
RollDialog.loadRollData(msg.paramChatDefense)
rddCombat?._chatMessageDefenseV2(msg.paramChatDefense)
} else {
rddCombat?._chatMessageDefense(msg.paramChatDefense, msg.defenderRoll)
}
} }
} }
@@ -464,8 +465,8 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
async onEvent(button, event) { async onEvent(button, event) {
const chatMessage = ChatUtility.getChatMessage(event); const chatMessage = ChatUtility.getChatMessage(event);
const defenderRoll = ChatUtility.getMessageData(chatMessage, 'defender-roll'); const defenderRoll = ChatUtility.getMessageData(chatMessage, 'rollData');
const attackerRoll = defenderRoll?.attackerRoll ?? ChatUtility.getMessageData(chatMessage, 'attacker-roll'); const attackerRoll = defenderRoll?.attackerRoll ?? ChatUtility.getMessageData(chatMessage, 'rollData');
console.log('RdDCombat', attackerRoll, defenderRoll); console.log('RdDCombat', attackerRoll, defenderRoll);
const armeParadeId = event.currentTarget.attributes['data-armeid']?.value; const armeParadeId = event.currentTarget.attributes['data-armeid']?.value;
@@ -665,12 +666,101 @@ export class RdDCombat {
return { msg: "à déterminer (0 immobile, -3 actif, -4 en mouvement, -5 en zig-zag)", diff: -3 }; return { msg: "à déterminer (0 immobile, -3 actif, -4 en mouvement, -5 en zig-zag)", diff: -3 };
} }
async attaqueV2() {
if (!await this.attacker.accorder(this.defender, 'avant-attaque')) {
return
}
await this.doRollAttaque({
ids: {
actorId: this.attackerId,
actorTokenId: this.attackerTokenId,
opponentId: this.defender.id,
opponentTokenId: this.defenderTokenId,
},
type: { allowed: ['attaque'], current: 'attaque' },
passeArme: foundry.utils.randomID(16),
})
}
async doRollAttaque(rollData, callbacks = []) {
// TODO V2 await this.proposerAjustementTirLancer(rollData)
await RollDialog.create(rollData, {
onRollDone: (dialog) => {
if (!OptionsAvancees.isUsing(ROLL_DIALOG_V2_TEST))
dialog.close()
},
customChatMessage: true,
callbacks: [
async (roll) => await this.onAttaqueV2(roll),
...callbacks
]
})
}
async onAttaqueV2(attackerRoll) {
if (!this.defender || !attackerRoll.rolled.isSuccess || attackerRoll.particulieres?.length > 1) {
return
}
if (!await this.attacker.accorder(this.defender, 'avant-defense')) {
return;
}
RollDialog.loadRollData(attackerRoll)
const surpriseDefender = this.defender.getSurprise(true);
const paramChatDefense = {
attackerRoll: attackerRoll,
isPossession: this.isPossession(attackerRoll),
defender: this.defender,
attacker: this.attacker,
attackerId: this.attackerId,
attackerToken: this.attackerToken,
defenderToken: this.defenderToken,
surprise: surpriseDefender,
}
if (Misc.isFirstConnectedGM()) {
await this._chatMessageDefenseV2(paramChatDefense);
}
else {
this._socketSendMessageDefense(paramChatDefense, {});
}
}
async _chatMessageDefenseV2(paramDemandeDefense) {
const attackerRoll = paramDemandeDefense.attackerRoll;
RollBasicParts.loadSurprises(attackerRoll)
attackerRoll.passeArme = attackerRoll.passeArme ?? foundry.utils.randomID(16)
attackerRoll.dmg = RdDBonus.dmgRollV2(attackerRoll, attackerRoll.current.attaque)
// attackerRoll.current.attaque.dmg = attackerRoll.dmg
// attaque.dmg = attackerRoll.current.attaque.dmg
const attaque = RollDialog.saveParts(attackerRoll)
const defense = {
attackerRoll: attaque,
ids: RollBasicParts.reverseIds(attaque),
passeArme: attaque.passeArme ?? foundry.utils.randomID(16)
}
const choixDefense = await ChatMessage.create({
// message privé: du défenseur à lui même (et aux GMs)
speaker: ChatMessage.getSpeaker(this.defender, canvas.tokens.get(this.defenderTokenId)),
alias: this.attacker?.getAlias(),
whisper: ChatUtility.getOwners(this.defender),
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.hbs', attackerRoll)
});
// flag pour garder les jets d'attaque/defense
ChatUtility.setMessageData(choixDefense, 'rollData', defense)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async attaque(competence, arme) { async attaque(competence, arme) {
if (!await this.attacker.accorder(this.defender, 'avant-attaque')) { if (!await this.attacker.accorder(this.defender, 'avant-attaque')) {
return return
} }
if (arme.system.cac == 'empoignade') { if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
return this.attacker.rollCompetence(competence.name, { arme: arme })
}
if (arme.system.cac == EMPOIGNADE) {
RdDEmpoignade.onAttaqueEmpoignade(this.attacker, this.defender) RdDEmpoignade.onAttaqueEmpoignade(this.attacker, this.defender)
return return
} }
@@ -723,9 +813,9 @@ export class RdDCombat {
} }
else { else {
// sans armes: à mains nues // sans armes: à mains nues
rollData.arme = RdDItemArme.corpsACorps(this.attacker) rollData.arme = RdDItemArme.pugilat(this.attacker)
rollData.arme.system.niveau = competence.system.niveau rollData.arme.system.niveau = competence.system.niveau
rollData.arme.system.initiative = RdDInitiative.calculInitiative(competence.system.niveau, this.attacker.system.carac['melee'].value); rollData.arme.system.initiative = RdDInitiative.getRollInitiative(this.attacker.system.carac['melee'].value, competence.system.niveau);
} }
return rollData; return rollData;
} }
@@ -776,7 +866,7 @@ export class RdDCombat {
passeArme: rollData.passeArme passeArme: rollData.passeArme
}) })
}); });
ChatUtility.setMessageData(choixParticuliere, 'attacker-roll', rollData); ChatUtility.setMessageData(choixParticuliere, 'rollData', rollData);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -852,10 +942,10 @@ export class RdDCombat {
speaker: ChatMessage.getSpeaker(this.defender, canvas.tokens.get(this.defenderTokenId)), speaker: ChatMessage.getSpeaker(this.defender, canvas.tokens.get(this.defenderTokenId)),
alias: this.attacker?.getAlias(), alias: this.attacker?.getAlias(),
whisper: ChatUtility.getOwners(this.defender), whisper: ChatUtility.getOwners(this.defender),
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.hbs', paramDemandeDefense), content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense-v1.hbs', paramDemandeDefense),
}); });
// flag pour garder les jets d'attaque/defense // flag pour garder les jets d'attaque/defense
ChatUtility.setMessageData(choixDefense, 'defender-roll', defenderRoll); ChatUtility.setMessageData(choixDefense, 'rollData', defenderRoll);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -869,7 +959,7 @@ export class RdDCombat {
defenderToken: this.defenderToken, defenderToken: this.defenderToken,
defenderRoll: defenderRoll, defenderRoll: defenderRoll,
paramChatDefense: paramChatDefense, paramChatDefense: paramChatDefense,
rollMode: true rollMode: true,
} }
}); });
} }
@@ -906,7 +996,7 @@ export class RdDCombat {
essais: attackerRoll.essais essais: attackerRoll.essais
}) })
}); });
ChatUtility.setMessageData(choixEchecTotal, 'attacker-roll', attackerRoll); ChatUtility.setMessageData(choixEchecTotal, 'rollData', attackerRoll);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -968,6 +1058,7 @@ export class RdDCombat {
async defenseV2(attackerRoll) { async defenseV2(attackerRoll) {
// this._prepareParade(attackerRoll, arme, competence); // this._prepareParade(attackerRoll, arme, competence);
RollDialog.loadRollData(attackerRoll)
await this.doRollDefense({ await this.doRollDefense({
ids: { ids: {
actorId: this.defender.id, actorId: this.defender.id,
@@ -975,7 +1066,7 @@ export class RdDCombat {
opponentTokenId: this.attackerTokenId, opponentTokenId: this.attackerTokenId,
opponentId: this.attackerId, opponentId: this.attackerId,
}, },
type: { allowed: ['defense'], current: 'defense' }, type: { allowed: [ROLL_TYPE_DEFENSE], current: ROLL_TYPE_DEFENSE },
attackerRoll: RollDialogAdapter.mapActionAttaque(attackerRoll), attackerRoll: RollDialogAdapter.mapActionAttaque(attackerRoll),
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
}) })
@@ -983,10 +1074,7 @@ export class RdDCombat {
async doRollDefense(rollData, callbacks = []) { async doRollDefense(rollData, callbacks = []) {
await RollDialog.create(rollData, { await RollDialog.create(rollData, {
onRollDone: (dialog) => { onRollDone: RollDialog.onRollDoneClose,
if (!OptionsAvancees.isUsing(ROLL_DIALOG_V2_TEST))
dialog.close()
},
customChatMessage: true, customChatMessage: true,
callbacks: [ callbacks: [
async (roll) => { async (roll) => {
@@ -1034,22 +1122,17 @@ export class RdDCombat {
if (RdDCombat.isReussite(rollData)) { if (RdDCombat.isReussite(rollData)) {
if (isParade) { if (isParade) {
await this.computeDeteriorationArme(rollData) await this.computeDeteriorationArme(rollData)
if (RdDCombat.isParticuliere(rollData)) {
await this.infoAttaquantDesarme(rollData)
}
} }
if (RdDCombat.isParticuliere(rollData)) {
await this._onDefenseParticuliere(rollData, isEsquive)
}
} }
this.removeChatMessageActionsPasseArme(rollData.passeArme) this.removeChatMessageActionsPasseArme(rollData.passeArme)
} }
async _onDefenseParticuliere(rollData, isEsquive) { async infoAttaquantDesarme(rollData) {
if (isEsquive) { if (/*TODO: parade?*/!rollData.attackerRoll?.particuliere) {
ChatUtility.createChatWithRollMode(
{ content: "<strong>Vous pouvez esquiver une deuxième fois!</strong>" },
this.defender)
}
else if (/*TODO: parade?*/!rollData.attackerRoll?.particuliere) {
// TODO: attaquant doit jouer résistance et peut être désarmé p132 // TODO: attaquant doit jouer résistance et peut être désarmé p132
ChatUtility.createChatWithRollMode( ChatUtility.createChatWithRollMode(
{ content: `(à gérer) L'attaquant doit jouer résistance et peut être désarmé (p132)` }, { content: `(à gérer) L'attaquant doit jouer résistance et peut être désarmé (p132)` },

View File

@@ -19,6 +19,7 @@ import { TMRUtility } from "./tmr-utility.js";
import { DialogFatigueVoyage } from "./voyage/dialog-fatigue-voyage.js"; import { DialogFatigueVoyage } from "./voyage/dialog-fatigue-voyage.js";
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { RdDRollResult } from "./rdd-roll-result.js"; import { RdDRollResult } from "./rdd-roll-result.js";
import { renderTemplate } from "./constants.js";
const rddRollNumeric = /^(\d+)\s*([\+\-]?\d+)?\s*(s)?/; const rddRollNumeric = /^(\d+)\s*([\+\-]?\d+)?\s*(s)?/;

View File

@@ -1,5 +1,5 @@
import { STATUSES } from "./settings/status-effects.js"; import { STATUSES } from "./settings/status-effects.js";
import { ITEM_TYPES } from "./constants.js"; import { ITEM_TYPES, renderTemplate } from "./constants.js";
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { RdDRollResult } from "./rdd-roll-result.js"; import { RdDRollResult } from "./rdd-roll-result.js";
import { RdDRoll } from "./rdd-roll.js"; import { RdDRoll } from "./rdd-roll.js";

View File

@@ -1,4 +1,4 @@
import { ATTAQUE_TYPE, RdDItemArme } from "./item/arme.js"; import { ATTAQUE_TYPE, EMPOIGNADE, PUGILAT, RdDItemArme } from "./item/arme.js";
import { ITEM_TYPES } from "./constants.js"; import { ITEM_TYPES } from "./constants.js";
export class RdDHotbar { export class RdDHotbar {
@@ -28,8 +28,8 @@ export class RdDHotbar {
return ' ' + maniement return ' ' + maniement
case 'tir': return ' (tir)'; case 'tir': return ' (tir)';
case 'lancer': return ' (lancer)'; case 'lancer': return ' (lancer)';
case 'pugilat': return ' (pugilat)'; case PUGILAT: return ' (pugilat)';
case 'empoignade': return ' (empoignade)'; case EMPOIGNADE: return ' (empoignade)';
} }
return '' return ''
} }
@@ -63,8 +63,8 @@ export class RdDHotbar {
case ITEM_TYPES.competence: case ITEM_TYPES.competence:
await this.createItemMacro(item, slot++, 'competence') await this.createItemMacro(item, slot++, 'competence')
if (item.isCorpsACorps()) { if (item.isCorpsACorps()) {
await this.createItemMacro(item, slot++, 'pugilat') await this.createItemMacro(item, slot++, PUGILAT)
await this.createItemMacro(item, slot++, 'empoignade') await this.createItemMacro(item, slot++, EMPOIGNADE)
} }
else if (item.isCompetenceArme()) { else if (item.isCompetenceArme()) {
ui.notifications.info(`${item.name} est une compétence d'arme, la macro n'est pas liée à un arme.<br> ui.notifications.info(`${item.name} est une compétence d'arme, la macro n'est pas liée à un arme.<br>
@@ -121,9 +121,9 @@ export class RdDHotbar {
case ITEM_TYPES.competence: case ITEM_TYPES.competence:
if (item.isCorpsACorps()) { if (item.isCorpsACorps()) {
switch (categorieArme) { switch (categorieArme) {
case 'pugilat': case PUGILAT:
return actor.rollArme(RdDItemArme.corpsACorps(actor)); return actor.rollArme(RdDItemArme.pugilat(actor));
case 'empoignade': case EMPOIGNADE:
return actor.rollArme(RdDItemArme.empoignade(actor)); return actor.rollArme(RdDItemArme.empoignade(actor));
} }
} }

View File

@@ -1,4 +1,5 @@
import { ChatUtility } from "./chat-utility.js" import { ChatUtility } from "./chat-utility.js"
import { renderTemplate } from "./constants.js"
const vents = [ const vents = [
{ min: 0, max: 0, valeur: 'Calme' }, { min: 0, max: 0, valeur: 'Calme' },

View File

@@ -1,5 +1,6 @@
import { RdDBaseActor } from "./actor/base-actor.js"; import { RdDBaseActor } from "./actor/base-actor.js";
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { renderTemplate } from "./constants.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "./constants.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js"; import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
@@ -66,9 +67,9 @@ export class RdDResolutionTable {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _computeCell(niveau, percentage) { static _computeCell(level, percentage) {
return { return {
niveau: niveau, level: level,
score: percentage, score: percentage,
norm: Math.min(99, percentage), norm: Math.min(99, percentage),
sign: this._reussiteSignificative(percentage), sign: this._reussiteSignificative(percentage),
@@ -188,7 +189,7 @@ export class RdDResolutionTable {
static computeReussite(chances, roll, diviseur) { static computeReussite(chances, roll, diviseur) {
const reussite = reussites.find(x => x.condition(chances, roll)) const reussite = reussites.find(x => x.condition(chances, roll))
if (diviseur > 1 && reussite.isSuccess) { if (diviseur > 1 && reussite.isSuccess) {
if (chances > roll * diviseur) { if (chances.norm < roll * diviseur) {
return reussiteInsuffisante return reussiteInsuffisante
} }
} }
@@ -236,7 +237,7 @@ export class RdDResolutionTable {
maxCarac = Math.min(maxCarac, minCarac + 20); maxCarac = Math.min(maxCarac, minCarac + 20);
minLevel = Math.max(minLevel, -10); minLevel = Math.max(minLevel, -10);
maxLevel = Math.max(Math.min(maxLevel, 30), minLevel + colonnes); maxLevel = Math.max(Math.min(maxLevel, 30), minLevel + colonnes);
return await foundry.applications.handlebars.renderTemplate('systems/foundryvtt-reve-de-dragon/templates/resolution-table.hbs', { return await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/resolution-table.hbs', {
carac: carac, carac: carac,
difficulte: level, difficulte: level,
min: minLevel, min: minLevel,

View File

@@ -1,4 +1,4 @@
import { ENTITE_BLURETTE, ENTITE_INCARNE } from "./constants.js"; import { ENTITE_BLURETTE, ENTITE_INCARNE, renderTemplate } from "./constants.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
/** /**

View File

@@ -1,5 +1,7 @@
import { renderTemplate } from "./constants.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDRollResult } from "./rdd-roll-result.js";
const titleTableDeResolution = 'Table de résolution'; const titleTableDeResolution = 'Table de résolution';
/** /**
@@ -98,14 +100,14 @@ export class RdDRollResolutionTable extends Dialog {
async onLancer() { async onLancer() {
await RdDResolutionTable.rollData(this.rollData); await RdDResolutionTable.rollData(this.rollData);
console.log("RdDRollResolutionTable -=>", this.rollData, this.rollData.rolled); console.log("RdDRollResolutionTable -=>", this.rollData, this.rollData.rolled);
await RdDResolutionTable.displayRollData(this.rollData); await RdDRollResult.displayRollData(this.rollData);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async onLancerFermer() { async onLancerFermer() {
await RdDResolutionTable.rollData(this.rollData); await RdDResolutionTable.rollData(this.rollData);
console.log("RdDRollResolutionTable -=>", this.rollData, this.rollData.rolled); console.log("RdDRollResolutionTable -=>", this.rollData, this.rollData.rolled);
await RdDResolutionTable.displayRollData(this.rollData); await RdDRollResult.displayRollData(this.rollData);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@@ -1,4 +1,5 @@
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { renderTemplate } from "./constants.js";
export class RdDRollResult { export class RdDRollResult {
@@ -13,6 +14,6 @@ export class RdDRollResult {
static async buildRollDataHtml(rollData, template = 'chat-resultat-general.hbs') { static async buildRollDataHtml(rollData, template = 'chat-resultat-general.hbs') {
rollData.show = rollData.show || {}; rollData.show = rollData.show || {};
return await foundry.applications.handlebars.renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/${template}`, rollData); return await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/${template}`, rollData);
} }
} }

View File

@@ -1,4 +1,4 @@
import { RollDataAjustements } from "./rolldata-ajustements.js"; import { RollDataAjustements } from "./rolldata-ajustements-v1.js";
import { HtmlUtility } from "./html-utility.js"; import { HtmlUtility } from "./html-utility.js";
import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetence } from "./item-competence.js";
import { RdDItemSort } from "./item-sort.js"; import { RdDItemSort } from "./item-sort.js";
@@ -8,8 +8,8 @@ import { RdDCarac } from "./rdd-carac.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js"; import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { ACTOR_TYPES } from "./constants.js"; import { ACTOR_TYPES, renderTemplate } from "./constants.js";
import { RdDUtility } from "./rdd-utility.js"; import { EMPOIGNADE } from "./item/arme.js";
/** /**
* Extend the base Dialog entity to select roll parameters * Extend the base Dialog entity to select roll parameters
@@ -23,7 +23,7 @@ export class RdDRoll extends Dialog {
RdDRoll._ensureCorrectAction(action); RdDRoll._ensureCorrectAction(action);
RdDRoll._setDefaultOptions(actor, rollData); RdDRoll._setDefaultOptions(actor, rollData);
const html = await foundry.applications.handlebars.renderTemplate(dialogConfig.html, rollData); const html = await renderTemplate(dialogConfig.html, rollData);
let options = { classes: ["rdd-roll-dialog"], width: 650, height: 'fit-content', 'z-index': 99999, close: html => { } }; let options = { classes: ["rdd-roll-dialog"], width: 650, height: 'fit-content', 'z-index': 99999, close: html => { } };
if (dialogConfig.close) { if (dialogConfig.close) {
@@ -334,10 +334,8 @@ export class RdDRoll extends Dialog {
// Mise à jour valeurs // Mise à jour valeurs
this.html.find(".dialog-roll-title").text(this._getTitle(rollData)); this.html.find(".dialog-roll-title").text(this._getTitle(rollData));
this.html.find("input.check-mortalite").prop('checked', rollData.dmg.mortalite == 'non-mortel'); this.html.find("input.check-mortalite").prop('checked', rollData.dmg.mortalite == 'non-mortel');
this.html.find("label.dmg-arme-actor").text(rollData.dmg.mortalite == 'empoignade' ? 'empoignade' : Misc.toSignedString(rollData.dmg.total)); this.html.find("label.dmg-arme-actor").text(rollData.dmg.mortalite == EMPOIGNADE ? EMPOIGNADE : Misc.toSignedString(rollData.dmg.total));
this.html.find("label.arme-mortalite").text(rollData.dmg.mortalite); this.html.find("label.arme-mortalite").text(rollData.dmg.mortalite);
// this.html.find("[name='dmg-arme-actor']").text(rollData.dmg.mortalite == 'empoignade'? 'empoignade': Misc.toSignedString(rollData.dmg.total) );
// this.html.find("[name='arme-mortalite']").text(rollData.dmg.mortalite);
this.html.find("div.placeholder-ajustements").empty().append(adjustements); this.html.find("div.placeholder-ajustements").empty().append(adjustements);
this.html.find("div.placeholder-resolution").empty().append(resolutionTable) this.html.find("div.placeholder-resolution").empty().append(resolutionTable)
} }
@@ -345,7 +343,7 @@ export class RdDRoll extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async buildAjustements(rollData) { async buildAjustements(rollData) {
return await foundry.applications.handlebars.renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.hbs`, rollData); return await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.hbs`, rollData);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@@ -1,5 +1,5 @@
import { SHOW_DICE, SYSTEM_RDD } from "./constants.js"; import { renderTemplate, SHOW_DICE, SYSTEM_RDD } from "./constants.js";
import { RollDataAjustements } from "./rolldata-ajustements.js"; import { RollDataAjustements } from "./rolldata-ajustements-v1.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
import { COORD_TMR_INCONNU, TMRUtility } from "./tmr-utility.js"; import { COORD_TMR_INCONNU, TMRUtility } from "./tmr-utility.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js";
@@ -47,7 +47,7 @@ export class RdDTMRDialog extends Dialog {
static async create(actor, tmrData) { static async create(actor, tmrData) {
await PixiTMR.init() await PixiTMR.init()
let html = await foundry.applications.handlebars.renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.hbs', tmrData); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.hbs', tmrData);
if (tmrData.mode != 'visu' && !game.user.isGM) { if (tmrData.mode != 'visu' && !game.user.isGM) {
ChatMessage.create({ content: actor.name + " est monté dans les TMR en mode : " + tmrData.mode, whisper: ChatUtility.getGMs() }); ChatMessage.create({ content: actor.name + " est monté dans les TMR en mode : " + tmrData.mode, whisper: ChatUtility.getGMs() });
} }
@@ -508,7 +508,7 @@ export class RdDTMRDialog extends Dialog {
ChatMessage.create({ ChatMessage.create({
whisper: ChatUtility.getOwners(this.actor), whisper: ChatUtility.getOwners(this.actor),
content: await foundry.applications.handlebars.renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-rencontre-tmr.hbs`, rencData) content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-rencontre-tmr.hbs`, rencData)
}); });
this.$updateValuesDisplay(); this.$updateValuesDisplay();

View File

@@ -1,6 +1,9 @@
/* -------------------------------------------- */ /* -------------------------------------------- */
import { renderTemplate } from "./constants.js";
import { HtmlUtility } from "./html-utility.js"; import { HtmlUtility } from "./html-utility.js";
import { Misc } from "./misc.js";
import { RdDCombatManager } from "./rdd-combat.js"; import { RdDCombatManager } from "./rdd-combat.js";
import { OptionsAvancees, ROLL_DIALOG_V2 } from "./settings/options-avancees.js";
import { Targets } from "./targets.js"; import { Targets } from "./targets.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -30,47 +33,92 @@ export class RdDTokenHud {
const combatant = game.combat.combatants.find(c => c.tokenId == tokenId) const combatant = game.combat.combatants.find(c => c.tokenId == tokenId)
const actor = RdDCombatManager.getActorCombatant(combatant, { warning: false }) const actor = RdDCombatManager.getActorCombatant(combatant, { warning: false })
if (actor) { if (actor) {
const actions = RdDCombatManager.listActionsActorCombatant(actor) if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
// initiative await RdDTokenHud.addExtensionHudCombat(html, combatant, actor, token)
await RdDTokenHud.addExtensionHudInit(html, combatant, actions) }
// combat else {
await RdDTokenHud.addExtensionHudCombat(html, combatant, token, actions.filter(it => !it.initOnly)) const actions = RdDCombatManager.listActionsActorCombatant(actor)
// initiative
await RdDTokenHud.addExtensionHudInit(html, combatant, actions)
// combat
await RdDTokenHud.addExtensionHudAttaques(html, combatant, token, actions.filter(it => !it.initOnly))
}
} }
} }
}
static async addExtensionHudCombat(html, combatant, actor, token) {
const actionsActor = actor.listActionsCombat();
const ajustements = combatant?.initiative ?
[
{ label: 'Initiative +1', action: 'delta', value: 1 },
{ label: 'Initiative -1', action: 'delta', value: -1 }
] : []
const autres = [{ label: "Autre action", action: 'autre' }]
const actions = Misc.indexed(actionsActor.concat(ajustements).concat(autres))
const hudData = { combatant, token, actions };
const hud = $(await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/hud-actor-combat.hbs', hudData))
$(html).find('div.col.left').append(hud)
const list = hud.find('div.rdd-hud-list')
RdDTokenHud.setupHudToggle(hud, list)
const selectInitiative = list.find('select[name="initiative"]');
selectInitiative.change(event => {
const action = actions.find(it => it.index == event.currentTarget.value)
console.log('select initiative', combatant.id, action)
if (action) {
switch (action.action) {
case 'delta':
RdDCombatManager.incDecInit(combatant.id, action.value);
break
case 'autre':
RdDCombatManager.rollInitiativeAction(combatant.id,
{ label: "Autre action", action: 'autre', system: { initOnly: true, competence: "Autre action" } });
break
default:
RdDCombatManager.rollInitiativeAction(combatant.id, action)
}
selectInitiative.select("")
}
})
list.find('.rdd-attaque-v2').click(event => combatant.actor.rollAttaque(token))
} }
static async addExtensionHudInit(html, combatant, actions) { static async addExtensionHudInit(html, combatant, actions) {
const hudData = { const hudData = {
combatant, actions, combatant, actions,
commandes: [ commandes: [
{ name: "Autre action", command: 'autre' }, { label: "Autre action", command: 'autre' },
{ name: 'Initiative +1', command: 'inc', value: 0.01 }, { label: 'Initiative +1', command: 'delta', value: 1 },
{ name: 'Initiative -1', command: 'dec', value: -0.01 }] { label: 'Initiative -1', command: 'deltac', value: -1 }]
}; };
const controlIconCombat = $(html).find('.control-icon[data-action=combat]'); const controlIconCombat = $(html).find('.control-icon[data-action=combat]');
await RdDTokenHud._configureSubMenu(controlIconCombat, await RdDTokenHud._configureSubMenu(it => controlIconCombat.after(it),
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.hbs', 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.hbs',
hudData, hudData,
(event) => { (event) => {
let initCommand = event.currentTarget.attributes['data-command']?.value; let initCommand = event.currentTarget.attributes['data-command']?.value
let combatantId = event.currentTarget.attributes['data-combatant-id']?.value; let initCommandValue = Number(event.currentTarget.attributes['data-command-value']?.value ?? 0)
let combatantId = event.currentTarget.attributes['data-combatant-id']?.value
if (initCommand) { if (initCommand) {
RdDTokenHud._initiativeCommand(initCommand, combatantId); RdDCombatManager.applyInitiativeCommand(combatantId, initCommand, initCommandValue)
} else { } else {
let index = event.currentTarget.attributes['data-action-index'].value; let index = event.currentTarget.attributes['data-action-index'].value
let action = hudData.actions[index]; let action = hudData.actions[index]
RdDCombatManager.rollInitiativeAction(combatantId, action); RdDCombatManager.rollInitiativeAction(combatantId, action)
} }
}); })
} }
static async addExtensionHudCombat(html, combatant, token, actions) { static async addExtensionHudAttaques(html, combatant, token, actions) {
const hudData = { combatant, token, actions, commandes: [] }; const hudData = { combatant, token, actions, commandes: [] };
const controlIconTarget = $(html).find('.control-icon[data-action=target]'); const divColLeft = $(html).find('div.col.left');
await RdDTokenHud._configureSubMenu(controlIconTarget, 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.hbs', hudData, await RdDTokenHud._configureSubMenu(it => divColLeft.append(it),
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.hbs',
hudData,
(event) => { (event) => {
const actionIndex = event.currentTarget.attributes['data-action-index']?.value; const actionIndex = event.currentTarget.attributes['data-action-index']?.value;
const action = hudData.actions[actionIndex]; const action = hudData.actions[actionIndex];
@@ -90,7 +138,7 @@ export class RdDTokenHud {
const hudSoins = { blessures: target.actor.blessuresASoigner() ?? [] }; const hudSoins = { blessures: target.actor.blessuresASoigner() ?? [] };
if (hudSoins.blessures.length > 0) { if (hudSoins.blessures.length > 0) {
const controlIconTarget = $(html).find('.control-icon[data-action=combat]'); const controlIconTarget = $(html).find('.control-icon[data-action=combat]');
await RdDTokenHud._configureSubMenu(controlIconTarget, await RdDTokenHud._configureSubMenu(it => controlIconTarget.after(it),
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-soins.hbs', 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-soins.hbs',
hudSoins, hudSoins,
(event) => { (event) => {
@@ -101,15 +149,6 @@ export class RdDTokenHud {
} }
} }
static _initiativeCommand(initCommand, combatantId) {
switch (initCommand) {
case 'inc': return RdDCombatManager.incDecInit(combatantId, 0.01);
case 'dec': return RdDCombatManager.incDecInit(combatantId, -0.01);
case 'autre': return RdDCombatManager.rollInitiativeAction(combatantId,
{ name: "Autre action", action: 'autre', system: { initOnly: true, competence: "Autre action" } });
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static async addTokenHudExtensions(app, html, tokenId) { static async addTokenHudExtensions(app, html, tokenId) {
console.log(`Adding token HUD extensions for token ${tokenId}`); console.log(`Adding token HUD extensions for token ${tokenId}`);
@@ -129,20 +168,24 @@ export class RdDTokenHud {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) { static async _configureSubMenu(callInsertion, template, hudData, onMenuItem) {
const hud = $(await foundry.applications.handlebars.renderTemplate(template, hudData)); const hud = $(await renderTemplate(template, hudData));
const list = hud.find('div.rdd-hud-list'); const list = hud.find('div.rdd-hud-list');
RdDTokenHud._toggleHudListActive(hud, list); RdDTokenHud.setupHudToggle(hud, list)
hud.find('img.rdd-hud-togglebutton').click(event => RdDTokenHud._toggleHudListActive(hud, list));
list.find('.rdd-hud-menu').click(onMenuItem); list.find('.rdd-hud-menu').click(onMenuItem);
insertionPoint.after(hud); callInsertion(hud);
} }
static _toggleHudListActive(hud, list) { static setupHudToggle(hud, list) {
hud.toggleClass('active'); function toggleHudList(hud, list) {
HtmlUtility.showControlWhen(list, hud.hasClass('active')); hud.toggleClass('active')
HtmlUtility.showControlWhen(list, hud.hasClass('active'))
}
toggleHudList(hud, list)
$(hud).find('img.rdd-hud-togglebutton').click(event => toggleHudList(hud, list))
} }
} }

View File

@@ -278,7 +278,7 @@ export class RdDUtility {
Handlebars.registerHelper('plusMoins', diff => parseInt(diff) ? (diff > 0 ? '+' : '') + Math.round(diff) : diff) Handlebars.registerHelper('plusMoins', diff => parseInt(diff) ? (diff > 0 ? '+' : '') + Math.round(diff) : diff)
Handlebars.registerHelper('fractionOneN', n => new Handlebars.SafeString(Misc.getFractionOneN(n))) Handlebars.registerHelper('fractionOneN', n => new Handlebars.SafeString(Misc.getFractionOneN(n)))
// Handle v12 removal of this helper // Handle v12 removal of this helper
Handlebars.registerHelper('select', function (selected, options) { Handlebars.registerHelper('select', function (selected, options) {
const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected)); const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected));
@@ -286,7 +286,7 @@ export class RdDUtility {
const html = options.fn(this); const html = options.fn(this);
return html.replace(rgx, "$& selected"); return html.replace(rgx, "$& selected");
}) })
// logic // logic
Handlebars.registerHelper('either', (a, b) => a ?? b); Handlebars.registerHelper('either', (a, b) => a ?? b);
// string manipulation // string manipulation
@@ -299,8 +299,10 @@ export class RdDUtility {
Handlebars.registerHelper('grammar-un', str => Grammar.articleIndetermine(str)); Handlebars.registerHelper('grammar-un', str => Grammar.articleIndetermine(str));
Handlebars.registerHelper('grammar-accord', (genre, ...args) => Grammar.accord(genre, args)); Handlebars.registerHelper('grammar-accord', (genre, ...args) => Grammar.accord(genre, args));
Handlebars.registerHelper('json-stringify', object => JSON.stringify(object)) Handlebars.registerHelper('json-stringify', object => JSON.stringify(object))
// math // math
Handlebars.registerHelper('math-sum', (...values) => values.slice(0, -1).reduce(Misc.sum(), 0))
Handlebars.registerHelper('math-abs', diff => Math.abs(parseInt(diff)))
Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1))); Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1)));
Handlebars.registerHelper('repeat', function (n, block) { Handlebars.registerHelper('repeat', function (n, block) {
let accum = ''; let accum = '';

View File

@@ -4,6 +4,8 @@ import { RdDCarac } from "../rdd-carac.js"
import { RdDCombat } from "../rdd-combat.js" import { RdDCombat } from "../rdd-combat.js"
import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll-constants.mjs" import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll-constants.mjs"
import { RdDResolutionTable } from "../rdd-resolution-table.js" import { RdDResolutionTable } from "../rdd-resolution-table.js"
import { RDD_CONFIG, renderTemplate } from "../constants.js"
import { EMPOIGNADE } from "../item/arme.js"
export default class ChatRollResult { export default class ChatRollResult {
static init() { static init() {
@@ -15,6 +17,7 @@ export default class ChatRollResult {
static onReady() { static onReady() {
foundry.applications.handlebars.loadTemplates({ foundry.applications.handlebars.loadTemplates({
'partial-appel-chance': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-appel-chance.hbs', 'partial-appel-chance': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-appel-chance.hbs',
'partial-attaque-particuliere': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-attaque-particuliere.hbs',
'partial-encaissement': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-encaissement.hbs', 'partial-encaissement': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-encaissement.hbs',
'partial-recul-choc': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-recul-choc.hbs', 'partial-recul-choc': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-recul-choc.hbs',
'partial-info-appel-moral': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-info-appel-moral.hbs', 'partial-info-appel-moral': 'systems/foundryvtt-reve-de-dragon/templates/roll/result/partial-info-appel-moral.hbs',
@@ -37,12 +40,12 @@ export default class ChatRollResult {
} }
prepareDisplay(roll) { prepareDisplay(roll) {
roll.done = roll.done || {} roll.done = roll.done ?? {}
roll.show = roll.show || {} roll.show = roll.show ?? {}
roll.show.chance = this.isAppelChancePossible(roll) roll.show.chance = this.isAppelChancePossible(roll)
roll.show.encaissement = this.isShowEncaissement(roll) roll.show.encaissement = this.isShowEncaissement(roll)
roll.show.recul = this.getReculChoc(roll) roll.show.recul = this.getRecul(roll)
//roll.show.particuliere = roll.show.particuliere ?? []
} }
isAppelChancePossible(roll) { isAppelChancePossible(roll) {
@@ -52,31 +55,50 @@ export default class ChatRollResult {
} }
isShowEncaissement(roll) { isShowEncaissement(roll) {
return roll.rolled.isEchec && switch (roll.type.current) {
roll.attackerRoll?.dmg.mortalite != 'empoignade' case ROLL_TYPE_DEFENSE:
return roll.rolled.isEchec && roll.attackerRoll?.dmg.mortalite != EMPOIGNADE
}
return false
} }
getReculChoc(roll, defender = roll.active.actor, attacker = roll.opponent.actor) {
const attaque = roll.attackerRoll getRecul(roll, defender = roll.active.actor, attacker = roll.opponent?.actor) {
if (attaque && switch (roll.type.current) {
(roll.rolled.isEchec || !roll.current.defense.isEsquive) && case ROLL_TYPE_DEFENSE:
(attaque.particuliere == 'force' || 'charge' == attaque.tactique?.key)) { {
const taille = defender.system.carac.taille.value const attaque = roll.attackerRoll
const impact = attacker.system.carac.force.value + roll.attackerRoll?.dmg.dmgArme if (attaque &&
return { (roll.rolled.isEchec || !roll.current.defense.isEsquive) &&
raison: 'charge' == attaque.tactique?.key ? 'charge' : 'particulière en force', (attaque.particuliere == 'force' || 'charge' == attaque.tactique?.key)) {
taille: taille, const taille = defender.system.carac.taille.value
impact: impact, const impact = attacker.system.carac.force.value + roll.attackerRoll?.dmg.dmgArme
chances: RdDResolutionTable.computeChances(10, taille-impact).norm, return {
diff: taille - impact raison: 'charge' == attaque.tactique?.key ? 'charge' : 'particulière en force',
} taille: taille,
impact: impact,
chances: RdDResolutionTable.computeChances(10, taille - impact).norm,
diff: taille - impact
}
}
break
}
case ROLL_TYPE_ATTAQUE:
{
const attaque = roll
if (attaque.particuliere == 'force' || 'charge' == attaque.tactique?.key) {
return {
raison: 'charge' == attaque.tactique?.key ? 'charge' : 'particulière en force',
}
}
}
} }
return undefined return undefined
} }
async buildRollHtml(roll) { async buildRollHtml(roll) {
const template = `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-${roll.type.current}.hbs` const template = `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-${roll.type.current}.hbs`
return await foundry.applications.handlebars.renderTemplate(template, roll) return await renderTemplate(template, roll)
} }
async chatListeners(html) { async chatListeners(html) {
@@ -84,6 +106,7 @@ export default class ChatRollResult {
$(html).on("click", '.appel-destinee', event => this.onClickAppelDestinee(event)) $(html).on("click", '.appel-destinee', event => this.onClickAppelDestinee(event))
$(html).on("click", '.encaissement', event => this.onClickEncaissement(event)) $(html).on("click", '.encaissement', event => this.onClickEncaissement(event))
$(html).on("click", '.resister-recul', event => this.onClickRecul(event)) $(html).on("click", '.resister-recul', event => this.onClickRecul(event))
$(html).on("click", '.choix-particuliere', event => this.onClickChoixParticuliere(event))
} }
@@ -177,4 +200,13 @@ export default class ChatRollResult {
await this.updateChatMessage(chatMessage, savedRoll) await this.updateChatMessage(chatMessage, savedRoll)
} }
async onClickChoixParticuliere(event) {
const choix = event.currentTarget.attributes['data-particuliere'].value
const chatMessage = ChatUtility.getChatMessage(event)
const savedRoll = ChatUtility.getMessageData(chatMessage, 'rollData')
savedRoll.particuliere = choix
savedRoll.particulieres = [RDD_CONFIG.particuliere[choix]]
await this.updateChatMessage(chatMessage, savedRoll)
await this.getCombat(savedRoll)?.onAttaqueV2(savedRoll, callbacks)
}
} }

View File

@@ -4,9 +4,10 @@ import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll-constants.mjs"
import { PART_ATTAQUE } from "./roll-part-attaque.mjs" import { PART_ATTAQUE } from "./roll-part-attaque.mjs"
import { PART_DEFENSE } from "./roll-part-defense.mjs" import { PART_DEFENSE } from "./roll-part-defense.mjs"
export class RollBasicParts { export class RollBasicParts {
restore(rollData) { static restore(rollData) {
rollData.ids.sceneId = rollData.ids.sceneId ?? canvas.scene.id rollData.ids.sceneId = rollData.ids.sceneId ?? canvas.scene.id
rollData.active = RollBasicParts.$getActor(rollData) rollData.active = RollBasicParts.$getActor(rollData)
rollData.opponent = RollBasicParts.$getOpponent(rollData) rollData.opponent = RollBasicParts.$getOpponent(rollData)
@@ -15,14 +16,14 @@ export class RollBasicParts {
} }
} }
loadSurprises(rollData, type) { static loadSurprises(rollData, type = rollData.type.current) {
if (!rollData.type.passif) { if (!rollData.type.passif) {
this.loadSurprise(rollData.active, this.getForceRequiseActiveActor(rollData, type)) RollBasicParts.loadSurprise(rollData.active, RollBasicParts.getForceRequiseActiveActor(rollData, type))
this.loadSurprise(rollData.opponent, 0) RollBasicParts.loadSurprise(rollData.opponent, 0)
} }
} }
loadSurprise(who, forceRequise) { static loadSurprise(who, forceRequise) {
if (who?.actor) { if (who?.actor) {
foundry.utils.mergeObject(who, foundry.utils.mergeObject(who,
StatusEffects.getActorEffetSurprise(who.actor, forceRequise), StatusEffects.getActorEffetSurprise(who.actor, forceRequise),
@@ -30,15 +31,15 @@ export class RollBasicParts {
} }
} }
getForceRequiseActiveActor(rollData, type) { static getForceRequiseActiveActor(rollData, type) {
switch (type) { switch (type) {
case ROLL_TYPE_ATTAQUE: return rollData.current[PART_ATTAQUE].attaque.forceRequise case ROLL_TYPE_ATTAQUE: return rollData.current[PART_ATTAQUE].forceRequise
case ROLL_TYPE_DEFENSE: return rollData.current[PART_DEFENSE].forceRequise case ROLL_TYPE_DEFENSE: return rollData.current[PART_DEFENSE].forceRequise
default: return 0 default: return 0
} }
} }
initFrom(rollData) { static initFrom(rollData) {
return { return {
selected: {}, selected: {},
type: rollData.type, type: rollData.type,
@@ -52,6 +53,16 @@ export class RollBasicParts {
} }
} }
static reverseIds(rollData) {
return {
sceneId: rollData.ids.sceneId,
actorId: rollData.ids.opponentId,
actorTokenId: rollData.ids.opponentTokenId,
opponentId: rollData.ids.actorId,
opponentTokenId: rollData.actorTokenId
}
}
static $getActor(rollData) { static $getActor(rollData) {
if (rollData.ids.actorTokenId) { if (rollData.ids.actorTokenId) {
return ActorToken.fromTokenId(rollData.ids.actorTokenId, rollData.ids.sceneId) return ActorToken.fromTokenId(rollData.ids.actorTokenId, rollData.ids.sceneId)

View File

@@ -4,10 +4,19 @@ export const ROLL_TYPE_COMP = 'comp'
export const ROLL_TYPE_DEFENSE = 'defense' export const ROLL_TYPE_DEFENSE = 'defense'
export const ROLL_TYPE_JEU = 'jeu' export const ROLL_TYPE_JEU = 'jeu'
export const ROLL_TYPE_MEDITATION = 'meditation' export const ROLL_TYPE_MEDITATION = 'meditation'
export const ROLL_TYPE_CUISINE = 'cuisine'
export const ROLL_TYPE_OEUVRE = 'oeuvre' export const ROLL_TYPE_OEUVRE = 'oeuvre'
export const ROLL_TYPE_SORT = 'sort' export const ROLL_TYPE_SORT = 'sort'
export const ROLL_TYPE_TACHE = 'tache' export const ROLL_TYPE_TACHE = 'tache'
export const ATTAQUE_ROLL_TYPES = [ROLL_TYPE_ATTAQUE]
export const COMBAT_ROLL_TYPES = [ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE]
export const DEMIREVE_ROLL_TYPES = [ROLL_TYPE_SORT]
export const DEFAULT_ROLL_TYPES = [ROLL_TYPE_COMP, ROLL_TYPE_JEU, ROLL_TYPE_MEDITATION, ROLL_TYPE_CUISINE, ROLL_TYPE_OEUVRE, ROLL_TYPE_TACHE]
export const ALL_ROLL_TYPES = [...DEFAULT_ROLL_TYPES, ...COMBAT_ROLL_TYPES, ...DEMIREVE_ROLL_TYPES]
export const DIFF = { export const DIFF = {
LIBRE: 'libre', LIBRE: 'libre',
ATTAQUE: 'attaque', ATTAQUE: 'attaque',

View File

@@ -6,6 +6,10 @@ import { ReglesOptionnelles } from "../settings/regles-optionnelles.js";
import { PART_OEUVRE } from "./roll-part-oeuvre.mjs"; import { PART_OEUVRE } from "./roll-part-oeuvre.mjs";
import { RdDItemArme } from "../item/arme.js"; import { RdDItemArme } from "../item/arme.js";
import { RdDBonus } from "../rdd-bonus.js"; import { RdDBonus } from "../rdd-bonus.js";
import { ITEM_TYPES, RDD_CONFIG } from "../constants.js";
import { CARACS } from "../rdd-carac.js";
import { ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs";
import { PART_ATTAQUE } from "./roll-part-attaque.mjs";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RollDialogAdapter { export class RollDialogAdapter {
@@ -15,21 +19,21 @@ export class RollDialogAdapter {
carac: rollData.current.carac.value, carac: rollData.current.carac.value,
diff: rollData.current.totaldiff, diff: rollData.current.totaldiff,
bonus: rollData.current.bonus, bonus: rollData.current.bonus,
sign: rollData.current.sign,
showDice: rollData.options.showDice, showDice: rollData.options.showDice,
rollMode: rollData.current.rollmode.key rollMode: rollData.current.rollmode.key
}) })
const rolled = await RollDialogAdapter.rollChances(rollData, chances) const rolled = await RollDialogAdapter.rollChances(rollData, chances)
RollDialogAdapter.adjustRollDataForV1(rollData, rolled, rollTitle) RollDialogAdapter.setRollDataRolled(rollData, rolled, rollTitle)
RollDialogAdapter.adjustRollDataForV1(rollData)
RollDialogAdapter.adjustAttaqueParticuliere(rollData)
return rolled return rolled
} }
static computeChances({ carac, diff, bonus, sign, showDice, rollMode }) { static computeChances({ carac, diff, bonus, showDice, rollMode }) {
const chances = foundry.utils.duplicate(RdDResolutionTable.computeChances(carac, diff)) const chances = foundry.utils.duplicate(RdDResolutionTable.computeChances(carac, diff))
RdDResolutionTable._updateChancesWithBonus(chances, bonus, diff) RdDResolutionTable._updateChancesWithBonus(chances, bonus, diff)
RdDResolutionTable._updateChancesFactor(chances, sign)
chances.showDice = showDice chances.showDice = showDice
chances.rollMode = rollMode chances.rollMode = rollMode
return chances return chances
@@ -37,7 +41,7 @@ export class RollDialogAdapter {
static async rollChances(rollData, chances) { static async rollChances(rollData, chances) {
const rolled = await RdDResolutionTable.rollChances(chances, const rolled = await RdDResolutionTable.rollChances(chances,
rollData.current.sign, rollData.current.sign.diviseur,
rollData.current.resultat) rollData.current.resultat)
rolled.caracValue = rollData.current.carac.value rolled.caracValue = rollData.current.carac.value
rolled.finalLevel = rollData.current.totaldiff rolled.finalLevel = rollData.current.totaldiff
@@ -46,13 +50,20 @@ export class RollDialogAdapter {
return rolled return rolled
} }
static adjustRollDataForV1(rollData, rolled, rollTitle) { static setRollDataRolled(rollData, rolled, rollTitle) {
rollData.rolled = rolled
rollData.choix = rollData.choix ?? {}
rollData.show = rollData.show ?? {}
rollData.show.title = rollTitle
}
static adjustRollDataForV1(rollData) {
const rolled = rollData.rolled
// temporaire pour être homogène roll v1 // temporaire pour être homogène roll v1
rollData.alias = rollData.active.actor.getAlias() rollData.alias = rollData.active.actor.getAlias()
// pour experience // pour experience
rollData.finalLevel = rollData.current.totaldiff rollData.finalLevel = rollData.current.totaldiff
if (rollData.use == undefined) { rollData.use = {} } if (rollData.use == undefined) { rollData.use = {} }
if (rollData.show == undefined) { rollData.show = {} }
if (rollData.ajustements == undefined) { if (rollData.ajustements == undefined) {
rollData.ajustements = {} rollData.ajustements = {}
} }
@@ -75,7 +86,6 @@ export class RollDialogAdapter {
if (rollData.current[PART_APPELMORAL]?.checked) { if (rollData.current[PART_APPELMORAL]?.checked) {
rollData.use.moral = true rollData.use.moral = true
} }
rollData.rolled = rolled
if (ReglesOptionnelles.isUsing("afficher-colonnes-reussite")) { if (ReglesOptionnelles.isUsing("afficher-colonnes-reussite")) {
rolled.niveauNecessaire = this.findNiveauNecessaire(carac, rolled.roll) rolled.niveauNecessaire = this.findNiveauNecessaire(carac, rolled.roll)
rolled.ajustementNecessaire = rolled.niveauNecessaire - diff rolled.ajustementNecessaire = rolled.niveauNecessaire - diff
@@ -88,7 +98,39 @@ export class RollDialogAdapter {
descr: aj.diff == undefined ? aj.label : undefined descr: aj.diff == undefined ? aj.label : undefined
} }
}) })
rollData.show.title = rollTitle }
static adjustAttaqueParticuliere(rollData) {
if (rollData.type.current != ROLL_TYPE_ATTAQUE || !rollData.rolled.isPart) {
return
}
const attaque = rollData.current.attaque;
const choix = []
const isEmpoignade = attaque.dmg.mortalite == 'empoignade';
const isCharge = attaque.tactique == 'charge'
/* TODO: cas de créatures faisant des lancers, Glou, Glipzouk */
const isMeleeDiffNegative = (attaque.comp.type == ITEM_TYPES.competencecreature || rollData.current.carac.key == CARACS.MELEE)
&& rollData.current.diff.value < 0
// force toujours, sauf empoignade
if (!isEmpoignade) {
choix.push(RDD_CONFIG.particuliere.force)
}
// finesse seulement en mélée, pour l'empoignade, ou si la difficulté libre est de -1 minimum
if (!isCharge && (isEmpoignade || isMeleeDiffNegative)) {
choix.push(RDD_CONFIG.particuliere.finesse)
}
// rapidité seulement en mêlée, si l'arme le permet, et si la difficulté libre est de -1 minimum
if (!isCharge && !isEmpoignade && isMeleeDiffNegative && attaque.arme.system.rapide) {
choix.push(RDD_CONFIG.particuliere.rapidite)
}
if (choix.length == 1) {
rollData.particuliere = choix[0].key
}
rollData.particulieres = choix
} }
static mapActionAttaque(attackerRoll) { static mapActionAttaque(attackerRoll) {
@@ -99,17 +141,15 @@ export class RollDialogAdapter {
return { return {
// correspond à l'attaque de RollPartAttaque (dans rollDta.current.attaque) // correspond à l'attaque de RollPartAttaque (dans rollDta.current.attaque)
label: label, label: label,
attaque: { // correspond aux actions d'attaques dans RdDActor.listActionsAttaque
// correspond aux actions d'attaques dans RdDActor.listActionsAttaque name: label,
name: label, // action: 'attaque',
// action: 'attaque', arme: attackerRoll.arme,
arme: attackerRoll.arme, comp: attackerRoll.competence,
comp: attackerRoll.competence, main: RdDItemArme.getMainAttaque(attackerRoll.competence),
main: RdDItemArme.getMainAttaque(attackerRoll.competence), equipe: attackerRoll.arme.system.equipe,
equipe: attackerRoll.arme.system.equipe, // carac: { key: caracCode, value: caracValue },
// carac: { key: caracCode, value: caracValue }, // dommagesArme: dommagesArme,
// dommagesArme: dommagesArme,
},
diff: attackerRoll.diffLibre, diff: attackerRoll.diffLibre,
particuliere: attackerRoll.particuliere, particuliere: attackerRoll.particuliere,
tactique: RdDBonus.find(attackerRoll.tactique), tactique: RdDBonus.find(attackerRoll.tactique),

View File

@@ -39,10 +39,13 @@ import { RollDialogAdapter } from "./roll-dialog-adapter.mjs";
import { ROLLDIALOG_SECTION } from "./roll-part.mjs"; import { ROLLDIALOG_SECTION } from "./roll-part.mjs";
import { ROLL_TYPE_COMP } from "./roll-constants.mjs"; import { ROLL_TYPE_COMP } from "./roll-constants.mjs";
import ChatRollResult from "./chat-roll-result.mjs"; import ChatRollResult from "./chat-roll-result.mjs";
import { renderTemplate } from "../constants.js";
import { RollTypeCuisine } from "./roll-type-cuisine.mjs";
import { RollPartCuisine } from "./roll-part-cuisine.mjs";
import { OptionsAvancees, ROLL_DIALOG_V2_TEST } from "../settings/options-avancees.js";
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api
const doNothing = (dialog) => { }
const ALL_ROLL_TYPES = [ const ALL_ROLL_TYPES = [
new RollTypeComp(), new RollTypeComp(),
@@ -51,14 +54,13 @@ const ALL_ROLL_TYPES = [
new RollTypeDefense(), new RollTypeDefense(),
new RollTypeSort(), new RollTypeSort(),
new RollTypeMeditation(), new RollTypeMeditation(),
new RollTypeCuisine(),
new RollTypeOeuvre(), new RollTypeOeuvre(),
new RollTypeJeu(), new RollTypeJeu(),
// new RollTypeResistance ?? // new RollTypeResistance ??
// new RollTypeFixedCarac ?? // new RollTypeFixedCarac ??
] ]
const BASIC_PARTS = new RollBasicParts()
const ROLL_PARTS = [ const ROLL_PARTS = [
new RollPartActor(), new RollPartActor(),
new RollPartAction(), new RollPartAction(),
@@ -72,6 +74,7 @@ const ROLL_PARTS = [
new RollPartMeditation(), new RollPartMeditation(),
new RollPartSort(), new RollPartSort(),
new RollPartTache(), new RollPartTache(),
new RollPartCuisine(),
new RollPartOeuvre(), new RollPartOeuvre(),
new RollPartJeu(), new RollPartJeu(),
@@ -169,6 +172,14 @@ const ROLL_PARTS = [
/* -------------------------------------------- */ /* -------------------------------------------- */
export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2) export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2)
{ {
static onRollDoneDoNothing(dialog) {
dialog.render()
}
static onRollDoneClose(dialog) {
if (!OptionsAvancees.isUsing(ROLL_DIALOG_V2_TEST))
dialog.close()
}
static init() { static init() {
} }
@@ -256,13 +267,13 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
rollData.selected = rollData.selected ?? {} rollData.selected = rollData.selected ?? {}
rollData.type = rollData.type ?? {} rollData.type = rollData.type ?? {}
rollData.type.retry = rollData.type.retry ?? false rollData.type.retry = rollData.type.retry ?? false
BASIC_PARTS.restore(rollData) RollBasicParts.restore(rollData)
const potential = ALL_ROLL_TYPES.find(m => m.code == rollData.type.current)?.code const potential = ALL_ROLL_TYPES.find(m => m.code == rollData.type.current)?.code
const allowed = rollData.type.retry && potential const allowed = rollData.type.retry && potential
? [potential] ? [potential]
: (rollData.type.allowed ?? ALL_ROLL_TYPES.filter(m => m.isAllowed(rollData) && m.visible(rollData)).map(m => m.code)) : (rollData.type.allowed ?? ALL_ROLL_TYPES.filter(m => m.isAllowed(rollData) && m.visible(rollData)).map(m => m.code) ?? [ROLL_TYPE_COMP])
const rollType = allowed.find(c => c == rollData.type.current) ?? (allowed.length > 0 ? allowed[0].code : ROLL_TYPE_COMP); const rollType = allowed.find(c => c == rollData.type.current) ?? allowed[0]
rollData.type.allowed = allowed rollData.type.allowed = allowed
rollData.type.current = rollType rollData.type.current = rollType
@@ -272,9 +283,9 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
rollData.options = rollData.options ?? { rollMode: game.settings.get("core", "rollMode") } rollData.options = rollData.options ?? { rollMode: game.settings.get("core", "rollMode") }
ROLL_PARTS.forEach(p => p.initialize(rollData)) ROLL_PARTS.forEach(p => p.initialize(rollData))
ROLL_PARTS.forEach(p => p.restore(rollData))
ROLL_PARTS.filter(p => p.isValid(rollData)) ROLL_PARTS.filter(p => p.isValid(rollData))
.forEach(p => { .forEach(p => {
p.restore(rollData)
p.loadRefs(rollData) p.loadRefs(rollData)
p.prepareContext(rollData) p.prepareContext(rollData)
}) })
@@ -282,13 +293,14 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
} }
static saveParts(rollData) { static saveParts(rollData) {
const target = BASIC_PARTS.initFrom(rollData) const target = RollBasicParts.initFrom(rollData)
ROLL_PARTS.filter(p => p.isActive(rollData)) ROLL_PARTS.filter(p => p.isActive(rollData))
.forEach(p => p.storeClean(rollData, target)) .forEach(p => p.storeClean(rollData, target))
target.attackerRoll = rollData.attackerRoll target.attackerRoll = rollData.attackerRoll
target.rolled = rollData.rolled target.rolled = rollData.rolled
target.result = rollData.result target.result = rollData.result
target.done = target.done ?? {} target.done = rollData.done ?? {}
target.dmg = rollData.dmg
return target return target
} }
@@ -303,7 +315,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
...(rollOptions.callbacks ?? []) ...(rollOptions.callbacks ?? [])
], ],
customChatMessage: rollOptions.customChatMessage, customChatMessage: rollOptions.customChatMessage,
onRollDone: rollOptions.onRollDone ?? doNothing onRollDone: rollOptions.onRollDone ?? RollDialog.onRollDoneDoNothing
} }
this.chatRollResult = new ChatRollResult(); this.chatRollResult = new ChatRollResult();
this.selectType() this.selectType()
@@ -324,16 +336,16 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
return ROLL_PARTS.filter(p => p.isActive(rollData)) return ROLL_PARTS.filter(p => p.isActive(rollData))
} }
// get title() {
// return this.rollData.title ?? `Jet de dés de ${this.rollData.active.actor.name}`
// }
rollTitle(rollData) { rollTitle(rollData) {
return rollData.label ?? ROLL_PARTS const title = rollData.label ?? ROLL_PARTS
.filter(it => it.section == ROLLDIALOG_SECTION.ACTION) .filter(it => it.section == ROLLDIALOG_SECTION.ACTION)
.filter(it => it.isActive(rollData)) .filter(it => it.isActive(rollData))
.map(it => it.title(rollData)) .map(it => it.title(rollData))
.reduce(Misc.joining(' ')) .reduce(Misc.joining(' '));
if (this.rollOptions.title) {
return `${this.rollOptions.title} ${title}`
}
return title
} }
async _onRender(context, options) { async _onRender(context, options) {
@@ -368,7 +380,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
} }
async buildHTMLTable(carac, diff) { async buildHTMLTable(carac, diff) {
return await foundry.applications.handlebars.renderTemplate('roll-table', { carac, diff }) return await renderTemplate('roll-table', { carac, diff })
} }
async _prepareContext() { async _prepareContext() {
@@ -376,7 +388,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
const types = ALL_ROLL_TYPES.filter(m => m.isAllowed(rollData) && m.visible(rollData)) const types = ALL_ROLL_TYPES.filter(m => m.isAllowed(rollData) && m.visible(rollData))
.map(m => m.toTypeData(rollData)) .map(m => m.toTypeData(rollData))
BASIC_PARTS.loadSurprises(rollData, this.getSelectedType().code) RollBasicParts.loadSurprises(rollData, this.getSelectedType().code)
rollData.type.label = this.getSelectedType()?.title(rollData) rollData.type.label = this.getSelectedType()?.title(rollData)
//TOCHECK: set type.label ? //TOCHECK: set type.label ?
const visibleRollParts = RollDialog.getActiveParts(rollData) const visibleRollParts = RollDialog.getActiveParts(rollData)
@@ -422,18 +434,22 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
} }
async roll() { async roll() {
// ROLL_PARTS.filter(p => p.isActive(this.rollData))
// .forEach(p => p.validate(this.rollData))
const roll = RollDialog.saveParts(this.rollData) const roll = RollDialog.saveParts(this.rollData)
const selectedRollType = this.getSelectedType(roll);
RollDialog.loadRollData(roll) RollDialog.loadRollData(roll)
roll.current.resultat = this.rollData.current[PART_TRICHER]?.resultat ?? -1 roll.current.resultat = this.rollData.current[PART_TRICHER]?.resultat ?? -1
roll.rolled = await this.$rollDice(roll) roll.choix = {}
roll.result = this.getSelectedType(roll).getResult(roll) roll.rolled = await RollDialogAdapter.rollDice(roll, this.rollTitle(roll))
console.info('RollDialog.roll:', roll) roll.result = selectedRollType.getResult(roll)
await Promise.all(this.rollOptions.callbacks.map(async callback => await callback(roll)))
await this.chatRollResult.display(roll)
console.info('RollDialog.roll:', roll)
const callbacks = [
...this.rollOptions.callbacks,
...selectedRollType.callbacks(this.rollOptions),
]
await Promise.all(callbacks.map(async callback => await callback(roll)))
await this.chatRollResult.display(roll)
this.rollOptions.onRollDone(this) this.rollOptions.onRollDone(this)
} }
@@ -443,12 +459,9 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
roll.v2 = true roll.v2 = true
} }
async defaultCallback(rollData, rolled) { async defaultCallback(roll, rolled) {
await rollData.active.actor.appliquerAjoutExperience(rollData) await roll.active.actor.appliquerAjoutExperience(roll)
await rollData.active.actor.appliquerAppelMoral(rollData) await roll.active.actor.appliquerAppelMoral(roll)
} }
async $rollDice(rollData) {
return await RollDialogAdapter.rollDice(rollData, this.rollTitle(rollData))
}
} }

View File

@@ -1,8 +1,8 @@
import { RdDBonus } from "../rdd-bonus.js" import { RdDBonus } from "../rdd-bonus.js"
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js" import { DIFF, ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs"
import { ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs" import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs" import { PART_COMP } from "./roll-part-comp.mjs"
import { PART_DIFF } from "./roll-part-diff.mjs"
import { RollPartSelect } from "./roll-part-select.mjs" import { RollPartSelect } from "./roll-part-select.mjs"
import { ROLLDIALOG_SECTION } from "./roll-part.mjs" import { ROLLDIALOG_SECTION } from "./roll-part.mjs"
@@ -23,7 +23,8 @@ export class RollPartAttaque extends RollPartSelect {
refs.attaques = attaques.map(it => RollPartAttaque.$extractAttaque(it, rollData.active.actor)) refs.attaques = attaques.map(it => RollPartAttaque.$extractAttaque(it, rollData.active.actor))
refs.tactiques = TACTIQUES refs.tactiques = TACTIQUES
if (refs.attaques.length > 0) { if (refs.attaques.length > 0) {
this.$selectAttaque(rollData) const attaque = this.findAttaque(refs.attaques, this.getSaved(rollData))
this.$selectAttaque(rollData, attaque?.key)
} }
} }
@@ -33,19 +34,34 @@ export class RollPartAttaque extends RollPartSelect {
} }
restore(rollData) { restore(rollData) {
const saved = this.getSaved(rollData)
super.restore(rollData) super.restore(rollData)
this.getCurrent(rollData).dmg = this.getSaved(rollData).dmg if (saved.dmg) {
this.getCurrent(rollData).dmg = this.getSaved(rollData).dmg
}
}
findAttaque(attaques, saved) {
return attaques.find(at => at.arme.id == saved?.arme?.id &&
at.comp.id == saved?.comp?.id
)
} }
choices(refs) { return refs.attaques } choices(refs) { return refs.attaques }
static $extractAttaque(attaque, actor) { static $extractAttaque(attaque, actor) {
return { // const extracted = foundry.utils.mergeObject({
key: `${attaque.action}::${attaque.name}`, // key: `${attaque.action}::${attaque.label}`,
label: attaque.name, // tactique: TACTIQUES[0]
attaque: attaque, // },
tactique: TACTIQUES[0], // attaque
} // )
// return extracted
// extracted.initialDiff = attaque.comp?.system.default_diffLibre ?? 0
attaque.key = `${attaque.action}::${attaque.label}`
attaque.tactique = TACTIQUES[0]
attaque.initialDiff = attaque.comp?.system.default_diffLibre ?? 0
return attaque
} }
prepareContext(rollData) { prepareContext(rollData) {
@@ -100,8 +116,14 @@ export class RollPartAttaque extends RollPartSelect {
if (this.visible(rollData)) { if (this.visible(rollData)) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
switch (part.code) { switch (part.code) {
case PART_CARAC: return part.filterCaracs(rollData, [current.attaque.carac.key]) case PART_CARAC: return part.filterCaracs(rollData, [current.carac.key])
case PART_COMP: return part.filterComps(rollData, [current.attaque.comp?.name]) case PART_COMP: return part.filterComps(rollData, [current.comp.name])
case PART_DIFF: {
if (current.initialDiff) {
part.setDiff(rollData, { type: DIFF.ATTAQUE, value: current.initialDiff })
current.initialDiff = undefined
}
}
} }
} }
return undefined return undefined

View File

@@ -28,9 +28,7 @@ export class RollPartCheckbox extends RollPart {
/* TODO: user setting? */ /* TODO: user setting? */
current.checked = true current.checked = true
} }
if (current.value == undefined) { current.value = this.getCheckboxValue(rollData)
current.value = this.getCheckboxValue(rollData)
}
current.icon = this.getCheckboxIcon(rollData) current.icon = this.getCheckboxIcon(rollData)
} }

View File

@@ -17,7 +17,14 @@ export class RollPartComp extends RollPartSelect {
loadRefs(rollData) { loadRefs(rollData) {
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
const selected = this.getSelected(rollData)
refs.all = this.$getActorComps(rollData) refs.all = this.$getActorComps(rollData)
.filter(comp => !selected.forced ||
(selected.key ?
Grammar.includesLowerCaseNoAccent(comp.name, selected.key)
: comp.key == '')
)
refs.comps = refs.all refs.comps = refs.all
this.$selectComp(rollData) this.$selectComp(rollData)
} }
@@ -49,7 +56,6 @@ export class RollPartComp extends RollPartSelect {
allowed = allowed.filter(it => it != undefined) allowed = allowed.filter(it => it != undefined)
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
refs.comps = allowed.length > 0 refs.comps = allowed.length > 0
// ? refs.all.filter(it => allowed.includes(Grammar.toLowerCaseNoAccent(it.label)))
? refs.all.filter(it => allowed.includes(it.label)) ? refs.all.filter(it => allowed.includes(it.label))
: refs.all : refs.all
this.$selectComp(rollData) this.$selectComp(rollData)

View File

@@ -0,0 +1,76 @@
import { ITEM_TYPES } from "../constants.js"
import { CARACS } from "../rdd-carac.js"
import { ROLL_TYPE_CUISINE } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs"
import { RollPartSelect } from "./roll-part-select.mjs"
import { ROLLDIALOG_SECTION } from "./roll-part.mjs"
export const PART_CUISINE = "cuisine"
export class RollPartCuisine extends RollPartSelect {
onReady() {
foundry.applications.handlebars.loadTemplates({ 'roll-oeuvre-recettecuisine': `systems/foundryvtt-reve-de-dragon/templates/roll/roll-oeuvre-recettecuisine.hbs` })
}
get code() { return PART_CUISINE }
get section() { return ROLLDIALOG_SECTION.CHOIX }
isValid(rollData) { return rollData.active.actor.isPersonnage() }
visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_CUISINE) }
loadRefs(rollData) {
const refs = this.getRefs(rollData)
refs.recettes = rollData.active.actor.items
.filter(it => it.type == ITEM_TYPES.recettecuisine)
.map(it => RollPartCuisine.$extractRecette(it, rollData.active.actor))
if (refs.recettes.length > 0) {
this.$selectRecette(rollData)
}
}
choices(refs) { return refs.recettes }
static $extractRecette(recette, actor) {
return {
key: recette.id,
label: recette.name,
caracs: RollPartCuisine.getCaracs(recette),
qualite: recette.system.niveau,
value: -recette.system.niveau,
recette: recette,
comp: actor.getCompetence('Cuisine')
}
}
static getCaracs(recette){
// TODO: permettre différentes caractéristiques pour la cuisine?
return [CARACS.ODORATGOUT, CARACS.EMPATHIE, CARACS.DEXTERITE]
}
$selectRecette(rollData, key) {
this.selectByKey(rollData, key, 0)
}
async _onRender(rollDialog, context, options) {
const selectRecette = rollDialog.element.querySelector(`roll-section[name="${this.code}"] select[name="select-recette"]`)
selectRecette.addEventListener("change", e => {
const selectOptions = e.currentTarget.options
const index = selectOptions.selectedIndex
this.$selectRecette(rollDialog.rollData, selectOptions[index]?.value)
rollDialog.render()
})
}
impactOtherPart(part, rollData) {
if (this.visible(rollData)) {
const current = this.getCurrent(rollData)
switch (part.code) {
case PART_CARAC: return part.filterCaracs(rollData, current.caracs)
case PART_COMP: return part.filterComps(rollData, [current.comp?.name])
}
}
return undefined
}
}

View File

@@ -34,7 +34,7 @@ export class RollPartDefense extends RollPartSelect {
.map(it => RollPartDefense.$extractEsquive(it, defenseur)) .map(it => RollPartDefense.$extractEsquive(it, defenseur))
const parades = defenseur.items.filter(it => it.isParade() && (!refs.isDistance || it.isBouclier())) const parades = defenseur.items.filter(it => it.isParade() && (!refs.isDistance || it.isBouclier()))
.map(it => RollPartDefense.$extractParade(it, attackerRoll?.attaque.arme, defenseur)) .map(it => RollPartDefense.$extractParade(it, attackerRoll?.arme, defenseur))
refs.defenses = [...esquives, ...parades].filter(it => it != undefined) refs.defenses = [...esquives, ...parades].filter(it => it != undefined)
this.$selectDefense(rollData) this.$selectDefense(rollData)
@@ -113,17 +113,16 @@ export class RollPartDefense extends RollPartSelect {
isArmeDisparate(rollData) { isArmeDisparate(rollData) {
const armeDefense = this.getCurrent(rollData).arme const armeDefense = this.getCurrent(rollData).arme
if (armeDefense) { if (armeDefense) {
const armeAttaque = rollData.attackerRoll?.attaque.arme const armeAttaque = rollData.attackerRoll?.arme
return RdDItemArme.defenseArmeParade(armeAttaque, armeDefense) == 'sign' return RdDItemArme.defenseArmeParade(armeAttaque, armeDefense) == 'sign'
} }
return false return false
} }
getDiffDefense(rollData) { getDiffDefense(rollData) {
const current = this.getCurrent(rollData)
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
if (refs.isDistance || !rollData.attackerRoll) { if (refs.isDistance || !rollData.attackerRoll) {
// Déterminer la difficulté de parade // TODO: Déterminer la difficulté de parade
return { diff: 0, type: DIFF.LIBRE } return { diff: 0, type: DIFF.LIBRE }
} }
else { else {

View File

@@ -51,10 +51,10 @@ export class RollPartDiff extends RollPart {
) )
} }
setDiff(rollData, diffDefense) { setDiff(rollData, diff) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
current.value = diffDefense.diff current.value = diff.diff
current.type = diffDefense.type current.type = diff.type
} }
getAjustements(rollData) { getAjustements(rollData) {

View File

@@ -11,26 +11,41 @@ import { ROLLDIALOG_SECTION } from "./roll-part.mjs"
export const PART_MEDITATION = "meditation" export const PART_MEDITATION = "meditation"
const COMPORTEMENTS = ['isComportement', 'isHeure', 'isPurification', 'isVeture']
export class RollPartMeditation extends RollPartSelect { export class RollPartMeditation extends RollPartSelect {
get code() { return PART_MEDITATION } get code() { return PART_MEDITATION }
get section() { return ROLLDIALOG_SECTION.CHOIX } get section() { return ROLLDIALOG_SECTION.CHOIX }
store(rollData, targetData) {
const current = this.getCurrent(rollData)
this.setSaved(targetData, {
key: current.key,
isComportement: current.isComportement,
isHeure: current.isHeure,
isPurification: current.isPurification,
isVeture: current.isVeture
})
}
isValid(rollData) { return rollData.active.actor.isPersonnage() && rollData.active.actor.isHautRevant() } isValid(rollData) { return rollData.active.actor.isPersonnage() && rollData.active.actor.isHautRevant() }
visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_MEDITATION) } visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_MEDITATION) }
loadRefs(rollData) { loadRefs(rollData) {
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
foundry.utils.mergeObject(refs, refs.meditations = rollData.active.actor.itemTypes[ITEM_TYPES.meditation]
{ .map(it => RollPartMeditation.$extractMeditation(it, rollData.active.actor))
meditations: rollData.active.actor.itemTypes[ITEM_TYPES.meditation]
.map(it => RollPartMeditation.$extractMeditation(it, rollData.active.actor))
}
)
if (refs.meditations.length > 0) { if (refs.meditations.length > 0) {
this.$selectMeditation(rollData) this.$selectMeditation(rollData)
this.$selectConditionMeditation(rollData)
const selected = this.getSelected(rollData)
const current = this.getCurrent(rollData)
COMPORTEMENTS.filter(it => selected[it]).forEach(it => current[it] = selected[it])
} }
} }
choices(refs) { return refs.meditations } choices(refs) { return refs.meditations }
static $extractMeditation(meditation, actor) { static $extractMeditation(meditation, actor) {
@@ -48,12 +63,7 @@ export class RollPartMeditation extends RollPartSelect {
getMalusConditions(rollData) { getMalusConditions(rollData) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
const conditionsManquantes = [ const conditionsManquantes = COMPORTEMENTS.filter(it => !current[it]).length
current.isComportement,
current.isHeure,
current.isPurification,
current.isVeture
].filter(it => !it).length
return -2 * conditionsManquantes return -2 * conditionsManquantes
} }
@@ -71,13 +81,18 @@ export class RollPartMeditation extends RollPartSelect {
const previous = this.getCurrent(rollData) const previous = this.getCurrent(rollData)
const current = this.selectByKey(rollData, key, 0) const current = this.selectByKey(rollData, key, 0)
if (current.key != previous.key) { if (current.key != previous.key) {
const heureMonde = RdDTimestamp.getWorldTime().heure this.$selectConditionMeditation(rollData)
const heureMeditation = RdDTimestamp.findHeure(current.meditation.system.heure)?.heure
current.isHeure = heureMeditation == heureMonde
current.isTMR = Grammar.equalsInsensitive(current.meditation.system.tmr, TMRUtility.getTMRType(rollData.active.actor.system.reve.tmrpos.coord))
} }
} }
$selectConditionMeditation(rollData) {
const current = this.getCurrent(rollData)
current.heureMonde = RdDTimestamp.getWorldTime().heure
current.heureMeditation = RdDTimestamp.findHeure(current.meditation.system.heure)?.heure
current.isHeure = current.heureMeditation == current.heureMonde
current.isTMR = Grammar.equalsInsensitive(current.meditation.system.tmr, TMRUtility.getTMRType(rollData.active.actor.system.reve.tmrpos.coord))
}
async _onRender(rollDialog, context, options) { async _onRender(rollDialog, context, options) {
const selectMeditation = rollDialog.element.querySelector(`roll-section[name="${this.code}"] select[name="select-meditation"]`) const selectMeditation = rollDialog.element.querySelector(`roll-section[name="${this.code}"] select[name="select-meditation"]`)
@@ -88,10 +103,7 @@ export class RollPartMeditation extends RollPartSelect {
rollDialog.render() rollDialog.render()
}) })
this.setupListenerCondition(rollDialog, 'isComportement') COMPORTEMENTS.forEach(it => this.setupListenerCondition(rollDialog, it))
this.setupListenerCondition(rollDialog, 'isHeure')
this.setupListenerCondition(rollDialog, 'isPurification')
this.setupListenerCondition(rollDialog, 'isVeture')
} }
setupListenerCondition(rollDialog, inputName) { setupListenerCondition(rollDialog, inputName) {
@@ -108,7 +120,7 @@ export class RollPartMeditation extends RollPartSelect {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
switch (part.code) { switch (part.code) {
case PART_CARAC: return part.filterCaracs(rollData, [CARACS.INTELLECT]) case PART_CARAC: return part.filterCaracs(rollData, [CARACS.INTELLECT])
case PART_COMP: return part.filterComps(rollData,[current.comp?.name]) case PART_COMP: return part.filterComps(rollData, [current.comp?.name])
} }
} }
return undefined return undefined

View File

@@ -11,6 +11,7 @@ export const PART_OEUVRE = "oeuvre"
const ARTS = [ const ARTS = [
{ type: ITEM_TYPES.oeuvre, action: "interpréte l'oeuvre", competence: it => it.system.competence, caracs: it => [it.system.default_carac] }, { type: ITEM_TYPES.oeuvre, action: "interpréte l'oeuvre", competence: it => it.system.competence, caracs: it => [it.system.default_carac] },
{ type: ITEM_TYPES.musique, action: "joue le morceau:", competence: it => 'Musique', caracs: it => [CARACS.OUIE] },
{ type: ITEM_TYPES.chant, action: "chante", competence: it => 'Chant', caracs: it => [CARACS.OUIE] }, { type: ITEM_TYPES.chant, action: "chante", competence: it => 'Chant', caracs: it => [CARACS.OUIE] },
{ {
type: ITEM_TYPES.danse, action: "danse:", competence: it => 'Danse', caracs: it => { type: ITEM_TYPES.danse, action: "danse:", competence: it => 'Danse', caracs: it => {
@@ -20,8 +21,6 @@ const ARTS = [
return caracs return caracs
} }
}, },
{ type: ITEM_TYPES.musique, action: "joue le morceau:", competence: it => 'Musique', caracs: it => [CARACS.OUIE] },
{ type: ITEM_TYPES.recettecuisine, action: "cuisine le plat:", competence: it => 'Cuisine', caracs: it => [CARACS.ODORATGOUT] },
] ]
export class RollPartOeuvre extends RollPartSelect { export class RollPartOeuvre extends RollPartSelect {

View File

@@ -1,5 +1,4 @@
import { ITEM_TYPES } from "../constants.js" import { ITEM_TYPES } from "../constants.js"
import { Grammar } from "../grammar.js"
import { ROLL_TYPE_TACHE } from "./roll-constants.mjs" import { ROLL_TYPE_TACHE } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs" import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs" import { PART_COMP } from "./roll-part-comp.mjs"
@@ -18,13 +17,17 @@ export class RollPartTache extends RollPartSelect {
loadRefs(rollData) { loadRefs(rollData) {
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
refs.taches = rollData.active.actor.itemTypes[ITEM_TYPES.tache] const selected = this.getSelected(rollData)
refs.all = rollData.active.actor.itemTypes[ITEM_TYPES.tache]
.filter(tache => !selected.forced || tache.id == selected.key)
.filter(tache => tache.system.points_de_tache_courant < tache.system.points_de_tache) .filter(tache => tache.system.points_de_tache_courant < tache.system.points_de_tache)
.map(tache => RollPartTache.$extractTache(tache, rollData.active.actor)) .map(tache => RollPartTache.$extractTache(tache, rollData.active.actor))
refs.taches = refs.all
if (refs.taches.length > 0) { if (refs.taches.length > 0) {
this.$selectTache(rollData) this.$selectTache(rollData)
} }
} }
choices(refs) { return refs.taches } choices(refs) { return refs.taches }
static $extractTache(tache, actor) { static $extractTache(tache, actor) {

View File

@@ -43,6 +43,7 @@ export class RollPart {
} }
/** les informations minimales représentant la sélection dans le rollData permettant de restaurer la fenêtre */ /** les informations minimales représentant la sélection dans le rollData permettant de restaurer la fenêtre */
getSelected(rollData) { return this.getSaved(rollData) }
getSaved(rollData) { getSaved(rollData) {
return rollData.selected[this.code] ?? {} return rollData.selected[this.code] ?? {}
} }
@@ -84,9 +85,9 @@ export class RollPart {
loadRefs(rollData) { } loadRefs(rollData) { }
prepareContext(rollData) { } prepareContext(rollData) { }
/** permet de sauvegarder dans rollData les informations (cas des champs edit) */ /** permet de sauvegarder dans rollData les informations (cas des champs edit) */
validate(rollData) {} validate(rollData) { }
/** ---- cross roll-part filtering ---- */ /** ---- cross roll-part filtering ---- */
applyImpact(rollData, filter) { } applyImpact(rollData, filter) { }

View File

@@ -1,4 +1,5 @@
import { DIFF, ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs" import { DIFF, ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs"
import { PART_ATTAQUE } from "./roll-part-attaque.mjs"
import { RollType } from "./roll-type.mjs" import { RollType } from "./roll-type.mjs"
export class RollTypeAttaque extends RollType { export class RollTypeAttaque extends RollType {
@@ -10,4 +11,5 @@ export class RollTypeAttaque extends RollType {
onSelect(rollData) { onSelect(rollData) {
this.setDiffType(rollData, DIFF.ATTAQUE) this.setDiffType(rollData, DIFF.ATTAQUE)
} }
} }

View File

@@ -0,0 +1,28 @@
import { DIFF, ROLL_TYPE_CUISINE } from "./roll-constants.mjs"
import { PART_CUISINE } from "./roll-part-cuisine.mjs"
import { RollType } from "./roll-type.mjs"
export class RollTypeCuisine extends RollType {
get code() { return ROLL_TYPE_CUISINE }
get name() { return `Interpréter une oeuvre` }
visible(rollData) { return rollData.active.actor.isPersonnage() }
title(rollData) {
const current = rollData.current[PART_CUISINE]
return `prépare une recette: ${current.label}`
}
onSelect(rollData) {
this.setDiffType(rollData, DIFF.AUCUN)
}
getResult(rollData){
const current = rollData.current[PART_CUISINE]
const qualite = rollData.rolled.isSuccess ? current.qualite : Math.min(current.qualite, current.comp.system.niveau)
return {
qualite: qualite + rollData.rolled.ptQualite
}
}
}

View File

@@ -1,3 +1,4 @@
import { RdDItemSigneDraconique } from "../item/signedraconique.js"
import { DIFF, ROLL_TYPE_MEDITATION } from "./roll-constants.mjs" import { DIFF, ROLL_TYPE_MEDITATION } from "./roll-constants.mjs"
import { PART_MEDITATION } from "./roll-part-meditation.mjs" import { PART_MEDITATION } from "./roll-part-meditation.mjs"
import { RollType } from "./roll-type.mjs" import { RollType } from "./roll-type.mjs"
@@ -16,4 +17,20 @@ export class RollTypeMeditation extends RollType {
onSelect(rollData) { onSelect(rollData) {
this.setDiffType(rollData, DIFF.AUCUN) this.setDiffType(rollData, DIFF.AUCUN)
} }
callbacks(rollOptions) { return [RollTypeMeditation.$onRollMeditation] }
static async $onRollMeditation(rollData) {
const actor = rollData.active.actor
const meditation = rollData.current.meditation.meditation
const rolled = rollData.rolled
if (meditation && rolled) {
if (rolled.isSuccess) {
await actor.createEmbeddedDocuments("Item", [RdDItemSigneDraconique.prepareSigneDraconiqueMeditation(meditation, rolled)])
}
if (rolled.isEPart) {
await actor.updateEmbeddedDocuments('Item', [{ _id: meditation._id, 'system.malus': meditation.system.malus - 1 }])
}
await actor.santeIncDec("fatigue", 2)
}
}
} }

View File

@@ -1,3 +1,5 @@
import { ITEM_TYPES } from "../constants.js"
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js"
import { DIFF, ROLL_TYPE_TACHE } from "./roll-constants.mjs" import { DIFF, ROLL_TYPE_TACHE } from "./roll-constants.mjs"
import { PART_TACHE } from "./roll-part-tache.mjs" import { PART_TACHE } from "./roll-part-tache.mjs"
import { RollType } from "./roll-type.mjs" import { RollType } from "./roll-type.mjs"
@@ -16,4 +18,26 @@ export class RollTypeTache extends RollType {
onSelect(rollData) { onSelect(rollData) {
this.setDiffType(rollData, DIFF.AUCUN) this.setDiffType(rollData, DIFF.AUCUN)
} }
callbacks(rollOptions) { return [ async r => await RollTypeTache.$onRollTache(r, rollOptions)] }
static async $onRollTache(rollData, rollOptions) {
const actor = rollData.active.actor
const tache = rollData.current[PART_TACHE].tache
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
await actor.santeIncDec("fatigue", tache.system.fatigue)
}
rollData.current[PART_TACHE].tache = await tache.update({
'system.points_de_tache_courant': tache.system.points_de_tache_courant + rollData.rolled.ptTache,
'system.nb_jet_succes': tache.system.nb_jet_succes + (rollData.rolled.isSuccess ? 1 : 0),
'system.nb_jet_echec': tache.system.nb_jet_echec + (rollData.rolled.isSuccess ? 0 : 1),
'system.difficulte': tache.system.difficulte - (rollData.rolled.isETotal ? 1 : 0),
}, {render:true})
if (rollOptions?.onRollAutomate) {
await rollOptions.onRollAutomate(rollData)
}
}
} }

View File

@@ -11,14 +11,13 @@ export class RollType {
get name() { return this.code } get name() { return this.code }
get icon() { return `systems/foundryvtt-reve-de-dragon/assets/actions/${this.code}.svg` } get icon() { return `systems/foundryvtt-reve-de-dragon/assets/actions/${this.code}.svg` }
get chatResultTemplate() { return `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-${this.code}.hbs` } get chatResultTemplate() { return `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-${this.code}.hbs` }
toTypeData(rollData) { toTypeData(rollData) {
return { code: this.code, name: this.name, icon: this.icon, section: 'type', template: this.template, selected: this.isSelected(rollData) } return { code: this.code, name: this.name, icon: this.icon, section: 'type', template: this.template, selected: this.isSelected(rollData) }
} }
isAllowed(rollData) { return rollData.type.allowed == undefined || rollData.type.allowed.includes(this.code) } isAllowed(rollData) { return rollData.type.allowed == undefined || rollData.type.allowed.includes(this.code) }
visible(rollData) { return true } visible(rollData) { return true }
title(rollData) { return this.code } title(rollData) { return this.code }
isSelected(rollData) { return rollData.type.current == this.code } isSelected(rollData) { return rollData.type.current == this.code }
@@ -33,11 +32,10 @@ export class RollType {
this.typeFromOpponents(rollData), this.typeFromOpponents(rollData),
rollData.selected[PART_DIFF].type rollData.selected[PART_DIFF].type
] ]
const type = possibleTypes.find(m => DEFAULT_DIFF_TYPES.includes(m)) ??DIFF.DEFAUT const type = possibleTypes.find(m => DEFAULT_DIFF_TYPES.includes(m)) ?? DIFF.DEFAUT
this.setDiffType(rollData, type) this.setDiffType(rollData, type)
} }
typeFromOpponents(rollData) { typeFromOpponents(rollData) {
if (rollData.type.opposed) { if (rollData.type.opposed) {
if (rollData.type.resistance) { if (rollData.type.resistance) {
@@ -53,7 +51,7 @@ export class RollType {
this.setRollDataType(rollData) this.setRollDataType(rollData)
} }
getResult(rollData){ callbacks(rollOptions) { return [] }
return undefined
} getResult(rollData) { return undefined }
} }

View File

@@ -50,7 +50,7 @@ export class OptionsAvancees extends FormApplication {
.map(it => { .map(it => {
it = foundry.utils.duplicate(it) it = foundry.utils.duplicate(it)
it.id = OptionsAvancees._getId(it.name) it.id = OptionsAvancees._getId(it.name)
it.active = OptionsAvancees.isSet(it.name) it.active = OptionsAvancees.isUsing(it.name)
return it return it
}) })
formData.regles = regles formData.regles = regles
@@ -63,10 +63,6 @@ export class OptionsAvancees extends FormApplication {
} }
static isUsing(name) { static isUsing(name) {
return OptionsAvancees.isSet(name)
}
static isSet(name) {
return game.settings.get(SYSTEM_RDD, OptionsAvancees._getId(name)) return game.settings.get(SYSTEM_RDD, OptionsAvancees._getId(name))
} }

View File

@@ -1,5 +1,5 @@
import { ChatUtility } from "../chat-utility.js"; import { ChatUtility } from "../chat-utility.js";
import { HIDE_DICE, SYSTEM_RDD } from "../constants.js"; import { HIDE_DICE, renderTemplate, SYSTEM_RDD } from "../constants.js";
import { Grammar } from "../grammar.js"; import { Grammar } from "../grammar.js";
import { RdDItem } from "../item.js"; import { RdDItem } from "../item.js";
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "../constants.js";
export class DialogChateauDormant extends Dialog { export class DialogChateauDormant extends Dialog {
@@ -9,7 +10,7 @@ export class DialogChateauDormant extends Dialog {
motifStress: `Nuit du ${date}`, motifStress: `Nuit du ${date}`,
finChateauDormant: game.system.rdd.calendrier.getTimestampFinChateauDormant() finChateauDormant: game.system.rdd.calendrier.getTimestampFinChateauDormant()
}; };
const html = await foundry.applications.handlebars.renderTemplate("systems/foundryvtt-reve-de-dragon/templates/sommeil/dialog-chateau-dormant.hbs", const html = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/sommeil/dialog-chateau-dormant.hbs",
dialogData); dialogData);
new DialogChateauDormant(dialogData, html) new DialogChateauDormant(dialogData, html)

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "../constants.js";
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js"; import { ReglesOptionnelles } from "../settings/regles-optionnelles.js";
import { EffetsDraconiques } from "../tmr/effets-draconiques.js"; import { EffetsDraconiques } from "../tmr/effets-draconiques.js";

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "../constants.js";
export class DialogStress extends Dialog { export class DialogStress extends Dialog {

View File

@@ -4,7 +4,7 @@ import { RdDResolutionTable } from "../rdd-resolution-table.js";
import { RdDDice } from "../rdd-dice.js"; import { RdDDice } from "../rdd-dice.js";
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";
import { DialogChronologie } from "../dialog-chronologie.js"; import { DialogChronologie } from "../dialog-chronologie.js";
import { HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "../constants.js"; import { HIDE_DICE, renderTemplate, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "../constants.js";
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js"; import { ReglesOptionnelles } from "../settings/regles-optionnelles.js";
import { DialogChateauDormant } from "../sommeil/dialog-chateau-dormant.js"; import { DialogChateauDormant } from "../sommeil/dialog-chateau-dormant.js";
import { APP_ASTROLOGIE_REFRESH, AppAstrologie } from "../sommeil/app-astrologie.js"; import { APP_ASTROLOGIE_REFRESH, AppAstrologie } from "../sommeil/app-astrologie.js";

View File

@@ -4,6 +4,7 @@ import { Misc } from "../misc.js";
import { CompendiumTableHelpers } from '../settings/system-compendiums.js'; import { CompendiumTableHelpers } from '../settings/system-compendiums.js';
import { RdDRaretes } from '../item/raretes.js'; import { RdDRaretes } from '../item/raretes.js';
import { Grammar } from '../grammar.js'; import { Grammar } from '../grammar.js';
import { renderTemplate } from '../constants.js';
const FILTER_GROUPS = [ const FILTER_GROUPS = [
{ group: 'type', label: "Type d'objet" }, { group: 'type', label: "Type d'objet" },

View File

@@ -1,3 +1,4 @@
import { renderTemplate } from "./constants.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
@@ -102,7 +103,7 @@ export class TMRRencontres {
/* -------------------------------------------- */ /* -------------------------------------------- */
async $chatRolledRencontre(row, rencontre, tmr) { async $chatRolledRencontre(row, rencontre, tmr) {
const flavorContent = await foundry.applications.handlebars.renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table-roll-rencontre.hbs', const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table-roll-rencontre.hbs',
{ {
roll: row.roll, roll: row.roll,
rencontre, rencontre,

View File

@@ -1,5 +1,6 @@
import { ExperienceLog, XP_TOPIC } from "../actor/experience-log.js"; import { ExperienceLog, XP_TOPIC } from "../actor/experience-log.js";
import { ChatUtility } from "../chat-utility.js"; import { ChatUtility } from "../chat-utility.js";
import { renderTemplate } from "../constants.js";
import { Poetique } from "../poetique.js"; import { Poetique } from "../poetique.js";
import { RdDDice } from "../rdd-dice.js"; import { RdDDice } from "../rdd-dice.js";
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js"; import { ReglesOptionnelles } from "../settings/regles-optionnelles.js";

View File

@@ -1,4 +1,4 @@
import { ITEM_TYPES } from "../constants.js" import { ITEM_TYPES, renderTemplate } from "../constants.js"
import { RdDItemCompetence } from "../item-competence.js" import { RdDItemCompetence } from "../item-competence.js"
import { ChatUtility } from "../chat-utility.js" import { ChatUtility } from "../chat-utility.js"
import { Misc } from "../misc.js" import { Misc } from "../misc.js"

View File

@@ -9,15 +9,14 @@
{{#each combat as |action key|}} {{#each combat as |action key|}}
<li class="item flexrow list-item" data-item-id="{{action._id}}" data-arme-name="{{action.arme.name}}" <li class="item flexrow list-item" data-item-id="{{action._id}}" data-arme-name="{{action.arme.name}}"
data-competence-name="{{action.comp.name}}" data-competence-name="{{action.comp.name}}"
data-tooltip="{{action.name}}: niveau {{plusMoins action.comp.system.niveau}}"> data-tooltip="{{action.label}}: niveau {{plusMoins action.comp.system.niveau}}">
<span class="list-item-label flexrow"> <span class="list-item-label flexrow">
<a class="roll-arme flexrow"> <a class="roll-arme flexrow">
{{#if action.arme.img}} {{#if action.arme.img}}
<img class="sheet-competence-img" src="{{action.arme.img}}" data-tooltip="{{action.arme.name}}" /> <img class="sheet-competence-img" src="{{action.arme.img}}" data-tooltip="{{action.arme.name}}" />
{{/if}} {{/if}}
<span>{{action.name}}</span> <span>{{action.label}}</span>
</a> </a>
({{action.comp.name}})
{{>"systems/foundryvtt-reve-de-dragon/templates/item/icon-arme-broken.hbs" action.arme}} {{>"systems/foundryvtt-reve-de-dragon/templates/item/icon-arme-broken.hbs" action.arme}}
</span> </span>
<span class="competence-value">{{plusMoins action.comp.system.niveau}}</span> <span class="competence-value">{{plusMoins action.comp.system.niveau}}</span>

View File

@@ -2,8 +2,8 @@
data-item-id="{{attaque.arme._id}}" data-item-id="{{attaque.arme._id}}"
data-arme-name="{{attaque.arme.name}}" data-arme-name="{{attaque.arme.name}}"
data-competence-name="{{attaque.comp.name}}"> data-competence-name="{{attaque.comp.name}}">
{{#if attaque.name}} {{#if attaque.label}}
<a class="roll-arme">{{upperFirst attaque.name}}</a> <a class="roll-arme">{{upperFirst attaque.label}}</a>
{{else}} {{else}}
<div></div> <div></div>
{{/if}} {{/if}}

View File

@@ -0,0 +1,103 @@
<div data-passearme="{{passeArme}}">
{{#if (eq surprise 'totale')}}
<span><strong>{{defenderToken.name}}</strong> est totalement surpris</span>
{{else if essais.defense}}
<span><strong>{{defenderToken.name}}</strong> doit :</span>
{{else}}
<span><strong>{{defenderToken.name}}</strong> doit se défendre
{{~#if (eq surprise 'demi')}} avec une significative {{/if}} d'une attaque
{{~#if attaqueParticuliere}} <strong>particulière en
{{~#if (eq attaqueParticuliere 'finesse')}} finesse
{{else if (eq attaqueParticuliere 'force')}} force
{{else if (eq attaqueParticuliere 'rapidite')}} rapidité
{{/if~}}</strong>
{{/if}} de {{attackerToken.name}} ({{attaqueArme.name}}):
</span>
{{/if}}
<span class='chat-card-button-area'>
<br>
{{#unless (eq surprise 'totale')}}
{{#if essais.defense}}
{{#unless essais.defenseChance}}
{{#if (eq defender.type 'personnage')}}
<a class='chat-card-button appel-chance-defense'
data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderToken.id}}' data-attackerTokenId='{{attackerToken.id}}'>
Faire appel à la chance
</a>
<br>
{{/if}}
{{#if (and (eq defender.type 'personnage') (gt defender.system.compteurs.destinee.value 0))}}
<a class='chat-card-button appel-destinee-defense'
data-attackerId='{{attackerId}}' data-attackerTokenId='{{attackerToken.id}}' data-defenderTokenId='{{defenderToken.id}}'>
Utiliser la destinée
</a>
<br>
{{/if}}
{{/unless}}
{{else}}
{{#if (settings-get 'rdd-advanced-roll-dialog-v2')}}
<a class='chat-card-button button-defense'
data-attackerId='{{attackerId}}'
data-attackerTokenId='{{attackerToken.id}}'
data-defenderTokenId='{{defenderToken.id}}'
>
Se défendre
{{#if (or (eq attaqueCategorie 'tir') (eq attaqueCategorie 'lancer'))}}
(difficulté à déterminer)
{{else}}
à {{diffLibre }}
{{/if}}
</a>
<br>
{{else}}
{{#each armes as |arme key|}}
<a class='chat-card-button button-parade'
data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderToken.id}}' data-attackerTokenId='{{../attackerToken.id}}'
data-armeid='{{arme._id}}'>
Parer avec {{arme.name}}
{{#if (or (eq ../attaqueCategorie 'tir') (eq ../attaqueCategorie 'lancer'))}}
(difficulté à déterminer)
{{else}}à {{../diffLibre }}
{{/if}}
{{#if (eq arme.typeParade 'sign')}}
<span class="rdd-diviseur">&times;&frac12;</span>
{{/if}}
{{#if arme.nbUsage}}(Utilisations : {{arme.nbUsage}}){{/if}}
</a>
<br>
{{/each}}
{{#if mainsNues}}
<a class='chat-card-button button-parade'
data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderToken.id}}' data-attackerTokenId='{{attackerToken.id}}'
data-armeid='{{arme._id}}' data-competence='{{arme.system.competence}}'>
Parer à mains nues à {{diffLibre}}{{#if arme.nbUsage}} (Utilisations : {{arme.nbUsage}}){{/if}}
</a>
<br>
{{/if}}
{{#if (ne attaqueCategorie 'tir')}}
{{#each esquives as |esquive key|}}
<a class='chat-card-button button-esquive'
data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderToken.id}}' data-attackerTokenId='{{../attackerToken.id}}'
data-compid='{{esquive._id}}' data-competence='{{esquive.name}}'>
{{esquive.name}}
{{#if (or (eq ../attaqueCategorie 'tir') (eq ../attaqueCategorie 'lancer'))}}
(difficulté à déterminer)
{{else}}à {{../diffLibre }}
{{/if}}
{{#if esquive.nbUsage}}(Utilisations : {{esquive.nbUsage}}){{/if}}
</a>
<br>
{{/each}}
{{/if}}
{{/if}}
{{/if}}
{{/unless}}
<a class='chat-card-button button-encaisser'
data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderToken.id}}' data-attackerTokenId='{{attackerToken.id}}'>
Encaisser à {{plusMoins dmg.total}}
{{#if (eq dmg.mortalite 'non-mortel')~}}
(non-mortel) !
{{/if}}
</a>
</span>
</div>

View File

@@ -1,103 +1,59 @@
<div data-passearme="{{passeArme}}"> {{log this}}
{{#if (eq surprise 'totale')}} <div class="roll-chat" data-passearme="{{passeArme}}">
<span><strong>{{defenderToken.name}}</strong> est totalement surpris</span> <div class="chat-img">
{{else if essais.defense}} <img src="{{opponent.img}}" data-tooltip="{{opponent.name}}" />
<span><strong>{{defenderToken.name}}</strong> doit :</span> </div>
{{else}}
<span><strong>{{defenderToken.name}}</strong> doit se défendre <div class="chat-header">
{{~#if (eq surprise 'demi')}} avec une significative {{/if}} d'une attaque <h4>Défense de {{opponent.name}}</h4>
{{~#if attaqueParticuliere}} <strong>particulière en </div>
{{~#if (eq attaqueParticuliere 'finesse')}} finesse
{{else if (eq attaqueParticuliere 'force')}} force <div class="chat-resume">
{{else if (eq attaqueParticuliere 'rapidite')}} rapidité {{#if (eq opponent.surprise.key 'totale')}}
{{/if~}}</strong> <span><strong>{{opponent.name}}</strong> est totalement surpris</span>
{{/if}} de {{attackerToken.name}} ({{attaqueArme.name}}): {{else}}
</span> <span><strong>{{opponent.name}}</strong> doit se défendre
{{/if}} {{~#if (eq opponent.surprise.key 'demi')}} avec une significative {{/if}} d'une attaque
<span class='chat-card-button-area'> {{~#if particuliere}} <strong>particulière en
<br> {{~#if (eq particuliere 'finesse')}} finesse
{{#unless (eq surprise 'totale')}} {{else if (eq particuliere 'force')}} force
{{#if essais.defense}} {{else if (eq particuliere 'rapidite')}} rapidité
{{#unless essais.defenseChance}} {{/if~}}</strong>
{{#if (eq defender.type 'personnage')}} {{/if}} de {{active.name}} ({{current.attaque.label}}):
<a class='chat-card-button appel-chance-defense' </span>
data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderToken.id}}' data-attackerTokenId='{{attackerToken.id}}'> {{/if}}
Faire appel à la chance </div>
</a>
<br> <div class="chat-details">
{{/if}} </div>
{{#if (and (eq defender.type 'personnage') (gt defender.system.compteurs.destinee.value 0))}}
<a class='chat-card-button appel-destinee-defense' <div class="chat-actions">
data-attackerId='{{attackerId}}' data-attackerTokenId='{{attackerToken.id}}' data-defenderTokenId='{{defenderToken.id}}'> {{#unless (eq opponent.surprise.key 'totale')}}
Utiliser la destinée <a class='chat-card-button button-defense'
</a> data-attackerId='{{ids.actorId}}'
<br> data-attackerTokenId='{{ids.actorTokenId}}'
{{/if}} data-defenderTokenId='{{ids.opponentTokenId}}'
{{/unless}}
{{else}}
{{#if (settings-get 'rdd-advanced-roll-dialog-v2')}}
<a class='chat-card-button button-defense'
data-attackerId='{{attackerId}}'
data-attackerTokenId='{{attackerToken.id}}'
data-defenderTokenId='{{defenderToken.id}}'
> >
<img src="systems/foundryvtt-reve-de-dragon/assets/actions/defense.svg"/>
Se défendre Se défendre
{{#if (or (eq attaqueCategorie 'tir') (eq attaqueCategorie 'lancer'))}} {{#if (or (eq attaqueCategorie 'tir') (eq attaqueCategorie 'lancer'))}}
(difficulté à déterminer) (difficulté à déterminer)
{{else}} {{else}}
à {{diffLibre }} à {{current.diff.value}}
{{/if}} {{/if}}
</a> </a>
<br> {{/unless}}
{{else}} {{#unless (eq dmg.mortalite 'empoignade')}}
{{#each armes as |arme key|}} <a class='chat-card-button encaissement'
<a class='chat-card-button button-parade' data-tooltip="Encaisser à {{plusMoins dmg.total}} {{#if (eq dmg.mortalite 'non-mortel')~}}(non-mortel){{/if}}"
data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderToken.id}}' data-attackerTokenId='{{../attackerToken.id}}' >
data-armeid='{{arme._id}}'> <img src="systems/foundryvtt-reve-de-dragon/assets/ui/encaisser.svg"/>
Parer avec {{arme.name}} Encaisser à {{plusMoins dmg.total}}
{{#if (or (eq ../attaqueCategorie 'tir') (eq ../attaqueCategorie 'lancer'))}} {{#if (eq dmg.mortalite 'non-mortel')~}}(non-mortel){{/if}}
(difficulté à déterminer) </a>
{{else}}à {{../diffLibre }} {{/unless}}
{{/if}} </div>
{{#if (eq arme.typeParade 'sign')}}
<span class="rdd-diviseur">&times;&frac12;</span> <div class="chat-buttons">
{{/if}} </div>
{{#if arme.nbUsage}}(Utilisations : {{arme.nbUsage}}){{/if}}
</a>
<br>
{{/each}}
{{#if mainsNues}}
<a class='chat-card-button button-parade'
data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderToken.id}}' data-attackerTokenId='{{attackerToken.id}}'
data-armeid='{{arme._id}}' data-competence='{{arme.system.competence}}'>
Parer à mains nues à {{diffLibre}}{{#if arme.nbUsage}} (Utilisations : {{arme.nbUsage}}){{/if}}
</a>
<br>
{{/if}}
{{#if (ne attaqueCategorie 'tir')}}
{{#each esquives as |esquive key|}}
<a class='chat-card-button button-esquive'
data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderToken.id}}' data-attackerTokenId='{{../attackerToken.id}}'
data-compid='{{esquive._id}}' data-competence='{{esquive.name}}'>
{{esquive.name}}
{{#if (or (eq ../attaqueCategorie 'tir') (eq ../attaqueCategorie 'lancer'))}}
(difficulté à déterminer)
{{else}}à {{../diffLibre }}
{{/if}}
{{#if esquive.nbUsage}}(Utilisations : {{esquive.nbUsage}}){{/if}}
</a>
<br>
{{/each}}
{{/if}}
{{/if}}
{{/if}}
{{/unless}}
<a class='chat-card-button button-encaisser'
data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderToken.id}}' data-attackerTokenId='{{attackerToken.id}}'>
Encaisser à {{plusMoins dmg.total}}
{{#if (eq dmg.mortalite 'non-mortel')~}}
(non-mortel) !
{{/if}}
</a>
</span>
</div> </div>

View File

@@ -1,13 +1,11 @@
{{log rolled}}
<div> <div>
<span {{#if ajustements}}class="tooltip-overflow tooltip-dotted" {{/if}}> <span {{#if ajustements}}class="tooltip-overflow tooltip-dotted" {{/if}}>
<span> <span>
<span>{{rolled.caracValue}} à {{plusMoins rolled.finalLevel}}</span> <span>{{rolled.caracValue}} à {{plusMoins rolled.finalLevel}}</span>
{{#if (and rolled.factorHtml (gt rolled.factorHtml 1))}}
<span class="rdd-diviseur">&times;{{{rolled.factorHtml}}}</span>
<span>= {{rolled.score}}%</span>
<span class="rdd-diviseur">&times;{{{rolled.factorHtml}}}</span>
{{else}}
<span>= {{rolled.score}}%</span> <span>= {{rolled.score}}%</span>
{{#if (and rolled.factorHtml (ne rolled.factorHtml 1))}}
<span class="rdd-diviseur">&times;{{{rolled.factorHtml}}}</span>
{{/if}} {{/if}}
</span> </span>
<div class="tooltiptext ttt-ajustements"> <div class="tooltiptext ttt-ajustements">

View File

@@ -6,8 +6,8 @@
<div class="control-icon token-hud-icon rdd-hud-menu rdd-attaque" <div class="control-icon token-hud-icon rdd-hud-menu rdd-attaque"
data-combatant-id="{{../combatant.id}}" data-combatant-id="{{../combatant.id}}"
data-action-index="{{action.index}}" data-action-index="{{action.index}}"
data-tooltip="Attaque: {{action.name}}"> data-tooltip="Attaque: {{action.label}}">
<label><i class="fa-solid fa-sword"></i> {{action.name}} {{action.system.infoMain}}</label> <label><i class="fa-solid fa-sword"></i> {{action.label}} {{action.system.infoMain}}</label>
</div> </div>
{{/unless}} {{/unless}}
{{/each}} {{/each}}

View File

@@ -0,0 +1,34 @@
{{log this}}
<div class="control-icon rdd-combat ">
<img class="rdd-hud-togglebutton"
src="systems/foundryvtt-reve-de-dragon/icons/heures/hd06.svg" width="36" height="36"
data-tooltip="Combat"/>
<div class="rdd-hud-list token-hud-ext left">
<div class="control-icon token-hud-icon select-init-v2">
<i class="fa-solid fa-dice-d6"></i>
<select name="initiative">
{{log combatant}}
<option value="">{{#if combatant.system.init}}
{{combatant.system.init.value}} {{combatant.system.init.label}}
{{else}}Initiative...{{/if}}
</option>
{{selectOptions actions selected='' valueAttr='index' labelAttr='label'}}
</select>
</div>
{{!-- <div class="control-icon token-hud-icon rdd-init-v2"
data-combatant-id="{{../combatant.id}}"
data-action="initiative"
data-tooltip="Choisir l'initiative">
<label><i class="fa-solid fa-dice-d6"></i><span> Initiative</span></label>
</div> --}}
<div class="control-icon token-hud-icon rdd-attaque-v2"
data-combatant-id="{{../combatant.id}}"
data-action="attaque"
data-tooltip="Attaquer la cible">
<label><i class="fa-solid fa-sword"></i> Attaquer</label>
</div>
</div>
</div>

View File

@@ -5,17 +5,17 @@
<div class="control-icon token-hud-icon rdd-hud-menu" <div class="control-icon token-hud-icon rdd-hud-menu"
data-combatant-id="{{../combatant.id}}" data-combatant-id="{{../combatant.id}}"
data-action-index="{{action.index}}" data-action-index="{{action.index}}"
data-tooltip="Initiative {{action.name}}"> data-tooltip="Initiative {{action.label}}">
<label><i class="fa-solid fa-dice-d6"></i><span> {{action.name}} {{action.system.infoMain}}</span></label> <label><i class="fa-solid fa-dice-d6"></i><span> {{action.label}} {{action.system.infoMain}}</span></label>
</div> </div>
{{/each}} {{/each}}
{{#each commandes as |commande key|}} {{#each commandes as |commande key|}}
<div class="control-icon token-hud-icon rdd-hud-menu" <div class="control-icon token-hud-icon rdd-hud-menu"
data-command="{{commande.command}}" data-command="{{commande.command}}"
data-command-value="{{commande.value}}"
data-combatant-id="{{../combatant.id}}" data-combatant-id="{{../combatant.id}}"
data-action-index="{{commande.index}}" data-tooltip="{{commande.label}}">
data-tooltip="{{commande.name}}"> <label>{{commande.label}}</label>
<label>{{commande.name}}</label>
</div> </div>
{{/each}} {{/each}}
</div> </div>

View File

@@ -0,0 +1,75 @@
<div class="roll-chat">
<div class="chat-img">
<img src="{{active.img}}" data-tooltip="{{active.name}}" />
<img src="{{current.comp.img}}" data-tooltip="{{current.comp.name}}" />
<img src="{{opponent.img}}" data-tooltip="{{opponent.name}}" />
</div>
<div class="chat-header">
{{active.name}} attaque {{opponent.name}}: {{current.label}}
</div>
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
</div>
<div class="chat-details">
<hr>
{{#if rolled.isSuccess}}
<span>
<strong>{{opponent.name}}</strong> doit se défendre à <strong>{{current.diff.value}}</strong>,
{{#if (eq current.dmg.mortalite 'empoignade')}}
ou {{active.name}} marquera un point d'empoignade
{{else if (eq current.dmg.mortalite 'non-mortel')}}
ou encaisser à <span class="rdd-roll-norm">{{plusMoins current.dmg.total}} (non-mortel)</span>
{{else}}
{{!-- {{~#if (eq current.dmg.mortalite 'mortel')}} --}}
ou encaisser à <span class="rdd-roll-echec">{{plusMoins current.dmg.total}}</span>
{{!-- {{~#if (eq current.dmg.mortalite 'cauchemar')}} --}}
{{!-- {{else}}
<span class="rdd-roll-etotal">{{plusMoins dmg.total}}</span> (entités de cauchemar) --}}
{{/if}}
</span>
{{#if show.recul}}
<span class='chat-card-info'>
<img src="icons/svg/thrust.svg" data-tooltip="charge" />
Si votre adversaire n'esquive pas cette {{show.recul.raison}}, il devra résister à l'impact ou reculer sous le choc!
</span>
{{/if}}
{{#if (eq particuliere 'rapidite')}}
<span>
<br>Votre attaque rapide vous permet une deuxième attaque, ou une défense supplémentaire!
</span>
{{/if}}
{{else}}
<span>Votre attaque a échoué!</span>
{{/if}}
{{#if (eq current.tactique 'charge')}}
<span class='chat-card-info'>
<img src="icons/svg/thrust.svg" data-tooltip="charge" />
C'est une charge, vos parades auront un -4 et vous ne pourrez pas esquiver!
</span>
{{/if}}
{{#if (and (eq current.tactique 'feinte') rolled.isSuccess)}}
<span class='chat-card-info'>
<img src="systems/foundryvtt-reve-de-dragon/icons/heures/hd06.svg" data-tooltip="feinte"/>
Votre feinte peut faire mouche!
</span>
{{/if}}
<p>
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-info-appel-au-moral.hbs"}}
</p>
</div>
<div class="chat-actions">
{{> 'partial-attaque-particuliere'}}
{{!-- TODO: maladresses --}}
</div>
<div class="chat-buttons">
{{> 'partial-appel-chance'}}
</div>
</div>

View File

@@ -0,0 +1,23 @@
<div class="roll-chat">
<div class="chat-img">
<img src="{{active.img}}" data-tooltip="{{active.name}}" />
<img src="{{current.comp.img}}" data-tooltip="{{current.comp.name}}" />
</div>
<div class="chat-header">
{{active.name}} fait un jet de {{current.comp.label}}
</div>
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
</div>
<div class="chat-details">
<p>Qualité {{rolled.ptQualite}}, points de tâche {{rolled.ptQualite}}
</p>
{{> 'partial-info-appel-moral'}}
</div>
<div class="chat-buttons">
{{> 'partial-appel-chance'}}
</div>
</div>

View File

@@ -0,0 +1,29 @@
<div class="roll-chat">
<div class="chat-img">
<img src="{{active.img}}" data-tooltip="{{active.name}}" />
<img src="{{current.comp.img}}" data-tooltip="{{current.comp.name}}" />
</div>
<div class="chat-header">
{{active.name}} prépare une recette de niveau {{current.cuisine.recette.system.niveau}}: : {{current.cuisine.label}} (
</div>
<div class="chat-resume">
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
</div>
<div class="chat-details">
<p>
{{active.name}}
{{#if rolled.isSuccess}}réussit la recette avec
{{else}}manque d'inspiration, le plat a
{{/if}}
une qualité de {{result.qualite}}.
</p>
{{> 'partial-info-appel-moral'}}
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-description.hbs" current.cuisine.recette.system}}
</div>
<div class="chat-buttons">
{{> 'partial-appel-chance'}}
</div>
</div>

Some files were not shown because too many files have changed in this diff Show More