From 6722053d9cfb768dc77f1260a3a71473473f5aaa Mon Sep 17 00:00:00 2001 From: Steffen Date: Sat, 11 Apr 2020 22:55:37 +0200 Subject: [PATCH] added role selection --- src/App.vue | 78 +++++++++---- src/components/Modal.vue | 20 ++-- src/components/RoleSelectionModal.vue | 156 ++++++++++++++++++++++++++ src/components/TownInfo.vue | 24 ++-- src/game.json | 22 ++-- 5 files changed, 245 insertions(+), 55 deletions(-) create mode 100644 src/components/RoleSelectionModal.vue diff --git a/src/App.vue b/src/App.vue index 2040a3b..4f92701 100644 --- a/src/App.vue +++ b/src/App.vue @@ -6,7 +6,12 @@ :players="players" :roles="roles" > - + +

Select an edition:

+ + +
    @@ -33,9 +46,15 @@
  • Clear Players
  • -
  • +
  • + Clear Roles +
  • +
  • Select Edition
  • +
  • + Select Roles +
@@ -45,24 +64,27 @@ import TownSquare from "./components/TownSquare"; import TownInfo from "./components/TownInfo"; import Modal from "./components/Modal"; +import RoleSelectionModal from "./components/RoleSelectionModal"; import rolesJSON from "./roles"; -import editions from "./editions"; +import editionJSON from "./editions"; export default { components: { TownSquare, TownInfo, - Modal + Modal, + RoleSelectionModal }, data: function() { return { - editions, + editions: editionJSON, isPublic: true, isControlOpen: false, + isEditionModalOpen: false, + isRoleModalOpen: false, players: [], roles: this.getRolesByEdition(), - edition: "tb", - showEditionModal: false + edition: "tb" }; }, methods: { @@ -89,7 +111,32 @@ export default { } }, clearPlayers() { - this.players = []; + if (confirm("Are you sure you want to remove all players?")) { + this.players = []; + } + }, + clearRoles() { + if (confirm("Are you sure you want to remove all player roles?")) { + this.players.forEach(player => { + player.role = {}; + player.reminders = []; + }); + } + }, + getRolesByEdition(edition = "tb") { + const selectedEdition = editionJSON.find(({ id }) => id === edition); + return new Map( + rolesJSON + .filter( + r => r.edition === edition || selectedEdition.roles.includes(r.id) + ) + .sort((a, b) => b.team.localeCompare(a.team)) + .map(role => [role.id, role]) + ); + }, + setEdition(edition) { + this.edition = edition; + this.isEditionModalOpen = false; }, keyup({ key }) { switch (key) { @@ -103,21 +150,6 @@ export default { this.randomizeSeatings(); break; } - }, - getRolesByEdition(edition = "tb") { - const selectedEdition = editions.find(({ id }) => id === edition); - return new Map( - rolesJSON - .filter( - r => r.edition === edition || selectedEdition.roles.includes(r.id) - ) - .sort((a, b) => b.team.localeCompare(a.team)) - .map(role => [role.id, role]) - ); - }, - setEdition(edition) { - this.edition = edition; - this.showEditionModal = false; } }, mounted() { diff --git a/src/components/Modal.vue b/src/components/Modal.vue index 2869f5c..144ae2a 100644 --- a/src/components/Modal.vue +++ b/src/components/Modal.vue @@ -1,12 +1,3 @@ - + + + diff --git a/src/components/TownInfo.vue b/src/components/TownInfo.vue index a7935ba..4cdebf4 100644 --- a/src/components/TownInfo.vue +++ b/src/components/TownInfo.vue @@ -1,35 +1,35 @@