diff --git a/components/CardsGrouped.vue b/components/CardsGrouped.vue
index 9a1aebf..1fb5182 100644
--- a/components/CardsGrouped.vue
+++ b/components/CardsGrouped.vue
@@ -1,10 +1,12 @@
@@ -121,15 +127,15 @@ function tokenClick(token: Effect, card: Card) {
{
if(playingTurn?.lockedEffects.includes(e._id)){
prev.push(i)
}
@@ -141,8 +147,29 @@ function tokenClick(token: Effect, card: Card) {
+
diff --git a/components/PlayerListElement.vue b/components/PlayerListElement.vue
index 9feb932..f194206 100644
--- a/components/PlayerListElement.vue
+++ b/components/PlayerListElement.vue
@@ -1,5 +1,6 @@
@@ -48,6 +67,24 @@ const props = withDefaults(defineProps(), {
+
+
diff --git a/components/PlayerSlot.vue b/components/PlayerSlot.vue
index 83a6589..2bd2216 100644
--- a/components/PlayerSlot.vue
+++ b/components/PlayerSlot.vue
@@ -52,7 +52,9 @@ const isSelfTurn = computed(() => isSelf && isPlayerTurn);
const cardTokens = computed(() =>
props.game.currentTurn.tokens.filter((t) =>
- [CardEffects.SACRIFICE, CardEffects.PREPARE].includes(t.effect)
+ [CardEffects.SACRIFICE, CardEffects.PREPARE, CardEffects.STUN].includes(
+ t.effect
+ )
)
);
@@ -196,6 +198,7 @@ function tokenClick({ card, token }: { card: Card; token: Effect }) {
@effectClick="effectClick"
:tokens="cardTokens"
@tokenClick="tokenClick"
+ :championsKillable="!isSelf && isSelfTurn.value"
>
diff --git a/netcode/index.ts b/netcode/index.ts
index 3b26f88..1d8fbbf 100644
--- a/netcode/index.ts
+++ b/netcode/index.ts
@@ -153,3 +153,59 @@ export async function lockEffect(game: string, effectId: string) {
}
);
}
+
+export async function makeDiscard(
+ game: string,
+ playerId: string,
+ amount: number = 1
+) {
+ const config = useRuntimeConfig();
+ await $fetch(
+ new URL(
+ `games/${game}/turn/makeDiscard/${playerId}`,
+ config.public.endpoint
+ ).href,
+ {
+ method: "POST",
+ credentials: "include",
+ }
+ );
+}
+
+export async function damagePlayer(
+ game: string,
+ playerId: string,
+ amount: number = 1
+) {
+ const config = useRuntimeConfig();
+ await $fetch(
+ new URL(
+ `games/${game}/turn/damagePlayer/${playerId}`,
+ config.public.endpoint
+ ).href,
+ {
+ method: "POST",
+ credentials: "include",
+ body: { amount },
+ }
+ );
+}
+
+export async function damageChampion(
+ game: string,
+ playerId: string,
+ cardId: string
+) {
+ const config = useRuntimeConfig();
+ await $fetch(
+ new URL(
+ `games/${game}/turn/damageChampion/${cardId}`,
+ config.public.endpoint
+ ).href,
+ {
+ method: "POST",
+ credentials: "include",
+ body: { playerId },
+ }
+ );
+}
diff --git a/netcode/interfaces.ts b/netcode/interfaces.ts
index 4c4d8b3..654e47a 100644
--- a/netcode/interfaces.ts
+++ b/netcode/interfaces.ts
@@ -41,6 +41,16 @@ export enum CardEffects {
PICK_FACTION = "pick_faction",
}
+export enum CardType {
+ HERO = "hero",
+ HERO_ABILITY = "hero_ability",
+ CURRENCY = "currency",
+ WEAPON = "weapon",
+ CHAMPION = "champion",
+ ACTION = "action",
+ ITEM = "item",
+}
+
export interface GameObject {
_id: string;
}
@@ -95,5 +105,6 @@ export interface Effect extends GameObject {
}
export interface Card extends GameObject {
cardId: number;
+ cardType: CardType;
effects: Effect[];
}
diff --git a/pages/game/[id].vue b/pages/game/[id].vue
index 6727b80..c052418 100644
--- a/pages/game/[id].vue
+++ b/pages/game/[id].vue
@@ -4,6 +4,7 @@ import { subscribe } from "~/netcode";
import { delay } from "~/netcode/events";
import { type Container, type Game, type Player } from "~/netcode/interfaces";
import { playSound } from "~/helpers/audioHelpers";
+import TokenComponent from "~/components/tokens/TokenComponent.vue";
const config = useRuntimeConfig();
const settingsStore = useSettingsStore();
@@ -211,6 +212,20 @@ eventSource.addEventListener("message", async (message) => {
console.log(`adding health amount : ` + data.operation);
team.health = data.health;
});
+ } else if (data.type == "killTeam") {
+ queueAction(async () => {
+ const index = game.value?.teams.findIndex((t) => t._id == data.teamId);
+ if (!index) {
+ console.error("team index not found. Desyncs might happen");
+ await refresh();
+ return;
+ }
+ game.value?.teams.splice(index, 1);
+ });
+ } else if (data.type == "endGame") {
+ queueAction(async () => {
+ alert("game Ended");
+ });
}
});
@@ -314,6 +329,12 @@ onUnmounted(() => {
:fire_gems="game.fireGems"
:marketStack="game.marketStack"
>
+
+
+