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