Improved log entries for actions
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import spendResources from '/imports/api/creature/actions/spendResources.js'
|
||||
import embedInlineCalculations from '/imports/api/creature/computation/afterComputation/embedInlineCalculations.js';
|
||||
|
||||
export default function applyAction({prop, log}){
|
||||
spendResources(prop);
|
||||
@@ -6,4 +7,18 @@ export default function applyAction({prop, log}){
|
||||
if (log.content.length){
|
||||
log.content.push({name: prop.name});
|
||||
}
|
||||
if (prop.summary){
|
||||
log.content.push({
|
||||
details: embedInlineCalculations(
|
||||
prop.summary, prop.summaryCalculations
|
||||
),
|
||||
});
|
||||
}
|
||||
if (prop.description){
|
||||
log.content.push({
|
||||
details: embedInlineCalculations(
|
||||
prop.description, prop.descriptionCalculations
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,18 +36,31 @@ export default function applyDamage({
|
||||
damageType: prop.damageType,
|
||||
amount: result,
|
||||
});
|
||||
insertCreatureLog.call({
|
||||
log: {
|
||||
text: `Recieved ${damageDealt} ${prop.damageType}${prop.damageType !== 'healing'? ' damage': ''}`,
|
||||
creatureId: target._id,
|
||||
}
|
||||
});
|
||||
if (target._id !== creature._id){
|
||||
if (target._id === creature._id){
|
||||
log.content.push({
|
||||
result: damageDealt,
|
||||
details: `${prop.damageType}${prop.damageType !== 'healing'? ' damage': ''}` +
|
||||
details: `${prop.damageType}`+
|
||||
`${prop.damageType !== 'healing' ? ' damage': ''} to self`,
|
||||
});
|
||||
} else {
|
||||
log.content.push({
|
||||
resultPrefix: 'Dealt ',
|
||||
result: damageDealt,
|
||||
details: `${prop.damageType}` +
|
||||
`${prop.damageType !== 'healing'? ' damage': ''}` +
|
||||
`${target.name && ' to '}${target.name}`,
|
||||
});
|
||||
insertCreatureLog.call({
|
||||
log: {
|
||||
content: [{
|
||||
resultPrefix: 'Recieved ',
|
||||
result: damageDealt,
|
||||
details: `${prop.damageType}` +
|
||||
`${prop.damageType !== 'healing'? ' damage': ''}`
|
||||
}],
|
||||
creatureId: target._id,
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
export default function embedInlineCalculations(string, calculations){
|
||||
if (!string) return '';
|
||||
let index = 0;
|
||||
return string.replace(/\{([^{}]*)\}/g, () => {
|
||||
let comp = calculations && calculations[index++];
|
||||
return comp && comp.result;
|
||||
});
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
<script>
|
||||
import MarkdownText from '/imports/ui/components/MarkdownText.vue';
|
||||
import embedInlineCalculations from '/imports/api/creature/computation/afterComputation/embedInlineCalculations.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -26,13 +27,8 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
computedValue(){
|
||||
if (!this.string) return '';
|
||||
if (this.inactive) return this.string;
|
||||
let index = 0;
|
||||
return this.string.replace(/\{([^{}]*)\}/g, () => {
|
||||
let comp = this.calculations && this.calculations[index++];
|
||||
return comp && comp.result;
|
||||
});
|
||||
return embedInlineCalculations(this.string, this.calculations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,14 +30,23 @@
|
||||
v-if="content.result"
|
||||
class="subheading font-weight-bold mx-1"
|
||||
>{{ content.result }}</span>
|
||||
{{ content.details }}
|
||||
<markdown-text
|
||||
v-if="content.details"
|
||||
class="details"
|
||||
:markdown="content.details"
|
||||
/>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MarkdownText from '/imports/ui/components/MarkdownText.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MarkdownText,
|
||||
},
|
||||
props: {
|
||||
model: {
|
||||
type: Object,
|
||||
@@ -51,4 +60,7 @@ export default {
|
||||
.content-line {
|
||||
min-height: 24px;
|
||||
}
|
||||
.content-line .details {
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user