FIX : Allow actions on discard
This commit is contained in:
+43
-10
@@ -8,6 +8,7 @@ import goStore, {
|
||||
heal,
|
||||
damage_champion,
|
||||
damage_team,
|
||||
|
||||
} from "~/netcode";
|
||||
import type { Card } from "~/netcode/Card";
|
||||
import type { Player } from "~/netcode/Player";
|
||||
@@ -16,10 +17,12 @@ import { CardEffects, type Effect } from "@/netcode/Effect";
|
||||
export interface Props {
|
||||
player: Player;
|
||||
hide_stack_and_discard?: boolean;
|
||||
discard_unwrapped?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
hide_stack_and_discard: () => false,
|
||||
discard_unwrapped: () => false,
|
||||
})
|
||||
|
||||
const isPlayerTurn = computed(() => props.player.team === goStore.game?.current_turn);
|
||||
@@ -31,7 +34,7 @@ function run_effect(
|
||||
effect_type: CardEffects,
|
||||
target: Player | Card
|
||||
) {
|
||||
const effect = goStore.self?.turn.find_effect(effect_type);
|
||||
const effect = goStore.self?.turn.find_effect(effect_type).value;
|
||||
if (!effect) {
|
||||
return;
|
||||
}
|
||||
@@ -42,20 +45,41 @@ const make_discard = (target: Player) =>
|
||||
run_effect(CardEffects.MAKE_DISCARD, target);
|
||||
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)
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="`player ${isPlayerTurn ? 'turn' : ''}`">
|
||||
<div :class="`player ${isPlayerTurn ? 'turn' : ''} ${discard_unwrapped ? 'discard_unwrapped' : ''}`">
|
||||
<template v-if="!hide_stack_and_discard">
|
||||
<div class="stack">
|
||||
<span>stack =</span>
|
||||
|
||||
<CardsGrouped :stack="props.player.stack_pile">
|
||||
<!-- <button v-if="isSelf && isTurn" @click="draw">DRAW</button> -->
|
||||
</CardsGrouped>
|
||||
<span>stack =</span>
|
||||
</div>
|
||||
<div class="discard">
|
||||
<CardsGrouped :stack="props.player.discard_pile"> </CardsGrouped>
|
||||
<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">
|
||||
|
||||
<button v-if="goStore.self?.turn.find_effect(CardEffects.SACRIFICE).value"
|
||||
@click="sacrifice(c)">
|
||||
SACRIFICE
|
||||
</button>
|
||||
<button v-if="goStore.self?.turn.find_effect(CardEffects.RESTACK_DISCARDED_CHAMPION).value"
|
||||
@click="restack_discarded_champion(c)">
|
||||
RESTACK_DISCARDED_CHAMPION
|
||||
</button>
|
||||
<button v-if="goStore.self?.turn.find_effect(CardEffects.RESTACK_DISCARDED_CARD).value"
|
||||
@click="restack_discarded_card(c)">
|
||||
RESTACK_DISCARDED_CARD
|
||||
</button>
|
||||
|
||||
</template>
|
||||
</CardPreview>
|
||||
</div>
|
||||
</template>
|
||||
<div id="player_stats">
|
||||
@@ -68,7 +92,7 @@ const stun = (target: Card) => run_effect(CardEffects.STUN, target)
|
||||
Damage
|
||||
</button>
|
||||
<button v-if="isSelfTurn && isPlayerEnemy" @click="make_discard(props.player)"
|
||||
:disabled="!goStore.self?.turn.find_effect(CardEffects.MAKE_DISCARD)">
|
||||
:disabled="!goStore.self?.turn.find_effect(CardEffects.MAKE_DISCARD).value">
|
||||
make Discard
|
||||
</button>
|
||||
<br />
|
||||
@@ -96,10 +120,12 @@ const stun = (target: Card) => run_effect(CardEffects.STUN, target)
|
||||
<button v-if="props.player.turn.discard_markers > 0" @click="discard(c)">
|
||||
DISCARD
|
||||
</button>
|
||||
<button v-if="goStore.self?.turn.find_effect(CardEffects.SACRIFICE)" @click="sacrifice(c)">
|
||||
<button v-if="goStore.self?.turn.find_effect(CardEffects.SACRIFICE).value"
|
||||
@click="sacrifice(c)">
|
||||
SACRIFICE
|
||||
</button>
|
||||
<button @click="lockCard(c)">
|
||||
<button @click="lockCard(c)"
|
||||
:disabled="(props.player.turn.discard_markers > 0 && c !== props.player.turn.discard_marker_card) || props.player.turn.fuck_u_markers > 0">
|
||||
LOCK
|
||||
</button>
|
||||
</template>
|
||||
@@ -108,11 +134,10 @@ const stun = (target: Card) => run_effect(CardEffects.STUN, target)
|
||||
<button :disabled="(goStore.self?.turn.damage_reserve ?? 0) <= 0" @click="damage_champion(c)">
|
||||
DAMAGE
|
||||
</button>
|
||||
<button v-if="goStore.self?.turn.find_effect(CardEffects.STUN)" @click="stun(c)">
|
||||
<button v-if="goStore.self?.turn.find_effect(CardEffects.STUN).value" @click="stun(c)">
|
||||
STUN
|
||||
</button>
|
||||
</template>
|
||||
|
||||
</CardPreview>
|
||||
</div>
|
||||
</div>
|
||||
@@ -134,6 +159,7 @@ const stun = (target: Card) => run_effect(CardEffects.STUN, target)
|
||||
}
|
||||
|
||||
.discard {
|
||||
margin-top: 50px;
|
||||
grid-area: discard;
|
||||
}
|
||||
|
||||
@@ -148,6 +174,13 @@ const stun = (target: Card) => run_effect(CardEffects.STUN, target)
|
||||
"discard player";
|
||||
}
|
||||
|
||||
.player.discard_unwrapped {
|
||||
grid-template-areas:
|
||||
"player_stats player_stats"
|
||||
"stack player"
|
||||
"discard discard";
|
||||
}
|
||||
|
||||
#current_player_board {
|
||||
grid-area: player;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user