Action interruption progress
This commit is contained in:
@@ -10,11 +10,11 @@
|
||||
{{ actionJson }}
|
||||
</code>
|
||||
</pre>
|
||||
<tree-node-view
|
||||
v-for="prop in taskProps"
|
||||
:key="prop._id"
|
||||
:model="prop"
|
||||
/>
|
||||
<pre>
|
||||
<code>
|
||||
{{ resultJson }}
|
||||
</code>
|
||||
</pre>
|
||||
<v-btn
|
||||
slot="actions"
|
||||
text
|
||||
@@ -26,7 +26,8 @@
|
||||
<v-btn
|
||||
slot="actions"
|
||||
text
|
||||
@click="apply(true)"
|
||||
:disabled="!ackNextStep"
|
||||
@click="step"
|
||||
>
|
||||
Step
|
||||
</v-btn>
|
||||
@@ -42,13 +43,12 @@
|
||||
|
||||
<script lang="js">
|
||||
import DialogBase from '/imports/client/ui/dialogStack/DialogBase.vue';
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
|
||||
import TreeNodeView from '/imports/client/ui/properties/treeNodeViews/TreeNodeView.vue';
|
||||
import EngineActions from '/imports/api/engine/action/EngineActions';
|
||||
import applyAction from '/imports/api/engine/action/functions/applyAction';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
DialogBase,
|
||||
TreeNodeView,
|
||||
},
|
||||
props: {
|
||||
actionId: {
|
||||
@@ -59,27 +59,66 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
meteor: {
|
||||
action() {
|
||||
return Actions.findOne(this.actionId);
|
||||
},
|
||||
taskProps() {
|
||||
if (!this.action) return;
|
||||
return this.action.taskQueue.map(task => {
|
||||
return CreatureProperties.findOne(task.propId);
|
||||
});
|
||||
},
|
||||
actionResult: undefined,
|
||||
ackNextStep: undefined,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
actionJson() {
|
||||
return JSON.stringify(this.action, null, 2);
|
||||
},
|
||||
resultJson() {
|
||||
return JSON.stringify(this.actionResult, null, 2);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const vueInstance = this;
|
||||
this.inputProvider = {
|
||||
ackNextStep: undefined,
|
||||
async nextStep() {
|
||||
return new Promise(resolve => {
|
||||
console.log('ackNexStep set')
|
||||
vueInstance.ackNextStep = () => {
|
||||
vueInstance.ackNextStep = undefined;
|
||||
resolve(undefined);
|
||||
}
|
||||
});
|
||||
},
|
||||
async advantage() {
|
||||
return 0;
|
||||
},
|
||||
async rollDice(dice) {
|
||||
const results = [];
|
||||
for (const die of dice) {
|
||||
const rolls = [];
|
||||
for (let i = 0; i < die.number; i++){
|
||||
rolls.push(1);
|
||||
}
|
||||
results.push(rolls);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
},
|
||||
meteor: {
|
||||
action() {
|
||||
return EngineActions.findOne(this.actionId);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async apply(stepThrough) {
|
||||
throw new Error('Not implemented')
|
||||
async apply() {
|
||||
this.actionResult = {
|
||||
...this.action,
|
||||
_stepThrough: undefined,
|
||||
_isSimulation: undefined,
|
||||
taskCount: undefined,
|
||||
};
|
||||
applyAction(
|
||||
this.actionResult, this.inputProvider, { simulate: true, stepThrough: true }
|
||||
)
|
||||
},
|
||||
step() {
|
||||
this.ackNextStep();
|
||||
},
|
||||
cancel() {
|
||||
this.$store.dispatch('popDialogStack');
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { insertAction } from '/imports/api/engine/actions/ActionEngine';
|
||||
import { insertAction } from '/imports/api/engine/action/methods/insertAction';
|
||||
|
||||
export default async function doAction(prop: any, $store, elementId) {
|
||||
const actionId = await insertAction.call({
|
||||
action: {
|
||||
creatureId: prop.ancestors[0].id,
|
||||
creatureId: prop.root.id,
|
||||
rootPropId: prop._id,
|
||||
taskQueue: [{ propId: prop._id }],
|
||||
results: [],
|
||||
taskCount: 0,
|
||||
}
|
||||
});
|
||||
$store.commit('pushDialogStack', {
|
||||
|
||||
@@ -116,15 +116,14 @@
|
||||
|
||||
<script lang="js">
|
||||
import { getPropertyName } from '/imports/constants/PROPERTIES';
|
||||
import numberToSignedString from '../../../../../api/utility/numberToSignedString';
|
||||
//TODO import doAction from '/imports/api/engine/actions/doAction';
|
||||
import numberToSignedString from '/imports/api/utility/numberToSignedString';
|
||||
import doAction from '/imports/client/ui/creature/actions/doAction';
|
||||
import ActionConditionView from '/imports/client/ui/properties/components/actions/ActionConditionView.vue';
|
||||
import AttributeConsumedView from '/imports/client/ui/properties/components/actions/AttributeConsumedView.vue';
|
||||
import ItemConsumedView from '/imports/client/ui/properties/components/actions/ItemConsumedView.vue';
|
||||
import PropertyIcon from '/imports/client/ui/properties/shared/PropertyIcon.vue';
|
||||
import RollPopup from '/imports/client/ui/components/RollPopup.vue';
|
||||
import MarkdownText from '/imports/client/ui/components/MarkdownText.vue';
|
||||
import { snackbar } from '/imports/client/ui/components/snackbars/SnackbarQueue';
|
||||
import CardHighlight from '/imports/client/ui/components/CardHighlight.vue';
|
||||
import TreeNodeList from '/imports/client/ui/components/tree/TreeNodeList.vue';
|
||||
import { docsToForest as nodeArrayToTree } from '/imports/api/parenting/parentingFunctions';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template lang="html">
|
||||
<v-btn
|
||||
:loading="doActionLoading"
|
||||
:disabled="context.editPermission === false"
|
||||
:data-id="`event-btn-${model._id}`"
|
||||
outlined
|
||||
class="event-button"
|
||||
style="min-width: 160px; max-width: 100%;"
|
||||
@@ -21,9 +21,8 @@
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
//TODO import doAction from '/imports/api/engine/actions/doAction';
|
||||
import doAction from '/imports/client/ui/creature/actions/doAction';
|
||||
import PropertyIcon from '/imports/client/ui/properties/shared/PropertyIcon.vue';
|
||||
import { snackbar } from '/imports/client/ui/components/snackbars/SnackbarQueue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -39,36 +38,12 @@ export default {
|
||||
},
|
||||
},
|
||||
data(){return {
|
||||
activated: undefined,
|
||||
doActionLoading: false,
|
||||
hovering: false,
|
||||
}},
|
||||
methods: {
|
||||
click(e) {
|
||||
this.$emit('click', e);
|
||||
doAction() {
|
||||
doAction(this.model, this.$store, `event-btn-${this.model._id}`);
|
||||
},
|
||||
doAction({ advantage }) {
|
||||
this.doActionLoading = true;
|
||||
this.shwing();
|
||||
doAction.call({
|
||||
actionId: this.model._id,
|
||||
scope: {
|
||||
'~attackAdvantage': { value: advantage },
|
||||
}
|
||||
}, error => {
|
||||
this.doActionLoading = false;
|
||||
if (error) {
|
||||
console.error(error);
|
||||
snackbar({ text: error.reason });
|
||||
}
|
||||
});
|
||||
},
|
||||
shwing() {
|
||||
this.activated = true;
|
||||
setTimeout(() => {
|
||||
this.activated = undefined;
|
||||
}, 150);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user