Chore : cleanup 2

This commit is contained in:
2024-08-01 17:38:01 +02:00
parent 23e5f9f432
commit de38416bcd
7 changed files with 325 additions and 329 deletions
+255 -26
View File
@@ -1,31 +1,260 @@
<script lang="ts"> <script setup lang="ts">
import { cards } from "~/services/loadCards"; export interface Props {
uuid?: string;
cardId: number | undefined;
locked?: boolean;
wrapped?: boolean;
tilted?: boolean;
interactible?: boolean;
noEffects?: boolean;
used_effects_indexes?: number[];
discardable?: boolean;
}
export default { const props = withDefaults(defineProps<Props>(), {
props: { wrapped: () => false,
cardId: { tilted: () => true,
required: true, locked: () => true,
type: Number, interactible: () => true,
}, noEffects: () => false,
used_effects_indexes: { discardable: () => false,
default: [], });
type: Array,
}, const emit = defineEmits([
}, "click",
data() { "effectClick",
return { cards }; "drop",
}, "move",
beforeCreate() { "startMove",
console.log(cards); "stopMove",
(this as any).component = () => cards[this.cardId]; ]);
},
}; const settingsStore = useSettingsStore();
const childCount = ref<number>(0);
const extension = computed(() => {
if (settingsStore.cardStyle == CardStyles.SVG) {
return ".svg";
}
return ".png";
});
function cardClick() {
if (!props.cardId) return;
emit("click");
}
const isZooming = ref<boolean>(false);
function mouseenter(e: MouseEvent) {
// User is Right Clicking
if ((e.buttons & 2) == 2) {
isZooming.value = true;
}
// goStore.hoveredCard = props.card_id
}
function mouseleave(e: MouseEvent) {
isZooming.value = false;
}
function rightClickDown(e: MouseEvent) {
isZooming.value = true;
}
function rightClickUp(e: MouseEvent) {
isZooming.value = false;
}
</script> </script>
<template> <template>
<Component <div
:is="cards[cardId]" ref="cardHTMLElement"
:cardId="cardId" class="card"
:used_effects_indexes="used_effects_indexes" :class="{
/> active: childCount > 0,
wrapped,
unlocked: !props.locked,
zoom: isZooming,
no_effects: noEffects || !props.locked,
discardable,
}"
@contextmenu.prevent="false"
@mousedown.right="rightClickDown"
@mouseup.right="rightClickUp"
@mouseenter="mouseenter"
@mouseleave="mouseleave"
>
<template v-if="props.cardId">
<GameCardAtom
v-if="settingsStore.cardStyle == CardStyles.SVG"
:cardId="props.cardId"
:used_effects_indexes="used_effects_indexes"
@effectClick="emit('effectClick', $event)"
></GameCardAtom>
<div id="overlay">
<slot></slot>
</div>
</template>
<img
:class="`card_image`"
v-else
:src="'/cards/background.png'"
draggable="false"
/>
</div>
</template> </template>
<style scoped>
/* .card.dragging {
transform: translateX(v-bind("translateX + 'px'"))
translateY(v-bind("translateY + 'px'"));
cursor: grabbing;
z-index: 999;
} */
/* .card.dragging > svg {
transform: scale(110%);
} */
.card.active {
cursor: pointer;
}
.card_image {
max-height: var(--max-height);
z-index: 1;
height: var(--max-height);
}
.card.wrapped {
height: 1px;
margin: 0;
}
.card.wrapped .card_image {
filter: drop-shadow(0.5px 0.5px 0.5px gray)
drop-shadow(-0.5px -0.5px 0.5px gray);
}
.card.zoom {
transform: scale(200%);
z-index: 10;
}
#contextMenuButtons {
position: absolute;
display: flex;
flex-direction: row;
flex-wrap: wrap;
word-break: break-word;
bottom: 0;
width: 99%;
transform: translateY(-0px);
transition: 0.1s transform cubic-bezier(1, 1.81, 0.59, 1.42);
}
.card.active:hover #contextMenuButtons {
transform: translateY(100%);
}
</style>
<style>
.card.no_effects svg > * {
pointer-events: none;
}
#contextMenuButtons > * {
flex: 1;
border-radius: 12px;
min-height: 50px;
}
@keyframes gelatine {
from,
to {
}
25% {
transform: scale(1, 1.5);
}
50% {
transform: scale(1.5, 1);
}
75% {
transform: scale(1.1, 1.3);
}
}
.svg_resource_icon {
cursor: pointer;
animation: gelatine 0.3s normal;
transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.svg_resource_icon:active {
animation: none;
}
.svg_resource_icon:hover {
transform: scale(130%);
}
.used {
opacity: 0.2;
filter: grayscale(0.6);
pointer-events: none;
}
.svg_effect text {
cursor: pointer;
}
.card {
--max-height: 250px;
--max-width: 179px;
--margin-bottom: calc(var(--max-height) * 0.05);
position: relative;
display: flex;
justify-content: center;
margin-bottom: 0px;
margin-top: var(--margin-bottom);
transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
pointer-events: all;
max-height: var(--max-height);
max-width: var(--max-width);
/* cursor: grab; */
}
.card:not(svg) {
cursor: grab;
}
#overlay {
position: absolute;
top: 20%;
width: calc(100% - 8%);
height: 49%;
}
.card.unlocked {
margin-top: 0px;
margin-bottom: var(--margin-bottom);
transform: translateY(calc(var(--margin-bottom) * -0.25));
filter: drop-shadow(
calc(var(--margin-bottom) * 0.3) var(--margin-bottom) 1px rgba(0, 0, 0, 0.6)
);
cursor: pointer;
}
.card.discardable {
cursor: not-allowed;
}
.card.discardable svg {
pointer-events: none;
}
</style>
+30
View File
@@ -0,0 +1,30 @@
<script lang="ts">
import { cards } from "~/services/loadCards";
export default {
props: {
cardId: {
required: true,
type: Number,
},
used_effects_indexes: {
default: [],
type: Array,
},
},
data() {
return { cards };
},
beforeCreate() {
(this as any).component = () => cards[this.cardId];
},
};
</script>
<template>
<Component
:is="cards[cardId]"
:cardId="cardId"
:used_effects_indexes="used_effects_indexes"
/>
</template>
+4 -4
View File
@@ -137,14 +137,14 @@ function discardCardClick(card: Card) {
:class="{ wrapped, rotate: container.shuffling }" :class="{ wrapped, rotate: container.shuffling }"
> >
<TransitionGroup name="list"> <TransitionGroup name="list">
<GameCardPreview <GameCard
@click="$emit('cardClick', c._id)" @click="$emit('cardClick', c._id)"
@effectClick="$emit('effectClick', c._id, $event)" @effectClick="$emit('effectClick', c._id, $event)"
v-for="(c, i) in cards" v-for="(c, i) in cards"
:card_id="c?.cardId" :cardId="c?.cardId"
:uuid="c._id"
:wrapped="wrapped" :wrapped="wrapped"
:key="c?._id || i" :key="c?._id || i"
:card="c"
:locked=" :locked="
!playingTurn || playingTurn?.cardsLocked.includes(c._id.toString()) !playingTurn || playingTurn?.cardsLocked.includes(c._id.toString())
" "
@@ -198,7 +198,7 @@ function discardCardClick(card: Card) {
> >
Discard Discard
</button> </button>
</GameCardPreview> </GameCard>
</TransitionGroup> </TransitionGroup>
<!-- <img :class="`card_image`" :src="'/cards/background.png'" draggable="false"> --> <!-- <img :class="`card_image`" :src="'/cards/background.png'" draggable="false"> -->
</div> </div>
-260
View File
@@ -1,260 +0,0 @@
<script setup lang="ts">
export interface Props {
uuid?: string;
cardId?: number;
locked?: boolean;
wrapped?: boolean;
tilted?: boolean;
interactible?: boolean;
noEffects?: boolean;
used_effects_indexes?: number[];
discardable?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
wrapped: () => false,
tilted: () => true,
locked: () => true,
interactible: () => true,
noEffects: () => false,
discardable: () => false,
});
const emit = defineEmits([
"click",
"effectClick",
"drop",
"move",
"startMove",
"stopMove",
]);
const settingsStore = useSettingsStore();
const childCount = ref<number>(0);
const extension = computed(() => {
if (settingsStore.cardStyle == CardStyles.SVG) {
return ".svg";
}
return ".png";
});
function cardClick() {
if (!props.cardId) return;
emit("click");
}
const isZooming = ref<boolean>(false);
function mouseenter(e: MouseEvent) {
// User is Right Clicking
if ((e.buttons & 2) == 2) {
isZooming.value = true;
}
// goStore.hoveredCard = props.card_id
}
function mouseleave(e: MouseEvent) {
isZooming.value = false;
}
function rightClickDown(e: MouseEvent) {
isZooming.value = true;
}
function rightClickUp(e: MouseEvent) {
isZooming.value = false;
}
</script>
<template>
<div
ref="cardHTMLElement"
class="card"
:class="{
active: childCount > 0,
wrapped,
unlocked: !props.locked,
zoom: isZooming,
no_effects: noEffects || !props.locked,
discardable,
}"
@contextmenu.prevent="false"
@mousedown.right="rightClickDown"
@mouseup.right="rightClickUp"
@mouseenter="mouseenter"
@mouseleave="mouseleave"
>
<template v-if="props.cardId">
<GameCard
v-if="settingsStore.cardStyle == CardStyles.SVG"
:cardId="props.cardId"
:used_effects_indexes="used_effects_indexes"
@effectClick="emit('effectClick', $event)"
></GameCard>
<div id="overlay">
<slot></slot>
</div>
</template>
<img
:class="`card_image`"
v-else
:src="'/cards/background.png'"
draggable="false"
/>
</div>
</template>
<style scoped>
/* .card.dragging {
transform: translateX(v-bind("translateX + 'px'"))
translateY(v-bind("translateY + 'px'"));
cursor: grabbing;
z-index: 999;
} */
/* .card.dragging > svg {
transform: scale(110%);
} */
.card.active {
cursor: pointer;
}
.card_image {
max-height: var(--max-height);
z-index: 1;
height: var(--max-height);
}
.card.wrapped {
height: 1px;
margin: 0;
}
.card.wrapped .card_image {
filter: drop-shadow(0.5px 0.5px 0.5px gray)
drop-shadow(-0.5px -0.5px 0.5px gray);
}
.card.zoom {
transform: scale(200%);
z-index: 10;
}
#contextMenuButtons {
position: absolute;
display: flex;
flex-direction: row;
flex-wrap: wrap;
word-break: break-word;
bottom: 0;
width: 99%;
transform: translateY(-0px);
transition: 0.1s transform cubic-bezier(1, 1.81, 0.59, 1.42);
}
.card.active:hover #contextMenuButtons {
transform: translateY(100%);
}
</style>
<style>
.card.no_effects svg > * {
pointer-events: none;
}
#contextMenuButtons > * {
flex: 1;
border-radius: 12px;
min-height: 50px;
}
@keyframes gelatine {
from,
to {
}
25% {
transform: scale(1, 1.5);
}
50% {
transform: scale(1.5, 1);
}
75% {
transform: scale(1.1, 1.3);
}
}
.svg_resource_icon {
cursor: pointer;
animation: gelatine 0.3s normal;
transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.svg_resource_icon:active {
animation: none;
}
.svg_resource_icon:hover {
transform: scale(130%);
}
.used {
opacity: 0.2;
filter: grayscale(0.6);
pointer-events: none;
}
.svg_effect text {
cursor: pointer;
}
.card {
--max-height: 250px;
--max-width: 179px;
--margin-bottom: calc(var(--max-height) * 0.05);
position: relative;
display: flex;
justify-content: center;
margin-bottom: 0px;
margin-top: var(--margin-bottom);
transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
pointer-events: all;
max-height: var(--max-height);
max-width: var(--max-width);
/* cursor: grab; */
}
.card:not(svg) {
cursor: grab;
}
#overlay {
position: absolute;
top: 20%;
width: calc(100% - 8%);
height: 49%;
}
.card.unlocked {
margin-top: 0px;
margin-bottom: var(--margin-bottom);
transform: translateY(calc(var(--margin-bottom) * -0.25));
filter: drop-shadow(
calc(var(--margin-bottom) * 0.3) var(--margin-bottom) 1px rgba(0, 0, 0, 0.6)
);
cursor: pointer;
}
.card.discardable {
cursor: not-allowed;
}
.card.discardable svg {
pointer-events: none;
}
</style>
+2 -2
View File
@@ -50,7 +50,7 @@ function tokenClick({ card, token }: { card: Card; token: Effect }) {
<span>Discard of {{ player.user.username }}</span> <span>Discard of {{ player.user.username }}</span>
<div class="discard_unwrapped" @click.stop> <div class="discard_unwrapped" @click.stop>
<GameCardPreview <GameCardGrouped
:container="discard" :container="discard"
:wrapped="false" :wrapped="false"
:hidden="false" :hidden="false"
@@ -58,7 +58,7 @@ function tokenClick({ card, token }: { card: Card; token: Effect }) {
:noEffects="true" :noEffects="true"
:playingTurn="game.currentTurn" :playingTurn="game.currentTurn"
@tokenClick="tokenClick" @tokenClick="tokenClick"
></GameCardPreview> ></GameCardGrouped>
</div> </div>
</div> </div>
</template> </template>
+33 -36
View File
@@ -31,10 +31,10 @@ const router = useRouter();
<p>&#8203;</p> <p>&#8203;</p>
<p>Et quoi de mieux pour faire ça que des cartes colorées?</p> <p>Et quoi de mieux pour faire ça que des cartes colorées?</p>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="6" :tilted="false"></GameCardPreview> <GameCard :cardId="6" :tilted="false"></GameCard>
<GameCardPreview :card_id="19" :tilted="false"></GameCardPreview> <GameCard :cardId="19" :tilted="false"></GameCard>
<GameCardPreview :card_id="36" :tilted="false"></GameCardPreview> <GameCard :cardId="36" :tilted="false"></GameCard>
<GameCardPreview :card_id="46" :tilted="false"></GameCardPreview> <GameCard :cardId="46" :tilted="false"></GameCard>
</div> </div>
<p>&#8203;</p> <p>&#8203;</p>
<hr /> <hr />
@@ -60,10 +60,7 @@ const router = useRouter();
"deck" et ce qui nous permet de le "build". "deck" et ce qui nous permet de le "build".
</p> </p>
<div class="card-row"> <div class="card-row">
<GameCardPreview <GameCard :cardId="undefined" :tilted="false"></GameCard>
:card_id="undefined"
:tilted="false"
></GameCardPreview>
</div> </div>
<p>&#8203;</p> <p>&#8203;</p>
<p> <p>
@@ -90,10 +87,10 @@ const router = useRouter();
<li>1x Dégats (2)</li> <li>1x Dégats (2)</li>
</ul> </ul>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="56" :tilted="false"></GameCardPreview> <GameCard :cardId="56" :tilted="false"></GameCard>
<GameCardPreview :card_id="59" :tilted="false"></GameCardPreview> <GameCard :cardId="59" :tilted="false"></GameCard>
<GameCardPreview :card_id="58" :tilted="false"></GameCardPreview> <GameCard :cardId="58" :tilted="false"></GameCard>
<GameCardPreview :card_id="57" :tilted="false"></GameCardPreview> <GameCard :cardId="57" :tilted="false"></GameCard>
</div> </div>
<p> <p>
La pioche est formée au hasard: on peut donc avoir une main de départ La pioche est formée au hasard: on peut donc avoir une main de départ
@@ -115,15 +112,15 @@ const router = useRouter();
champions. champions.
</p> </p>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="56" :tilted="false"></GameCardPreview> <GameCard :cardId="56" :tilted="false"></GameCard>
<GameCardPreview :card_id="52" :tilted="false"></GameCardPreview> <GameCard :cardId="52" :tilted="false"></GameCard>
<GameCardPreview :card_id="43" :tilted="false"></GameCardPreview> <GameCard :cardId="43" :tilted="false"></GameCard>
</div> </div>
<p>&#8203;</p> <p>&#8203;</p>
<h3>Objets & actions</h3> <h3>Objets & actions</h3>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="56" :tilted="false"></GameCardPreview> <GameCard :cardId="56" :tilted="false"></GameCard>
<GameCardPreview :card_id="52" :tilted="false"></GameCardPreview> <GameCard :cardId="52" :tilted="false"></GameCard>
</div> </div>
<p> <p>
Par simplicité, disons que les objets et les actions sont pareil: on Par simplicité, disons que les objets et les actions sont pareil: on
@@ -132,7 +129,7 @@ const router = useRouter();
</p> </p>
<h3>Champions (& gardes)</h3> <h3>Champions (& gardes)</h3>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="43" :tilted="false"></GameCardPreview> <GameCard :cardId="43" :tilted="false"></GameCard>
</div> </div>
<p> <p>
Les champions sont un peu plus complexes: ils restent sur le terrain, Les champions sont un peu plus complexes: ils restent sur le terrain,
@@ -153,7 +150,7 @@ const router = useRouter();
de dégats pendant un tour, et un peu le tour d'après pour les tuer. de dégats pendant un tour, et un peu le tour d'après pour les tuer.
</p> </p>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="49" :tilted="false"></GameCardPreview> <GameCard :cardId="49" :tilted="false"></GameCard>
</div> </div>
<p> <p>
Par ailleurs, certains champions sont des Gardes Par ailleurs, certains champions sont des Gardes
@@ -183,10 +180,10 @@ const router = useRouter();
exclusivement à accomplir ce but: acheter des cartes. exclusivement à accomplir ce but: acheter des cartes.
</p> </p>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="6" :tilted="false"></GameCardPreview> <GameCard :cardId="6" :tilted="false"></GameCard>
<GameCardPreview :card_id="19" :tilted="false"></GameCardPreview> <GameCard :cardId="19" :tilted="false"></GameCard>
<GameCardPreview :card_id="36" :tilted="false"></GameCardPreview> <GameCard :cardId="36" :tilted="false"></GameCard>
<GameCardPreview :card_id="46" :tilted="false"></GameCardPreview> <GameCard :cardId="46" :tilted="false"></GameCard>
</div> </div>
<p> <p>
Un marché est mis à disposition de tous les joueurs, mettant à Un marché est mis à disposition de tous les joueurs, mettant à
@@ -211,9 +208,9 @@ const router = useRouter();
</p> </p>
<p>&#8203;</p> <p>&#8203;</p>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="13" :tilted="false"></GameCardPreview> <GameCard :cardId="13" :tilted="false"></GameCard>
<GameCardPreview :card_id="3" :tilted="false"></GameCardPreview> <GameCard :cardId="3" :tilted="false"></GameCard>
<GameCardPreview :card_id="1" :tilted="false"></GameCardPreview> <GameCard :cardId="1" :tilted="false"></GameCard>
</div> </div>
<p>&#8203;</p> <p>&#8203;</p>
<p> <p>
@@ -225,9 +222,9 @@ const router = useRouter();
</p> </p>
<p>&#8203;</p> <p>&#8203;</p>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="39" :tilted="false"></GameCardPreview> <GameCard :cardId="39" :tilted="false"></GameCard>
<GameCardPreview :card_id="34" :tilted="false"></GameCardPreview> <GameCard :cardId="34" :tilted="false"></GameCard>
<GameCardPreview :card_id="40" :tilted="false"></GameCardPreview> <GameCard :cardId="40" :tilted="false"></GameCard>
</div> </div>
<p>&#8203;</p> <p>&#8203;</p>
<p> <p>
@@ -240,9 +237,9 @@ const router = useRouter();
</p> </p>
<p>&#8203;</p> <p>&#8203;</p>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="52" :tilted="false"></GameCardPreview> <GameCard :cardId="52" :tilted="false"></GameCard>
<GameCardPreview :card_id="46" :tilted="false"></GameCardPreview> <GameCard :cardId="46" :tilted="false"></GameCard>
<GameCardPreview :card_id="47" :tilted="false"></GameCardPreview> <GameCard :cardId="47" :tilted="false"></GameCard>
</div> </div>
<p>&#8203;</p> <p>&#8203;</p>
<p> <p>
@@ -255,9 +252,9 @@ const router = useRouter();
</p> </p>
<p>&#8203;</p> <p>&#8203;</p>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="24" :tilted="false"></GameCardPreview> <GameCard :cardId="24" :tilted="false"></GameCard>
<GameCardPreview :card_id="25" :tilted="false"></GameCardPreview> <GameCard :cardId="25" :tilted="false"></GameCard>
<GameCardPreview :card_id="19" :tilted="false"></GameCardPreview> <GameCard :cardId="19" :tilted="false"></GameCard>
</div> </div>
<p>&#8203;</p> <p>&#8203;</p>
<p> <p>
@@ -275,7 +272,7 @@ const router = useRouter();
Les effets de cartes peuvent se déclencher pour 3 raisons différentes. Les effets de cartes peuvent se déclencher pour 3 raisons différentes.
</p> </p>
<div class="card-row"> <div class="card-row">
<GameCardPreview :card_id="14" :tilted="false"></GameCardPreview> <GameCard :cardId="14" :tilted="false"></GameCard>
</div> </div>
<p>Sur cette carte, on peut voir les trois en même temps.</p> <p>Sur cette carte, on peut voir les trois en même temps.</p>
<p>La 1ère ligne s'active tout le temps.</p> <p>La 1ère ligne s'active tout le temps.</p>
+1 -1
View File
@@ -6,6 +6,6 @@ config.public.welcomeMessage;
<template> <template>
<div> <div>
{{ config.public.welcomeMessage }} {{ config.public.welcomeMessage }}
<GameCardPreview :cardId="6" :tilted="false"></GameCardPreview> <GameCard :cardId="6" :tilted="false"></GameCard>
</div> </div>
</template> </template>