Playtest
This commit is contained in:
+33
-16
@@ -1,7 +1,7 @@
|
||||
import { GameObjectRegister } from "."
|
||||
import type { GameObjectNetcode } from "./GameObject"
|
||||
|
||||
enum CardEffects {
|
||||
export enum CardEffects {
|
||||
GOLD = "gold",
|
||||
DAMAGE = "damage",
|
||||
HEAL = "heal",
|
||||
@@ -18,14 +18,14 @@ enum CardEffects {
|
||||
PLAY_NEXT_CARD_BOUGHT = "play_next_card_bought"
|
||||
}
|
||||
|
||||
enum EffectTimes {
|
||||
export 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 {
|
||||
export enum EffectType {
|
||||
CHAMPION_ACTION = "champion_action",
|
||||
SUICIDE = "suicide",
|
||||
FACTION_COMBO = "faction_combo"
|
||||
@@ -43,21 +43,38 @@ export interface EffectNetcode extends GameObjectNetcode {
|
||||
export type Effect = Omit<EffectNetcode, 'sub_effects' | 'mutex'> & {
|
||||
sub_effects: { [key: string]: Effect }
|
||||
mutex: { [key: string]: Effect }
|
||||
usable: boolean
|
||||
}
|
||||
|
||||
export function create_effect(input: EffectNetcode, register: GameObjectRegister) {
|
||||
return new Proxy<any>(input, {
|
||||
get(target, prop, reciever) {
|
||||
if (prop == "sub_effects") {
|
||||
return Object.fromEntries(Object.entries(register.effects).filter(([i, v]) => i in target.sub_effects))
|
||||
const effect =
|
||||
new Proxy<any>(input, {
|
||||
get(target: EffectNetcode, 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))
|
||||
}
|
||||
if (prop == "usable") {
|
||||
if (target.effect_type == EffectType.FACTION_COMBO) {
|
||||
if (!register.self) { return false }
|
||||
// ugly bastard
|
||||
const card = register.self.board.find(c => c.effects.map(e => e.uuid).includes(effect.uuid))
|
||||
|
||||
if (!card) { return false }
|
||||
console.log(
|
||||
register.self.board.some(c => c !== card && c.faction === card.faction)
|
||||
)
|
||||
return register.self.board.some(c => c !== card && c.faction === card.faction)
|
||||
}
|
||||
return true
|
||||
}
|
||||
return Reflect.get(target, prop, reciever);
|
||||
},
|
||||
set(target, prop, val, receiver) {
|
||||
return Reflect.set(target, prop, val, receiver);
|
||||
}
|
||||
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
|
||||
}) as Effect
|
||||
return effect
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user