intelligent-system-design-language 0.3.13
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 -0
- package/.claude/agents/typescript-vscode-expert.md +29 -0
- package/.claude/agents/ui-ux-designer.md +36 -0
- package/.claude/settings.local.json +33 -0
- package/.idea/inspectionProfiles/Project_Default.xml +7 -0
- package/.idea/isdl.iml +14 -0
- package/.idea/modules.xml +9 -0
- package/.idea/vcs.xml +7 -0
- package/.idea/watcherTasks.xml +4 -0
- package/.vscodeignore +18 -0
- package/LICENSE +674 -0
- package/README.md +86 -0
- package/bin/cli.js +4 -0
- package/bin/lsp.js +8 -0
- package/isdl.png +0 -0
- package/out/_backgrounds.scss +91 -0
- package/out/_handlebars.scss +505 -0
- package/out/_isdlStyles.scss +1357 -0
- package/out/_vuetifyOverrides.scss +425 -0
- package/out/_vuetifyStyles.scss +31957 -0
- package/out/cli/cli-util.js +39 -0
- package/out/cli/cli-util.js.map +1 -0
- package/out/cli/components/_backgrounds.scss +91 -0
- package/out/cli/components/_handlebars.scss +505 -0
- package/out/cli/components/_isdlStyles.scss +1357 -0
- package/out/cli/components/_vuetifyOverrides.scss +425 -0
- package/out/cli/components/_vuetifyStyles.scss +31957 -0
- package/out/cli/components/active-effect-sheet-generator.js +643 -0
- package/out/cli/components/active-effect-sheet-generator.js.map +1 -0
- package/out/cli/components/base-actor-sheet-generator.js +125 -0
- package/out/cli/components/base-actor-sheet-generator.js.map +1 -0
- package/out/cli/components/base-sheet-generator.js +525 -0
- package/out/cli/components/base-sheet-generator.js.map +1 -0
- package/out/cli/components/chat-card-generator.js +683 -0
- package/out/cli/components/chat-card-generator.js.map +1 -0
- package/out/cli/components/css-generator.js +58 -0
- package/out/cli/components/css-generator.js.map +1 -0
- package/out/cli/components/damage-roll-generator.js +173 -0
- package/out/cli/components/damage-roll-generator.js.map +1 -0
- package/out/cli/components/datamodel-generator.js +672 -0
- package/out/cli/components/datamodel-generator.js.map +1 -0
- package/out/cli/components/derived-data-generator.js +1340 -0
- package/out/cli/components/derived-data-generator.js.map +1 -0
- package/out/cli/components/hotbar-drop-hook-generator.js +95 -0
- package/out/cli/components/hotbar-drop-hook-generator.js.map +1 -0
- package/out/cli/components/init-hook-generator.js +597 -0
- package/out/cli/components/init-hook-generator.js.map +1 -0
- package/out/cli/components/keywords-generator.js +220 -0
- package/out/cli/components/keywords-generator.js.map +1 -0
- package/out/cli/components/language-generator.js +110 -0
- package/out/cli/components/language-generator.js.map +1 -0
- package/out/cli/components/measured-template-preview.js +234 -0
- package/out/cli/components/measured-template-preview.js.map +1 -0
- package/out/cli/components/method-generator.js +1812 -0
- package/out/cli/components/method-generator.js.map +1 -0
- package/out/cli/components/ready-hook-generator.js +448 -0
- package/out/cli/components/ready-hook-generator.js.map +1 -0
- package/out/cli/components/token-generator.js +138 -0
- package/out/cli/components/token-generator.js.map +1 -0
- package/out/cli/components/utils.js +176 -0
- package/out/cli/components/utils.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-attribute.js +148 -0
- package/out/cli/components/vue/base-components/vue-attribute.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-boolean.js +77 -0
- package/out/cli/components/vue/base-components/vue-boolean.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-calculator.js +106 -0
- package/out/cli/components/vue/base-components/vue-calculator.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-damage-application.js +369 -0
- package/out/cli/components/vue/base-components/vue-damage-application.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-damage-bonuses.js +225 -0
- package/out/cli/components/vue/base-components/vue-damage-bonuses.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-damage-resistances.js +256 -0
- package/out/cli/components/vue/base-components/vue-damage-resistances.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-damage-track.js +134 -0
- package/out/cli/components/vue/base-components/vue-damage-track.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-date-time.js +55 -0
- package/out/cli/components/vue/base-components/vue-date-time.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-dice.js +111 -0
- package/out/cli/components/vue/base-components/vue-dice.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-die.js +86 -0
- package/out/cli/components/vue/base-components/vue-die.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-document-choice.js +172 -0
- package/out/cli/components/vue/base-components/vue-document-choice.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-document-choices.js +203 -0
- package/out/cli/components/vue/base-components/vue-document-choices.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-document-link.js +73 -0
- package/out/cli/components/vue/base-components/vue-document-link.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-extended-choice.js +101 -0
- package/out/cli/components/vue/base-components/vue-extended-choice.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-inventory.js +532 -0
- package/out/cli/components/vue/base-components/vue-inventory.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-macro-choice.js +150 -0
- package/out/cli/components/vue/base-components/vue-macro-choice.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-measured-template.js +543 -0
- package/out/cli/components/vue/base-components/vue-measured-template.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-money.js +496 -0
- package/out/cli/components/vue/base-components/vue-money.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-number.js +184 -0
- package/out/cli/components/vue/base-components/vue-number.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-paperdoll.js +56 -0
- package/out/cli/components/vue/base-components/vue-paperdoll.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-parent-property-reference.js +89 -0
- package/out/cli/components/vue/base-components/vue-parent-property-reference.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-prosemirror.js +31 -0
- package/out/cli/components/vue/base-components/vue-prosemirror.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-resource.js +149 -0
- package/out/cli/components/vue/base-components/vue-resource.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-roll-visualizer.js +121 -0
- package/out/cli/components/vue/base-components/vue-roll-visualizer.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-self-property-reference.js +75 -0
- package/out/cli/components/vue/base-components/vue-self-property-reference.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-string-choice.js +111 -0
- package/out/cli/components/vue/base-components/vue-string-choice.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-string-choices.js +216 -0
- package/out/cli/components/vue/base-components/vue-string-choices.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-string.js +73 -0
- package/out/cli/components/vue/base-components/vue-string.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-text-field.js +66 -0
- package/out/cli/components/vue/base-components/vue-text-field.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-tracker.js +444 -0
- package/out/cli/components/vue/base-components/vue-tracker.js.map +1 -0
- package/out/cli/components/vue/vue-action-component-generator.js +88 -0
- package/out/cli/components/vue/vue-action-component-generator.js.map +1 -0
- package/out/cli/components/vue/vue-active-effect-sheet-generator.js +1016 -0
- package/out/cli/components/vue/vue-active-effect-sheet-generator.js.map +1 -0
- package/out/cli/components/vue/vue-base-components-generator.js +59 -0
- package/out/cli/components/vue/vue-base-components-generator.js.map +1 -0
- package/out/cli/components/vue/vue-datatable-component-generator.js +307 -0
- package/out/cli/components/vue/vue-datatable-component-generator.js.map +1 -0
- package/out/cli/components/vue/vue-datatable-sheet-class-generator.js +342 -0
- package/out/cli/components/vue/vue-datatable-sheet-class-generator.js.map +1 -0
- package/out/cli/components/vue/vue-datatable2-component-generator.js +939 -0
- package/out/cli/components/vue/vue-datatable2-component-generator.js.map +1 -0
- package/out/cli/components/vue/vue-document-creation-app.js +140 -0
- package/out/cli/components/vue/vue-document-creation-app.js.map +1 -0
- package/out/cli/components/vue/vue-document-creation-sheet.js +105 -0
- package/out/cli/components/vue/vue-document-creation-sheet.js.map +1 -0
- package/out/cli/components/vue/vue-generator.js +240 -0
- package/out/cli/components/vue/vue-generator.js.map +1 -0
- package/out/cli/components/vue/vue-mixin.js +338 -0
- package/out/cli/components/vue/vue-mixin.js.map +1 -0
- package/out/cli/components/vue/vue-pinned-datatable-component-generator.js +306 -0
- package/out/cli/components/vue/vue-pinned-datatable-component-generator.js.map +1 -0
- package/out/cli/components/vue/vue-prompt-generator.js +201 -0
- package/out/cli/components/vue/vue-prompt-generator.js.map +1 -0
- package/out/cli/components/vue/vue-prompt-sheet-class-generator.js +252 -0
- package/out/cli/components/vue/vue-prompt-sheet-class-generator.js.map +1 -0
- package/out/cli/components/vue/vue-sheet-application-generator.js +2008 -0
- package/out/cli/components/vue/vue-sheet-application-generator.js.map +1 -0
- package/out/cli/components/vue/vue-sheet-class-generator.js +484 -0
- package/out/cli/components/vue/vue-sheet-class-generator.js.map +1 -0
- package/out/cli/generator.js +659 -0
- package/out/cli/generator.js.map +1 -0
- package/out/cli/main.js +43 -0
- package/out/cli/main.js.map +1 -0
- package/out/datatables.min.css +54 -0
- package/out/datatables.min.js +178 -0
- package/out/extension/github/githubAuthProvider.js +345 -0
- package/out/extension/github/githubAuthProvider.js.map +1 -0
- package/out/extension/github/githubConfig.js +132 -0
- package/out/extension/github/githubConfig.js.map +1 -0
- package/out/extension/github/githubGistActions.js +251 -0
- package/out/extension/github/githubGistActions.js.map +1 -0
- package/out/extension/github/githubGistManager.js +255 -0
- package/out/extension/github/githubGistManager.js.map +1 -0
- package/out/extension/github/githubManager.js +1735 -0
- package/out/extension/github/githubManager.js.map +1 -0
- package/out/extension/github/githubQuickActions.js +659 -0
- package/out/extension/github/githubQuickActions.js.map +1 -0
- package/out/extension/github/githubTreeProvider.js +181 -0
- package/out/extension/github/githubTreeProvider.js.map +1 -0
- package/out/extension/github/system-workflow.yml +48 -0
- package/out/extension/main.cjs +70315 -0
- package/out/extension/main.cjs.map +7 -0
- package/out/extension/main.js +237 -0
- package/out/extension/main.js.map +1 -0
- package/out/extension/package.json +426 -0
- package/out/isdl.png +0 -0
- package/out/language/generated/ast.js +2992 -0
- package/out/language/generated/ast.js.map +1 -0
- package/out/language/generated/grammar.js +13970 -0
- package/out/language/generated/grammar.js.map +1 -0
- package/out/language/generated/module.js +20 -0
- package/out/language/generated/module.js.map +1 -0
- package/out/language/intelligent-system-design-language-formatter.js +85 -0
- package/out/language/intelligent-system-design-language-formatter.js.map +1 -0
- package/out/language/intelligent-system-design-language-module.js +69 -0
- package/out/language/intelligent-system-design-language-module.js.map +1 -0
- package/out/language/intelligent-system-design-language-quickfixes.js +37 -0
- package/out/language/intelligent-system-design-language-quickfixes.js.map +1 -0
- package/out/language/intelligent-system-design-language-validator.js +515 -0
- package/out/language/intelligent-system-design-language-validator.js.map +1 -0
- package/out/language/isdl-hover-provider.js +77 -0
- package/out/language/isdl-hover-provider.js.map +1 -0
- package/out/language/isdl-scope-provider.js +149 -0
- package/out/language/isdl-scope-provider.js.map +1 -0
- package/out/language/main.cjs +47655 -0
- package/out/language/main.cjs.map +7 -0
- package/out/language/main.js +11 -0
- package/out/language/main.js.map +1 -0
- package/out/missing-character.png +0 -0
- package/out/package.json +426 -0
- package/out/paperdoll_default.png +0 -0
- package/out/progressbar.min.js +7 -0
- package/out/styles.scss +722 -0
- package/out/test/formatting/formatter.test.js +46 -0
- package/out/test/formatting/formatter.test.js.map +1 -0
- package/out/vuetify.esm.js +30279 -0
- package/package.json +426 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import { expandToNode, toString } from 'langium/generate';
|
|
4
|
+
import { globalGetAllOfType } from "../../utils.js";
|
|
5
|
+
import { isChoiceStringValue, isColorParam, isDamageTypeChoiceField, isIconParam, isLabelParam, isStringExtendedChoice, isStringParamChoices } from "../../../../language/generated/ast.js";
|
|
6
|
+
export default function generateDamageBonusesComponent(destination, entry) {
|
|
7
|
+
const generatedFileDir = path.join(destination, "system", "templates", "vue", "components");
|
|
8
|
+
const generatedFilePath = path.join(generatedFileDir, `damage-bonuses.vue`);
|
|
9
|
+
if (!fs.existsSync(generatedFileDir)) {
|
|
10
|
+
fs.mkdirSync(generatedFileDir, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
// Extract damage types from AST
|
|
13
|
+
function extractDamageTypes() {
|
|
14
|
+
if (!entry)
|
|
15
|
+
return '{}';
|
|
16
|
+
const damageTypeFields = globalGetAllOfType(entry, isDamageTypeChoiceField);
|
|
17
|
+
const damageTypeMap = {};
|
|
18
|
+
for (const field of damageTypeFields) {
|
|
19
|
+
const choicesParam = field.params.find(isStringParamChoices);
|
|
20
|
+
if (!choicesParam)
|
|
21
|
+
continue;
|
|
22
|
+
for (const choice of choicesParam.choices) {
|
|
23
|
+
let damageTypeKey = '';
|
|
24
|
+
let damageTypeInfo = { icon: 'fa-solid fa-circle-info', color: '#666666', label: '' };
|
|
25
|
+
if (isStringExtendedChoice(choice.value)) {
|
|
26
|
+
// Extended choice with properties
|
|
27
|
+
const valueProperty = choice.value.properties.find(isChoiceStringValue);
|
|
28
|
+
if (valueProperty) {
|
|
29
|
+
damageTypeKey = valueProperty.value.replace(/"/g, '').toLowerCase();
|
|
30
|
+
}
|
|
31
|
+
const labelProperty = choice.value.properties.find(isLabelParam);
|
|
32
|
+
if (labelProperty) {
|
|
33
|
+
damageTypeInfo.label = labelProperty.value.replace(/"/g, '');
|
|
34
|
+
}
|
|
35
|
+
const iconProperty = choice.value.properties.find(isIconParam);
|
|
36
|
+
if (iconProperty) {
|
|
37
|
+
damageTypeInfo.icon = iconProperty.value.replace(/"/g, '');
|
|
38
|
+
}
|
|
39
|
+
const colorProperty = choice.value.properties.find(isColorParam);
|
|
40
|
+
if (colorProperty) {
|
|
41
|
+
damageTypeInfo.color = colorProperty.value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// Simple string choice
|
|
46
|
+
damageTypeKey = choice.value.replace(/"/g, '').toLowerCase();
|
|
47
|
+
damageTypeInfo.label = choice.value.replace(/"/g, '');
|
|
48
|
+
}
|
|
49
|
+
if (damageTypeKey) {
|
|
50
|
+
damageTypeMap[damageTypeKey] = damageTypeInfo;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return JSON.stringify(damageTypeMap, null, 8);
|
|
55
|
+
}
|
|
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 bonuses from the actor's system
|
|
86
|
+
const damageBonuses = computed(() => {
|
|
87
|
+
const system = document.system;
|
|
88
|
+
const bonusInfo = {};
|
|
89
|
+
|
|
90
|
+
// Scan all system properties for bonus damage fields
|
|
91
|
+
for (const [key, value] of Object.entries(system)) {
|
|
92
|
+
const bonusMatch = key.match(/^(.+)bonusdamage$/);
|
|
93
|
+
|
|
94
|
+
if (bonusMatch) {
|
|
95
|
+
const damageType = bonusMatch[1];
|
|
96
|
+
const damageTypeObj = damageTypeConfig[damageType] || {};
|
|
97
|
+
|
|
98
|
+
bonusInfo[damageType] = {
|
|
99
|
+
type: damageType,
|
|
100
|
+
label: damageTypeObj.label || damageType,
|
|
101
|
+
icon: damageTypeObj.icon || 'fa-solid fa-circle-info',
|
|
102
|
+
color: damageTypeObj.color || '#666666',
|
|
103
|
+
bonus: Number(value) || 0
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Convert to array and sort by damage type name
|
|
109
|
+
return Object.values(bonusInfo).sort((a, b) => a.type.localeCompare(b.type));
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Helper function to capitalize damage type names
|
|
113
|
+
const capitalize = (str) => {
|
|
114
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Helper function to format bonus values
|
|
118
|
+
const formatBonus = (value) => {
|
|
119
|
+
const numValue = Number(value) || 0;
|
|
120
|
+
return numValue > 0 ? \`+\${numValue}\` : \`\${numValue}\`;
|
|
121
|
+
};
|
|
122
|
+
</script>
|
|
123
|
+
|
|
124
|
+
<template>
|
|
125
|
+
<div v-if="!isHidden" class="isdl-damage-bonuses pt-2 single-wide">
|
|
126
|
+
<v-card class="damage-bonuses-card" variant="outlined" theme="light" color="white">
|
|
127
|
+
<v-card-title class="damage-bonuses-header bg-grey-darken-3 text-white">
|
|
128
|
+
<v-icon v-if="icon" class="me-2">{{ icon }}</v-icon>
|
|
129
|
+
<span>{{ game.i18n.localize(label) }}</span>
|
|
130
|
+
</v-card-title>
|
|
131
|
+
|
|
132
|
+
<v-card-text class="pa-0">
|
|
133
|
+
<div v-if="damageBonuses.length === 0" class="text-center text-disabled pa-2">
|
|
134
|
+
No damage bonuses found
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<v-table v-else density="compact" class="damage-bonuses-table">
|
|
138
|
+
<thead>
|
|
139
|
+
<tr>
|
|
140
|
+
<th class="text-left text-white">Type</th>
|
|
141
|
+
<th class="text-center text-white">Bonus</th>
|
|
142
|
+
</tr>
|
|
143
|
+
</thead>
|
|
144
|
+
<tbody>
|
|
145
|
+
<tr v-for="damage in damageBonuses" :key="damage.type" class="damage-type-row">
|
|
146
|
+
<td class="damage-type-name">
|
|
147
|
+
<div class="damage-type-header">
|
|
148
|
+
<v-icon :color="damage.color" size="small" class="me-2">{{ damage.icon }}</v-icon>
|
|
149
|
+
<span class="text-subtitle-2">{{ damage.label || capitalize(damage.type) }}</span>
|
|
150
|
+
</div>
|
|
151
|
+
</td>
|
|
152
|
+
<td class="text-center">
|
|
153
|
+
<v-chip
|
|
154
|
+
size="small"
|
|
155
|
+
:color="Number(damage.bonus) > 0 ? 'success' : Number(damage.bonus) < 0 ? 'error' : 'default'"
|
|
156
|
+
variant="flat"
|
|
157
|
+
class="text-white font-weight-bold"
|
|
158
|
+
>
|
|
159
|
+
{{ formatBonus(damage.bonus) }}
|
|
160
|
+
</v-chip>
|
|
161
|
+
</td>
|
|
162
|
+
</tr>
|
|
163
|
+
</tbody>
|
|
164
|
+
</v-table>
|
|
165
|
+
</v-card-text>
|
|
166
|
+
</v-card>
|
|
167
|
+
</div>
|
|
168
|
+
</template>
|
|
169
|
+
|
|
170
|
+
<style scoped>
|
|
171
|
+
.damage-bonuses-card {
|
|
172
|
+
border-radius: 6px;
|
|
173
|
+
background: #ffffff;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.damage-bonuses-header {
|
|
177
|
+
background: #424242;
|
|
178
|
+
color: #ffffff;
|
|
179
|
+
padding: 6px 12px;
|
|
180
|
+
font-size: 0.85rem;
|
|
181
|
+
font-weight: 600;
|
|
182
|
+
border-bottom: 1px solid #333;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.damage-bonuses-table {
|
|
186
|
+
background: #ffffff;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.damage-type-row:hover {
|
|
190
|
+
background-color: #f9f9f9;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.damage-type-name {
|
|
194
|
+
font-weight: 500;
|
|
195
|
+
min-width: 120px;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.damage-type-header {
|
|
199
|
+
display: flex;
|
|
200
|
+
align-items: center;
|
|
201
|
+
gap: 4px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.v-table th {
|
|
205
|
+
font-weight: 600;
|
|
206
|
+
font-size: 0.8rem;
|
|
207
|
+
color: #555;
|
|
208
|
+
background: #fafafa;
|
|
209
|
+
border-bottom: 1px solid #e0e0e0;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.v-table td {
|
|
213
|
+
padding: 4px 12px;
|
|
214
|
+
border-bottom: 1px solid #f0f0f0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.v-chip {
|
|
218
|
+
min-width: 48px;
|
|
219
|
+
justify-content: center;
|
|
220
|
+
}
|
|
221
|
+
</style>
|
|
222
|
+
`.appendNewLine();
|
|
223
|
+
fs.writeFileSync(generatedFilePath, toString(fileNode));
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=vue-damage-bonuses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue-damage-bonuses.js","sourceRoot":"","sources":["../../../../../src/cli/components/vue/base-components/vue-damage-bonuses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAEI,mBAAmB,EAAE,YAAY,EACxC,uBAAuB,EAAE,WAAW,EAAE,YAAY,EAAE,sBAAsB,EAC1E,oBAAoB,EACvB,MAAM,uCAAuC,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,8BAA8B,CAAC,WAAmB,EAAE,KAAa;IACrF,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAA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;;;;;;;;;;;;;;;;;;;;;;KAqJ/C,CAAC,aAAa,EAAE,CAAC;IAElB,EAAE,CAAC,aAAa,CAAC,iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import { expandToNode, toString } from 'langium/generate';
|
|
4
|
+
import { globalGetAllOfType } from "../../utils.js";
|
|
5
|
+
import { isChoiceStringValue, isColorParam, isDamageTypeChoiceField, isIconParam, isLabelParam, isStringExtendedChoice, isStringParamChoices } from "../../../../language/generated/ast.js";
|
|
6
|
+
export default function generateDamageResistancesComponent(destination, entry) {
|
|
7
|
+
const generatedFileDir = path.join(destination, "system", "templates", "vue", "components");
|
|
8
|
+
const generatedFilePath = path.join(generatedFileDir, `damage-resistances.vue`);
|
|
9
|
+
if (!fs.existsSync(generatedFileDir)) {
|
|
10
|
+
fs.mkdirSync(generatedFileDir, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
// Extract damage types from AST
|
|
13
|
+
function extractDamageTypes() {
|
|
14
|
+
if (!entry)
|
|
15
|
+
return '{}';
|
|
16
|
+
const damageTypeFields = globalGetAllOfType(entry, isDamageTypeChoiceField);
|
|
17
|
+
const damageTypeMap = {};
|
|
18
|
+
for (const field of damageTypeFields) {
|
|
19
|
+
const choicesParam = field.params.find(isStringParamChoices);
|
|
20
|
+
if (!choicesParam)
|
|
21
|
+
continue;
|
|
22
|
+
for (const choice of choicesParam.choices) {
|
|
23
|
+
let damageTypeKey = '';
|
|
24
|
+
let damageTypeInfo = { icon: 'fa-solid fa-circle-info', color: '#666666', label: '' };
|
|
25
|
+
if (isStringExtendedChoice(choice.value)) {
|
|
26
|
+
// Extended choice with properties
|
|
27
|
+
const valueProperty = choice.value.properties.find(isChoiceStringValue);
|
|
28
|
+
if (valueProperty) {
|
|
29
|
+
damageTypeKey = valueProperty.value.replace(/"/g, '').toLowerCase();
|
|
30
|
+
}
|
|
31
|
+
const labelProperty = choice.value.properties.find(isLabelParam);
|
|
32
|
+
if (labelProperty) {
|
|
33
|
+
damageTypeInfo.label = labelProperty.value.replace(/"/g, '');
|
|
34
|
+
}
|
|
35
|
+
const iconProperty = choice.value.properties.find(isIconParam);
|
|
36
|
+
if (iconProperty) {
|
|
37
|
+
damageTypeInfo.icon = iconProperty.value.replace(/"/g, '');
|
|
38
|
+
}
|
|
39
|
+
const colorProperty = choice.value.properties.find(isColorParam);
|
|
40
|
+
if (colorProperty) {
|
|
41
|
+
damageTypeInfo.color = colorProperty.value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// Simple string choice
|
|
46
|
+
damageTypeKey = choice.value.replace(/"/g, '').toLowerCase();
|
|
47
|
+
damageTypeInfo.label = choice.value.replace(/"/g, '');
|
|
48
|
+
}
|
|
49
|
+
if (damageTypeKey) {
|
|
50
|
+
damageTypeMap[damageTypeKey] = damageTypeInfo;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return JSON.stringify(damageTypeMap, null, 8);
|
|
55
|
+
}
|
|
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>
|
|
253
|
+
`.appendNewLine();
|
|
254
|
+
fs.writeFileSync(generatedFilePath, toString(fileNode));
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=vue-damage-resistances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue-damage-resistances.js","sourceRoot":"","sources":["../../../../../src/cli/components/vue/base-components/vue-damage-resistances.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAEI,mBAAmB,EAAE,YAAY,EACxC,uBAAuB,EAAE,WAAW,EAAE,YAAY,EAAE,sBAAsB,EAC1E,oBAAoB,EACvB,MAAM,uCAAuC,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,kCA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoL/C,CAAC,aAAa,EAAE,CAAC;IAElB,EAAE,CAAC,aAAa,CAAC,iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import { expandToNode, toString } from 'langium/generate';
|
|
4
|
+
export default function generateDamageTrackComponent(destination) {
|
|
5
|
+
const generatedFileDir = path.join(destination, "system", "templates", "vue", "components");
|
|
6
|
+
const generatedFilePath = path.join(generatedFileDir, `damage-track.vue`);
|
|
7
|
+
if (!fs.existsSync(generatedFileDir)) {
|
|
8
|
+
fs.mkdirSync(generatedFileDir, { recursive: true });
|
|
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>
|
|
131
|
+
`.appendNewLine();
|
|
132
|
+
fs.writeFileSync(generatedFilePath, toString(fileNode));
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=vue-damage-track.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue-damage-track.js","sourceRoot":"","sources":["../../../../../src/cli/components/vue/base-components/vue-damage-track.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAExD,MAAM,CAAC,OAAO,UAAU,4BAA4B,CAAC,WAAmB;IACpE,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAC5F,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;IAE1E,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QAClC,EAAE,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;KACrD;IAED,MAAM,QAAQ,GAAG,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyH5B,CAAC,aAAa,EAAE,CAAC;IAElB,EAAE,CAAC,aAAa,CAAC,iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5D,CAAC"}
|