FIX : Allow actions on discard
This commit is contained in:
@@ -3,6 +3,8 @@ import goStore from '~/netcode';
|
|||||||
import type { Player } from '~/netcode/Player';
|
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 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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -15,7 +17,8 @@ const current_players = computed<Array<Player>>(() => Array.from(goStore.players
|
|||||||
</PlayerListElement>
|
</PlayerListElement>
|
||||||
</div>
|
</div>
|
||||||
<div id="current_player">
|
<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>
|
</div>
|
||||||
<SelfView></SelfView>
|
<SelfView></SelfView>
|
||||||
</div>
|
</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)">
|
<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">
|
<template v-if="isTurn && c && c.cost && (goStore.self?.turn.gold_reserve ?? 0) >= c.cost">
|
||||||
<button @click="buy(c)">BUY</button>
|
<button @click="buy(c)">BUY</button>
|
||||||
<button @click="useEffect(goStore.self!.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT)!, c)"
|
<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)">
|
v-if="goStore.self?.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT).value">
|
||||||
BUY IN HAND</button>
|
BUY IN HAND</button>
|
||||||
<button @click="useEffect(goStore.self!.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT)!, c)"
|
<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)">
|
v-if="goStore.self?.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT).value">
|
||||||
BUY IN STACK (generic)</button>
|
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>
|
BUY IN STACK (actions)</button>
|
||||||
</template>
|
</template>
|
||||||
</CardPreview>
|
</CardPreview>
|
||||||
@@ -33,12 +35,12 @@ const isTurn = computed(() => goStore.self && goStore.game?.started && (goStore.
|
|||||||
BUY
|
BUY
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT)!, goStore.game.gem_stack.at(-1))"
|
@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)">
|
v-if="goStore.self?.turn.find_effect(CardEffects.PLAY_NEXT_CARD_BOUGHT).value">
|
||||||
BUY IN HAND</button>
|
BUY IN HAND</button>
|
||||||
<button
|
<button
|
||||||
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT)!, goStore.game.gem_stack.at(-1))"
|
@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)">
|
v-if="goStore.self?.turn.find_effect(CardEffects.STACK_NEXT_CARD_BOUGHT).value">
|
||||||
BUY IN STACK(generic)
|
BUY IN STACK(generic)
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -43,8 +43,11 @@ const props = defineProps<Props>()
|
|||||||
|
|
||||||
<div class="view">
|
<div class="view">
|
||||||
<PlayerSlot :player="player" :hide_stack_and_discard="true" v-if="view == 'main'" />
|
<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>
|
</CardPreview>
|
||||||
|
</template>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+43
-10
@@ -8,6 +8,7 @@ import goStore, {
|
|||||||
heal,
|
heal,
|
||||||
damage_champion,
|
damage_champion,
|
||||||
damage_team,
|
damage_team,
|
||||||
|
|
||||||
} from "~/netcode";
|
} from "~/netcode";
|
||||||
import type { Card } from "~/netcode/Card";
|
import type { Card } from "~/netcode/Card";
|
||||||
import type { Player } from "~/netcode/Player";
|
import type { Player } from "~/netcode/Player";
|
||||||
@@ -16,10 +17,12 @@ import { CardEffects, type Effect } from "@/netcode/Effect";
|
|||||||
export interface Props {
|
export interface Props {
|
||||||
player: Player;
|
player: Player;
|
||||||
hide_stack_and_discard?: boolean;
|
hide_stack_and_discard?: boolean;
|
||||||
|
discard_unwrapped?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
hide_stack_and_discard: () => false,
|
hide_stack_and_discard: () => false,
|
||||||
|
discard_unwrapped: () => false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const isPlayerTurn = computed(() => props.player.team === goStore.game?.current_turn);
|
const isPlayerTurn = computed(() => props.player.team === goStore.game?.current_turn);
|
||||||
@@ -31,7 +34,7 @@ function run_effect(
|
|||||||
effect_type: CardEffects,
|
effect_type: CardEffects,
|
||||||
target: Player | Card
|
target: Player | Card
|
||||||
) {
|
) {
|
||||||
const effect = goStore.self?.turn.find_effect(effect_type);
|
const effect = goStore.self?.turn.find_effect(effect_type).value;
|
||||||
if (!effect) {
|
if (!effect) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -42,20 +45,41 @@ const make_discard = (target: Player) =>
|
|||||||
run_effect(CardEffects.MAKE_DISCARD, target);
|
run_effect(CardEffects.MAKE_DISCARD, target);
|
||||||
const sacrifice = (target: Card) => run_effect(CardEffects.SACRIFICE, target);
|
const sacrifice = (target: Card) => run_effect(CardEffects.SACRIFICE, target);
|
||||||
const stun = (target: Card) => run_effect(CardEffects.STUN, 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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="`player ${isPlayerTurn ? 'turn' : ''}`">
|
<div :class="`player ${isPlayerTurn ? 'turn' : ''} ${discard_unwrapped ? 'discard_unwrapped' : ''}`">
|
||||||
<template v-if="!hide_stack_and_discard">
|
<template v-if="!hide_stack_and_discard">
|
||||||
<div class="stack">
|
<div class="stack">
|
||||||
<span>stack =</span>
|
|
||||||
<CardsGrouped :stack="props.player.stack_pile">
|
<CardsGrouped :stack="props.player.stack_pile">
|
||||||
<!-- <button v-if="isSelf && isTurn" @click="draw">DRAW</button> -->
|
<!-- <button v-if="isSelf && isTurn" @click="draw">DRAW</button> -->
|
||||||
</CardsGrouped>
|
</CardsGrouped>
|
||||||
|
<span>stack =</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="discard">
|
<div :class="`discard ${discard_unwrapped ? 'unwrapped' : ''}`">
|
||||||
<CardsGrouped :stack="props.player.discard_pile"> </CardsGrouped>
|
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div id="player_stats">
|
<div id="player_stats">
|
||||||
@@ -68,7 +92,7 @@ const stun = (target: Card) => run_effect(CardEffects.STUN, target)
|
|||||||
Damage
|
Damage
|
||||||
</button>
|
</button>
|
||||||
<button v-if="isSelfTurn && isPlayerEnemy" @click="make_discard(props.player)"
|
<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
|
make Discard
|
||||||
</button>
|
</button>
|
||||||
<br />
|
<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)">
|
<button v-if="props.player.turn.discard_markers > 0" @click="discard(c)">
|
||||||
DISCARD
|
DISCARD
|
||||||
</button>
|
</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
|
SACRIFICE
|
||||||
</button>
|
</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
|
LOCK
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</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)">
|
<button :disabled="(goStore.self?.turn.damage_reserve ?? 0) <= 0" @click="damage_champion(c)">
|
||||||
DAMAGE
|
DAMAGE
|
||||||
</button>
|
</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
|
STUN
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</CardPreview>
|
</CardPreview>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -134,6 +159,7 @@ const stun = (target: Card) => run_effect(CardEffects.STUN, target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
.discard {
|
.discard {
|
||||||
|
margin-top: 50px;
|
||||||
grid-area: discard;
|
grid-area: discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +174,13 @@ const stun = (target: Card) => run_effect(CardEffects.STUN, target)
|
|||||||
"discard player";
|
"discard player";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.player.discard_unwrapped {
|
||||||
|
grid-template-areas:
|
||||||
|
"player_stats player_stats"
|
||||||
|
"stack player"
|
||||||
|
"discard discard";
|
||||||
|
}
|
||||||
|
|
||||||
#current_player_board {
|
#current_player_board {
|
||||||
grid-area: player;
|
grid-area: player;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ const isTurn = computed(() => goStore.self?.team == goStore.game?.current_turn)
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="'player ' + (isTurn ? 'turn' : '')">
|
<div :class="'player ' + (isTurn ? 'turn' : '')">
|
||||||
<button v-if="goStore.self && goStore.self?.team != goStore.self?.team"
|
<button v-if="goStore.self && goStore.self?.team != goStore.self?.team" id="end_turn"
|
||||||
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.MAKE_DISCARD)!, goStore.self)"
|
@click="useEffect(goStore.self!.turn.find_effect(CardEffects.MAKE_DISCARD).value!, goStore.self)"
|
||||||
:disabled="!goStore.self!.turn.find_effect(CardEffects.MAKE_DISCARD)">
|
:disabled="!goStore.self!.turn.find_effect(CardEffects.MAKE_DISCARD).value">
|
||||||
make Discard</button>
|
make Discard</button>
|
||||||
<div id="turn_data">
|
<div id="turn_data">
|
||||||
<button id="end_turn" v-if="isTurn" @click="endTurn">END TURN</button>
|
<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;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
/* background: lightgreen; */
|
z-index: 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#end_turn {
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
#self_hand {
|
#self_hand {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|||||||
+10
-3
@@ -1,3 +1,4 @@
|
|||||||
|
import { registerRuntimeCompiler } from "vue"
|
||||||
import { type GameObjectRegister } from "."
|
import { type GameObjectRegister } from "."
|
||||||
import type { Card } from "./Card"
|
import type { Card } from "./Card"
|
||||||
import { type Effect, CardEffects } from "./Effect"
|
import { type Effect, CardEffects } from "./Effect"
|
||||||
@@ -7,16 +8,19 @@ export interface TurnNetcode extends GameObjectNetcode {
|
|||||||
effects_availables: Array<string>
|
effects_availables: Array<string>
|
||||||
champions_health: { [key: string]: string }
|
champions_health: { [key: string]: string }
|
||||||
discard_markers: number
|
discard_markers: number
|
||||||
|
discard_marker_card: string
|
||||||
|
fuck_u_markers: number
|
||||||
damage_reserve: number
|
damage_reserve: number
|
||||||
gold_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 }
|
cards_locked: { [key: string]: Card }
|
||||||
effects_availables: Array<Effect>
|
effects_availables: Array<Effect>
|
||||||
champions_health: Map<string, number>
|
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) {
|
export function create_turn(input: TurnNetcode, register: GameObjectRegister) {
|
||||||
const turn = new Proxy<any>(input, {
|
const turn = new Proxy<any>(input, {
|
||||||
@@ -36,9 +40,12 @@ export function create_turn(input: TurnNetcode, register: GameObjectRegister) {
|
|||||||
}
|
}
|
||||||
if (prop == "find_effect") {
|
if (prop == "find_effect") {
|
||||||
return (card_effect: CardEffects) => {
|
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);
|
return Reflect.get(target, prop, reciever);
|
||||||
},
|
},
|
||||||
set(target, prop, val, receiver) {
|
set(target, prop, val, receiver) {
|
||||||
|
|||||||
Reference in New Issue
Block a user