package com.alterdekim.hearthhack.util;


import com.alterdekim.hearthhack.game.GameTag;
import lombok.*;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

@ToString
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class FormattedCards {
    private List<CardsObject> objects;

    public List<CardsObject> findEntitiesByTagVal(GameTag tag, Integer val) {
        return this.objects.stream()
                .filter(o -> o.getEntity().getTags()
                    .stream()
                    .anyMatch(f -> f.getEnumID().intValue() == tag.getValue().intValue() && f.getValue().intValue() == val.intValue())
                )
                .collect(Collectors.toList());
    }

    public List<CardsObject> findEntitiesByTagVal(GameTag tag, String val) {
        return this.objects.stream()
                .filter(o -> o.getEntity().getTags()
                        .stream()
                        .anyMatch(f -> f.getEnumID().intValue() == tag.getValue().intValue() && val.equals(f.getRawValue()))
                )
                .collect(Collectors.toList());
    }
}
