intelligent-system-design-language 0.3.21 → 0.3.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/langium-language-designer.md +38 -38
- package/.claude/agents/typescript-vscode-expert.md +29 -29
- package/.claude/agents/ui-ux-designer.md +36 -36
- package/.claude/settings.local.json +33 -33
- package/.idea/inspectionProfiles/Project_Default.xml +6 -6
- package/.idea/isdl.iml +13 -13
- package/.idea/modules.xml +8 -8
- package/.idea/vcs.xml +6 -6
- package/.idea/watcherTasks.xml +3 -3
- package/.vscodeignore +18 -18
- package/LICENSE +673 -673
- package/README.md +86 -86
- package/bin/cli.js +4 -4
- package/bin/lsp.js +8 -8
- package/out/_backgrounds.scss +91 -91
- package/out/_handlebars.scss +497 -497
- package/out/_isdlStyles.scss +1444 -1381
- package/out/_vuetifyOverrides.scss +425 -425
- package/out/_vuetifyStyles.scss +31957 -31957
- package/out/cli/components/_backgrounds.scss +91 -91
- package/out/cli/components/_handlebars.scss +497 -497
- package/out/cli/components/_isdlStyles.scss +1444 -1381
- package/out/cli/components/_vuetifyOverrides.scss +425 -425
- package/out/cli/components/_vuetifyStyles.scss +31957 -31957
- package/out/cli/components/active-effect-sheet-generator.js +453 -453
- package/out/cli/components/chat-card-generator.js +654 -651
- package/out/cli/components/chat-card-generator.js.map +1 -1
- package/out/cli/components/css-generator.js +4 -4
- package/out/cli/components/damage-roll-generator.js +160 -160
- package/out/cli/components/datamodel-generator.js +264 -257
- package/out/cli/components/datamodel-generator.js.map +1 -1
- package/out/cli/components/derived-data-generator.js +923 -923
- package/out/cli/components/hotbar-drop-hook-generator.js +82 -82
- package/out/cli/components/init-hook-generator.js +495 -495
- package/out/cli/components/language-generator.js +1 -1
- package/out/cli/components/language-generator.js.map +1 -1
- package/out/cli/components/measured-template-preview.js +221 -221
- package/out/cli/components/method-generator.js +979 -887
- package/out/cli/components/method-generator.js.map +1 -1
- package/out/cli/components/ready-hook-generator.js +404 -404
- package/out/cli/components/token-generator.js +116 -116
- package/out/cli/components/vue/base-components/vue-attribute.js +138 -138
- package/out/cli/components/vue/base-components/vue-boolean.js +64 -64
- package/out/cli/components/vue/base-components/vue-calculator.js +93 -93
- package/out/cli/components/vue/base-components/vue-damage-application.js +356 -356
- package/out/cli/components/vue/base-components/vue-damage-bonuses.js +165 -165
- package/out/cli/components/vue/base-components/vue-damage-resistances.js +196 -196
- package/out/cli/components/vue/base-components/vue-damage-track.js +121 -121
- package/out/cli/components/vue/base-components/vue-date-time.js +42 -42
- package/out/cli/components/vue/base-components/vue-dice.js +98 -98
- package/out/cli/components/vue/base-components/vue-die.js +73 -73
- package/out/cli/components/vue/base-components/vue-document-choice.js +149 -149
- package/out/cli/components/vue/base-components/vue-document-choices.js +179 -179
- package/out/cli/components/vue/base-components/vue-document-link.js +60 -60
- package/out/cli/components/vue/base-components/vue-extended-choice.js +88 -88
- package/out/cli/components/vue/base-components/vue-inventory.js +519 -519
- package/out/cli/components/vue/base-components/vue-macro-choice.js +138 -138
- package/out/cli/components/vue/base-components/vue-measured-template.js +530 -530
- package/out/cli/components/vue/base-components/vue-money.js +483 -483
- package/out/cli/components/vue/base-components/vue-number.js +174 -174
- package/out/cli/components/vue/base-components/vue-paperdoll.js +43 -43
- package/out/cli/components/vue/base-components/vue-parent-property-reference.js +76 -76
- package/out/cli/components/vue/base-components/vue-prosemirror.js +18 -18
- package/out/cli/components/vue/base-components/vue-resource.js +136 -136
- package/out/cli/components/vue/base-components/vue-roll-visualizer.js +286 -109
- package/out/cli/components/vue/base-components/vue-roll-visualizer.js.map +1 -1
- package/out/cli/components/vue/base-components/vue-self-property-reference.js +62 -62
- package/out/cli/components/vue/base-components/vue-string-choice.js +98 -98
- package/out/cli/components/vue/base-components/vue-string-choices.js +203 -203
- package/out/cli/components/vue/base-components/vue-string.js +60 -60
- package/out/cli/components/vue/base-components/vue-text-field.js +53 -53
- package/out/cli/components/vue/base-components/vue-tracker.js +431 -431
- package/out/cli/components/vue/vue-action-component-generator.js +64 -64
- package/out/cli/components/vue/vue-active-effect-sheet-generator.js +856 -856
- package/out/cli/components/vue/vue-datatable-sheet-class-generator.js +292 -292
- package/out/cli/components/vue/vue-datatable2-component-generator.js +824 -824
- package/out/cli/components/vue/vue-document-creation-app.js +121 -121
- package/out/cli/components/vue/vue-document-creation-sheet.js +94 -94
- package/out/cli/components/vue/vue-generator.js +40 -40
- package/out/cli/components/vue/vue-mixin.js +296 -296
- package/out/cli/components/vue/vue-pinned-datatable-component-generator.js +260 -260
- package/out/cli/components/vue/vue-prompt-generator.js +91 -76
- package/out/cli/components/vue/vue-prompt-generator.js.map +1 -1
- package/out/cli/components/vue/vue-prompt-sheet-class-generator.js +317 -317
- package/out/cli/components/vue/vue-sheet-application-generator.js +1177 -1167
- package/out/cli/components/vue/vue-sheet-application-generator.js.map +1 -1
- package/out/cli/components/vue/vue-sheet-class-generator.js +510 -510
- package/out/cli/generator.js +438 -433
- package/out/cli/generator.js.map +1 -1
- package/out/extension/github/githubAuthProvider.js +71 -29
- package/out/extension/github/githubAuthProvider.js.map +1 -1
- package/out/extension/github/githubGistManager.js +4 -3
- package/out/extension/github/githubGistManager.js.map +1 -1
- package/out/extension/github/githubManager.js +40 -38
- package/out/extension/github/githubManager.js.map +1 -1
- package/out/extension/github/githubQuickActions.js +120 -120
- package/out/extension/github/system-workflow.yml +47 -47
- package/out/extension/main.cjs +909 -532
- package/out/extension/main.cjs.map +3 -3
- package/out/extension/package.json +419 -419
- package/out/language/generated/ast.js +51 -2
- package/out/language/generated/ast.js.map +1 -1
- package/out/language/generated/grammar.js +14240 -13991
- package/out/language/generated/grammar.js.map +1 -1
- package/out/language/intelligent-system-design-language-validator.js +32 -2
- package/out/language/intelligent-system-design-language-validator.js.map +1 -1
- package/out/language/isdl-scope-provider.js +14 -1
- package/out/language/isdl-scope-provider.js.map +1 -1
- package/out/language/main.cjs +913 -569
- package/out/language/main.cjs.map +3 -3
- package/out/package.json +419 -419
- package/out/progressbar.min.js +6 -6
- package/out/styles.scss +762 -747
- package/out/test/validating/diagnostics.test.js +40 -0
- package/out/test/validating/diagnostics.test.js.map +1 -1
- package/package.json +419 -419
|
@@ -54,202 +54,202 @@ export default function generateDamageResistancesComponent(destination, entry) {
|
|
|
54
54
|
return JSON.stringify(damageTypeMap, null, 8);
|
|
55
55
|
}
|
|
56
56
|
const damageTypesObject = extractDamageTypes();
|
|
57
|
-
const fileNode = expandToNode `
|
|
58
|
-
<script setup>
|
|
59
|
-
import { ref, computed, inject, watchEffect } from "vue";
|
|
60
|
-
|
|
61
|
-
const props = defineProps({
|
|
62
|
-
label: String,
|
|
63
|
-
systemPath: String,
|
|
64
|
-
context: Object,
|
|
65
|
-
visibility: String,
|
|
66
|
-
editMode: Boolean,
|
|
67
|
-
icon: String
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const document = inject("rawDocument");
|
|
71
|
-
|
|
72
|
-
// Static damage type configuration extracted from AST
|
|
73
|
-
const damageTypeConfig = ${damageTypesObject};
|
|
74
|
-
|
|
75
|
-
const isHidden = computed(() => {
|
|
76
|
-
if (props.visibility === "hidden") {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
if (props.visibility === "gm" && !game.user.isGM) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
return false;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Get all damage resistances from the actor's system
|
|
86
|
-
const damageResistances = computed(() => {
|
|
87
|
-
const system = document.system;
|
|
88
|
-
const resistanceInfo = {};
|
|
89
|
-
|
|
90
|
-
// Scan all system properties for resistance damage fields
|
|
91
|
-
for (const [key, value] of Object.entries(system)) {
|
|
92
|
-
const flatResistMatch = key.match(/^(.+)damageresistanceflat$/);
|
|
93
|
-
const percentResistMatch = key.match(/^(.+)damageresistancepercent$/);
|
|
94
|
-
|
|
95
|
-
let damageType = null;
|
|
96
|
-
let effectType = null;
|
|
97
|
-
|
|
98
|
-
if (flatResistMatch) {
|
|
99
|
-
damageType = flatResistMatch[1];
|
|
100
|
-
effectType = 'flatResistance';
|
|
101
|
-
} else if (percentResistMatch) {
|
|
102
|
-
damageType = percentResistMatch[1];
|
|
103
|
-
effectType = 'percentResistance';
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (damageType && effectType) {
|
|
107
|
-
if (!resistanceInfo[damageType]) {
|
|
108
|
-
const damageTypeObj = damageTypeConfig[damageType] || {};
|
|
109
|
-
|
|
110
|
-
resistanceInfo[damageType] = {
|
|
111
|
-
type: damageType,
|
|
112
|
-
label: damageTypeObj.label || damageType,
|
|
113
|
-
icon: damageTypeObj.icon || 'fa-solid fa-circle-info',
|
|
114
|
-
color: damageTypeObj.color || '#666666',
|
|
115
|
-
flatResistance: 0,
|
|
116
|
-
percentResistance: 0
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (effectType === 'flatResistance') {
|
|
121
|
-
resistanceInfo[damageType].flatResistance = Number(value) || 0;
|
|
122
|
-
} else if (effectType === 'percentResistance') {
|
|
123
|
-
resistanceInfo[damageType].percentResistance = Number(value) || 0;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Convert to array and sort by damage type name
|
|
129
|
-
return Object.values(resistanceInfo).sort((a, b) => a.type.localeCompare(b.type));
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// Helper function to capitalize damage type names
|
|
133
|
-
const capitalize = (str) => {
|
|
134
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// Helper function to format resistance values
|
|
138
|
-
const formatValue = (value, suffix = '') => {
|
|
139
|
-
const numValue = Number(value) || 0;
|
|
140
|
-
return \`\${numValue}\${suffix}\`;
|
|
141
|
-
};
|
|
142
|
-
</script>
|
|
143
|
-
|
|
144
|
-
<template>
|
|
145
|
-
<div v-if="!isHidden" class="isdl-damage-resistances pt-2 double-wide">
|
|
146
|
-
<v-card class="damage-resistances-card" variant="outlined" theme="light" color="white">
|
|
147
|
-
<v-card-title class="damage-resistances-header bg-grey-darken-3 text-white">
|
|
148
|
-
<v-icon v-if="icon" class="me-2">{{ icon }}</v-icon>
|
|
149
|
-
<span>{{ game.i18n.localize(label) }}</span>
|
|
150
|
-
</v-card-title>
|
|
151
|
-
|
|
152
|
-
<v-card-text class="pa-0">
|
|
153
|
-
<div v-if="damageResistances.length === 0" class="text-center text-disabled pa-2">
|
|
154
|
-
No damage resistances found
|
|
155
|
-
</div>
|
|
156
|
-
|
|
157
|
-
<v-table v-else density="compact" class="damage-resistances-table">
|
|
158
|
-
<thead>
|
|
159
|
-
<tr>
|
|
160
|
-
<th class="text-left text-white">Type</th>
|
|
161
|
-
<th class="text-center text-white">Flat Resistance</th>
|
|
162
|
-
<th class="text-center text-white">% Resistance</th>
|
|
163
|
-
</tr>
|
|
164
|
-
</thead>
|
|
165
|
-
<tbody>
|
|
166
|
-
<tr v-for="damage in damageResistances" :key="damage.type" class="damage-type-row">
|
|
167
|
-
<td class="damage-type-name">
|
|
168
|
-
<div class="damage-type-header">
|
|
169
|
-
<v-icon :color="damage.color" size="small" class="me-2">{{ damage.icon }}</v-icon>
|
|
170
|
-
<span class="text-subtitle-2">{{ damage.label || capitalize(damage.type) }}</span>
|
|
171
|
-
</div>
|
|
172
|
-
</td>
|
|
173
|
-
<td class="text-center">
|
|
174
|
-
<v-chip
|
|
175
|
-
size="small"
|
|
176
|
-
:color="Number(damage.flatResistance) > 0 ? 'primary' : 'default'"
|
|
177
|
-
variant="flat"
|
|
178
|
-
class="text-white font-weight-bold"
|
|
179
|
-
>
|
|
180
|
-
{{ formatValue(damage.flatResistance) }}
|
|
181
|
-
</v-chip>
|
|
182
|
-
</td>
|
|
183
|
-
<td class="text-center">
|
|
184
|
-
<v-chip
|
|
185
|
-
size="small"
|
|
186
|
-
:color="Number(damage.percentResistance) > 0 ? 'primary' : 'default'"
|
|
187
|
-
variant="flat"
|
|
188
|
-
class="text-white font-weight-bold"
|
|
189
|
-
>
|
|
190
|
-
{{ formatValue(damage.percentResistance, '%') }}
|
|
191
|
-
</v-chip>
|
|
192
|
-
</td>
|
|
193
|
-
</tr>
|
|
194
|
-
</tbody>
|
|
195
|
-
</v-table>
|
|
196
|
-
</v-card-text>
|
|
197
|
-
</v-card>
|
|
198
|
-
</div>
|
|
199
|
-
</template>
|
|
200
|
-
|
|
201
|
-
<style scoped>
|
|
202
|
-
.damage-resistances-card {
|
|
203
|
-
border-radius: 6px;
|
|
204
|
-
background: #ffffff;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
.damage-resistances-header {
|
|
208
|
-
background: #424242;
|
|
209
|
-
color: #ffffff;
|
|
210
|
-
padding: 6px 12px;
|
|
211
|
-
font-size: 0.85rem;
|
|
212
|
-
font-weight: 600;
|
|
213
|
-
border-bottom: 1px solid #333;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.damage-resistances-table {
|
|
217
|
-
background: #ffffff;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.damage-type-row:hover {
|
|
221
|
-
background-color: #f9f9f9;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.damage-type-name {
|
|
225
|
-
font-weight: 500;
|
|
226
|
-
min-width: 120px;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.damage-type-header {
|
|
230
|
-
display: flex;
|
|
231
|
-
align-items: center;
|
|
232
|
-
gap: 4px;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
.v-table th {
|
|
236
|
-
font-weight: 600;
|
|
237
|
-
font-size: 0.8rem;
|
|
238
|
-
color: #555;
|
|
239
|
-
background: #fafafa;
|
|
240
|
-
border-bottom: 1px solid #e0e0e0;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.v-table td {
|
|
244
|
-
padding: 4px 12px;
|
|
245
|
-
border-bottom: 1px solid #f0f0f0;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
.v-chip {
|
|
249
|
-
min-width: 48px;
|
|
250
|
-
justify-content: center;
|
|
251
|
-
}
|
|
252
|
-
</style>
|
|
57
|
+
const fileNode = expandToNode `
|
|
58
|
+
<script setup>
|
|
59
|
+
import { ref, computed, inject, watchEffect } from "vue";
|
|
60
|
+
|
|
61
|
+
const props = defineProps({
|
|
62
|
+
label: String,
|
|
63
|
+
systemPath: String,
|
|
64
|
+
context: Object,
|
|
65
|
+
visibility: String,
|
|
66
|
+
editMode: Boolean,
|
|
67
|
+
icon: String
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const document = inject("rawDocument");
|
|
71
|
+
|
|
72
|
+
// Static damage type configuration extracted from AST
|
|
73
|
+
const damageTypeConfig = ${damageTypesObject};
|
|
74
|
+
|
|
75
|
+
const isHidden = computed(() => {
|
|
76
|
+
if (props.visibility === "hidden") {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if (props.visibility === "gm" && !game.user.isGM) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Get all damage resistances from the actor's system
|
|
86
|
+
const damageResistances = computed(() => {
|
|
87
|
+
const system = document.system;
|
|
88
|
+
const resistanceInfo = {};
|
|
89
|
+
|
|
90
|
+
// Scan all system properties for resistance damage fields
|
|
91
|
+
for (const [key, value] of Object.entries(system)) {
|
|
92
|
+
const flatResistMatch = key.match(/^(.+)damageresistanceflat$/);
|
|
93
|
+
const percentResistMatch = key.match(/^(.+)damageresistancepercent$/);
|
|
94
|
+
|
|
95
|
+
let damageType = null;
|
|
96
|
+
let effectType = null;
|
|
97
|
+
|
|
98
|
+
if (flatResistMatch) {
|
|
99
|
+
damageType = flatResistMatch[1];
|
|
100
|
+
effectType = 'flatResistance';
|
|
101
|
+
} else if (percentResistMatch) {
|
|
102
|
+
damageType = percentResistMatch[1];
|
|
103
|
+
effectType = 'percentResistance';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (damageType && effectType) {
|
|
107
|
+
if (!resistanceInfo[damageType]) {
|
|
108
|
+
const damageTypeObj = damageTypeConfig[damageType] || {};
|
|
109
|
+
|
|
110
|
+
resistanceInfo[damageType] = {
|
|
111
|
+
type: damageType,
|
|
112
|
+
label: damageTypeObj.label || damageType,
|
|
113
|
+
icon: damageTypeObj.icon || 'fa-solid fa-circle-info',
|
|
114
|
+
color: damageTypeObj.color || '#666666',
|
|
115
|
+
flatResistance: 0,
|
|
116
|
+
percentResistance: 0
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (effectType === 'flatResistance') {
|
|
121
|
+
resistanceInfo[damageType].flatResistance = Number(value) || 0;
|
|
122
|
+
} else if (effectType === 'percentResistance') {
|
|
123
|
+
resistanceInfo[damageType].percentResistance = Number(value) || 0;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Convert to array and sort by damage type name
|
|
129
|
+
return Object.values(resistanceInfo).sort((a, b) => a.type.localeCompare(b.type));
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Helper function to capitalize damage type names
|
|
133
|
+
const capitalize = (str) => {
|
|
134
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Helper function to format resistance values
|
|
138
|
+
const formatValue = (value, suffix = '') => {
|
|
139
|
+
const numValue = Number(value) || 0;
|
|
140
|
+
return \`\${numValue}\${suffix}\`;
|
|
141
|
+
};
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
<template>
|
|
145
|
+
<div v-if="!isHidden" class="isdl-damage-resistances pt-2 double-wide">
|
|
146
|
+
<v-card class="damage-resistances-card" variant="outlined" theme="light" color="white">
|
|
147
|
+
<v-card-title class="damage-resistances-header bg-grey-darken-3 text-white">
|
|
148
|
+
<v-icon v-if="icon" class="me-2">{{ icon }}</v-icon>
|
|
149
|
+
<span>{{ game.i18n.localize(label) }}</span>
|
|
150
|
+
</v-card-title>
|
|
151
|
+
|
|
152
|
+
<v-card-text class="pa-0">
|
|
153
|
+
<div v-if="damageResistances.length === 0" class="text-center text-disabled pa-2">
|
|
154
|
+
No damage resistances found
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<v-table v-else density="compact" class="damage-resistances-table">
|
|
158
|
+
<thead>
|
|
159
|
+
<tr>
|
|
160
|
+
<th class="text-left text-white">Type</th>
|
|
161
|
+
<th class="text-center text-white">Flat Resistance</th>
|
|
162
|
+
<th class="text-center text-white">% Resistance</th>
|
|
163
|
+
</tr>
|
|
164
|
+
</thead>
|
|
165
|
+
<tbody>
|
|
166
|
+
<tr v-for="damage in damageResistances" :key="damage.type" class="damage-type-row">
|
|
167
|
+
<td class="damage-type-name">
|
|
168
|
+
<div class="damage-type-header">
|
|
169
|
+
<v-icon :color="damage.color" size="small" class="me-2">{{ damage.icon }}</v-icon>
|
|
170
|
+
<span class="text-subtitle-2">{{ damage.label || capitalize(damage.type) }}</span>
|
|
171
|
+
</div>
|
|
172
|
+
</td>
|
|
173
|
+
<td class="text-center">
|
|
174
|
+
<v-chip
|
|
175
|
+
size="small"
|
|
176
|
+
:color="Number(damage.flatResistance) > 0 ? 'primary' : 'default'"
|
|
177
|
+
variant="flat"
|
|
178
|
+
class="text-white font-weight-bold"
|
|
179
|
+
>
|
|
180
|
+
{{ formatValue(damage.flatResistance) }}
|
|
181
|
+
</v-chip>
|
|
182
|
+
</td>
|
|
183
|
+
<td class="text-center">
|
|
184
|
+
<v-chip
|
|
185
|
+
size="small"
|
|
186
|
+
:color="Number(damage.percentResistance) > 0 ? 'primary' : 'default'"
|
|
187
|
+
variant="flat"
|
|
188
|
+
class="text-white font-weight-bold"
|
|
189
|
+
>
|
|
190
|
+
{{ formatValue(damage.percentResistance, '%') }}
|
|
191
|
+
</v-chip>
|
|
192
|
+
</td>
|
|
193
|
+
</tr>
|
|
194
|
+
</tbody>
|
|
195
|
+
</v-table>
|
|
196
|
+
</v-card-text>
|
|
197
|
+
</v-card>
|
|
198
|
+
</div>
|
|
199
|
+
</template>
|
|
200
|
+
|
|
201
|
+
<style scoped>
|
|
202
|
+
.damage-resistances-card {
|
|
203
|
+
border-radius: 6px;
|
|
204
|
+
background: #ffffff;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.damage-resistances-header {
|
|
208
|
+
background: #424242;
|
|
209
|
+
color: #ffffff;
|
|
210
|
+
padding: 6px 12px;
|
|
211
|
+
font-size: 0.85rem;
|
|
212
|
+
font-weight: 600;
|
|
213
|
+
border-bottom: 1px solid #333;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.damage-resistances-table {
|
|
217
|
+
background: #ffffff;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.damage-type-row:hover {
|
|
221
|
+
background-color: #f9f9f9;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.damage-type-name {
|
|
225
|
+
font-weight: 500;
|
|
226
|
+
min-width: 120px;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.damage-type-header {
|
|
230
|
+
display: flex;
|
|
231
|
+
align-items: center;
|
|
232
|
+
gap: 4px;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.v-table th {
|
|
236
|
+
font-weight: 600;
|
|
237
|
+
font-size: 0.8rem;
|
|
238
|
+
color: #555;
|
|
239
|
+
background: #fafafa;
|
|
240
|
+
border-bottom: 1px solid #e0e0e0;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.v-table td {
|
|
244
|
+
padding: 4px 12px;
|
|
245
|
+
border-bottom: 1px solid #f0f0f0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.v-chip {
|
|
249
|
+
min-width: 48px;
|
|
250
|
+
justify-content: center;
|
|
251
|
+
}
|
|
252
|
+
</style>
|
|
253
253
|
`.appendNewLine();
|
|
254
254
|
fs.writeFileSync(generatedFilePath, toString(fileNode));
|
|
255
255
|
}
|
|
@@ -7,127 +7,127 @@ export default function generateDamageTrackComponent(destination) {
|
|
|
7
7
|
if (!fs.existsSync(generatedFileDir)) {
|
|
8
8
|
fs.mkdirSync(generatedFileDir, { recursive: true });
|
|
9
9
|
}
|
|
10
|
-
const fileNode = expandToNode `
|
|
11
|
-
<script setup>
|
|
12
|
-
import { computed, inject } from "vue";
|
|
13
|
-
|
|
14
|
-
const props = defineProps({
|
|
15
|
-
label: String,
|
|
16
|
-
systemPath: String,
|
|
17
|
-
context: Object,
|
|
18
|
-
editMode: Boolean,
|
|
19
|
-
primaryColor: String,
|
|
20
|
-
secondaryColor: String,
|
|
21
|
-
types: Array,
|
|
22
|
-
max: Number,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const document = inject("rawDocument");
|
|
26
|
-
|
|
27
|
-
// types ordered from least to most severe (first type is least severe)
|
|
28
|
-
// empty is always the "unfilled" state
|
|
29
|
-
const typeColors = ['#888888', '#4fc3f7', '#ef5350', '#7b1fa2', '#ff9800', '#43a047'];
|
|
30
|
-
|
|
31
|
-
const getColor = (index) => {
|
|
32
|
-
if (index === 0) return props.secondaryColor ?? '#555';
|
|
33
|
-
return typeColors[index] ?? typeColors[typeColors.length - 1];
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// Build ordered list of boxes: [most-severe ... least-severe ... empty]
|
|
37
|
-
// We render: all aggravated boxes, then lethal, then bashing, then empty
|
|
38
|
-
const boxes = computed(() => {
|
|
39
|
-
const result = [];
|
|
40
|
-
const types = props.types ?? [];
|
|
41
|
-
// Fill from most severe (last type) to least severe (first type), then empty
|
|
42
|
-
for (let t = types.length - 1; t >= 0; t--) {
|
|
43
|
-
const count = getVal(types[t]);
|
|
44
|
-
for (let i = 0; i < count; i++) {
|
|
45
|
-
result.push({ type: types[t], typeIndex: t + 1 });
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const emptyCount = getVal('empty');
|
|
49
|
-
for (let i = 0; i < emptyCount; i++) {
|
|
50
|
-
result.push({ type: 'empty', typeIndex: 0 });
|
|
51
|
-
}
|
|
52
|
-
return result;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const getVal = (type) => {
|
|
56
|
-
const v = foundry.utils.getProperty(props.context, props.systemPath + '.' + type);
|
|
57
|
-
return Math.max(0, Math.floor(v ?? 0));
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const setVal = (type, value) => {
|
|
61
|
-
foundry.utils.setProperty(props.context, props.systemPath + '.' + type, value);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// Left-click: fill an empty box with least-severe type
|
|
65
|
-
const addDamage = (box, index) => {
|
|
66
|
-
if (!props.editMode) return;
|
|
67
|
-
const types = props.types ?? [];
|
|
68
|
-
if (types.length === 0) return;
|
|
69
|
-
if (box.type === 'empty') {
|
|
70
|
-
const leastSevere = types[0];
|
|
71
|
-
setVal(leastSevere, getVal(leastSevere) + 1);
|
|
72
|
-
setVal('empty', getVal('empty') - 1);
|
|
73
|
-
} else {
|
|
74
|
-
// Upgrade: cycle to next more severe type if available
|
|
75
|
-
const typeIndex = types.indexOf(box.type);
|
|
76
|
-
if (typeIndex < types.length - 1) {
|
|
77
|
-
const nextType = types[typeIndex + 1];
|
|
78
|
-
setVal(box.type, getVal(box.type) - 1);
|
|
79
|
-
setVal(nextType, getVal(nextType) + 1);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// Right-click: heal most-severe filled box → empty
|
|
85
|
-
const healDamage = (box, index) => {
|
|
86
|
-
if (!props.editMode) return;
|
|
87
|
-
if (box.type === 'empty') return;
|
|
88
|
-
setVal(box.type, getVal(box.type) - 1);
|
|
89
|
-
setVal('empty', getVal('empty') + 1);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const getLabel = computed(() => game.i18n.localize(props.label));
|
|
93
|
-
|
|
94
|
-
const boxSymbol = (type) => {
|
|
95
|
-
const types = props.types ?? [];
|
|
96
|
-
const idx = types.indexOf(type);
|
|
97
|
-
if (type === 'empty') return '';
|
|
98
|
-
if (idx === types.length - 1) return 'X';
|
|
99
|
-
if (idx === types.length - 2) return '/';
|
|
100
|
-
return '\\\\';
|
|
101
|
-
};
|
|
102
|
-
</script>
|
|
103
|
-
|
|
104
|
-
<template>
|
|
105
|
-
<div class="isdl-damage-track">
|
|
106
|
-
<div class="damage-track-label">{{ getLabel }}</div>
|
|
107
|
-
<div class="damage-track-boxes">
|
|
108
|
-
<div
|
|
109
|
-
v-for="(box, i) in boxes"
|
|
110
|
-
:key="i"
|
|
111
|
-
class="damage-box"
|
|
112
|
-
:class="{ 'damage-box--filled': box.type !== 'empty', 'damage-box--empty': box.type === 'empty' }"
|
|
113
|
-
:style="{
|
|
114
|
-
borderColor: getColor(box.typeIndex),
|
|
115
|
-
backgroundColor: box.type !== 'empty' ? getColor(box.typeIndex) : 'transparent',
|
|
116
|
-
}"
|
|
117
|
-
:data-tooltip="box.type !== 'empty' ? box.type : 'empty'"
|
|
118
|
-
@click.stop="addDamage(box, i)"
|
|
119
|
-
@contextmenu.prevent.stop="healDamage(box, i)"
|
|
120
|
-
>
|
|
121
|
-
<span class="damage-symbol">{{ boxSymbol(box.type) }}</span>
|
|
122
|
-
</div>
|
|
123
|
-
</div>
|
|
124
|
-
<div class="damage-track-legend" v-if="types && types.length">
|
|
125
|
-
<span v-for="(t, i) in types" :key="t" class="damage-legend-item">
|
|
126
|
-
<span :style="{ color: getColor(i + 1) }">{{ boxSymbol(t) }}</span> {{ t }}
|
|
127
|
-
</span>
|
|
128
|
-
</div>
|
|
129
|
-
</div>
|
|
130
|
-
</template>
|
|
10
|
+
const fileNode = expandToNode `
|
|
11
|
+
<script setup>
|
|
12
|
+
import { computed, inject } from "vue";
|
|
13
|
+
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
label: String,
|
|
16
|
+
systemPath: String,
|
|
17
|
+
context: Object,
|
|
18
|
+
editMode: Boolean,
|
|
19
|
+
primaryColor: String,
|
|
20
|
+
secondaryColor: String,
|
|
21
|
+
types: Array,
|
|
22
|
+
max: Number,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const document = inject("rawDocument");
|
|
26
|
+
|
|
27
|
+
// types ordered from least to most severe (first type is least severe)
|
|
28
|
+
// empty is always the "unfilled" state
|
|
29
|
+
const typeColors = ['#888888', '#4fc3f7', '#ef5350', '#7b1fa2', '#ff9800', '#43a047'];
|
|
30
|
+
|
|
31
|
+
const getColor = (index) => {
|
|
32
|
+
if (index === 0) return props.secondaryColor ?? '#555';
|
|
33
|
+
return typeColors[index] ?? typeColors[typeColors.length - 1];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Build ordered list of boxes: [most-severe ... least-severe ... empty]
|
|
37
|
+
// We render: all aggravated boxes, then lethal, then bashing, then empty
|
|
38
|
+
const boxes = computed(() => {
|
|
39
|
+
const result = [];
|
|
40
|
+
const types = props.types ?? [];
|
|
41
|
+
// Fill from most severe (last type) to least severe (first type), then empty
|
|
42
|
+
for (let t = types.length - 1; t >= 0; t--) {
|
|
43
|
+
const count = getVal(types[t]);
|
|
44
|
+
for (let i = 0; i < count; i++) {
|
|
45
|
+
result.push({ type: types[t], typeIndex: t + 1 });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const emptyCount = getVal('empty');
|
|
49
|
+
for (let i = 0; i < emptyCount; i++) {
|
|
50
|
+
result.push({ type: 'empty', typeIndex: 0 });
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const getVal = (type) => {
|
|
56
|
+
const v = foundry.utils.getProperty(props.context, props.systemPath + '.' + type);
|
|
57
|
+
return Math.max(0, Math.floor(v ?? 0));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const setVal = (type, value) => {
|
|
61
|
+
foundry.utils.setProperty(props.context, props.systemPath + '.' + type, value);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Left-click: fill an empty box with least-severe type
|
|
65
|
+
const addDamage = (box, index) => {
|
|
66
|
+
if (!props.editMode) return;
|
|
67
|
+
const types = props.types ?? [];
|
|
68
|
+
if (types.length === 0) return;
|
|
69
|
+
if (box.type === 'empty') {
|
|
70
|
+
const leastSevere = types[0];
|
|
71
|
+
setVal(leastSevere, getVal(leastSevere) + 1);
|
|
72
|
+
setVal('empty', getVal('empty') - 1);
|
|
73
|
+
} else {
|
|
74
|
+
// Upgrade: cycle to next more severe type if available
|
|
75
|
+
const typeIndex = types.indexOf(box.type);
|
|
76
|
+
if (typeIndex < types.length - 1) {
|
|
77
|
+
const nextType = types[typeIndex + 1];
|
|
78
|
+
setVal(box.type, getVal(box.type) - 1);
|
|
79
|
+
setVal(nextType, getVal(nextType) + 1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Right-click: heal most-severe filled box → empty
|
|
85
|
+
const healDamage = (box, index) => {
|
|
86
|
+
if (!props.editMode) return;
|
|
87
|
+
if (box.type === 'empty') return;
|
|
88
|
+
setVal(box.type, getVal(box.type) - 1);
|
|
89
|
+
setVal('empty', getVal('empty') + 1);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const getLabel = computed(() => game.i18n.localize(props.label));
|
|
93
|
+
|
|
94
|
+
const boxSymbol = (type) => {
|
|
95
|
+
const types = props.types ?? [];
|
|
96
|
+
const idx = types.indexOf(type);
|
|
97
|
+
if (type === 'empty') return '';
|
|
98
|
+
if (idx === types.length - 1) return 'X';
|
|
99
|
+
if (idx === types.length - 2) return '/';
|
|
100
|
+
return '\\\\';
|
|
101
|
+
};
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<template>
|
|
105
|
+
<div class="isdl-damage-track">
|
|
106
|
+
<div class="damage-track-label">{{ getLabel }}</div>
|
|
107
|
+
<div class="damage-track-boxes">
|
|
108
|
+
<div
|
|
109
|
+
v-for="(box, i) in boxes"
|
|
110
|
+
:key="i"
|
|
111
|
+
class="damage-box"
|
|
112
|
+
:class="{ 'damage-box--filled': box.type !== 'empty', 'damage-box--empty': box.type === 'empty' }"
|
|
113
|
+
:style="{
|
|
114
|
+
borderColor: getColor(box.typeIndex),
|
|
115
|
+
backgroundColor: box.type !== 'empty' ? getColor(box.typeIndex) : 'transparent',
|
|
116
|
+
}"
|
|
117
|
+
:data-tooltip="box.type !== 'empty' ? box.type : 'empty'"
|
|
118
|
+
@click.stop="addDamage(box, i)"
|
|
119
|
+
@contextmenu.prevent.stop="healDamage(box, i)"
|
|
120
|
+
>
|
|
121
|
+
<span class="damage-symbol">{{ boxSymbol(box.type) }}</span>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
<div class="damage-track-legend" v-if="types && types.length">
|
|
125
|
+
<span v-for="(t, i) in types" :key="t" class="damage-legend-item">
|
|
126
|
+
<span :style="{ color: getColor(i + 1) }">{{ boxSymbol(t) }}</span> {{ t }}
|
|
127
|
+
</span>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
</template>
|
|
131
131
|
`.appendNewLine();
|
|
132
132
|
fs.writeFileSync(generatedFilePath, toString(fileNode));
|
|
133
133
|
}
|