Skip to content

Commit

Permalink
Move action logic to ContextMenu vue component.
Browse files Browse the repository at this point in the history
  • Loading branch information
agitperson committed Jan 3, 2018
1 parent 43ae632 commit 1963b25
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/components/sub/ContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default {
props: ['game'],
created() {
bus.$on('PLAYER:MENU', this.openMenu);
this.$forceUpdate();
},
data() {
return {
Expand All @@ -48,10 +47,9 @@ export default {
const data = {
item,
tile: this.tile,
actions: this.actions,
};
bus.$emit('ITEM:DO', data);
this.actions.do(data);
this.closeMenu();
},
Expand Down
7 changes: 3 additions & 4 deletions src/core/engine/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ class Actions {
constructor(data) {
this.player = data.player;
this.board = data.board;

bus.$on('ITEM:DO', Actions.do);
}

/**
* Execute the certain action by checking (if allowed)
*
* @param {object} data Information of tile, Action class and items
*/
static do(data) {
do(data) {
const player = this.player;
const board = this.board;
const item = data.item;
const { player, board } = data.actions;
const clickedTile = data.tile;

switch (item) {
Expand Down
1 change: 0 additions & 1 deletion src/core/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ class Player {
} else {
// We are done walking
// so let's reset path
debugger;
this.stopMovement();
}
} else {
Expand Down

0 comments on commit 1963b25

Please sign in to comment.