Close #14; Add back prepare effect
release-tag / release-image (push) Successful in 1m9s

This commit is contained in:
2024-05-13 11:59:27 +02:00
parent 260a46fc2f
commit dc80228668
3 changed files with 30 additions and 17 deletions
+28 -15
View File
@@ -10,7 +10,7 @@ import goStore, {
damage_team,
} from "~/netcode";
import type { Card } from "~/netcode/Card";
import { CardType, type Card } from "~/netcode/Card";
import type { Player } from "~/netcode/Player";
import { CardEffects, type Effect } from "@/netcode/Effect";
@@ -34,6 +34,9 @@ function run_effect(
effect_type: CardEffects,
target: Player | Card
) {
if (!goStore.self?.turn) {
return
}
const effect = goStore.self?.turn.find_effect(effect_type);
if (!effect) {
return;
@@ -47,6 +50,7 @@ const sacrifice = (target: Card) => run_effect(CardEffects.SACRIFICE, target);
const stun = (target: Card) => run_effect(CardEffects.STUN, target)
const restack_discarded_champion = (target: Card) => run_effect(CardEffects.RESTACK_DISCARDED_CHAMPION, target)
const restack_discarded_card = (target: Card) => run_effect(CardEffects.RESTACK_DISCARDED_CARD, target)
const prepare_champion = (target: Card) => run_effect(CardEffects.PREPARE, target)
</script>
@@ -63,7 +67,7 @@ const restack_discarded_card = (target: Card) => run_effect(CardEffects.RESTACK_
<div :class="`discard ${discard_unwrapped ? 'unwrapped' : ''}`">
<CardsGrouped :stack="props.player.discard_pile" v-if="!props.discard_unwrapped"> </CardsGrouped>
<CardPreview v-if="props.discard_unwrapped" :data="c" v-for="c in props.player.discard_pile">
<template v-if="c && isSelf && isPlayerTurn">
<template v-if="goStore.self?.turn && c && isSelf && isPlayerTurn">
<button v-if="goStore.self?.turn.find_effect(CardEffects.SACRIFICE)" @click.stop="sacrifice(c)">
SACRIFICE
@@ -91,11 +95,13 @@ const restack_discarded_card = (target: Card) => run_effect(CardEffects.RESTACK_
</div>
</div>
<div id="current_player_board">
<button @click.stop="damage_team(props.player.team)" v-if="isSelfTurn && isPlayerEnemy"
<button @click.stop="damage_team(props.player.team)"
v-if="isSelfTurn && isPlayerEnemy && goStore.self?.turn && props.player.team"
:disabled="(goStore.self?.turn.damage_reserve ?? 0) <= 0">
Damage
</button>
<button v-if="goStore.self && isSelfTurn && isPlayerEnemy" @click.stop="make_discard(props.player)"
<button v-if="goStore.self && isSelfTurn && isPlayerEnemy && goStore.self?.turn"
@click.stop="make_discard(props.player)"
:disabled="!goStore.self!.turn.find_effect(CardEffects.MAKE_DISCARD)">
make Discard
</button>
@@ -105,29 +111,35 @@ const restack_discarded_card = (target: Card) => run_effect(CardEffects.RESTACK_
<!-- HAND -->
<CardPreview :data="c" v-for="c in props.player.hand" @click="c && playCard(c)">
<button
v-if="c && isSelf && (props.player.turn.discard_markers + props.player.turn.fuck_u_markers) > 0"
v-if="props.player.turn && c && isSelf && (props.player.turn.discard_markers + props.player.turn.fuck_u_markers) > 0"
@click.stop="discard(c)">
DISCARD
</button>
</CardPreview>
<!-- BOARD -->
<CardPreview :data="c" v-for="c in props.player.board" @click="lockCard(c)"
:locked="c.uuid in props.player.turn.cards_locked">
:locked="props.player.turn && c.uuid in props.player.turn.cards_locked">
<template v-if="c && isSelf && isPlayerTurn">
<template v-if="c.uuid in props.player.turn.cards_locked"
v-for="e in props.player.turn.effects_availables">
<button v-if="e.card == c" @click.stop="useEffect(e)" :disabled="!e.usable">
EFFECT<br>
{{ e.effect + " " + (e.effect_type ?? '') }}
</button>
<template v-if="c && isSelf && isPlayerTurn && props.player.turn">
<!-- Card Locked -->
<template v-if="c.uuid in props.player.turn.cards_locked">
<template v-for="e in props.player.turn.effects_availables">
<button v-if="e.card == c" @click.stop="useEffect(e)" :disabled="!e.usable">
EFFECT<br>
{{ e.effect + " " + (e.effect_type ?? '') }}
</button>
</template>
<button
v-if="props.player.turn.find_effect(CardEffects.PREPARE) && c.card_type == CardType.CHAMPION"
@click.stop="prepare_champion(c)">PREPARE</button>
</template>
<!-- Card Unlocked -->
<template v-if="!(c.uuid in props.player.turn.cards_locked)">
<button v-if="(props.player.turn.discard_markers + props.player.turn.fuck_u_markers) > 0"
@click.stop="discard(c)">
DISCARD
</button>
<button v-if="goStore.self?.turn.find_effect(CardEffects.SACRIFICE)"
<button v-if="props.player.turn.find_effect(CardEffects.SACRIFICE)"
@click.stop="sacrifice(c)">
SACRIFICE
</button>
@@ -137,7 +149,8 @@ const restack_discarded_card = (target: Card) => run_effect(CardEffects.RESTACK_
</button>
</template>
</template>
<template v-if="isPlayerEnemy && isSelfTurn && (c.health_as_champion ?? 0) > 0">
<template
v-if="c && goStore.self?.turn && isPlayerEnemy && isSelfTurn && (c.health_as_champion ?? 0) > 0">
<button class="enemy_action"
:disabled="(goStore.self?.turn.damage_reserve ?? 0) < (c.health_as_champion ?? Infinity)"
@click.stop="damage_champion(c)">