Skip to content

Commit

Permalink
feat(Game): Add game sides in modal for smaller screens. Closes #111
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi committed Jan 30, 2021
1 parent 68723b2 commit 8ef9ae5
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [#100](https://github.com/antoinezanardi/werewolves-assistant-web/issues/100) - Implement the Ancient role.
* [#103](https://github.com/antoinezanardi/werewolves-assistant-web/issues/103) - Implement the Scapegoat role.
* [#104](https://github.com/antoinezanardi/werewolves-assistant-web/issues/104) - Implement the Idiot role.
* [#111](https://github.com/antoinezanardi/werewolves-assistant-web/issues/111) - Add game sides in modal for smaller screens.

### 🌟 Enhancements

Expand Down
6 changes: 5 additions & 1 deletion src/classes/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class Game {
};
}

get isCreated() {
return !!this._id;
}

get alivePlayers() {
return this.players.filter(player => player.isAlive);
}
Expand Down Expand Up @@ -109,7 +113,7 @@ class Game {
}

get canUpdateOptions() {
return !this._id;
return !this.isCreated;
}

get firstWaiting() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Game/Game.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import { mapActions, mapGetters } from "vuex";
import Swal from "sweetalert2";
import Loading from "@/components/shared/Loading";
import GameVillagersSide from "./GameVillagersSide/GameVillagersSide";
import GameWerewolvesSide from "./GameWerewolvesSide/GameWerewolvesSide";
import GameVillagersSide from "../shared/Game/Sides/GameVillagersSide/GameVillagersSide";
import GameWerewolvesSide from "../shared/Game/Sides/GameWerewolvesSide/GameWerewolvesSide";
import GameContent from "./GameContent/GameContent";
import GameWinners from "./GameWinners/GameWinners";
import { isAPIError } from "@/helpers/functions/Error";
Expand Down
91 changes: 91 additions & 0 deletions src/components/NavBar/GameSidesModal/GameSidesModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<template>
<div id="game-sides-modal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" v-html="$t('GameSidesModal.gameSides')"/>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true" class="text-white">
&times;
</span>
</button>
</div>
<div class="modal-body h-100 visible-scrollbar">
<ul id="game-sides-modal-tabs" class="nav nav-pills nav-fill">
<li id="game-results-tab" class="nav-item" @click="openGameVillagersSidesPanel">
<a class="nav-link" :class="{ active: panel === 'game-villagers-side' }" href="#">
<img :src="SVGs.villagers" width="20" alt="Villagers Side" class="mr-2"/>
<span v-html="$t('GameSidesModal.villagersSide')"/>
</a>
</li>
<li id="game-history-tab" class="nav-item" @click="openGameWerewolvesSidesPanel">
<a class="nav-link" :class="{ active: panel === 'game-werewolves-side' }" href="#">
<img :src="SVGs.werewolves" width="20" alt="Werewolves Side" class="mr-2"/>
<span v-html="$t('GameSidesModal.werewolvesSide')"/>
</a>
</li>
</ul>
<div>
<hr class="bg-dark my-2"/>
</div>
<div class="row justify-content-between">
<transition mode="out-in" name="fade">
<GameVillagersSide v-if="panel === 'game-villagers-side'" key="game-villagers-side" class="col-12"/>
<GameWerewolvesSide v-else-if="panel === 'game-werewolves-side'" key="game-werewolves-side" class="col-12"/>
</transition>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" v-html="$t('GameSidesModal.close')"/>
</div>
</div>
</div>
</div>
</template>

<script>
import $ from "jquery";
import GameWerewolvesSide from "@/components/shared/Game/Sides/GameWerewolvesSide/GameWerewolvesSide";
import GameVillagersSide from "@/components/shared/Game/Sides/GameVillagersSide/GameVillagersSide";
import villagers from "@/assets/svg/roles/villager.svg";
import werewolves from "@/assets/svg/attributes/eaten.svg";
export default {
name: "GameSidesModal",
components: { GameVillagersSide, GameWerewolvesSide },
data() {
return {
panel: "game-villagers-side",
SVGs: { werewolves, villagers },
};
},
methods: {
show() {
$("#game-sides-modal").modal("show");
},
openGameVillagersSidesPanel() {
this.panel = "game-villagers-side";
},
openGameWerewolvesSidesPanel() {
this.panel = "game-werewolves-side";
},
},
};
</script>

<style lang="scss" scoped>
#game-sides-modal {
overflow-y: hidden;
.modal-body {
min-height: calc(85vh - 150px);
max-height: calc(85vh - 150px);
overflow-y: auto;
overflow-x: hidden;
}
}
.nav-link {
transition: all 0.25s linear;
}
</style>
14 changes: 13 additions & 1 deletion src/components/NavBar/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
<span class="d-none d-md-inline-block" v-html="$t('NavBar.werewolvesAssistant')"/>
</a>
<div class="navbar-nav d-flex w-100 justify-content-end">
<transition mode="out-in" name="fade">
<div v-if="game.isCreated" class="nav-item d-md-none d-sm-block">
<a class="nav-link" href="#" role="button" aria-haspopup="true" @click.prevent="showGameSidesModal">
<i class="fa fa-chess mr-2"/>
</a>
</div>
</transition>
<div id="nav-bar-options" class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true">
<i class="fa fa-cog mr-2"/>
Expand All @@ -28,17 +35,19 @@
</div>
</div>
<GameOptionsModal ref="gameOptionsModal"/>
<GameSidesModal v-if="game.isCreated" ref="gameSidesModal"/>
</nav>
</template>

<script>
import Swal from "sweetalert2";
import { mapActions, mapGetters } from "vuex";
import GameOptionsModal from "@/components/NavBar/GameOptionsModal/GameOptionsModal";
import GameSidesModal from "@/components/NavBar/GameSidesModal/GameSidesModal";
export default {
name: "NavBar",
components: { GameOptionsModal },
components: { GameSidesModal, GameOptionsModal },
computed: { ...mapGetters("game", { game: "game" }) },
methods: {
...mapActions("game", { setGame: "setGame" }),
Expand Down Expand Up @@ -71,6 +80,9 @@ export default {
showGameOptionsModal() {
this.$refs.gameOptionsModal.show();
},
showGameSidesModal() {
this.$refs.gameSidesModal.show();
},
},
};
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template>
<tr class="row">
<td class="col-1 d-flex align-items-center justify-content-center">
<td class="d-none d-lg-flex col-lg-1 align-items-center justify-content-center">
<img width="45" alt="Death Icon" :src="SVGs.dead"/>
</td>
<td class="col-4 d-flex flex-column justify-content-center align-items-center">
<td class="col-6 col-lg-4 d-flex flex-column justify-content-center align-items-center">
<RoleImage width="30" :role="deadPlayer.role.current"/>
<div class="text-center" v-html="deadPlayer.name"/>
<RoleText class="text-center small cursor-text" :role="deadPlayer.role.current"/>
</td>
<td class="col-7 d-flex flex-column align-items-center justify-content-center">
<td class="col-6 col-lg-7 d-flex flex-column align-items-center justify-content-center">
<img width="30" alt="Death Icon" :src="deathIcon"/>
<span v-html="deathText"/>
<span class="text-center" v-html="deathText"/>
</td>
</tr>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<tr id="game-summary-history-line" class="row">
<td class="col-md-1 d-none d-md-flex align-items-center justify-content-center">
<td class="col-lg-1 d-none d-lg-flex align-items-center justify-content-center">
<img width="45" alt="Icon" :src="actionImageSource"/>
</td>
<td class="col-4 d-flex flex-column align-items-center justify-content-center">
Expand All @@ -15,7 +15,7 @@
<RoleText class="text-center small cursor-text" :role="source.role.current"/>
</div>
</td>
<td class="col-4 col-md-3 d-flex flex-column align-items-center justify-content-center">
<td class="col-4 col-lg-3 d-flex flex-column align-items-center justify-content-center">
<i class="fa fa-2x" :class="actionIconClass"/>
<div class="text-center" v-html="actionText"/>
</td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<template>
<tr class="row">
<td class="col-1 d-flex flex-column align-items-center justify-content-center">
<td class="d-none d-lg-flex col-lg-1 flex-column align-items-center justify-content-center">
<img width="45" alt="Seen Icon" :src="SVGs.seen"/>
</td>
<td class="col-4 d-flex flex-column justify-content-center align-items-center">
<td class="col-6 col-lg-4 d-flex flex-column justify-content-center align-items-center">
<RoleImage width="30" :role="revealedPlayer.role.current"/>
<div class="text-center" v-html="revealedPlayer.name"/>
<RoleText class="text-center small cursor-text" :role="revealedPlayer.role.current"/>
</td>
<td class="col-7 d-flex justify-content-center align-items-center">
<span v-html="revealedText"/>
<td class="col-6 col-lg-7 d-flex justify-content-center align-items-center">
<span class="text-center" v-html="revealedText"/>
</td>
</tr>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</span>
</button>
</div>
<div class="modal-body d-flex flex-column h-100 visible-scrollbar">
<div class="modal-body h-100 visible-scrollbar">
<ul id="game-summary-modal-tabs" class="nav nav-pills nav-fill">
<li id="game-results-tab" class="nav-item" @click="openGameResultsPanel">
<a class="nav-link" :class="{ active: panel === 'game-results' }" href="#">
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/Game/PlayerThumbnail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
} else if (this.player.isRoleRevealed) {
content += `<hr class="bg-dark my-1"/><div>${this.$t("PlayerThumbnail.thisPlayerRoleIsRevealed")}</div>`;
}
return { content, boundariesElement: ".player-strip" };
return { content };
}
return this.$t("PlayerThumbnail.chooseRole");
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

<script>
import { mapGetters } from "vuex";
import PlayerThumbnail from "../../shared/Game/PlayerThumbnail";
import PlayerAttribute from "../../shared/Game/PlayerAttribute/PlayerAttribute";
import PlayerThumbnail from "../../PlayerThumbnail";
import PlayerAttribute from "../../PlayerAttribute/PlayerAttribute";
import AliveVillagers from "@/components/shared/Game/Sides/AliveVillagers";
export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

<script>
import { mapGetters } from "vuex";
import PlayerAttribute from "../../shared/Game/PlayerAttribute/PlayerAttribute";
import PlayerThumbnail from "../../shared/Game/PlayerThumbnail";
import PlayerAttribute from "../../PlayerAttribute/PlayerAttribute";
import PlayerThumbnail from "../../PlayerThumbnail";
import AliveWerewolves from "@/components/shared/Game/Sides/AliveWerewolves";
export default {
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/v-tooltip/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import Vue from "vue";
import VTooltip from "v-tooltip";
import { isTouchDevice } from "@/helpers/functions/Device";

Vue.use(VTooltip, { defaultContainer: "body" });
Vue.use(VTooltip, {
defaultContainer: "body",
defaultTrigger: isTouchDevice() ? "hover focus click" : "hover",
});
6 changes: 6 additions & 0 deletions src/plugins/vue-i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
"description": "Les Trois Frères ne se réveillent que la première nuit. | Les Trois Frères se réveillent toutes les nuits. | Les Trois Frères se réveillent toutes les {brothersWakingUpInterval} nuits."
}
},
"GameSidesModal": {
"gameSides": "Camps de la partie",
"villagersSide": "Camp des villageois",
"werewolvesSide": "Camp des loups-garous",
"close": "Fermer"
},
"Home": {
"werewolvesAssistant": "Assistant Loups-Garous",
"play": "Jouer",
Expand Down

0 comments on commit 8ef9ae5

Please sign in to comment.