This commit is contained in:
2024-04-26 16:08:04 +02:00
parent 6e9077404a
commit d0816f9fc9
9 changed files with 169 additions and 65 deletions
+20 -4
View File
@@ -1,5 +1,5 @@
import { type Card, create_card, type CardNetcode } from "./Card"
import { type Effect, create_effect, type EffectNetcode } from "./Effect"
import { type Effect, create_effect, type EffectNetcode, EffectType, CardEffects } from "./Effect"
import { type Game, create_game, type GameNetcode } from "./Game"
import type { GameObjectNetcode } from "./GameObject"
import { type Player, create_player, type PlayerNetcode } from "./Player"
@@ -176,16 +176,24 @@ export function lockCard(card: Card) {
data_type: "lock_card",
data: card.uuid
}))
card.effects.forEach(e => {
if (e.effect_type !== EffectType.SUICIDE && e.usable && [CardEffects.DAMAGE, CardEffects.GOLD, CardEffects.HEAL].includes(e.effect)) {
for (let i = 0; i < e.amount; i++) {
useEffect(e)
}
}
})
}
export function useEffect(effect: Effect, target?: Effect | Card | Player | Team) {
console.log({ effect_id: effect.uuid, target: target?.uuid })
socket.send(JSON.stringify({
type: "action",
data_type: "use_effect",
data: { effect_id: effect.uuid, target: target?.uuid }
}))
}
export function discard(card: Card) {
socket.send(JSON.stringify({
type: "action",
@@ -202,10 +210,18 @@ export function heal() {
}))
}
export function damage(target: Team) {
export function damage_team(target: Team) {
socket.send(JSON.stringify({
type: "action",
data_type: "damage",
data_type: "damage_team",
data: target.uuid
}))
}
export function damage_champion(target: Card) {
socket.send(JSON.stringify({
type: "action",
data_type: "damage_champion",
data: target.uuid
}))
}