import { GameObjectRegister } from "." import type { GameObjectNetcode } from "./GameObject" enum CardEffects { GOLD = "gold", DAMAGE = "damage", HEAL = "heal", PERPARE = "prepare", STUN = "stun", SACRIFICE = "sacrifice", DRAW = "draw", DRAW_AND_DISCARD = "draw_and_discard", DISCARD = "discard", RESTACK_DISCARDED_CHAMPION = "restack_discarded_champion", RESTACK_DISCARDED_CARD = "restack_discarded_card", STACK_NEXT_ACTION_BOUGHT = "stack_next_action_bought", STACK_NEXT_CARD_BOUGHT = "stack_next_card_bought", PLAY_NEXT_CARD_BOUGHT = "play_next_card_bought" } enum EffectTimes { PER_CHAMPION = "per_champion", PER_OTHER_CHAMPION = "per_other_champion", PER_OTHER_GUARD = "per_other_guard", PER_CARD_OF_SAME_FACTION = "per_card_of_same_faction" } enum EffectType { CHAMPION_ACTION = "champion_action", SUICIDE = "suicide", FACTION_COMBO = "faction_combo" } export interface EffectNetcode extends GameObjectNetcode { effect: CardEffects amount: number sub_effects: Array mutex: Array effect_type?: EffectType times?: EffectTimes } export type Effect = Omit & { sub_effects: { [key: string]: Effect } mutex: { [key: string]: Effect } } export function create_effect(input: EffectNetcode, register: GameObjectRegister) { return new Proxy(input, { get(target, prop, reciever) { if (prop == "sub_effects") { return Object.fromEntries(Object.entries(register.effects).filter(([i, v]) => i in target.sub_effects)) } if (prop == "mutex") { return Object.fromEntries(Object.entries(register.effects).filter(([i, v]) => i in target.mutex)) } return Reflect.get(target, prop, reciever); }, set(target, prop, val, receiver) { return Reflect.set(target, prop, val, receiver); } }) as Effect }