import { CardClass , CardType , Race , SpellSchool } from '@firestone-hs/reference-data' ; import { DeckState } from '../../../models/decktracker/deck-state' ; import { Handler } from './cards-highlight.service' ; export const and = ( ... filters ) : ( ( handler : Handler , d ? : DeckState ) => boolean ) => { return ( handler , deckState ) => filters . every ( ( filter ) => filter ( handler , deckState ) ) ; } ; export const or = ( ... filters ) : ( ( handler : Handler , d ? : DeckState ) => boolean ) => { return ( handler , deckState ) => filters . some ( ( filter ) => filter ( handler , deckState ) ) ; } ; export const not = ( filter ) : ( ( handler : Handler , d ? : DeckState ) => boolean ) => { return ( handler , deckState ) => ! filter ( handler , deckState ) ; } ; export const inDeck = ( handler ) : boolean => { return handler . zoneProvider ( ) ?. id === 'deck' ; } ; export const inHand = ( handler ) : boolean => { return handler . zoneProvider ( ) ?. id === 'hand' ; } ; export const inOther = ( handler ) : boolean => { return handler . zoneProvider ( ) ?. id === 'other' ; } ; export const inGraveyard = ( handler ) : boolean => { return handler . deckCardProvider ( ) ?. zone === 'GRAVEYARD' ; } ; export const effectiveCostLess = ( cost ) => ( handler ) : boolean => { return handler . deckCardProvider ( ) ?. getEffectiveManaCost ( ) < cost ; } ; export const effectiveCostMore = ( cost ) => ( handler ) : boolean => { return handler . deckCardProvider ( ) ?. getEffectiveManaCost ( ) > cost ; } ; export const effectiveCostEqual = ( cost ) => ( handler ) : boolean => { return handler . deckCardProvider ( ) ?. getEffectiveManaCost ( ) === cost ; } ; export const notInInitialDeck = ( handler ) : boolean => { return handler . deckCardProvider ( ) . creatorCardId != null || handler . deckCardProvider ( ) . creatorCardIds ?. length > 0 ; } ; export const spellPlayedThisMatch = ( handler , deckState ) : boolean => { return deckState ?. spellsPlayedThisMatch . map ( ( spell ) => spell . entityId ) . includes ( handler . deckCardProvider ( ) ?. entityId ) ; } ; export const outcast = ( handler ) : boolean => { return ( handler . referenceCardProvider ( ) ?. mechanics ?? [ ] ) . includes ( 'OUTCAST' ) ; } ; export const deathrattle = ( handler ) : boolean => { return ( handler . referenceCardProvider ( ) ?. mechanics ?? [ ] ) . includes ( 'DEATHRATTLE' ) ; } ; export const frenzy = ( handler ) : boolean => { return ( handler . referenceCardProvider ( ) ?. mechanics ?? [ ] ) . includes ( 'FRENZY' ) ; } ; export const corrupt = ( handler ) : boolean => { return ( handler . referenceCardProvider ( ) ?. mechanics ?? [ ] ) . includes ( 'CORRUPT' ) ; } ; export const rush = ( handler ) : boolean => { return ( handler . referenceCardProvider ( ) ?. mechanics ?? [ ] ) . includes ( 'RUSH' ) ; } ; export const taunt = ( handler ) : boolean => { return ( handler . referenceCardProvider ( ) ?. mechanics ?? [ ] ) . includes ( 'TAUNT' ) ; } ; export const divineShield = ( handler ) : boolean => { return ( handler . referenceCardProvider ( ) ?. mechanics ?? [ ] ) . includes ( 'DIVINE_SHIELD' ) ; } ; export const corrupted = ( handler ) : boolean => { return ( handler . referenceCardProvider ( ) ?. mechanics ?? [ ] ) . includes ( 'CORRUPTED' ) ; } ; export const secret = ( handler ) : boolean => { return ( handler . referenceCardProvider ( ) ?. mechanics ?? [ ] ) . includes ( 'SECRET' ) ; } ; export const spellSchool = ( spellSchool ) => ( handler ) : boolean => { return handler . referenceCardProvider ( ) ?. spellSchool === SpellSchool [ spellSchool ] ; } ; export const shadow = spellSchool ( SpellSchool . SHADOW ) ; export const fel = spellSchool ( SpellSchool . FEL ) ; export const holy = spellSchool ( SpellSchool . HOLY ) ; export const frost = spellSchool ( SpellSchool . FROST ) ; export const cardType = ( type ) => ( handler ) : boolean => { return ( handler . deckCardProvider ( ) ?. cardType ?. toLowerCase ( ) === CardType [ type ] . toLowerCase ( ) || handler . referenceCardProvider ( ) ?. type ?. toLowerCase ( ) === CardType [ type ] . toLowerCase ( ) ) ; } ; export const minion = cardType ( CardType . MINION ) ; export const spell = cardType ( CardType . SPELL ) ; export const weapon = cardType ( CardType . WEAPON ) ; export const race = ( race ) => ( handler ) : boolean => { return handler . referenceCardProvider ( ) ?. race === Race [ race ] ; } ; export const beast = race ( Race . BEAST ) ; export const demon = race ( Race . DEMON ) ; export const dragon = race ( Race . DRAGON ) ; export const mech = race ( Race . MECH ) ; export const pirate = race ( Race . PIRATE ) ; export const cardClass = ( cardClass ) => ( handler ) : boolean => { return handler . referenceCardProvider ( ) ?. cardClass === CardClass [ cardClass ] ; } ; export const rogue = cardClass ( CardClass . ROGUE ) ;