Fix: add effect.times check for effect.usable getter
release-tag / release-image (push) Successful in 27s
release-tag / release-image (push) Successful in 27s
Closes #58
This commit is contained in:
+22
-13
@@ -1,5 +1,5 @@
|
|||||||
import { GameObjectRegister } from "."
|
import { GameObjectRegister } from "."
|
||||||
import type { Card } from "./Card"
|
import { CardType, type Card } from "./Card"
|
||||||
import type { GameObjectNetcode } from "./GameObject"
|
import type { GameObjectNetcode } from "./GameObject"
|
||||||
|
|
||||||
export enum CardEffects {
|
export enum CardEffects {
|
||||||
@@ -23,7 +23,8 @@ export enum EffectTimes {
|
|||||||
PER_CHAMPION = "per_champion",
|
PER_CHAMPION = "per_champion",
|
||||||
PER_OTHER_CHAMPION = "per_other_champion",
|
PER_OTHER_CHAMPION = "per_other_champion",
|
||||||
PER_OTHER_GUARD = "per_other_guard",
|
PER_OTHER_GUARD = "per_other_guard",
|
||||||
PER_CARD_OF_SAME_FACTION = "per_card_of_same_faction"
|
PER_CARD_OF_SAME_FACTION = "per_card_of_same_faction",
|
||||||
|
PER_OTHER_CARD_OF_SAME_FACTION = "per_other_card_of_same_faction"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum EffectType {
|
export enum EffectType {
|
||||||
@@ -42,7 +43,7 @@ export interface EffectNetcode extends GameObjectNetcode {
|
|||||||
times?: EffectTimes
|
times?: EffectTimes
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Effect = Omit<EffectNetcode, 'sub_effects' | 'mutex' | 'card' > & {
|
export type Effect = Omit<EffectNetcode, 'sub_effects' | 'mutex' | 'card'> & {
|
||||||
sub_effects: { [key: string]: Effect }
|
sub_effects: { [key: string]: Effect }
|
||||||
mutex: { [key: string]: Effect }
|
mutex: { [key: string]: Effect }
|
||||||
card: Card
|
card: Card
|
||||||
@@ -60,20 +61,28 @@ export function create_effect(input: EffectNetcode, register: GameObjectRegister
|
|||||||
return Object.fromEntries(Object.entries(register.effects).filter(([i, v]) => i in target.mutex))
|
return Object.fromEntries(Object.entries(register.effects).filter(([i, v]) => i in target.mutex))
|
||||||
}
|
}
|
||||||
if (prop == "usable") {
|
if (prop == "usable") {
|
||||||
if (target.effect_type === EffectType.FACTION_COMBO) {
|
// ugly bastard
|
||||||
if (!register.self) { return false }
|
if (!register.self) { return false }
|
||||||
// ugly bastard
|
|
||||||
let cardLocked = register.self.value?.turn.cards_locked
|
|
||||||
if(!cardLocked) { return false }
|
|
||||||
let cardList = Object.values(cardLocked)
|
|
||||||
const card = cardList.find(c => c.effects.map(e => e.uuid).includes(effect.uuid))
|
|
||||||
|
|
||||||
if (!card) { return false }
|
let cardLocked = register.self.value?.turn?.cards_locked
|
||||||
return cardList.some(c => c !== card && c.faction === card.faction)
|
if (!cardLocked) { return false }
|
||||||
|
let cardList = Object.values(cardLocked)
|
||||||
|
const card = cardList.find(c => c.effects.map(e => e.uuid).includes(effect.uuid))
|
||||||
|
if (!card) { return false }
|
||||||
|
|
||||||
|
if (target.effect_type === EffectType.FACTION_COMBO) {
|
||||||
|
if (!cardList.some(c => c !== card && c.faction === card.faction)) { return false }
|
||||||
|
}
|
||||||
|
if (target.times === EffectTimes.PER_OTHER_CARD_OF_SAME_FACTION) {
|
||||||
|
if (!cardList.some(c => c !== card && c.faction === card.faction)) { return false }
|
||||||
|
} else if (target.times === EffectTimes.PER_OTHER_CHAMPION) {
|
||||||
|
if (!cardList.some(c => c !== card && c.card_type === CardType.CHAMPION)) { return false }
|
||||||
|
} else if (target.times === EffectTimes.PER_OTHER_GUARD) {
|
||||||
|
if (!cardList.some(c => c !== card && c.guard)) { return false }
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (prop == "card"){
|
if (prop == "card") {
|
||||||
return register.cards.get(target.card)
|
return register.cards.get(target.card)
|
||||||
}
|
}
|
||||||
return Reflect.get(target, prop, reciever);
|
return Reflect.get(target, prop, reciever);
|
||||||
|
|||||||
Reference in New Issue
Block a user