Skip to content

Commit 7e4607a

Browse files
author
Caesar0815
committed
added dice roller popup
1 parent db69854 commit 7e4607a

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed

components/FloatingButtons.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,24 @@
5858
/>
5959
</popper>
6060

61+
<popper
62+
trigger="hover"
63+
:options="popperOptions"
64+
>
65+
<div
66+
class="w-48 text-center bg-red-300 uppercase text-white text-sm p-1 rounded font-bold animate__animated animate__fadeIn animate__fast"
67+
>
68+
Dice Popup
69+
</div>
70+
71+
<fa
72+
slot="reference"
73+
icon="dice-d20"
74+
class="button active:border-2"
75+
@click="$root.$emit('open-dice-popup');"
76+
/>
77+
</popper>
78+
6179
<popper
6280
trigger="hover"
6381
:options="popperOptions"

components/popups/DicePopup.vue

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<template>
2+
<PopupContainer
3+
ref="popupContainer"
4+
title="Dice Popup"
5+
class="text-white"
6+
>
7+
<span class="text-xl">Basic Rolls</span>
8+
<div
9+
class="w-full flex flex-row justify-between mt-5"
10+
>
11+
<div
12+
v-for="dice in diceTypes"
13+
:key="dice.key"
14+
>
15+
<div
16+
@click="roll(1, dice)"
17+
>
18+
{{ dice }}
19+
</div>
20+
</div>
21+
</div>
22+
23+
<span class="text-xl">Advanced Roll</span>
24+
<div
25+
class="w-full flex-row justify-between mt-5"
26+
>
27+
Roll:
28+
29+
<input
30+
v-model="number"
31+
type="number"
32+
value="1"
33+
class="input"
34+
>
35+
<select
36+
v-model="sides"
37+
class="input"
38+
>
39+
<option
40+
v-for="dice in diceTypes"
41+
:key="dice.key"
42+
:value="dice"
43+
:selected="dice === 'd20'"
44+
>
45+
{{ dice }}
46+
</option>
47+
</select>
48+
49+
+
50+
51+
<input
52+
v-model="modifire"
53+
type="number"
54+
value="0"
55+
class="input"
56+
disabled
57+
>
58+
59+
<button
60+
class="bg-accent-light active:bg-accent p-2 ml-5 font-bold w-20 rounded text-white text-center select-none"
61+
@click="roll(number, sides)"
62+
>
63+
Roll
64+
</button>
65+
</div>
66+
67+
Modifires will be supported soon
68+
</PopupContainer>
69+
</template>
70+
<script>
71+
import PopupContainer from "../gui-components/PopupContainer";
72+
73+
export default {
74+
components: {PopupContainer},
75+
data() {
76+
return {
77+
diceTypes: [ "d4", "d6", "d8", "d10", "d12", "d20", "d100" ],
78+
number: 1,
79+
sides: "d20",
80+
modifire: 0
81+
};
82+
},
83+
mounted() {
84+
this.$root.$on("open-dice-popup", () => {
85+
this.$refs.popupContainer.active = true;
86+
});
87+
this.$root.$on("close-dice-popup", () => {
88+
this.$refs.popupContainer.active = false;
89+
});
90+
},
91+
methods: {
92+
roll(number, sides) {
93+
this.$store.dispatch("console/execute", "/roll " + number + sides);
94+
}
95+
}
96+
};
97+
</script>
98+
<style scoped lang="scss">
99+
@import "assets/css/scheme";
100+
101+
.input {
102+
@apply w-20 h-6 rounded text-black pl-2
103+
}
104+
</style>

pages/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<AddPlayersToCharacter v-if="device === devices.DEFAULT" />
3030
<AddCharacterConditions v-if="device === devices.DEFAULT" />
3131
<ConsolePopup />
32+
<DicePopup />
3233
<MobileMovement v-if="device === devices.MOBILE" />
3334
<div
3435
v-show="visible"
@@ -61,9 +62,11 @@ import AddPlayersToCharacter from "@/components/popups/AddPlayersToCharacter";
6162
import AddCharacterConditions from "@/components/popups/AddCharacterConditions";
6263
import Dice from "@/components/Dice";
6364
import ConsolePopup from "@/components/popups/ConsolePopup";
65+
import DicePopup from "@/components/popups/DicePopup";
6466
6567
export default {
6668
components: {
69+
DicePopup,
6770
ConsolePopup,
6871
Dice,
6972
AddCharacterConditions,

0 commit comments

Comments
 (0)