import { Injectable } from '@angular/core' ; import { Language , TradeSearchHttpQuery } from '@data/poe/schema' ; import { Item , ItemRarity , ItemService } from '../../../item' ; import { ItemCategory } from '../../../item/base-item-type' ; import { TradeSearchFilterService } from './trade-search-filter.service' ; @ Injectable ( { providedIn : 'root' } ) export class TradeSearchFilterTypeService implements TradeSearchFilterService { constructor ( private readonly item ) { } public add ( item , language , query ) { query . filters . type_filters = { filters : { } } ; const name = this . item . getName ( item . nameId , language ) ; if ( name ) { query . name = name ; } const type = this . item . getType ( item . typeId , language ) ; if ( type ) { query . type = type ; } switch ( item . category ) { case ItemCategory . Weapon : case ItemCategory . WeaponOne : case ItemCategory . WeaponOneMelee : case ItemCategory . WeaponTwoMelee : case ItemCategory . WeaponBow : case ItemCategory . WeaponClaw : case ItemCategory . WeaponDagger : case ItemCategory . WeaponRunedagger : case ItemCategory . WeaponOneAxe : case ItemCategory . WeaponOneMace : case ItemCategory . WeaponOneSword : case ItemCategory . WeaponSceptre : case ItemCategory . WeaponStaff : case ItemCategory . WeaponWarstaff : case ItemCategory . WeaponTwoAxe : case ItemCategory . WeaponTwoMace : case ItemCategory . WeaponTwoSword : case ItemCategory . WeaponWand : case ItemCategory . WeaponRod : case ItemCategory . Armour : case ItemCategory . ArmourChest : case ItemCategory . ArmourBoots : case ItemCategory . ArmourGloves : case ItemCategory . ArmourHelmet : case ItemCategory . ArmourShield : case ItemCategory . ArmourQuiver : case ItemCategory . Accessory : case ItemCategory . AccessoryAmulet : case ItemCategory . AccessoryBelt : case ItemCategory . AccessoryRing : case ItemCategory . AccessoryTrinket : if ( item . rarity === ItemRarity . Unique ) { query . filters . type_filters . filters . rarity = { option : ItemRarity . Unique } ; } else { query . filters . type_filters . filters . rarity = { option : ItemRarity . NonUnique } ; if ( query . name ) { query . term = `${ query . name || '' } ${ query . type || '' }` . trim ( ) ; query . name = query . type = undefined ; } } query . filters . type_filters . filters . category = { option : item . category , } ; break ; case ItemCategory . Jewel : case ItemCategory . JewelAbyss : case ItemCategory . Flask : case ItemCategory . Map : case ItemCategory . MonsterBeast : query . filters . type_filters . filters . rarity = { option : item . rarity === ItemRarity . Unique ? ItemRarity . Unique : ItemRarity . NonUnique } ; query . filters . type_filters . filters . category = { option : item . category , } ; break ; case ItemCategory . Gem : case ItemCategory . GemActivegem : case ItemCategory . GemSupportGem : case ItemCategory . GemSupportGemplus : case ItemCategory . Watchstone : case ItemCategory . Leaguestone : case ItemCategory . Currency : case ItemCategory . CurrencyPiece : case ItemCategory . CurrencyResonator : case ItemCategory . CurrencyFossil : case ItemCategory . CurrencyIncubator : case ItemCategory . CurrencyHeistTarget : case ItemCategory . HeistEquipment : case ItemCategory . HeistEquipmentGear : case ItemCategory . HeistEquipmentTool : case ItemCategory . HeistEquipmentCloak : case ItemCategory . HeistEquipmentBrooch : case ItemCategory . HeistEquipmentMission : case ItemCategory . HeistEquipmentContract : case ItemCategory . HeistEquipmentBlueprint : case ItemCategory . MapFragment : case ItemCategory . MapScarab : case ItemCategory . Card : query . filters . type_filters . filters . category = { option : item . category , } ; break ; case ItemCategory . MonsterSample : case ItemCategory . Prophecy : query . filters . type_filters . filters . category = { option : item . category , } ; query . term = query . type ; query . type = undefined ; break ; default : break ; } } }