FIX : Allow actions on discard
This commit is contained in:
@@ -3,6 +3,8 @@ import goStore from '~/netcode';
|
||||
import type { Player } from '~/netcode/Player';
|
||||
|
||||
const current_players = computed<Array<Player>>(() => Array.from(goStore.players.values()).filter(p => p.team === goStore.game?.current_turn))
|
||||
|
||||
const discard_unwrapped = ref<boolean>(false)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -15,7 +17,8 @@ const current_players = computed<Array<Player>>(() => Array.from(goStore.players
|
||||
</PlayerListElement>
|
||||
</div>
|
||||
<div id="current_player">
|
||||
<PlayerSlot v-for="p in current_players" :player="p"></PlayerSlot>
|
||||
<input type="checkbox" v-model="discard_unwrapped">
|
||||
<PlayerSlot v-for="p in current_players" :player="p" :discard_unwrapped="discard_unwrapped"></PlayerSlot>
|
||||
</div>
|
||||
<SelfView></SelfView>
|
||||
</div>
|
||||
|
||||
+12
-10
@@ -14,14 +14,16 @@ const isTurn = computed(() => goStore.self && goStore.game?.started && (goStore.
|
||||
<CardPreview :data="c" v-for="c in goStore.game?.market" @click="c && buy(c)">
|
||||
<template v-if="isTurn && c && c.cost && (goStore.self?.turn.gold_reserve ?? 0) >= c.cost">
|
||||
<button @click="buy(c)">BUY</button>
|
||||
<button @click="useEffect(goStore.self!.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT)!, c)"
|
||||
v-if="goStore.self?.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT)">
|
||||
<button @click="useEffect(goStore.self!.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT).value!, c)"
|
||||
v-if="goStore.self?.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT).value">
|
||||
BUY IN HAND</button>
|
||||
<button @click="useEffect(goStore.self!.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT)!, c)"
|
||||
v-if="goStore.self?.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT)">
|
||||
<button @click="useEffect(goStore.self!.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT).value!, c)"
|
||||
v-if="goStore.self?.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT).value">
|
||||
BUY IN STACK (generic)</button>
|
||||
<button @click="useEffect(goStore.self!.turn.find_effect(CardEffects.STACK_NEXT_ACTION_BOUGHT)!, c)"
|
||||
v-if="c.card_type == CardType.ACTION && goStore.self?.turn.find_effect(CardEffects.STACK_NEXT_ACTION_BOUGHT)">
|
||||
|
||||
<button
|
||||
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.STACK_NEXT_ACTION_BOUGHT).value!, c)"
|
||||
v-if="c.card_type == CardType.ACTION && goStore.self?.turn.find_effect(CardEffects.STACK_NEXT_ACTION_BOUGHT).value">
|
||||
BUY IN STACK (actions)</button>
|
||||
</template>
|
||||
</CardPreview>
|
||||
@@ -33,12 +35,12 @@ const isTurn = computed(() => goStore.self && goStore.game?.started && (goStore.
|
||||
BUY
|
||||
</button>
|
||||
<button
|
||||
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT)!, goStore.game.gem_stack.at(-1))"
|
||||
v-if="goStore.self?.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT)">
|
||||
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT).value!, goStore.game.gem_stack.at(-1))"
|
||||
v-if="goStore.self?.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT).value">
|
||||
BUY IN HAND</button>
|
||||
<button
|
||||
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT)!, goStore.game.gem_stack.at(-1))"
|
||||
v-if="goStore.self?.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT)">
|
||||
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT).value!, goStore.game.gem_stack.at(-1))"
|
||||
v-if="goStore.self?.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT).value">
|
||||
BUY IN STACK(generic)
|
||||
</button>
|
||||
</template>
|
||||
|
||||
@@ -43,8 +43,11 @@ const props = defineProps<Props>()
|
||||
|
||||
<div class="view">
|
||||
<PlayerSlot :player="player" :hide_stack_and_discard="true" v-if="view == 'main'" />
|
||||
<CardPreview v-for=" card in player.discard_pile " :data="card" v-if="view == 'discard'">
|
||||
<template v-if="view == 'discard'">
|
||||
<CardPreview v-for=" card in player.discard_pile " :data="card">
|
||||
</CardPreview>
|
||||
</template>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
+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;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ const isTurn = computed(() => goStore.self?.team == goStore.game?.current_turn)
|
||||
|
||||
<template>
|
||||
<div :class="'player ' + (isTurn ? 'turn' : '')">
|
||||
<button v-if="goStore.self && goStore.self?.team != goStore.self?.team"
|
||||
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.MAKE_DISCARD)!, goStore.self)"
|
||||
:disabled="!goStore.self!.turn.find_effect(CardEffects.MAKE_DISCARD)">
|
||||
<button v-if="goStore.self && goStore.self?.team != goStore.self?.team" id="end_turn"
|
||||
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.MAKE_DISCARD).value!, goStore.self)"
|
||||
:disabled="!goStore.self!.turn.find_effect(CardEffects.MAKE_DISCARD).value">
|
||||
make Discard</button>
|
||||
<div id="turn_data">
|
||||
<button id="end_turn" v-if="isTurn" @click="endTurn">END TURN</button>
|
||||
@@ -58,9 +58,12 @@ const isTurn = computed(() => goStore.self?.team == goStore.game?.current_turn)
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
/* background: lightgreen; */
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
#end_turn {
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
#self_hand {
|
||||
position: fixed;
|
||||
|
||||
+10
-3
@@ -1,3 +1,4 @@
|
||||
import { registerRuntimeCompiler } from "vue"
|
||||
import { type GameObjectRegister } from "."
|
||||
import type { Card } from "./Card"
|
||||
import { type Effect, CardEffects } from "./Effect"
|
||||
@@ -7,16 +8,19 @@ export interface TurnNetcode extends GameObjectNetcode {
|
||||
effects_availables: Array<string>
|
||||
champions_health: { [key: string]: string }
|
||||
discard_markers: number
|
||||
discard_marker_card: string
|
||||
fuck_u_markers: number
|
||||
damage_reserve: number
|
||||
gold_reserve: number
|
||||
}
|
||||
|
||||
|
||||
export type Turn = Omit<TurnNetcode, 'cards_locked' | 'effects_availables' | 'champions_health'> & {
|
||||
export type Turn = Omit<TurnNetcode, 'cards_locked' | 'effects_availables' | 'champions_health'|"discard_marker_card"> & {
|
||||
cards_locked: { [key: string]: Card }
|
||||
effects_availables: Array<Effect>
|
||||
champions_health: Map<string, number>
|
||||
find_effect: (card_effect: CardEffects) => Effect | undefined
|
||||
discard_marker_card: Card
|
||||
find_effect: (card_effect: CardEffects) => ComputedRef<Effect | undefined>
|
||||
}
|
||||
export function create_turn(input: TurnNetcode, register: GameObjectRegister) {
|
||||
const turn = new Proxy<any>(input, {
|
||||
@@ -36,9 +40,12 @@ export function create_turn(input: TurnNetcode, register: GameObjectRegister) {
|
||||
}
|
||||
if (prop == "find_effect") {
|
||||
return (card_effect: CardEffects) => {
|
||||
return turn.effects_availables.find(e => (e.effect == card_effect) && e.usable)
|
||||
return computed(()=>turn.effects_availables.find((e:Effect) => (e.effect == card_effect) && e.usable))
|
||||
}
|
||||
}
|
||||
if(prop == "discard_marker_card"){
|
||||
return register.cards.get(target.discard_marker_card)
|
||||
}
|
||||
return Reflect.get(target, prop, reciever);
|
||||
},
|
||||
set(target, prop, val, receiver) {
|
||||
|
||||
Reference in New Issue
Block a user